tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From some user <oliver.frit...@nordlb.de>
Subject ValidationException due to META-INF/validation.xml's url capitalization
Date Thu, 22 Jun 2017 09:02:34 GMT
Hi,

I'm using OpenEJB in embedded mode to test an EJB service (for the first
time, so I'm not an expert OpenEJB user). The project containing the EJB
class has also a META-INF/validation.xml. 
The Problem: the deployment via EJBContainer.createEJBContainer() fails with
a "javax.validation.ValidationException: More than one
META-INF/validation.xml is found in the classpath", thrown by the validation
framework.

My setup:
OpenEJB 7.0.4-SNAPSHOT, used inside a JUnit test case
IDE: Eclipse 4.6 Neon
OS: Windows 7
Bean Validation implementation: Apache bval-jsr 1.1.2
Dependency management with Maven
(there is no META-INF/ejb-jar.xml in the project, if that's of any
importance)

In more detail: the bval-jsr-ValidationParser complains about two different
META-INF/validation.xml files on the classpath (which is forbidden by spec
of jsr 303). The reason is: 
the project containing the EJB class is turned into an EjbModule by OpenEJB.
Inside the EjbModule, the META-INF/validation.xml is known by the url 

file:/c:/users/someuser/git/someproject/someproject-ejb/target/classes/META-INF/validation.xml.

The project also contains the test code, which OpenEJB deploys as a separate
module / application. Inside that module, the same resource is known by the
url 

file:/C:/Users/someuser/git/someproject3/someproject3-ejb/target/classes/META-INF/validation.xml.

Due to the different capitalization, the URL.equals() fails, with both URLs
referencing the same resource, which leads to the ValidationException during
deployment.

I found out that on windows os, the
org.apache.openejb.config.DeploymentsResolver.ClasspathSearcher.loadUrls()
method converts URLs to lowercase when creating the EjbModule; I guess, on a
host machine with a different os, my problem wouldn't appear.

My questions:
1. Just curious: what's the reason for lowercasing all URLs in EjbModules on
windows systems?
2. Am I doing something fundamentally wrong within my test setup? I'm using
OpenEJB in embedded mode directly (not via arquillian) from inside a JUnit
test case, and want to use Bean Validation. A combination that shouldn't be
too exotic. After some google research, I'm quite puzzled that nobody seems
to have - at least not exactly - the same problem. 

Any advice would be appreciated.

Here my test code:

public class SomeTestCase {

    protected EJBContainer ejbContainer;

    @Before
    public void setUp() {
        final Properties p = new Properties();
        p.put("someproject_junit", "new://Resource?type=DataSource");
        p.put("someproject_junit.JdbcDriver", "org.hsqldb.jdbcDriver");
        p.put("someproject_junit.JdbcUrl",
"jdbc:hsqldb:mem:someproject_junit");
        p.put("openjpa.jdbc.DBDictionary", "hsql");
        p.put("openejb.jpa.deploy-time-enhancement", "true");
        p.put("openejb.jar.enhancement.include", "/**");
        try {
            // Some test code to find out about the validation.xml url
            Enumeration<URL> ejbJars;
            ejbJars =
this.getClass().getClassLoader().getResources("META-INF/validation.xml");
            while (ejbJars.hasMoreElements()) {
                URL url = ejbJars.nextElement();
                System.out.println("app = " + url + ", filename=" +
url.getFile());

            }
        } catch (IOException e) {
            fail(e.getMessage());
        }
        ejbContainer = EJBContainer.createEJBContainer(p);
        try {
            ejbContainer.getContext().bind("inject", this);
        } catch (NamingException e) {
            fail(e.getMessage());
        }

    }

    @After
    public void tearDown() {
        ejbContainer.close();
    }

    @Test
    public void testSomething() {
        fail("not yet implemented");
    }
}

Here the log output:
app =
file:/C:/Users/someuser/git/someproject3/someproject3-ejb/target/classes/META-INF/validation.xml,
filename=/C:/Users/someuser/git/someproject3/someproject3-ejb/target/classes/META-INF/validation.xml
INFORMATION -
********************************************************************************
INFORMATION - OpenEJB http://tomee.apache.org/
INFORMATION - Startup: Thu Jun 22 08:16:16 CEST 2017
INFORMATION - Copyright 1999-2017 (C) Apache OpenEJB Project, All Rights
Reserved.
INFORMATION - Version: 7.0.4-SNAPSHOT
INFORMATION - Build date: 20170620
INFORMATION - Build time: 04:07
INFORMATION -
********************************************************************************
INFORMATION - openejb.home =
C:\Users\someuser\git\someproject3\someproject3-ejb
INFORMATION - openejb.base =
C:\Users\someuser\git\someproject3\someproject3-ejb
INFORMATION - Created new singletonService
org.apache.openejb.cdi.ThreadSingletonServiceImpl@78047b92
INFORMATION - Succeeded in installing singleton service
INFORMATION - Using 'javax.ejb.embeddable.EJBContainer=true'
INFORMATION - TomEE configuration file is
'C:\Users\someuser\git\someproject3\someproject3-ejb\etc\openejb.xml'
INFORMATION - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFORMATION - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFORMATION - Configuring Service(id=My DataSource, type=Resource,
provider-id=Default JDBC Database)
INFORMATION - Configuring Service(id=My Unmanaged DataSource, type=Resource,
provider-id=Default JDBC Database)
INFORMATION - Configuring Service(id=someproject_junit, type=Resource,
provider-id=Default JDBC Database)
INFORMATION - Configuring Service(id=My Singleton Container, type=Container,
provider-id=Default Singleton Container)
INFORMATION - Configuring Service(id=My Stateful Container, type=Container,
provider-id=Default Stateful Container)
INFORMATION - Configuring Service(id=My Stateless Container, type=Container,
provider-id=Default Stateless Container)
INFORMATION - Using 'openejb.jpa.deploy-time-enhancement=true'
INFORMATION - Creating TransactionManager(id=Default Transaction Manager)
INFORMATION - Creating SecurityService(id=Default Security Service)
INFORMATION - Creating Resource(id=My DataSource)
INFORMATION - Creating Resource(id=My Unmanaged DataSource)
INFORMATION - Creating Resource(id=someproject_junit)
INFORMATION - Creating Container(id=My Singleton Container)
INFORMATION - Creating Container(id=My Stateful Container)
INFORMATION - Using directory C:\Users\someuser\AppData\Local\Temp for
stateful session passivation
INFORMATION - Creating Container(id=My Stateless Container)
INFORMATION - Found EjbModule in classpath:
c:\users\someuser\.m2\repository\org\apache\deltaspike\core\deltaspike-core-api\1.7.1\deltaspike-core-api-1.7.1.jar
INFORMATION - Found EjbModule in classpath:
c:\users\someuser\.m2\repository\org\apache\deltaspike\cdictrl\deltaspike-cdictrl-openejb\1.7.1\deltaspike-cdictrl-openejb-1.7.1.jar
INFORMATION - Found EjbModule in classpath:
c:\users\someuser\.m2\repository\org\apache\deltaspike\core\deltaspike-core-impl\1.7.1\deltaspike-core-impl-1.7.1.jar
INFORMATION - Found EjbModule in classpath:
c:\users\someuser\git\someproject3\someproject3-ejb\target\classes
INFORMATION - Found EjbModule in classpath:
c:\users\someuser\.m2\repository\com\somecompany\someframework\someframework-commons\6.1.0-snapshot\someframework-commons-6.1.0-snapshot.jar
INFORMATION - Beginning load:
c:\users\someuser\.m2\repository\org\apache\deltaspike\core\deltaspike-core-api\1.7.1\deltaspike-core-api-1.7.1.jar
INFORMATION - Enhancing url(s):
[file:/c:/users/someuser/.m2/repository/org/apache/deltaspike/core/deltaspike-core-api/1.7.1/deltaspike-core-api-1.7.1.jar]
INFORMATION - Beginning load:
c:\users\someuser\.m2\repository\org\apache\deltaspike\cdictrl\deltaspike-cdictrl-openejb\1.7.1\deltaspike-cdictrl-openejb-1.7.1.jar
INFORMATION - Enhancing url(s):
[file:/c:/users/someuser/.m2/repository/org/apache/deltaspike/cdictrl/deltaspike-cdictrl-openejb/1.7.1/deltaspike-cdictrl-openejb-1.7.1.jar]
INFORMATION - Beginning load:
c:\users\someuser\.m2\repository\org\apache\deltaspike\core\deltaspike-core-impl\1.7.1\deltaspike-core-impl-1.7.1.jar
INFORMATION - Enhancing url(s):
[file:/c:/users/someuser/.m2/repository/org/apache/deltaspike/core/deltaspike-core-impl/1.7.1/deltaspike-core-impl-1.7.1.jar]
INFORMATION - Beginning load:
c:\users\someuser\git\someproject3\someproject3-ejb\target\classes
INFORMATION - Enhancing url(s):
[file:/c:/users/someuser/git/someproject3/someproject3-ejb/target/classes/]
INFORMATION - Beginning load:
c:\users\someuser\.m2\repository\com\somecompany\someframework\someframework-commons\6.1.0-snapshot\someframework-commons-6.1.0-snapshot.jar
INFORMATION - Enhancing url(s):
[file:/c:/users/someuser/.m2/repository/de/nordlb/someframework/someframework-commons/6.1.0-snapshot/someframework-commons-6.1.0-snapshot.jar]
INFORMATION - Configuring enterprise application:
C:\Users\someuser\git\someproject3\someproject3-ejb
java.lang.ExceptionInInitializerError
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at org.apache.openejb.util.Classes.forName(Classes.java:64)
	at
org.apache.openejb.config.rules.ValidationBase.loadClass(ValidationBase.java:151)
	at
org.apache.openejb.config.rules.CheckClasses.check_hasInterface(CheckClasses.java:195)
	at
org.apache.openejb.config.rules.CheckClasses.validate(CheckClasses.java:118)
	at
org.apache.openejb.config.rules.ValidationBase.validate(ValidationBase.java:50)
	at org.apache.openejb.config.AppValidator.validate(AppValidator.java:102)
	at
org.apache.openejb.config.ValidateModules.deploy(ValidateModules.java:38)
	at
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:420)
	at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:1037)
	at
org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:322)
	at
javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
	at de.nordlb.someproject.biz.bc.SomeTestCase.setUp(SomeTestCase.java:39)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: javax.validation.ValidationException: More than one
META-INF/validation.xml is found in the classpath
	at
org.apache.bval.jsr.xml.ValidationParser.getInputStream(ValidationParser.java:204)
	at
org.apache.bval.jsr.xml.ValidationParser.__privileged_parseXmlConfig(ValidationParser.java:167)
	at
org.apache.bval.jsr.xml.ValidationParser.parseXmlConfig(ValidationParser.java)
	at
org.apache.bval.jsr.xml.ValidationParser.processValidationConfig(ValidationParser.java:108)
	at
org.apache.bval.jsr.ConfigurationImpl.parseValidationXml(ConfigurationImpl.java:357)
	at
org.apache.bval.jsr.ConfigurationImpl.createBootstrapConfiguration(ConfigurationImpl.java:349)
	at
org.apache.bval.jsr.ConfigurationImpl.prepare(ConfigurationImpl.java:340)
	at
org.apache.bval.jsr.ConfigurationImpl.__privileged_doBuildValidatorFactory(ConfigurationImpl.java:329)
	at
org.apache.bval.jsr.ConfigurationImpl.doBuildValidatorFactory(ConfigurationImpl.java)
	at
org.apache.bval.jsr.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:324)
	at
javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:41)
	at
de.nordlb.someproject.biz.bc.AbstractsomeprojectEntityService.<clinit>(AbstractsomeprojectEntityService.java:29)
	... 38 more
INFORMATION - Auto-deploying ejb AssetShipSearchService:
EjbDeployment(deployment-id=AssetShipSearchService)
INFORMATION - Auto-deploying ejb OrderShipService:
EjbDeployment(deployment-id=OrderShipService)
INFORMATION - Auto-deploying ejb EngineTypeService:
EjbDeployment(deployment-id=EngineTypeService)
INFORMATION - Auto-deploying ejb SelectableService:
EjbDeployment(deployment-id=SelectableService)
INFORMATION - Auto-deploying ejb LandService:
EjbDeployment(deployment-id=LandService)
INFORMATION - Auto-deploying ejb UserService:
EjbDeployment(deployment-id=UserService)
INFORMATION - Auto-deploying ejb StammdatenDefaultService:
EjbDeployment(deployment-id=StammdatenDefaultService)
INFORMATION - Auto-deploying ejb OrderShipSearchService:
EjbDeployment(deployment-id=OrderShipSearchService)
INFORMATION - Auto-deploying ejb ContractorService:
EjbDeployment(deployment-id=ContractorService)
INFORMATION - Auto-deploying ejb AssetShipService:
EjbDeployment(deployment-id=AssetShipService)
INFORMATION - Auto-deploying ejb MathHelper:
EjbDeployment(deployment-id=MathHelper)
INFORMATION - Auto-deploying ejb someprojectConfiguration:
EjbDeployment(deployment-id=someprojectConfiguration)
INFORMATION - Auto-deploying ejb InstituteEntityManager:
EjbDeployment(deployment-id=InstituteEntityManager)
INFORMATION - Configuring Service(id=Default Managed Container,
type=Container, provider-id=Default Managed Container)
INFORMATION - Auto-creating a container for bean
deltaspike-core-api-1.7.1.Comp536671860: Container(type=MANAGED, id=Default
Managed Container)
INFORMATION - Creating Container(id=Default Managed Container)
INFORMATION - Using directory C:\Users\someuser\AppData\Local\Temp for
stateful session passivation
INFORMATION - Auto-linking resource-ref 'java:comp/env/jdbc/dezentral.xa' in
bean AssetShipSearchService to Resource(id=My DataSource)
INFORMATION - Auto-linking resource-ref 'java:comp/env/jdbc/dezentral.xa' in
bean OrderShipSearchService to Resource(id=My DataSource)
INFORMATION - Auto-linking resource-ref 'java:comp/env/jdbc/dezentral.xa' in
bean someproject3-ejb.Comp719146276 to Resource(id=My DataSource)
INFORMATION - Configuring PersistenceUnit(name=someprojectPU)
INFORMATION - Adjusting PersistenceUnit someprojectPU <jta-data-source> to
Resource ID 'My DataSource' from 'jdbc/dezentral.xa'
INFORMATION - Adjusting PersistenceUnit someprojectPU <non-jta-data-source>
to Resource ID 'My Unmanaged DataSource' from 'null'
SCHWERWIEGEND - ERROR ... null:	Cannot validate jar: null
SCHWERWIEGEND - Invalid AppModule(name=, path=)
INFORMATION - Set the 'openejb.validation.output.level' system property to
VERBOSE for increased validation details.
WARNUNG - configureApplication.loadFailed
INFORMATION - Closing DataSource: My DataSource
INFORMATION - Closing DataSource: My Unmanaged DataSource
INFORMATION - Closing DataSource: someproject_junit

Many Thanks!



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/ValidationException-due-to-META-INF-validation-xml-s-url-capitalization-tp4681940.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Mime
View raw message