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>
Related
I want to connect to mysql using jdbc in my spring project. I havee added the mysql-connector dependency to the pom.xml project file:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.26</version>
</dependency>
This is throwing an error:
The container 'Maven Dependencies' references non existing library 'C:\Users\User\.m2\repository\mysql\mysql-connector-java\8.0.26\mysql-connector-java-8.0.26.jar'
Once I remove this, everything works fine. Same issue with c3p0 dependency.
Please help.
1.Go to your project path and run maven install.wait until the installation process is completed successfully.
2.Then Run maven update.
3.Try to clean your project and do maven build.
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.
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...
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've included the Maven based project into my application, added Deployment Assembly which shows that the .jar file gets copied to WEB-INF/lib/ImportedProject.jar.
Problem occurs when imported lib wants to reference the lib that it is using which, apparently, does not get included inside the ImportedProject.jar.
Example:
ImportedProject pom.xml has:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
When I add ImportedProject.jar to my Non-Maven project and run it, I get exception:
threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
My question is: How to add both that Maven project and its dependencies?
maven dependency plugin helps to get required project library with it's dependencies.
So, If you would like to add POM based project on NON-POM based project, all you would do is to execute mvn dependency:copy-dependencies command and you will have all dependencies on target/dependencies folder. Copy all jar from dependencies and paste to WEB-INF/lib directory.