I just created web application using maven -3.2.3 and there after i just some dependencies in pom.xml next just right click on my pom.xml-->RunAs-->maven install.All jars are downloaded.Then while trying to build(like my pom.xml-->RunAs-->maven build) i got one pop up to set goal. i just typed goal field as a "package" -->run.
i am facing below issue
Downloaded: http://repo.maven.apache.org/maven2/org/springframework/spring/2.5.6/spring-2.5.6.jar (2881 KB at 3.3 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15:26.448s
[INFO] Finished at: Wed Oct 29 08:33:31 IST 2014
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project SpringMVCMaven: Could not resolve dependencies for project com.rajendra.spring:SpringMVCMaven:war:1.0: Failure to find javax.transaction:jta:jar:1.0.1B in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
and for reference below is 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rajendra.spring</groupId>
<artifactId>SpringMVCMaven</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>SpringMVCMaven Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.3.ga</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
</dependencies>
<build>
<finalName>SpringMVCMaven</finalName>
</build>
</project>
Could you suggest me where exactly things are getting wrong. Appreciating your help here
You're having a problem because you're using relatively old frameworks. They are dependent upon a version of JTA that could not be made available in a public repository due to licensing restrictions. In that era there were a number of artifacts like this that we had to download from Sun (after agreeing to the licence) and install in our own local repository.
Thankfully, in your case you just need to add:
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
to your pom.xml and that should override the older version.
This is a newer version but it only contains API classes (not implementations) and I believe that it is backward compatible.
Related
Here is my 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.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.mailer</groupId>
<artifactId>portfolio</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>portfolio</name>
<description>portfolio services</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</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>
<dependency>
<groupId>com.mailjet</groupId>
<artifactId>mailjet-client</artifactId>
<version>4.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Build logs:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.mailer:portfolio >------------------------
[INFO] Building portfolio 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
.
.
.
[WARNING] The POM for org.hamcrest:hamcrest-core:jar:1.4-atlassian-1 is missing, no dependency information available
.
.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project portfolio: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.22.2 or one of its dependencies could not be resolved: Failure to find org.hamcrest:hamcrest-core:jar:1.4-atlassian-1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
**
Any idea why am getting this error related to hamcrest jar? I added the same version of the jar in .m2/repo/... but I still get the same error. Any idea which dependency in this POM is using it internally? Do I have to change any version?
Command used to build
mvn clean install
If I run this project as Spring Boot app then the service is up but what I need is a jar out of this to host in a cloud.
This was the issue with my local repository. I had to point to a new repo location under .m2 in settings.xml.
I am trying to deploy maven web app in the Heroku which have a dependency on some other application. When I am trying to deploy the app and getting this error. I have no clue what is going wrong in passing the dependency.
This is my pom.xml file
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.1.3.RELEASE
com.merizameen
merizameen
0.0.1-SNAPSHOT
merizameen
Frontend project for Merizameen
<properties>
<start-class>com.merizameen.MerizameenApplication</start-class>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- MY PROJECT -->
<dependency>
<groupId>com.merizameen</groupId>
<artifactId>merizameenbackend</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Error Logs---------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.953 s
[INFO] Finished at: 2019-04-16T18:29:11+00:00
[INFO] Final Memory: 20M/162M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project merizameen: Could not resolve dependencies for project com.merizameen:merizameen:jar:0.0.1-SNAPSHOT: Could not find artifact com.merizameen:merizameenbackend:jar:0.0.1-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
! ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
! Push rejected, failed to compile Java app.
! Push failed
You'll need to add com.merizameen:merizameenbackend as an un-managed dependency with a command like:
$ mvn deploy:deploy-file -Durl=file:///path/to/yourproject/repo/ -Dfile=merizameenbackend.jar -DgroupId=com.merizameen -DartifactId=merizameenbackend -Dpackaging=jar -Dversion=1.0
See this guide: https://devcenter.heroku.com/articles/local-maven-dependencies
I'm building a custom sonar plugin which is a maven project.
Sonar asks to mention it's required sonar-plugin-api dependency as scope provided. I think it's okay because it will run inside sonar container which will have this jar.
In my use case I want to add additional dependency of httpclient. If I add it under default scope, it refuses to build, throwing below error:
[ERROR] This dependency must be declared with scope <provided>: commons-logging:commons-logging:jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.364 s
[INFO] Finished at: 2019-03-05T13:52:22+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.sonar-packaging-maven-plugin:sonar-packaging-maven-plugin:1.18.0.372:check (default-check) on project myPlugin: Unsupported dependencies
If I change the scope of httpclient to provided, it will build but will not work in sonar as it does not have this jar in its env.
All the dependencies in httpclient, including commons-logging is mentioned as scope - compile.
This is what my current pom looks like:
<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>
<groupId>com.plugin.sonar</groupId>
<artifactId>myPlugin</artifactId>
<!-- this is important for sonar-packaging-maven-plugin -->
<packaging>sonar-plugin</packaging>
<version>1.0</version>
<name>myPlugin</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
<!-- minimal version of SonarQube to support. Note that the groupId was "org.codehaus.sonar" before version 5.2 -->
<version>6.7</version>
<!-- mandatory scope -->
<scope>provided</scope>
</dependency>
<!-- facing problem after adding this dependency-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.18.0.372</version>
<extensions>true</extensions>
<configuration>
<pluginKey>MyCustomPlugin</pluginKey>
<pluginClass>com.plugin.sonar.MyCustomPlugin</pluginClass>
<pluginDescription>Sonar plugin of Test</pluginDescription>
</configuration>
</plugin>
</plugins>
</build>
</project>
Any suggestions, how to solve it?
Thank You
The Sonar Maven plugin contains a check that disallows commons-logging and LOG4J because SonarQube supports only SLF4J.
So what you can do is switch to SLF4J and exclude commons-logging from the httpclient dependency:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.26</version>
</dependency>
Add an entry in the <dependencyManagement> section to manage commons-logging to provided, i.e.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>...</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
For the version: Use the one you find in your dependency:list at the moment.
When i run install Maven, it throws error like.
[INFO] java-COUNTER ...................................... SUCCESS [ 1.093 s]
[INFO] java-COUNTER Utils ................................ SUCCESS [ 1.312 s]
[INFO] java-COUNTER domain model ......................... SUCCESS [ 1.593 s]
[INFO] java-COUNTER persistence layer .................... FAILURE [ 2.843 s]
[INFO] java-COUNTER core functionality ................... SKIPPED
[INFO] java-COUNTER inbound message processor ............ SKIPPED
[INFO] java-COUNTER web commons .......................... SKIPPED
[INFO] java-COUNTER message receiver ..................... SKIPPED
[INFO] java-COUNTER client API definition ................ SKIPPED] java-COUNTER API implementation ................... SKIPPED
[INFO] STAR benchmarks ................................... SKIPPED
[INFO] java-COUNTER admin UI ............................. SKIPPED
[INFO] java-COUNTER reporting UI ......................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.029 s
[INFO] Finished at: 2015-08-06T17:01:33+05:30
[INFO] Final Memory: 26M/222M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project persistence: Could not resolve dependencies for project com.semantico.counter:persistence:jar:1.1.1: Could not find artifact com.semantico.counter:utils:jar:tests:1.1.1 in project_lib (file:///F:\ConnectBooks\star_15Jul15\star_15Jul15\persistence/mvnLib) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :persistence
My pom.xml file
<?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>
<parent>
<groupId>com.semantico.counter</groupId>
<artifactId>parent</artifactId>
<version>1.1.1</version>
</parent>
<groupId>com.semantico.counter</groupId>
<artifactId>receiver</artifactId>
<name>java-COUNTER message receiver</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.semantico.counter</groupId>
<artifactId>web-commons</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
</dependency>
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-servlet</artifactId>
</dependency>
<dependency>
<!-- CD-1158 For double-click. NB: 2.1.0 is a bit old -->
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.1.0</version>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
</dependency>
<dependency>
<groupId>com.riffpie.common.testing</groupId>
<artifactId>jersey-test-support</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client</artifactId>
</dependency>
<dependency>
<groupId>com.sun.grizzly</groupId>
<artifactId>grizzly-webserver</artifactId>
</dependency>
<dependency>
<groupId>com.semantico.counter</groupId>
<artifactId>persistence</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>com.semantico.counter</groupId>
<artifactId>utils</artifactId>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
</dependency>
<!-- Container provided -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
</dependencies>
Are you configuring a multi-module project? If so, have a look at some examples of how to configure them. If this is the approach you are taking then the parent pom should declare your persistence and utils projects as modules:-
<modules>
<module>persistence</module>
<module>utils</module>
</modules>
This way your parent should be able to access the jars resulting from building of the two modules - rather than having them as completely separate projects.
I have been trying to maven test my codes, but i keep having this in my console:
[INFO] Scanning for projects... [INFO]
[INFO]
------------------------------------------------------------------------ [INFO] Building SonarQube Java :: Checks 2.3-SNAPSHOT [INFO]
------------------------------------------------------------------------ [WARNING] The POM for
org.codehaus.sonar-plugins.java:java-squid:jar:2.3-SNAPSHOT is
missing, no dependency information available [INFO]
------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 2.791s [INFO] Finished at: Wed May 21 16:18:34 CST
2014 [INFO] Final Memory: 9M/61M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal on project java-checks: Could not
resolve dependencies for project
org.codehaus.sonar-plugins.java:java-checks:jar:2.3-SNAPSHOT: Could
not find artifact
org.codehaus.sonar-plugins.java:java-squid:jar:2.3-SNAPSHOT -> [Help
1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run
Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to
enable full debug logging. [ERROR] [ERROR] For more information about
the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
My pom.xml are:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.codehaus.sonar-plugins.java</groupId>
<artifactId>java</artifactId>
<version>2.3-SNAPSHOT</version> </parent>
<artifactId>java-checks</artifactId>
<name>SonarQube Java :: Checks</name>
<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-deprecated</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>java-squid</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.sonar.sslr</groupId>
<artifactId>sslr-testing-harness</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Is there anyway to resolve such error?
Try to add this as a repository in your pom.xml. In the XML element repositories, add this:
<repository>
<id>sonarplugins</id>
<url>http://repository-sonarplugins.forge.cloudbees.com/snapshot/</url>
</repository>
Maven try to get java-squid.jar in 2.3-SNAPSHOT version but it does not find it in your local repository, in the central Maven repository and in the repositories you indicate in your POM. The URL I give you is an URL for a public repo which contains the artifact you need. It should work, unless if there is other missing dependencies.
A few more thing: why do you use a SNAPSHOT lib? Are you really sure you want to do that?