[EXCEPTION]:Task execution exception, Cause : java.lang.NoClassDefFoundError: org/apache/openjpa/conf/OpenJPAConfiguration - maven

Ihave started receiving this exception after including new dependencies in my pom.xml which are related to Cassandra. I'm using it for logging purpose in my application.
[EXCEPTION]:Task execution exception, Cause : java.lang.NoClassDefFoundError: org/apache/openjpa/conf/OpenJPAConfiguration
java.lang.NoClassDefFoundError: org/apache/openjpa/conf/OpenJPAConfiguration
at java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:1.7.0_79]
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585) ~[na:1.7.0_79]
at java.lang.Class.getConstructor0(Class.java:2885) ~[na:1.7.0_79]
at java.lang.Class.newInstance(Class.java:350) ~[na:1.7.0_79]
at org.apache.geronimo.osgi.locator.ProviderLocator.getServices(ProviderLocator.java:319) ~[geronimo-jpa_2.0_spec-1.1.jar:1.1]
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:108) ~[geronimo-jpa_2.0_spec-1.1.jar:1.1]
at javax.persistence.Persistence$PersistenceUtilImpl.isLoaded(Persistence.java:278) ~[geronimo-jpa_2.0_spec-1.1.jar:1.1]
at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:94) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:324) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]
at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:757) ~[hibernate-validator-4.1.0.Final.jar:4.1.0.Final]
at
Here's my pom.xml :
<dependencies>
<dependency>
<groupId>com.app.cops</groupId>
<artifactId>logging</artifactId>
<version>0.0.5-SNAPSHOT</version>
</dependency>
</dependencies>
Here's the logging project's pom.xml :
<dependencies>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-mapping</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<artifactId>hector-object-mapper</artifactId>
<groupId>org.hectorclient</groupId>
<version>3.1-10</version>
</dependency>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-all</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
Even after including the openjpa-all dependency in my pom.xml which has the OpenJPAConfiguration I still see this issue. Any help on this would be appreciated.

What's is OpenJPA doing with Cassandra ?
In your maven dependency, I can see:
cassandra-driver-core
cassandra-driver-mapping
hector-object-mapper
openjpa-all
If you're using Cassandra, the first 2 dependencies are enough. hector-object-mapper is useless because you have already cassandra-driver-mapping and openjpa-all is useless because it will never work for Cassandra.
Remember, Cassandra != relational database

Related

java.lang.ClassNotFoundException: io.netty.handler.logging.ByteBufFormat

I'm on integrating a third-party library into our application. For that I have added all the dependencies, however facing below error stack on application run.
Error stack-trace:
`
Caused by: java.lang.ClassNotFoundException: io.netty.handler.logging.ByteBufFormat
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 31 common frames omitted
`
Maven dependencies:
`
<dependency>
<groupId>com.affinda.api</groupId>
<artifactId>affinda-api-client</artifactId>
<version>0.4.2</version>
</dependency>
<dependency>
<groupId>com.microsoft.rest</groupId>
<artifactId>client-runtime</artifactId>
<version>1.7.14</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-runtime</artifactId>
<version>1.7.14</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-client-authentication</artifactId>
<version>1.7.14</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.84.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.84.Final</version>
</dependency>
`
I did check that ByteBufFormat is in netty-handler library from the docs and did check the dependency tree but haven't got any clue.
It might be too late, however I had the same problem.
The cause is that another dependency is overriding the netty version in your final pom. In my case it was spring boot dependencies (2.2.0-RELEASE) which was overriding netty to version 4.1.42Final instead of needed 4.1.86Final.
If you want to check who is responsible, you can run maven with goal help:effective-pom and search for the effective netty version management owner.
In order to solve the issue you can just specify the netty version among maven properties:
<properties>
.
.
<netty.version>4.1.86.Final</netty.version>
</properties>
In this way you will put back the expected netty version and everything will work like a charm.
Be careful to check that the other library is still working as well.

org.springframework.beans.factory.BeanDefinitionStoreException Failed to read candidate component class

I've read similar post but still cannot resolve this problem. I am using JDK 8 and Spring 5. So it's not due to version issue.
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [G:\githome\product-aggregation\target\classes\com\roger\product\ipc\viewobject\product\MultiUnitVO.class]; nested exception is java.lang.ArrayIndexOutOfBoundsException: 90
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:454)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:316)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:275)
at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:288)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 90
at org.springframework.asm.ClassReader.readUTF(ClassReader.java:2646)
at org.springframework.asm.ClassReader.readUTF8(ClassReader.java:2618)
at org.springframework.asm.ClassReader.readMethod(ClassReader.java:1110)
at org.springframework.asm.ClassReader.accept(ClassReader.java:729)
at org.springframework.asm.ClassReader.accept(ClassReader.java:527)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:65)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:430)
... 20 common frames omitted
It's like this. I developed a maven plugin and included it in my project. This plugin is used to generate fields for specific classes in process-classes phase. To achieve this, I used ASM(version 5.0) to modify classes. Maven dependency like this:
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.roger</groupId>
<artifactId>permission</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>5.0</version>
</dependency>
Then I included it in my project.
<plugin>
<groupId>com.roger</groupId>
<artifactId>authorization-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<id>execution1</id>
<phase>process-classes</phase>
<goals>
<goal>addFieldPermission</goal>
</goals>
</execution>
</executions>
</plugin>
My project also has indirect dependency on ASM(version 5.0.4). I even upgraded ASM to 5.0.4(same as project), it's still going wrong.
I doubted that it's due to ASM conflict but have no idea how to fix it. Any idea?
EDIT Seems it has problem with the modified class. I debugged ClassPathScanningCandidateComponentProvider(spring-context-5.0.8) and found that exception thrown from line 430 just for the modified resources(as I said I added some fields in them by maven plugin). But I decompiled the modified classes using javap and found it's valid. I guess there is problem with the modified classes but don't know what's it.
As stated in the error log this is clear index out of bound exception.
Caused by: java.lang.ArrayIndexOutOfBoundsException: 90
Finally I got a temp solution. I made the fields public and removed the methods generated and everything goes well.
The generated methods are the root cause. When I keep only the generated fields, Spring Boot started up successfully. Seems javassist 3.12.1.GA might go wrong with JDK 1.8. I will further investigate.

Maven embedded deploy not working with org.apache.httpcomponents.httpclient version 4.4

Within my application I have to (mvn) deploy artifacts programmatically. I do this with the help of the maven-embedder artifact and some really simple code:
MavenCli client = new MavenCli();
int result = client.doMain(new String[] { "deploy" }, "C:/some/path/to/my/pom", System.out, System.out);
To be able to do this, I had to add the following dependencies to my pom:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-basic</artifactId>
<version>1.0.2.v20150114</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-wagon</artifactId>
<version>1.0.2.v20150114</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3</version>
</dependency>
Problem is, when I change the version of httpclient to version 4.4 (the most recent one), I get the following error when trying to deploy:
4840 [main] WARN Sisu - Error injecting: org.apache.maven.wagon.providers.http.HttpWagon
java.lang.NoClassDefFoundError: org/apache/http/ssl/TrustStrategy
at java.lang.ClassLoader.defineClass1(Native Method)
...
Caused by: java.lang.ClassNotFoundException: org.apache.http.ssl.TrustStrategy
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
... 72 more
Anybody got an idea, why deploy works fine with version 4.3.x of org.apache.httpcomponents.httpclient and fails with version 4.4?
I suspect that the version of HttpCore? which HttpClient is based upon, still resolves to 4.3.x. Try explicitly setting it to 4.4
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4</version>
</dependency>

Could not initialize class org.apache.cxf.staxutils.StaxUtils

I'm developing an application using Spring/Maven and I'm experiencing a problem with a dependency. Everything was working but when I added a dependency to Spring-WS, my tests stopped working.
Here is the stacktrace I have, leading to a Failed to load ApplicationContext
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.cxf.staxutils.StaxUtils
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:256)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:203)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:199)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:98)
at javax.xml.ws.Service.<init>(Service.java:77)
at com.mycompany.webservice.documentservice.client.DocumentServiceService.<init>(DocumentServiceService.java:61)
at com.mycompany.service.implementation.DocumentService.<init>(DocumentService.java:121)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
And here is the new dependencies :
<!--
Spring WS
-->
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>${spring-ws.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-security</artifactId>
<version>${spring-ws.version}</version>
</dependency>
I think there is a conflict with CXF dependencies but can't find where :
<!--
Web Service
-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf.version}</version>
</dependency>
Here are the conflicts, but when I add an exclusion the problem still occurs
Thanks for the help.
Ok I fixed the issue by doing the following :
Upgrade from CXF 2.7.6 to 2.7.7
Add dependency to
<dependency>
<groupId>com.sun.xml.stream</groupId>
<artifactId>sjsxp</artifactId>
<version>${sjsxp.version}</version>
</dependency>
Can't explain why but the tests run well and the application too.

Thrift service as a bundle in OSGI

I was creating a simple Calculator service in thrift as a bundle in OSGI. The src/lib contains all the dependent jars, and they have been included in the pom.xml
<dependency>
<groupId>commons-lang-2.4</groupId>
<artifactId>commons-lang-2.4</artifactId>
<scope>system</scope>
<version>2.4</version>
<systemPath>${basedir}\src\lib\commons-lang-2.4.jar</systemPath>
</dependency>
<dependency>
<groupId>httpcore-4.1.3</groupId>
<artifactId>httpcore-4.1.3</artifactId>
<scope>system</scope>
<version>4.1.3</version>
<systemPath>${basedir}\src\lib\httpcore-4.1.3.jar</systemPath>
</dependency>
<dependency>
<groupId>httpclient-4.0-alpha4</groupId>
<artifactId>httpclient-4.0-alpha4</artifactId>
<scope>system</scope>
<version>4.0</version>
<systemPath>${basedir}\src\lib\httpclient-4.0-alpha4.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.thrift-0.9.0</groupId>
<artifactId>org.apache.thrift-0.9.0</artifactId>
<scope>system</scope>
<version>0.9.0</version>
<systemPath>${basedir}\src\lib\org.apache.thrift-0.9.0.jar</systemPath>
</dependency>
</dependencies>
Also the imported package has references to :
<Import-Package>
org.apache.commons.logging,
org.apache.felix.dm,
org.apache.thrift,
org.apache.thrift.async,
org.apache.thrift.meta_data,
org.apache.thrift.protocol,
org.apache.thrift.scheme,
org.apache.thrift.server,
org.apache.thrift.transport
......
It compiles fine but the bundle refuses to come up :
!Message framework Event Error
!STACK 0
org.osgi.framework.BundleException: The Bundle "org.thrift.northbound_0.4.0:SNAPSHOT[95]" could not be resolved. Reason:Missing Constraint Import-Package: org.apache.thift ; version="[0.9.0, 1.0.0)"
Any pointers as to what am I missing ?

Resources