I am java/maven newbie and I am running into this weird issue and was hoping someone can shade some lights on it.
I have two maven project. Project A which is a dependency of class B. Project A in its pom.xml declare aws java sdk as its dependency:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.549</version>
</dependency>
Now Project B declare project A as its dependency and also declare aws-java-sdk-s3 with the exact same version as aws-java-sdk in project A:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.549</version>
</dependency>
However In my Intellij Dependency Analyzer I can see project B is using two version of s3 sdk 1.11.43 and 1.11.549. But Project A is using the correct version 1.11.549.
If I run project B inside my docker container it is throwing the following error:
... 41 more Caused by: java.lang.ClassNotFoundException:
com.amazonaws.SdkClientException at
java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at
org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedUR
LClassLoader.java:93) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 53 more
However when I remove the s3 sdk from dependency of project B the application come up successfully!
Can someone please explain to me or show me some pointers on how to debug this?
Also here is my intellij Analyzer
Related
I have 4 modules in my project.
Module1 (i.e. com.assign.print:printlog.value:3.0.0-SNAPSHOT) has one class i.e. Foo.java, inside this class, on more class is there which is using com.print.assess: mns.pro:2.0
Module2 , Module2 and Module4 are using com.print.assess: mns.pro:6.2.
In my project main pom.xml, the dependency is added as :
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
<version>6.2</version>
</dependency>
In Foo.java, I have one class as DataVal.java which is using older version.
If I don't add
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
<version>2.0</version>
</dependency>
to Module1 pom.xml, Redline error is coming for DataVal.java saying "cannot resolve the symbol". So when I added the dependency with version 2.0, the error was resolved but while installing project:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for com.print.assess:mns.pro:6.2 paths to
dependency are:
+-com.assign.print:printlog.value:3.0.0-SNAPSHOT
+-com.app.print:print.sal:1.1.3
+-com.print.assess:mns.pro:6.2
and
+-com.assign.print:printlog.value:3.0.0-SNAPSHOT
+-com.print.assess:mns.pro:2.0
and
+-com.assign.print:printlog.value:3.0.0-SNAPSHOT
+-com.print.assess.over:multi-task.rev:3.1
+-com.print.assess:mns.pro:6.2
How to resolve this issue?
Thanks in advance
If you have the dependencyConvergence enforcer rule active (which you obviously have), you need to determine your versions in the <dependencyManagement> (which is different from the standard <dependencies>).
Then you can declare the dependencies without version in <dependencies>. dependencyManagement entries can be in the main pom and in modules as well. #Bahmut gave you the link to understand dependencyManagement.
You may want to move your 6.2 dependency in your main pom to <dependencyManagement> so it does not get imported by default. Then you can simply import the 6.2 version in your module poms like this:
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
</dependency>
and in the module where you need version 2, you can import it like this:
<dependency>
<groupId>com.print.assess</groupId>
<artifactId>mns.pro</artifaxtId>
<version>2.0</version>
</dependency>
More information about dependency management can be found here:
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
I am trying to deploy sample Java EE Cargo Tracker application
https://github.com/javaee/cargotracker
I am able to deploy it by executing maven, which build project completely
mvn package cargo:run
However when I am trying to deploying application from IntelliJ Idea on Glassfish 4.1.12 I am getting
Internal Exception: java.lang.NoClassDefFoundError:
org/apache/commons/lang3/Validate. Please see server.log for more details.
My pom contains
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
<scope>compile</scope>
</dependency>
Tried 3.4 and 3.6, does not help, application fails to deploy with above error
This is configuration of artifact in IntelliJ IDEA
Project -> Artifact
Exploded WAR details
may be old or previous dependency occurring the issue so delete .m2 folder and use commons-lang3 version 3.5 update maven project and rebuild it and run it.
I'm getting the following errors :
Caused by: javax.persistence.PersistenceException: Failed to load provider from META-INF/services
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:115)
at javax.persistence.Persistence$PersistenceUtilImpl.isLoaded(Persistence.java:278)
at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62)
at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:94)
at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47)
at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:757)
... 96 more
Caused by: java.lang.ClassNotFoundException: me.prettyprint.hom.CassandraPersistenceProvider
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1858)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1709)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.apache.geronimo.osgi.locator.ProviderLocator.loadClass(ProviderLocator.java:195)
at org.apache.geronimo.osgi.locator.ProviderLocator.locateServiceClasses(ProviderLocator.java:524)
at org.apache.geronimo.osgi.locator.ProviderLocator.getServices(ProviderLocator.java:315)
at javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver.getPersistenceProviders(PersistenceProviderResolverHolder.java:108)
... 101 more
I have imported a pom dependeny in my project, the new pom dependeny inturn has some cassandra related dependeny shown below :
<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>
The cassandra project works good in stand alone. Can someone help me with this
Your project is complaining ClassNotFoundException:me.prettyprint.hom.CassandraPersistenceProvider which belongs to Cassandra hector client.
I am guessing your project was using hector core which is no longer active hector client github page. You have to migrate all dependencies to datastax's cassandra drivers and remove all hector-client related dependencies. check it here
I'm currently working with Intellij as IDE, and I have 4 projects:
- An Admin project (contains java & ember for the front-end)
- An WS project (contains the WS)
- An API project (contains the objects, dao's etc)
- A master project which only contains a pom to reference the other 3.
Admin and WS depend on API.
I deploy everything in JBoss. Maven clean-install works, but I can't deploy to jboss: I get a ClassNotFoundError: WS can't find classes in API
My pom of the master file looks like this:
<dependencies>
<dependency>
<groupId>API</groupId>
<artifactId>API</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:/.../api/target/API-1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>WS</groupId>
<artifactId>WS</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:/.../ws/www/target/WS-1.0.war</systemPath>
</dependency>
<dependency>
<groupId>Admin</groupId>
<artifactId>Admin</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:/.../admin/www/target/Admin-1.0.war</systemPath>
</dependency>
</dependencies>
I use Maven 3.3.3 and Jboss WildFly 8.2.1
In Project Settings I've simply put the 3 Maven libraries (Admin, WS, API) under
In the Deployement tab of the Jboss condfiguration, the 2 wars (Admin, WS) and the jar (API) are listed
The errors I get:
Failed to define class ...ws.endpoints.helpers.WS in Module "deployment.WS-1.0.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link .../ws/endpoints/helpers/WS (Module "deployment.WS-1.0.war:main" from Service Module Loader) Caused by: java.lang.NoClassDefFoundError: .../dao/helpers/Dao Caused by: java.lang.ClassNotFoundException: ...dao.helpers.Dao from [Module "deployment.WS-1.0.war:main" from Service Module Loader]
What am I doing wrong? Is there a better way to deploy all this?
I've also tried to use the local Maven repository to find the correct depedencies (removed the scope and system path), but I can't find them, although they are correct located under the C:\users.m2 directory
Thanks in advance!
Specifying scope as 'system' means that your artifact is always available and is not looked up in a repository, so if you are building those artifacts during your build life cycle - "system" scope is not the right way to go.
I would recommend:
1. Try packaging your artifacts and deploy to JBoss manually, just to make sure that it works
2. Then try it out with Maven plugin for JBoss: http://docs.jboss.org/jbossas/7/plugins/maven/latest/examples/deployment-example.html
I've been trying to setup the simplest of simple hibernate applications and for reasons beyond my mediocre way of thinking I cannot get it running. Maven is easy enough - adding dependencies to the build path, updating the project, blah blah blah yadda yadda yadda
It started off as a single ClassNotFoundException which required a missing dependency. I would import the missing jar and run the app again, only to get another ClassNotFoundException. Next thing I know I HAVE A TON OF JARS AND NO WORKING APPLICATION
*Directories have been masked to protect the unfortunate
I've used both Maven and Hibernate in my last project in Eclipse Kepler and it was almost too easy, ha! Updating to Luna was a real pain trying to get Maven to run correctly - disabling the Java Compilier Compliance Level just to be able to update the Dynamic Web Module, not to mention manually creating the missing src/main/java and src/test/java folders that are standard with a maven-archetype-webapp, the list goes on. I've spent tooooo much time just to get the thing to not fail.
In my last project all I needed to import was:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
That' was it! I was swimming in Session Factories and Updating database tables like it was my job (it is).
This leads me to believe some core functionality is missing from this new project. Perhaps I've overlooked something in the IDE Upgrade. Could almost guarantee its my Build Path. Please Help!
About my project - I'm using:
Eclipse Luna (Kepler was 100x easier to setup with Maven)
Maven Webapp Archetype
JDK-1.7
Hibernate Core 4-3.6
My latest Exception was
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/NamedStoredProcedureQuery
at org.hibernate.cfg.AnnotationBinder.bindDefaults(AnnotationBinder.java:276)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1402)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
at com.boa.ecris.test.Main.main(Main.java:22)
Caused by: java.lang.ClassNotFoundException: javax.persistence.NamedStoredProcedureQuery
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 4 more
If this is specific to the javax persistence-api.jar, it's already in there!!!
Java APIs change over time. You need to find the correct version of your dependency (namely the one which contains the version of the API which you want/need to use). Since you told Maven to use version 1.0.2 of persistance-api, that's what Maven will do - you might know better.
If the error doesn't go away, then your next step should be the Maven central repo, specifically the "find class for me" search dialog: http://search.maven.org/#search%7Cga%7C1%7Cfc%3Ajavax.persistence.NamedStoredProcedureQuery
Next, you need to understand which dependencies you want in your project and select the correct one from the list. Since Maven doesn't know about your constraints, that is something you have to figure out yourself.
A word of wisdom: A computer doesn't have a brain, bring your own.
When you have ClassNotFoundException, first of all you have to look at your repository site. You can get maven repository url from settings file in .m2 folder. Then you can search your dependency at that site with your artifact id and version. If your version is not there, you can see some other version and put it instead yours. So you can provide stability at your project without manual adding.
Luna can create the maven project hierarchy too. On the New maven project dialog check the Create a simple project (skip archetype selection) checkbox.