I am encounting bug which is supposed to be fixed: isMember on #ElementCollection throws QuerySyntaxException: unexpected end of subtree
I googled about this issue and found ticket HHH-5799 and HHH-5209 where its claimed to be resolved in Hibernate 4.1.8, 4.3.0.Beta1.
I am trying to query for ProductType by one of its barcodes.
My entity looks like this:
#Entity
#XmlRootElement
public class ProductType implements Serializable {
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue
private Long id;
#NotNull
#ElementCollection
private List<String> barcodes = new LinkedList<String>();
... getters+setters
}
I am using criteria api to query for product type by barcode using this code:
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ProductType> c = cb.createQuery(ProductType.class);
Root<ProductType> f = c.from(ProductType.class);
c.select(f).where(cb.isMember(barcode, f.get(ProductType_.barcodes)));
TypedQuery<ProductType> query = em.createQuery(c);
return query.getSingleResult();
I made a simple test:
#Test
public void testProductTypeWithMultipleBarcodes()
{
ProductType type = new ProductType();
List<String> barcodes = new LinkedList<String>();
barcodes.add("1234561");
barcodes.add("1234562");
barcodes.add("1234563");
type.setBarcodes(barcodes);
em.persist(type);
em.flush();
assertEquals(type, productRepository.findProductTypeByBarcode("1234561"));
assertEquals(type, productRepository.findProductTypeByBarcode("1234562"));
assertEquals(type, productRepository.findProductTypeByBarcode("1234563"));
}
But I am getting org.hibernate.hql.internal.ast.QuerySyntaxException:
Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException: org.hibernate.hql.internal.ast.QuerySyntaxException : unexpected end of subtree [select generatedAlias0 from cz.nuc.skladnik.storagecycle.product.ProductType as generatedAlias0 where :param0 member of generatedAlias0.barcodes] [Proxied because : Original exception not deserilizable, ClassNotFoundException]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:79)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:238)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:119)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:214)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:192)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1537)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:487)
Before exception I see:
00:40:44,965 ERROR [org.hibernate.hql.internal.ast.ErrorCounter] (http--0_0_0_0_0_0_0_0-8080-1) <AST>:0:0: unexpected end of subtree: <AST>:0:0: unexpected end of subtree
at org.hibernate.hql.internal.antlr.SqlGeneratorBase.selectClause(SqlGeneratorBase.java:490) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
mentioning hibernate-core-4.0.1.Final. So I've tried to add dependency on hibernate-core in my pom with no result:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.1.Final</version>
</dependency>
Full pom.xml is here: http://pastebin.com/8U30fPpn
I think that hibernate-core-4.0.1.Final is dragged in by some other dependency. Is this source of my problem? And if yes is there any way to find out what dependency is the black sheep?
My container is JBoss 7.1.1 and I am using Arquillian for tests. As IDE I use IntelliJ Idea 13.
mvn dependency:tree: http://pastebin.com/k4YM1DpY
UPDATE: I found out that hibernate 4.0.1 was dragged in by JBoss server itself. So I tried to ugrade Hibernate using this Updating the Hibernate 4.x jars to a different Hibernate 4.x version
However after doing this I am getting NoClassDefFoundError: org/jboss/as/jpa/hibernate4/JBossAppServerJtaPlatform.
00:18:36,088 ERROR [org.jboss.as.controller.management-operation] JBAS014612: Operation ("parallel-extension-add") failed - address: ([]): java.lang.RuntimeException: JBAS014670: Failed initializing module org.jboss.as.jpa
at org.jboss.as.controller.extension.ParallelExtensionAddHandler$1.execute(ParallelExtensionAddHandler.java:99) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:385) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:272) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:200) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:149) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:190) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.ServerService.boot(ServerService.java:291) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.server.ServerService.boot(ServerService.java:266) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:155) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/jboss/as/jpa/hibernate4/JBossAppServerJtaPlatform
at java.util.concurrent.FutureTask.report(FutureTask.java:122) [rt.jar:1.7.0_51]
at java.util.concurrent.FutureTask.get(FutureTask.java:188) [rt.jar:1.7.0_51]
at org.jboss.as.controller.extension.ParallelExtensionAddHandler$1.execute(ParallelExtensionAddHandler.java:91) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
... 9 more
Caused by: java.lang.NoClassDefFoundError: org/jboss/as/jpa/hibernate4/JBossAppServerJtaPlatform
at org.jboss.as.jpa.hibernate4.HibernatePersistenceProviderAdaptor.injectJtaManager(HibernatePersistenceProviderAdaptor.java:59)
at org.jboss.as.jpa.processor.PersistenceProviderAdaptorLoader.loadPersistenceAdapterModule(PersistenceProviderAdaptorLoader.java:112)
at org.jboss.as.jpa.subsystem.JPAExtension.initialize(JPAExtension.java:118)
at org.jboss.as.controller.extension.ExtensionAddHandler.initializeExtension(ExtensionAddHandler.java:88) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.extension.ParallelExtensionAddHandler$ExtensionInitializeTask.call(ParallelExtensionAddHandler.java:127) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.extension.ParallelExtensionAddHandler$ExtensionInitializeTask.call(ParallelExtensionAddHandler.java:113) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.0.0.GA.jar:2.0.0.GA]
Caused by: java.lang.ClassNotFoundException: org.jboss.as.jpa.hibernate4.JBossAppServerJtaPlatform from [Module "org.jboss.as.jpa.hibernate:4" from local module loader #4e66ae7 (roots: d:\Programy\jboss-as-7.1.1.Final\modules)]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398) [jboss-modules.jar:1.1.1.GA]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120) [jboss-modules.jar:1.1.1.GA]
... 11 more
If you are somehow pulling in two org.hibernate:hibernate-core artifacts, dependency mediation should kick in and choose one. And there's no sign that you're pulling in two Hibernate artifacts with different coordinates from your dependency:tree output. So it sounds more like a misconfigured project than JAR hell per se, i.e. where you're pulling in conflicting libraries. If you want to be completely sure, though, check for duplicate files in your classpath using
mvn com.ning.maven.plugins:maven-duplicate-finder-plugin:1.0.4:check
which is a good JAR hell plugin.
Your POM file and dependency:tree output is showing your JBoss and Hibernate versions as RELEASE. I don't know if that's a JBoss thing, but it's unclear to me what version RELEASE corresponds to. You should try specifying versions in your dependency management section and seeing if the problem persists, e.g.
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.4.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
...
<dependencies>
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
</dependencies>
This has the advantage that you fix the version of the dependency for your whole project, including transitive dependencies, instead of hoping dependency mediation picks the right one.
By the way, a simpler way to get what you need out of dependency:tree is to filter, in your case using
mvn dependency:tree -Dincludes=:*hibernate*::
Try to run this command in the same directory as the pom.xml:
mvn dependency:tree -Ddetail=true -Dincludes=org.hibernate:hibernate-core
This will give you the dependency tree of not only the hibernate-core that was chosen, but other versions dependencies that altough present, where not chosen because some other dependency took precendence.
When in doubt which transitive dependency to choose, maven applies the following rules:
the dependency that is the closest to the pom.xml project wins. for example if one version is two levels away in the tree and another 1 level away, the one 1 level away wins.
if all dependencies are at the same level of distance from the pom.xml artifact, the one that shows up first on the pom wins.
The solution for this problem is to see with the comand above everyone that is requiring hibernate-core, decide which version you want and add the proper exclusions.
EDIT: The problem is that JBoss 7 is an EJB container that includes JPA, and the JPA on the server is interfering with the JPA on the WAR. This is because by default JBoss 7 works in 'server first' mode, where it will fetch libraries first from the server and only if they don't exist from the application.
You can change this to 'server last', where the jars on your application always take precedence. This can be done by setting java2ParentDelegation=false in file jboss-app.xml or jboss-web.xml - see also this answer.
You can also turn off server modules one by one, but this is more error prone.
For that, create a file in src/main/resources/META-INF named jboss-deployment-structure.xml, and there turn off the hibernate/JPA modules on the server:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.hibernate" />
<module name="org.jboss.as.jpa" />
<module name="org.jboss.as.jpa.hibernate" />
...
</exclusions>
</deployment>
</jboss-deployment-structure>
Related
EDIT: Just realised it's caused by a ClassNotFoundException, would still like some help.
I'm trying to update keycloak from version 12.0.3 to version 13.0.0, however when I make that change I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/jsontype/PolymorphicTypeValidator
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructors(Class.java:1651)
at org.jboss.resteasy.util.PickConstructor.pickSingletonConstructor(PickConstructor.java:30)
at org.jboss.resteasy.spi.ResteasyProviderFactory.createConstructorInjector(ResteasyProviderFactory.java:2821)
at org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2813)
at org.jboss.resteasy.spi.ResteasyProviderFactory.addMessageBodyReader(ResteasyProviderFactory.java:1048)
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1821)
at org.jboss.resteasy.spi.ResteasyProviderFactory.register(ResteasyProviderFactory.java:3026)
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.register(ResteasyClientBuilder.java:559)
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.register(ResteasyClientBuilder.java:48)
at org.keycloak.admin.client.Keycloak.newRestEasyClient(Keycloak.java:71)
at org.keycloak.admin.client.Keycloak.<init>(Keycloak.java:53)
at org.keycloak.admin.client.KeycloakBuilder.build(KeycloakBuilder.java:147)
at socsan.myapp.v1.mymodule.keycloak.KeycloakUserManager.createKeycloakInstance(KeycloakUserManager.java:187)
at socsan.myapp.v1.mymodule.keycloak.KeycloakUserManager.<init>(KeycloakUserManager.java:36)
at socsan.myapp.v1.mymodule.mymodule.startServices(mymodule.java:51)
at socsan.myapp.common.lifecycle.ProcessStarter.runStartupTasks(ProcessStarter.java:61)
at socsan.myapp.common.lifecycle.ProcessStarter.start(ProcessStarter.java:48)
at socsan.myapp.v1.mymodule.mymodule.main(mymodule.java:34)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 20 more
I tried updating the fasterxml databind package too, but it didn't make any difference.
I noticed that the path to the correct jar in the maven repository is different to the path in the error.
In the maven repository there are stored at com/fasterxml/jackson/core/databind.
Does that have any baring on the issue?
How can I fix this?
EDIT 2:
In the parent pom we have this:
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.8</version>
</dependency>
The only change made to the module pom was to increase the version as stated above.
looking at the dependency analyser for jackson-databind it does look a bit of a mess, I should also point out that we're using the maven shade plugin:
I'm having errors during deployment with Spring-boot 2.1.2.RELEASE on
WebLogic 12.2.1.2.0.
This is the stack trace:
Caused By: java.lang.IllegalAccessError: tried to access method com.fasterxml.jackson.databind.ser.std.StdSerializer.<init>(Ljava/lang/Class;)V from class com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
at com.fasterxml.jackson.datatype.jsr310.JavaTimeModule.<init>(JavaTimeModule.java:168)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:122)
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.registerWellKnownModulesIfAvailable(Jackson2ObjectMapperBuilder.java:760)
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.configure(Jackson2ObjectMapperBuilder.java:639)
at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:623)
at org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.<init>(MappingJackson2HttpMessageConverter.java:59)
at org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.<init>(AllEncompassingFormHttpMessageConverter.java:76)
at org.springframework.web.filter.FormContentFilter.<init>(FormContentFilter.java:60)
at org.springframework.boot.web.servlet.filter.OrderedFormContentFilter.<init>(OrderedFormContentFilter.java:29)
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.formContentFilter(WebMvcAutoConfiguration.java:166)
I've tried adding this to the weblogic.xml:
<wls:package-name>com.fasterxml.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.databind.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.datatype.jsr310.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.datatype.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.module.*</wls:package-name>
I've also tried using prefer-web-inf classes. The StdSerializer class is in the jackson-datatype-jsr310:2.9.8 jar, which theoretically shouldn't be an issue because welogic doesn't have Jackson included. Any help would be appreciated.
1) Keep only these packages in your weblogic.xml file, the others are unnecessary:
<wls:prefer-application-packages>
<wls:package-name>org.slf4j.*</wls:package-name>
<wls:package-name>org.springframeworks.*</wls:package-name>
<wls:package-name>com.fasterxml.jackson.*</wls:package-name>
</wls:prefer-application-packages>
2) Include this in your pom.xml as per Spring Docs, section 92.1:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
This error happens because Spring Boot is trying to start a Tomcat container, causing classpath conflicts. Setting the dependency as provided will remove most of those, and including com.fasterxml.jackson.* in your weblogic.xml will take care of the remaining conflict.
Below is my stack trace.
Caused by: java.lang.NoClassDefFoundError: org/apache/axiom/om/util/StAXParserConfiguration
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:64)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:197)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
After a bit searching found that, the dependencies in my project for org.apache.axis2 were been upgraded from 1.5.1 to 1.5.3.
After 1.5.1 version had a transitive dependency on the library having the StAXParserConfiguration class.
But the later(newer) one does not have it. As such, I have to add the artifact explicitly in my pom.
You probably need to bundle the missing library with your deployed artifact,
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.14</version>
</dependency>
I am receiving an error when running my spring-boot application with embedded-tomcat (haven't tried with server tomcat yet).
java.lang.IllegalStateException: Tomcat 7 reflection failed
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.scan(SkipPatternJarScanner.java:77)
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:271)
at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:590)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5522)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException: null
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.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.scan(SkipPatternJarScanner.java:73)
... 12 common frames omitted
Caused by: java.lang.NoClassDefFoundError: oracle/i18n/util/LocaleMapper
at oracle.xml.parser.v2.XMLReader.setEncoding(XMLReader.java:980)
at oracle.xml.parser.v2.XMLReader.checkXMLDecl(XMLReader.java:3284)
at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:570)
at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:274)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:232)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1576)
at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:565)
at org.apache.catalina.startup.TldConfig.tldScanJar(TldConfig.java:513)
at org.apache.catalina.startup.TldConfig.access$200(TldConfig.java:61)
at org.apache.catalina.startup.TldConfig$TldJarScannerCallback.scan(TldConfig.java:300)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:259)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:221)
... 17 common frames omitted
Caused by: java.lang.ClassNotFoundException: oracle.i18n.util.LocaleMapper
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 29 common frames omitted
On further inspection, It appears as though the previous version of the orai18n.jar depended on by the ojdbc7 maven dep contained this class in vesion 11.2.0.3 but the newer (12.1.0.2) file does not contain it.
After much hassle, I've found the root cause (Edit: Actually the better answer provided has a more appropriate cause/solution, see Serri's answer):
according to this bug comment in spring-boot The Oracle SaxParserFactory impl and the (later run into after solving the first) DocumentBuilderFactory implementations are picked up instead of the default xerces impls. Changing the implementation using the META-INF/services/<class-name> files solved the issue:
in my.jar:
and each file:
// javax.xml.parsers.DocumentBuilderFactory
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
// javax.xml.parsers.SAXParserFactory
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
This causes each service finder to resolve the default xerces implementation in the standard java library.
It's a conflict with xmlparserv2.
Try this :
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
<exclusions>
<exclusion>
<groupId>com.oracle.jdbc</groupId>
<artifactId>xmlparserv2</artifactId>
</exclusion>
</exclusions>
</dependency>
In my case I had the Oracle Jars installed under $CATALINA_HOME/lib to be able to set up a JNDI DB connection in Tomcat, simply removing xmlparserv2.jar from the $CATALINA_HOME/lib directory resolved the problem.
New change for xdb instead com.oracle.jdbc use: com.oracle.ojdbc.
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>xdb</artifactId>
<version>19.3.0.0</version>
<exclusions>
<exclusion>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>xmlparserv2</artifactId>
</exclusion>
</exclusions>
</dependency>
The cause of the problem is as Serri said, except for the solution given by Serri I think if you use IntelliJ IDEA as a coding tool, please check Project Structure Artifacts to remove the dependency on xmlparserv2, this worked for me
Remove conflicting dependencies
I'm doing a major refactor of a web application using the maven multi-module approach.
At the get-go there was only 1 module.
I've slowly been breaking out functionality and creating a dependency chain that the main module would depend on.
Other pertinent information worth mentioning:
We are using the following:
TomEE (Apache TomEE-JAXRS 1.5.1)
OpenEJB
Apache Maven
JDK 1.7.x
Currently my web-app is structured like this:
parent
pom.xml
|
common
pom.xml
|
persistence
pom.xml
|
export
pom.xml
|
main
pom.xml
So...
The common module's pom has NO other module dependencies.
The persistence module's pom has the following dependencies:
common
The export module's pom has the following dependencies:
common
persistence
The main module's pom has the following dependencies:
common
persistence
export
The parent module's pom specifies the REACTOR Build Order as follows:
common
persistence
export
main
Prior to the creation of the export module everything would build and deploy fine; however, now that I've broken out additional stuff from main and put it into the export module, the build is fine, but when I deploy the generated WAR file, the following stack-trace shows up upon start-up:
SEVERE: ContainerBase.removeChild: destroy:
org.apache.catalina.LifecycleException: An invalid Lifecycle transition was attempted ([before_destroy]) for component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]] in state [STARTING_PREP]
at org.apache.catalina.util.LifecycleBase.invalidTransition(LifecycleBase.java:409)
at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:299)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1041)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1167)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeploy(TomcatWebAppBuilder.java:1148)
at org.apache.tomee.catalina.TomcatWebAppBuilder.undeployWebApps(TomcatWebAppBuilder.java:635)
at org.apache.openejb.assembler.classic.Assembler.destroyApplication(Assembler.java:1275)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:955)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:537)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:982)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Oct 05, 2016 12:51:23 PM org.apache.tomee.catalina.TomcatWebAppBuilder startInternal
SEVERE: Unable to deploy collapsed ear in war
StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp] org.apache.openejb.OpenEJBException: Creating application failed:
C:\java\servers\apache-tomee-jaxrs-1.5.1\webapps\act-cde: Error building bean 'TaskDataAccessServices'. Exception: class java.lang.NoClassDefFoundError:
Could not initialize class com.myapp.cde.persistence.ejb.TaskDataAccessServices: Could not initialize class com.myapp.cde.persistence.ejb.TaskDataAccessServices
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:959)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:537)
at org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:982)
at org.apache.tomee.catalina.TomcatWebAppBuilder.configureStart(TomcatWebAppBuilder.java:901)
at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:118)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.openejb.OpenEJBException: Error building bean 'TaskDataAccessServices'. Exception: class java.lang.NoClassDefFoundError:
Could not initialize class
com.myapp.cde.persistence.ejb.TaskDataAccessServices: Could not
initialize class
com.myapp.cde.persistence.ejb.TaskDataAccessServices
at org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarBuilder.java:81)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:713)
... 18 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.myapp.cde.persistence.ejb.TaskDataAccessServices
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.load(EnterpriseBeanBuilder.java:425)
at org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.loadClass(EnterpriseBeanBuilder.java:405)
at org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.build(EnterpriseBeanBuilder.java:81)
at org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarBuilder.java:66)
... 19 more
Notice the TaskDataAccessServices mentioned in the stack-trace. This class is located in the persistence module. What's weird is that it's NOT used at all in the export module, which I've just created.
Question of the day: What's the best approach at debugging this issue?
I've thought about backing out changes one by one and putting classes back into the main module --- but this could take awhile ...
Wondering if there was a silver bullet approach to resolving this?
Cheers.
I'd open up your artifact and see if com.myapp.cde.persistence.ejb.TaskDataAccessServices is actually present in it.
That's what this stack trace is telling you:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.myapp.cde.persistence.ejb.TaskDataAccessServices
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.load(EnterpriseBeanBuilder.java:425)
at org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.loadClass(EnterpriseBeanBuilder.java:405)
at org.apache.openejb.assembler.classic.EnterpriseBeanBuilder.build(EnterpriseBeanBuilder.java:81)
at org.apache.openejb.assembler.classic.EjbJarBuilder.build(EjbJarBuilder.java:66)
... 19 more
In the main pom.xml file, I had the following <dependency>:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.8.3</version>
</dependency>
In the export pom.xml file, I had the following <dependency>:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
</dependency>
Little did I know that the ehcache had it's own dependency of slf4j.
Changing the ehcache <dependency> to the following fixed things up for me:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.8.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Figuring this out required me to back things out one at a time until things stopped breaking.
Lesson learned here: commit small, commit often.