I have recently started having trouble releasing a maven project which has worked fine for a long time now. The project consists of several modules with a structure looking something like:
project_server
project_webserver
project_qp
project_qp_ingr
project_repo
project_repo_ingr
Both modules project_qp and project_repo are dependent on project_webserver with ${project.version} references.
The project is build using Jenkins and everything works fine when I am building snapshot builds.
When I try to build a release with version 3.1-RC1 in a maven release build configuration with the options/goals "-Dresume=false release:prepare release:perform -e", everything works fine in the "clean, verify" phase, but in the "deploy, site-deploy", project_repo suddenly doesn't compile.
The compilation errors consist of the module not finding classes from the project_webserver module. However, the project_qp_ingr module has already been built and is working fine.
All of this suggests to me that there is something wrong with the reference from project_repo_ingr to project_webserver but since the project builds fine when I am building snapshot releases.
The pom of project_repo_ingr looks like:
<?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>
<artifactId>project_repo_ingr</artifactId>
<name>project_repo_ingr</name>
<packaging>jar</packaging>
<parent>
<groupId>com.apptus.ecom</groupId>
<artifactId>project_repo</artifactId>
<version>3.1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.apptus.ecom</groupId>
<artifactId>project_webserver</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>com.apptus.ecom</groupId>
<artifactId>project_webserver</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
I have omitted some dependencies but that is pretty much it. Both the module project_repo_ingr and project_qp_ingr have the dependency to both the regular artifact and the test-jar.
I use Java 6, Maven 2 and Jenkins 1.436 with M2 Release Plugin 0.8.1.
Any help is greatly appreciated, I have torn my hair all day long about this.
Update:
The changes that I have made since the last time this worked is branching the svn repo from the trunk to a release branch. The jenkins job in trunk has been copied into one for the branch and the svn path is changed. I have also updated the part of the project_server pom.
Related
I am following the tutorial at spring.io to build a spring app using spring boot.
I can get the program to run perfectly on one computer.
When I try on a different computer I get the following error
The type org.springframework.context.ConfigurableApplicationContext cannot be resolved. It is indirectly referenced from required .class files
I have tried deleting and adding my JRE Systems Library (JDK 1.8), as well as cleaning and updating the project using maven, and even deleting and re-importing the entire project. All of these methods have shown no success.
My pom file is
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<groupId>test.api</groupId>
<artifactId>api.test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>api.test Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<finalName>api.test</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
The class that is giving me the error is the HelloWorldConfiguration.java class
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class HelloWorldConfiguration {
public static void main(String[] args) {
SpringApplication.run(HelloWorldConfiguration.class, args);
}
}
Any help would be greatly appreciated. Thank you.
Your Maven cache is corrupted on the second machine. The JAR can't be opened, that's why you get this exception.
You can fix that by running this command on the second machine for that project:
mvn dependency:purge-local-repository
If that doesn't work, try remove your local repo on that machine (~/.m2/repository/org/springframework) and run mvn package again.
I also faced the same issue before. Some dependency corruption might have occurred. You can purge and re-resolve the dependencies.
For that :
go to the project location where the pom.xml is present.
open a command prompt there and enter the command below :
mvn dependency:purge-local-repository -DreResolve=true
I had the same issue and I followed these steps to fix it:
1. Close Eclipse
2. Remove all files inside the repository folder .m2/repository
3. reopen Eclipse and update your Maven project
I had the same problem. I resolved this my deleting the local repository directory of Maven (.m2) on your local computer. It resolved the problem for me.
Find out the version of spring-context your project uses:
(in Eclipse : Project Explorer -> [your project] -> Maven Dependencies)
or
mvn dependency:tree
Lists all dependencies for your project
Delete the folder org/springframework/spring-context/5.0.9.RELEASE from your maven repository .m2/repository. Assuming 5.0.9.RELEASE is the spring-context release version.
this conflict occurs, because some of your dependencies have corrupted.follow this:->
for removing this conflict just go in to your .m2 folder open repository and delete all the files from that folder. and now open your project go in debug do maven clean and after cleaning and all downloading just update your maven projet. and your conflict will have been going to resolve.
I too have same problem, I resolved by removing .m2/repository/org folder,later did maven updated form STS.
Add bellow dependancy
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
It may be because some of the dependency is not resolved correctly.
You can try to change/de-grade version of "spring-boot-starter-parent" to other working project in your local.
E.g. mine Error gone by setting "spring-boot-starter-parent" to "1.5.9.RELEASE" from "2.3.0.RELEASE" (that version was working for other project).
My answer is too late, but maybe helps others.
I had the same issue while using Eclipse IDE with spring project that I made using start.spring.io. The way I fixed it:
Right-click on your project.
Runs As.
Maven Install.
For me ,first answer only works when open the child project as a new project in a new window .
You can try delete main.iml or xxx.iml in your child project src\main\main.iml.
That works for me
EDIT: dont worry, main.iml is auto generated by idea
I also faced the same issue and to resolve this I downloaded the jar and added as an external jar.
Here is the download link: http://www.java2s.com/Code/Jar/o/Downloadorgspringframeworkcontextjar.htm
I have three modules of a project, getting developed as two seperate jars and one WAR. WAR is referring to two other jar. Please see the details below-
1.processDAO-this is a java Project producing a jar(processDAO.jar)
2.ProcessModel-this is a java project producing a jar(processModel.jar). And in pom.xml it is referring (processDAO.jar)
3.ProcessWebApp-this is Main web app project as War producing (processWebApp.WAR). Now this is using (processModel.jar)
Now currently after each development when I need to build the WAR file I first build -(processDAO.jar)
then 2nd- processModel.jar
and in last I build ProcessWebApp.WAR
So each time I have to follow this sequential build process. Now, I want whenever I go to build my ProcessWebApp.WAR other dependency gets build automatically in same sequential manner(1->2->3).
Any advice on this will be very helpful.
Environment I am using Eclipse which have mavenplugin. I just right click on every project and do RunAs 'Maven install'.
1.processDAO.pom
<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>processDAO</groupId>
<artifactId>processDAO</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
2.ProcessModel.pom
<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>ProcessModel</groupId>
<artifactId>ProcessModel</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>processDAO</groupId>
<artifactId>processDAO</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
3.ProcessWebApp.pom
<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>ProcessWebApp</groupId>
<artifactId>ProcessWebApp</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>ProcessModel</groupId>
<artifactId>ProcessModel</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Listen there several issues with the way you have created your pom or what you want to achieve.
A minor comment on the existing samples is to fix the <groupid> element usually it is something of com.xxx.my.company and is not identical with the artifact id.
Now from what I understand it seems that you are still changing the code on the dependent modules, so that means you are releasing SNAPSHOT versions (otherwise you wont need to check the compatibility of your libs every time right?). See this question on using xxx-SNAPSHOT here
Also check the use of the -U flag mvn clean install -U . See mvn -help.
-U,--update-snapshots Forces a check for missing
releases and updated snapshots on
remote repositories
This is usually achieved by use of a parent project POM, the only purpose of which is to build the modules that it depends on. When creating the POM, specify the packaging type as 'POM' and then specify your WAR and JARs as module elements. There's a pretty good example and description of this on Sonatype's site here.
I'm using Maven 3.
I have multiple maven projects, namely: the 'data model', the 'service', and the 'presentation', split into 3 different projects. They are configured separately (ie. not using maven parent pom).
I have maven release plugin setup on my project correctly, such that when I run mvn release:clean release:prepare release:perform on each individual project, it updates the project version (ie: from 3.4.5-SNAPSHOT to 3.4.5) as well as all the other things.
The problem here is, 'presentation' is dependent on 'service' is dependent on 'data model', and I refer to the projects in the pom files with the version number.
While I develop, say for example I would refer to 'service' in 'presentation' as 3.4.5-SNAPSHOT. But during deploy, I have to release 'service' to change the version to 3.4.5, then I have to update my version reference of 'service' in 'presentation', before I can run a release on 'presentation'.
Is there an automated way of doing this such that I don't need to update the reference of dependent projects during release?
What I have so from thanks to below comments: Updated: 25/03/2013
Run maven with:
versions:use-releases -Dmessage="update from snapshot to release" scm:checkin release:clean release:prepare release:perform
Outcome: version updated, but release build failed.
The Versions Maven Plugin may help you to achieve requirement, especially the goal versions:use-releases. You may be interested in the goal versions:use-next-releases and versions:use-latest-releases as well.
Side Note:
Normally, the good practice is define them as a Maven Multiple Module( here and here). This allow us to manage the version easier as the following example.
The parent
<groupId>my-group</groupId>
<artifactId>my-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
.....
<modules>
<module>my-model</module>
<module>my-service</module>
<module>my-ui</module>
</modules>
The my-model
<parent>
<groupId>my-group</groupId>
<artifactId>my-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>my-model</artifactId>
The my-service
<parent>
<groupId>my-group</groupId>
<artifactId>my-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>my-service</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>my-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
The my-ui
<parent>
<groupId>my-group</groupId>
<artifactId>my-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>my-ui</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>my-service</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Regarding to the above example when we release, the related version will be updated based on the parent version automatically.
I'm trying to use a SimpleMongoBolt from storm-contrib. I downloaded the source, entered the storm-contrib-mongo directory and ran mvn package and mvn install. Everything worked fine and IntelliJ was able to resolve things while coding. When I try to build my project, however, it tries to find a pom for this library on an external repository. When it can't find it, it fails. What do I need to do to fix this?
<?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>StormTest</groupId>
<artifactId>StormTest</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>StormTest</name>
<repositories>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>storm</groupId>
<artifactId>storm</artifactId>
<version>0.7.2</version>
<scope>Test</scope>
</dependency>
<dependency>
<groupId>com.rapportive</groupId>
<artifactId>storm-amqp-spout</artifactId>
<version>0.1.1</version>
</dependency>
<dependency>
<groupId>com.rapportive</groupId>
<artifactId>storm-json</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>storm</groupId>
<artifactId>storm-contrib-mongo</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
You can try to check if you have proper dependencies defined in your project pom and compare them to storm artifact one. groupId, artifactId and version must be the same or Maven will try to download it from external repository and probably failed as it has never been installed on any public Maven repo.
When you install your artifact, it goes to user-directory/.m2/repostiory/group/id/path/*artifact/id/path*/version.
For your storm-amqp-spout you should have it in:
user-directory/.m2/repository/com/rapportive/storm-amqp-spout/0.1.1 folder.
There you should have few files:
jar itself (if it was packaged as jar file).
pom.xml file (the same you created for your project and you used to built and install it).
optionally sha1 files for both above.
If you don't have them, you probably made some mistake installing the artifact into repository. You can try to install it again or manually create pom just copying it from artifact source directory.
If there's correct pom.xml, I don't really have idea as I have never worked with IntelliJ (idea? ;)).
SimpleMongoBolt in Storm-Contrib was actually out of date. I updated the module myself and submitted a pull request, which has yet to be merged. Currently you can retrieve the updated code from my Storm-Contrib fork.
I've installed the following maven module to my local maven repository
EWS Maven Module but the IDE (Eclipse in this case) doesn't seem to know about the following class `GetUserAvailabilityRequest.
Interestingly, I can run a mvn compile on my project that uses the dependency above successfully.
I can even see the class file in the jar file under my Maven Dependencies in Eclipse.
Does anyone know why this might be occurring ?
Edit #tolitius:
ews-java is a dependency for my project, not the project I'm trying to import
Here is the pom file in question:
<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.conf</groupId>
<artifactId>conferenceclient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>microsoft.exchange</groupId>
<artifactId>exchange-ws-api</artifactId>
<version>1.1.4-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Turns out that the class in question is not public. It had nothing to do with Maven or Eclipse or anything.I wasn't looking at the class since I didn't have the source attachment.