Using the following command line:
mvn versions:unlock-snapshots dependency:copy-dependencies
I get all snapshot jars with the SNAPSHOT.jar name in the dependency folder.
Why do I don't get the same behavior when packaging my project into a war?
Instead of getting mylibs-modules-1.0-SNAPSHOT.jar, I get those incrementing numbers.
EDITED
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>mylibs</artifactId>
<packaging>war</packaging>
<version>3.4</version>
<parent>
<groupId>parent</groupId>
<artifactId>mylibs-parent</artifactId>
<version>3.4</version>
</parent>
<build>
<finalName>mylibs-war</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
</plugins>
</build>
PARENT POM FILE
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>parent</groupId>
<artifactId>mylibs</artifactId>
<packaging>pom</packaging>
<version>3.4</version>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-tests</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-processor</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-persistence</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-databean</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-localization</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-net</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-lang</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-metadata</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-events</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>mylibs</groupId>
<artifactId>mylibs-logging</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
The plugin goal is not designed to be run as part of the lifecycle per the documentation. The Attributes section describing the unlock-snapshots goal says
Executes by direct invocation only.
This means it will only run if you type mvn versions:unlock-snapshots at the command line as you have been doing.
Just noted the comment above about how the commands are run:
mvn versions:unlock-snapshots package
I suspect this doesn't work because the unlock-snapshots goal is actually changing the POM, however the package phase is running with the original, unmodified version of the POM. Perhaps running the build with -X will show this.
Related
I have a maven Spring boot project for which I've created a jar to use as a dependency externally in other projects. I just can't get it to work. Here are my steps.
Here is my pom.xml for Project 1.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.myapp.logmonitoring</groupId>
<artifactId>logmonitoring</artifactId>
<name>logmonitoring</name>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.awaitility/awaitility -->
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.4.5</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>logmonitoring/logmonitoring-app</finalName>
</configuration>
</plugin>
</plugins>
</build>
And this is my pom.xml for Project 2. It just doesn't work.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.myapp.logmonitoring.host1</groupId>
<artifactId>logmonitoring-host1</artifactId>
<name>logmonitoring-host1</name>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.myapp.logmonitoring</groupId>
<artifactId>logmonitoring</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
You have to put Jar as well as pom file of 1st project in.m2 repository.
.m2/org/myapp/logmonitoring/1.0-SNAPSHOT.
then add dependency like this
<dependency>
<groupId>org.myapp</groupId>
<artifactId>logmonitoring</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
If you are using mac then you can find .m2 repository in
/Users/<user_name>/.m2.
In Windowns it's in
C:\Users<User_Name>.m2
In linux it's in
/home/<User_Name>/.m2
Also unhide Hidden files
This really helped me solve it - http://www.avajava.com/tutorials/lessons/how-do-i-add-a-project-as-a-dependency-of-another-project.html
I've created a SpringBoot2.4.2/Maven/Java8 project like this :
hr-sprg (parent project 1.0-SNAPSHOT)
hr-objects-sprg (module 0.0.1-SNAPSHOT)
hr-cucumber-sprg (module 0.0.1-SNAPSHOT with dependency on hr-objects)
I've created a dummy object in hr-objects and test it both in hr-objects and in hr-cucumber (unit tests).
Import is OK, object is instanciated and tests pass.
When I want to clean install the parent project, I have this error :
java.lang.NoClassDefFoundError: com/citizenweb/games/hrsprg/hrobjectssprg/entities/Game at com.citizenweb.games.hrsprg.hrcucumbersprg.HrCucumberSprgApplicationTests.createGame(HrCucumberSprgApplicationTests.java:17)
I've done many tries since a few days, always finishing with an error saying that the Game object isn't found.
But if I do a clean test or clean test test-compile, it works.
I don't understand why "mvn test" is OK while "mvn install" fails.
I've passed a lot of time to resolve this problem, but I'm drying now.
Have you any suggestions ?
I can show u :
Parent POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.citizenweb.games</groupId>
<artifactId>hr-sprg</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>hr-sprg</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<modules>
<module>../hr-objects-sprg</module>
<module>../hr-cucumber-sprg</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
hr-objects POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.citizenweb.games</groupId>
<artifactId>hr-sprg</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../hr-sprg</relativePath>
</parent>
<groupId>com.citizenweb.games.hr-sprg</groupId>
<artifactId>hr-objects-sprg</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>hr-objects-sprg</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
hr-cucumber POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.citizenweb.games</groupId>
<artifactId>hr-sprg</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../hr-sprg</relativePath>
</parent>
<groupId>com.citizenweb.games.hr-sprg</groupId>
<artifactId>hr-cucumber-sprg</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>hr-cucumber-sprg</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.citizenweb.games.hr-sprg</groupId>
<artifactId>hr-objects-sprg</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Following a response made to my question, I think these informations could be usefull :
M2 folder content :
:
HR-OBJECTS JAR content :
First you said:
Import is OK, object is instanciated and tests pass.
Then:
Now with IntelliJ, problem arise... (I've seen posts about similar
problems with Idea)
You contradict to yourself. Your first statement means actually that IDEA works perfectly. The problem occurs not with IDEA, but with Maven. Please be more precise in what are you saying :)
Have you any suggestions ?
Check if your directory structure corresponds to structure in pom.xml. According to your pom.xml files, all projects are in the same directory, module projects are not nested into the parent project "hr-prg". If actually the modules are subdirectories of "hr-prg", then adjust all pom.xml files accordingly.
I suppose that you use IDEA to compile your code and to run tests. That's why it works. IDEA compiles the needed code, sets class path accordingly and all needed classes will be found. But when you execute test with Maven, maven needs JAR for every dependency. I suppose you have built module "hr-objects-sprg" before there was class Game. After you created class Game, you have not rebuilt "hr-objects-sprg" with Maven.
What can you do in such case? First "clean install" for "hr-objects-sprg". This will update JAR in your local Maven repository. Then run your tests.
I'm just starting to use IntelliJ and working on making a very simple "hello world" application. It looks like a very simple setup issue but I can't find a solution here that works.
Here's the pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jay.jayWorld</groupId>
<artifactId>simple-project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>simple-project</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>Spring4MVCHelloWorldDemo</finalName>
</build>
</project>
Is it because I'm using ${springframework.version}? I've seen from some project that this works but not to be the case in my project. Do i need to define it somewhere?
Here's the screenshot of the error.
You need to define a property named springframework.version in your maven POM. Like this
<properties>
<springframework.version>4.3.11</springframework.version>
</properties>
The scope - runtime added for spring-context dependency was the issue in pom. Once removed(runtime attribute)and maven clean install builds successfully.
We're using spring-boot-starter-jetty in our maven pom, which means we don't have any direct dependency on jetty hence no control on its version.
This all works good, but we now need to add a dependency onone of jetty's modules, which are using the same jetty version convention.
This is all great and dandy, but because we can't use spring-boot-starter-jetty as our root pom, we're declaring jetty's version again under the module's dependency declaration, something like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<version>1.4.3-RELEASE</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-nosql</artifactId>
<version>9.3.14.v20161028</version>
</dependency>
This is no fun PLUS dangerous as if we upgrade one of them, we have to remember to upgrade the latter to the same version.
I know we can add an exclude under the module's dependency but this feels like a hack plus still doesn't fully protect us from breaking changes.
Is there anyway to extract the jetty version from spring boot and reuse it for the module's dependency?
Thanks!!
Maven creates the version properties for it's dependencies in the effective POM. For jetty it's jetty.version
So your dependencies will become
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-nosql</artifactId>
<version>${jetty.version}</version>
</dependency>
Here's complete POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestDependency</groupId>
<artifactId>TestDependency</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>TestDependency</name>
<description>TestDependency</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-nosql</artifactId>
<version>${jetty.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
It's worth pointing out that this is not required with the latest version of Spring Boot. I checked with the 1.5.4.RELEASE. Following is suficient.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-nosql</artifactId>
</dependency>
Complete POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestDependency</groupId>
<artifactId>TestDependency</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>TestDependency</name>
<description>TestDependency</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-nosql</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Effective POM can be generated by using following command
mvn help:effective-pom
Or if you're using Spring Tool Suite or latest version of Eclipse then you can directly check it inside the bottom tab in the Maven POM Editor
Edit
Without spring-boot parent pom the same can be done using dependencyManagement
Following is the complete pom without spring-boot parent
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestDependency</groupId>
<artifactId>TestDependency</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>TestDependency</name>
<description>TestDependency</description>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-nosql</artifactId>
<version>${jetty.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
ich have tree modules for my projec, server,client and core. Core module should be imported as jar dependency in other modules.
On eclipse i see no warnings, but if i'm starting the application i'm getting following error :
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [at.ac.tuwien.inso.verteilte.service.HelloServiceImpl] for bean with name 'helloServiceImpl' defined in ServletContext resource [/WEB-INF/appContext.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: at/ac/tuwien/inso/verteilte/services/IHelloService
Caused by: java.lang.ClassNotFoundException: at.ac.tuwien.inso.verteilte.services.IHelloService
this interface is imported on a HelloServiceImpl. HelloServiceImpl is created on the beans as following :
<jaxws:endpoint id="helloService" implementorClass="at.ac.tuwien.inso.verteilte.service.HelloServiceImpl">
i have removed the namespaces because of link protection of stackoverflow :)
By the way, my pom.xml's are :
for core :
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>verteiltepaxen-parent</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<name>core</name>
<packaging>jar</packaging>
<description>Verteilte Praxen - core</description>
<build>
<finalName>core-1.0-SNAPSHOT</finalName>
</build>
</project>
Server :
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>verteiltepaxen-parent</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>server</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>server</name>
<description>Verteilte Praxen - Server</description>
<dependencies>
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>core</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
<build>
<finalName>server-1.0-SNAPSHOT</finalName>
</build>
</project>
Client :
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>verteiltepaxen-parent</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>client</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>client</name>
<description>Verteilte Praxen - Client</description>
<dependencies>
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
</dependencies>
</dependencyManagement>
<build>
<finalName>client-1.0-SNAPSHOT</finalName>
</build>
</project>
And the parent pom :
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>verteiltepaxen-parent</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>verteiltepaxen Maven Webapp</name>
<properties>
<cxf.version>2.2.3</cxf.version>
<spring.version>2.5.6.SEC02</spring.version>
</properties>
<dependencies>
... other dependencies ...
</dependencies>
<repositories>
... Repositories ...
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<projectNameTemplate>verteiltepaxen-parent-1.0-SNAPSHOT</projectNameTemplate>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.8</version>
<configuration>
<!-- Configure the webapp -->
<contextPath>/verteiltepaxen</contextPath>
</configuration>
</plugin>
</plugins>
<finalName>verteiltepaxen-parent-1.0SNAPSHOT</finalName>
</build>
<modules>
<module>client</module>
<module>server</module>
<module>core</module>
</modules>
</project>
Thanks you very much for your helps :)
Thank your for your help, i've removed it but the error is the same
<dependencies>
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
I'm not sure what this would actually do, but in the server's POM you are listing core as a dependency and then also excluding it:
<dependency>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>core</artifactId>
<groupId>at.ac.inso.tuwien.verteiltepraxen</groupId>
</exclusion>
</exclusions>
</dependency>
Why would you do this? Exclusions are used to tell Maven to ignore some dependencies dragged in by other dependencies in your build.Try removing the exclusion.
You likely just need a mvn clean install in the parent directory to get a fresh war file. Otherwise, clarify what you mean by "if i'm starting the application": using the maven jetty plugin? Deploying to Tomcat? Something else?