My application is failing because of the following issue :
Source '/.../.ivy2/jars/org.apache.zookeeper_zookeeper-3.4.6.jar' does not exist
But I see, there exists a jar in that folder with "tests" suffix - org.apache.zookeeper_zookeeper-3.4.6-tests.jar
If I remove -tests from the name manually, the application runs fine.
I need to understand how can I place the jar my application is expecting in .ivy folder through my program/dependency.
Also, when are the all jars loaded in .ivy/jars folder, is it during the build?
I am using java with maven.
<!-- https://mvnrepository.com/artifact/org.apache.zookeeper/zookeeper -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
<type>pom</type>
</dependency>
add this to your maven dependencies also the org.apache.zookeeper_zookeeper-3.4.6-tests.jar is for the test environment.
Related
Following import in an existing class is throwing a compilation error "import cannot be resolved" on eclipse -
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
The corresponding jar inclusion in pom.xml is -
<properties>
<fasterxml.version>0.7.0</fasterxml.version>
</properties>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-module-hibernate</artifactId>
<version>${fasterxml.version} </version>
</dependency>
I checked that the corresponding jar file is not present in .m2.
There is no such directory as jackson-module-hibernate inside .m2/fasterxml/
However, jar corresponding to another declaration is present in .m2 -
com.fasterxml.jackson.core
jackson-annotations
2.6.1
Is present in .m2/fasterxml/jackson/core/jackson-annotations/2.6.1
as jackson-annotations-2.6.1.jar
Setup details
Maven version - 3.3
Java version - 1.8.
Eclipse latest version - 2019-06.
I could not verify the absence of the first jar in the working sandbox setup, but that's how it should be, as we had taken a backup of the .m2 directory. How is it possible that the application runs in another setup without the presence of the jar.
Note - I am still a struggler when it comes to maven dependencies and the setup of this legacy project has made me pull hairs. I am trying to do the setup on eclipse. It got setup sometime back, after a lot of struggle, but before I could document all the steps/workarounds we made, I deleted the working setup by mistake.
Update
The pom declaration for jackson-annotations is in the pom of another project. That project has been included in the pom of the dependent project as -
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.dependencies</groupId>
<artifactId>dependency-project</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
You also need:
Execute mvn clean compile from Command Line, on another project
Execute mvn clean compile on your project
Right-click on Project > Maven > Update project...
We are not Maven yet, and I’m trying to run a cucumber feature. Getting the below error.
java.lang.NoClassDefFoundError: org.picocontainer.PicoBuilder at
cucumber.runtime.java.picocontainer.PicoFactory.start(PicoFactory.java:17)
Below is my folder structure for src.
src
test.java.stepdefinition.holiday
Myholiday_StepDef.java
MyRunner.java
test.resources.features
holiday.feature
Add Jar file of “PicoContainer Core” to build path of your project if you are using java project.
You can use maven dependency for “PicoContainer Core” to your pom.xml (for Maven project) as mentioned below.
<dependency>
<groupId>org.picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>2.14.1</version>
</dependency>
I have 4 projects in my eclipse workspace. They are all 4 maven projects. The names are API, Games, Faction, Board.
API is used in all the other maven projects (Games, Faction, Board) and itself depends of a jar into my PC and also HikariCP.
I declare this dependencies in my API pom.xml
<dependency>
<groupId>org.github.paperspigot</groupId>
<artifactId>paperspigot-api</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}\lib\paperspigot-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.8</version>
<scope>compile</scope>
</dependency>
Then I declare on my 3 other projects that they depend of API
<dependency>
<groupId>net.onima</groupId>
<artifactId>onimaapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
But I have a big warning on the API and the error log says this:
I don't understand why is there this error as I can code with the API in my classes. Can someone explain me? Thanks
EDIT: As requested the text of the screenshot:
Description Resource Path Location Type
Project 'OnimaAPI' is missing required Java project: 'paperspigot' OnimaAPI Build path Build Path Problem
Description Resource Path Location Type
Project 'OnimaGames' is missing required Java project: 'onimaapi' OnimaGames Build path Build Path Problem
I don't know why I can't set the pom.xml here so here's a link: https://ghostbin.com/paste/r4u62
You're declaring paperspigot with system scope.
<dependency>
<groupId>org.github.paperspigot</groupId>
<artifactId>paperspigot-api</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${basedir}\lib\paperspigot-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
Dependencies with the scope system are always available and are not looked up in repository. They are usually used to tell Maven about dependencies which are provided by the JDK or the VM.
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies
You should declare it with compile scope:
This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
I'm new to Maven, have looked for some help with my problem but couldn't find a proper solution.
I have a main project in Maven, which has a dependency to my second project:
<dependency>
<groupId>a.b.c</groupId>
<artifactId>childproject</artifactId>
<version>1.1</version>
</dependency>
Both projects have their properties files: mainproject.properties, childproject.properties.
When I deploy the main project, childproject.jar goes to \lib folder, along with all other dependencies. But the childproject.properties is "build into" the childproject.jar. If I place another childproject.properties file next to mainproject.properties in \configuration folder, it is seen and used.
What could I do so Maven places childproject.properties automatically in the \configuration folder?
childproject.properties
pom mainproject has :
<dependency>
<groupId>a.b.c</groupId>
<artifactId>childproject</artifactId>
<version>1.1</version>
</dependency>
And add file in :
mainproject
/src/main/resources/mainproject.properties
childproject , add file in:
childproject
/src/main/resources/childproject.properties
When you deploy the main project => childproject.jar contain in classpath childproject.properties
You do not need to create a directory 'configuration' for the project 'mainproject' uses 'childproject.properties'.
I'm brand new in Maven. I'm working with Spring-Maven project, it generates a WAR file with 95Mb of dependencies (JARs) and 5Mb of my code.
There is anyway to separate code and libs? packaging my code into WAR and all dependencies into other WAR/Jar?.
Im deploying my app in tomcat server.
Thank you in advance!
You can exclude selected dependencies in the WAR by specifying scope as provided in your pom.
For example:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
Just make sure your dependencies are available in the classpath. You can put them in shared lib directory in server.
For example, in tomcat it's /lib directory.