How to install tomcat maven plugin? - java

I'm trying to run the basic CXF maven archetype.
I've just tried to install tomcat7-maven-plugin-2.2.jar manually using :
mvn -X install:install-file -Dfile=/tmp/path/tomcat7-maven-plugin-2.2.jar -DgroupId=org.apache.tomcat.maven -DartifactId=tomcat7-maven-plugin -Dversion=2.2 -Dpackaging=jar
which leads to :
[INFO] Installing /tmp/path/tomcat7-maven-plugin-2.2.jar to /home/userxxx/.m2/repository/org/apache/tomcat/maven/tomcat7-maven-plugin/2.2/tomcat7-maven-plugin-2.2.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Fri Jan 23 17:50:42 CET 2015
[INFO] Final Memory: 4M/179M
[INFO] ------------------------------------------------------------------------
BUT when I try to call it on my project via :
mvn clean install tomcat:run-war
It says :
[INFO] Searching repository for plugin with prefix: 'tomcat'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin '**org.codehaus.mojo**:tomcat-maven-plugin' does not exist or no valid version could be found
Would u have an idea why maven is looking for "org.codehaus.mojo" groupId instead of "org.apache.tomcat.maven" ?
I know it was hosted at "org.codehaus.mojo" before, so is it a bug ?
Should I install the plugin in this groupId ?

Ok, I get it, the comment in the CXF archetype is wrong :
<!-- mvn clean install tomcat:run-war to deploy
Look for "Running war on http://xxx" and
"Setting the server's publish address to be /yyy"
in console output; WSDL browser address will be
concatenation of the two: http://xxx/yyy?wsdl
-->
It should say mvn clean install **tomcat7**:run-war to deploy to correspond to the plugin they use in this archetype.

Related

Maven does not find local dependency

TL;DR
Maven does not find <importedGroupid>:<importedArtifactid>:jar:1.0 in repository file://<homeDirectory>/.m2/repository/. The package actually is in <homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/
I do not presume to understand Maven, but the two potential reasons I could imagine are:
it gets confused with : and / (i.e. UNIX style path seperator vs. whatever : means in Maven), or
if : and / are actually interpreted as the same, the path it searches for includes another subdirectory level jar that is not present in the real directory structure.
Detailed Explanation
I was trying to import a package locally in Maven (as the package is not deployed online). Various answers (e.g., this, and this) on stackoverflow recommend running mvn install on the jar containing the package like so (assuming the jar is in /usr/share/java, is version 1.0, etc. etc.):
mvn install:install-file -Dfile=/usr/share/java/<importedArtifactid>-1.0-SNAPSHOT.jar -DgroupId=<importedGroupid> -DartifactId=<importedArtifactid> -Dversion=1.0 -Dpackaging=JAR -DgeneratePom=true
and defining this in the current package's pom.xml by adding:
<repository>
<id>repository</id>
<url>file://${user.home}/.m2/repository/</url>
</repository>
The mvn install command deploys the package into <homeDirectory>/.m2/repository/. So far, this works fine:
<prompt> $ mvn install:install-file -Dfile=/usr/share/java/<importedArtifactid>-1.0-SNAPSHOT.jar -DgroupId=<importedGroupid> -DartifactId=<importedArtifactid> -Dversion=1.0 -Dpackaging=JAR -DgeneratePom=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building <currentDirectoryProject> 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) # <currentDirectoryProjectArtifactid> ---
[INFO] Installing /usr/share/java/economicsl-1.0-SNAPSHOT.jar to <homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/<importedArtifactid>-1.0.JAR
[INFO] Installing /tmp/mvninstall256012398997457078.pom to <homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/<importedArtifactid>-1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.489 s
[INFO] Finished at: 2017-05-11T19:11:12+01:00
[INFO] Final Memory: 9M/292M
[INFO] ------------------------------------------------------------------------
<prompt> $
The package also appears in <homeDirectory>/.m2/repository/
<prompt> $ ls `<homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/`
<importedArtifactid>-1.0.JAR <importedArtifactid>-1.0.jar.lastUpdated <importedArtifactid>-1.0.pom _remote.repositories
<prompt> $
However, building the project that attempts to import the package fails:
<prompt> $ mvn package -U
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building <currentDirectoryProject> 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: file://<homeDirectory>/.m2/repository/<importedGroupid>/<importedArtifactid>/1.0/<importedArtifactid>-1.0.jar
Downloading: https://repo.maven.apache.org/maven2/<importedGroupid>/<importedArtifactid>/1.0/<importedArtifactid>-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.730 s
[INFO] Finished at: 2017-05-12T17:59:43+01:00
[INFO] Final Memory: 13M/292M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project <currentDirectoryProjectArtifactid>: Could not resolve dependencies for project <currentDirectoryProjectGroupid>:<currentDirectoryProjectArtifactid>:jar:1.0-SNAPSHOT: Could not find artifact <importedGroupid>:<importedArtifactid>:jar:1.0 in repository (file://<homeDirectory>/.m2/repository/) -> [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
<prompt> $
If an absolute path to the jar in /usr/share/java is defined in the pom.xml, the project builds successfully with a warning about not using absolute paths, but execution fails as it does not find the package again this time.
Maven version is Apache Maven 3.3.9.
Placeholders
<currentDirectoryProject> The project that is supposed to import the other package. All terminal commands are executed from the root directory of this project (this is where its pom.xml resides).
<currentDirectoryProjectArtifactid> ArtifactID of the project that is supposed to import the other package.
<currentDirectoryProjectGroupid> GroupID of the project that is supposed to import the other package.
<importedArtifactid> ArtifactID of the project that is to be imported
<importedGroupid> GroupID of the project that is to be imported
<homeDirectory> the user's home directory, i.e. /home/<userName>
<prompt> terminal prompt
You have a file extension "JAR" in upper case and maven is looking "jar" in lower case. If your file system is case sensitive, then that's important.

"mvn install " A maven commend not installed a jar from local into maven repository

I am new to MAC. I need to install some jars from local to maven repository.
Steps I followed :-
Kept jars "monte-screen-recorder.jar" at my local and run the below command to install into Maven repository.
mvn install:install-file -Dfile="\Downloads\monte-screen-recorder.jar" -DgroupId="org.monte" -DartifactId="monte-screen-recorder" -Dversion=0.7.7 -Dpackaging="jar"
SUCCESS message is shown in terminal. But actual jar is not present in Maven repository.
INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) # test ---
[INFO] Installing /Users/admnistrator/Documents/workSpaceIOS/test-automation-library/imageClient.jar to /Users/admnistrator/.m2/repository/com/experitest/client/imageClient/1.0/imageClient-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.527s
[INFO] Finished at: Thu Nov 17 17:02:07 IST 2016
[INFO] Final Memory: 8M/309M
[INFO] ------------------------------------------------------------------------
Please let me know where I am making a mistake .
[INFO] Installing /Users/admnistrator/Documents/workSpaceIOS/test-automation-library/imageClient.jar to /Users/admnistrator/.m2/repository/com/experitest/client/imageClient/1.0/imageClient-1.0.jar
Maven install the image client jar file in your local maven repo curently. So you must have write a wrong command.
Can you show the full log (command + maven in the same log) ?
Use this central repository instead:
<dependency>
<groupId>com.pojosontheweb</groupId>
<artifactId>monte-repack</artifactId>
<version>1.0.1</version>
</dependency>

Install manually jar file

Install manually jar file into repository.
I want to install this SDK as maven dependency.
https://developer.intuit.com/docs/0100_quickbooks_online/0400_tools/0005_accounting/0200_java/0002_installing_the_java_sdk_for_quickbooks
I tried this:
mvn install:install-file -DgroupId=com.intuit.code.devkit.v3 -DartifactId=ipp-v3-java-devkit -Dversion=2.5.0 -Dpackaging=jar -Dfile=c:\lib\ipp-java-qbapihelper-1.2.1-jar-with-dependencies.jar
But I get
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) # standalone-pom ---
[INFO] Installing c:\lib\ipp-java-qbapihelper-1.2.1-jar-with-dependencies.jar to C:\Users\plamen\.m2\repository\com\intuit\code\devkit\v3\ipp-v3-java-devkit\2.5.0\ipp-v3-java-devkit-2.5.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.631 s
[INFO] Finished at: 2016-09-02T17:04:51+03:00
[INFO] Final Memory: 7M/123M
[INFO] ------------------------------------------------------------------------
When I browse my local repository I can't find any jar file into the directory. Can somebody give some advice how I can fix this?
What I've done in the past to make this work is:
Copy the jar file(s) of interest to a temp folder i.e. project root/tmp
Run the following command (adjusting the parameters accordingly) in the command line from the the project root directory:
mvn install:install-file -Dfile=tmp/<filename>.jar -DgroupId=intuit.code.devkit.v3 -DartifactId=ipp-v3-java-devkit -Dversion=2.5.0 -Dpackaging=jar -DlocalRepositoryPath=<repo path> (i.e. src/dependencies/jars)
After that command you should see a src/dependencies/jars/com/... directory with maven artifacts under it
Add dependency to your pom.xml
<!— <project> is the parent element —>
<repositories>
<repository>
<id>system-jars</id>
<url>file://${basedir}/src/dependencies/jars</url>
</repository>
</repositories>
<!— Add the dependency —>
<dependency>
<groupId>com.intuit.code.devkit.v3</groupId>
<artifactId>ipp-v3-java-devkit</artifactId>
<version>2.5.0</version>
</dependency>
Perform a maven clean and package. Verify the classes are included in the end artifact and then delete the tmp directory once everything is correct.

com.sun:tools:jar:1.4.2 missing when running "perform eclipse" in roo

When I run "perform eclipse" in Roo I get:
roo> perform eclipse
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building bugzter
[INFO] task-segment: [eclipse:clean, eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] [eclipse:clean {execution: default-cli}]
[INFO] Deleting file: .project
[INFO] Deleting file: .classpath
[INFO] Deleting file: .wtpmodules
[INFO] Deleting file: .component
[INFO] Deleting file: org.eclipse.wst.common.component
[INFO] Deleting file: org.eclipse.wst.common.project.facet.core.xml
[INFO] Deleting file: org.eclipse.jdt.core.prefs
[INFO] Deleting file: org.eclipse.ajdt.ui.prefs
[INFO] Preparing eclipse:eclipse
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) com.sun:tools:jar:1.4.2
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.codehaus.mojo:aspectj-maven-plugin:maven-plugin:1.0
2) com.sun:tools:jar:1.4.2
----------
1 required artifact is missing.
for artifact:
org.codehaus.mojo:aspectj-maven-plugin:maven-plugin:1.0
from the specified remote repositories:
com.springsource.repository.bundles.release (http://repository.springsource.com/maven/bundles/release),
com.springsource.repository.bundles.external (http://repository.springsource.com/maven/bundles/external),
central (http://repo1.maven.org/maven2),
codehaus.org (http://repository.codehaus.org),
com.springsource.repository.bundles.milestone (http://repository.springsource.com/maven/bundles/milestone),
com.springsource.repository.bundles.snapshot (http://repository.springsource.com/maven/bundles/snapshot),
snapshots (http://snapshots.repository.codehaus.org)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Wed Jul 28 20:57:52 CEST 2010
[INFO] Final Memory: 30M/298M
[INFO] ------------------------------------------------------------------------
Tried downloaded the tools-1.4.2.jar and run mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file but it doesn't solve the problem.
Running ubuntu 10.04 and maven 2.2
Any suggestions?
Repoint your system environment parameter JAVA_HOME to JDK (1.5+) directory instead of JRE.
According to Spring Source Roo and missing com.sun:tools:jar:1.4.2:
If you are trying to get the latest
version of SpringSource ROO working,
with an x64 Java JDK, such as the
latest JDK 1.6 update 20, there is
unfortunately a missing tools.jar from
the default lib\ directory of the JDK
(tut tut tut Sun/Oracle). This will
prevent Roo from working and therefore
prevent Maven compilation. You would
probably see an error similar to this:
Error message: Missing:
----------
1) com.sun:tools:jar:1.4.2
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
----------
1 required artifact is missing.
To correct this error, install an
additional x86 JDK, repoint the
JAVA_HOME and the PATH to the new JDK
and restart the mvn process
i thought i had java_home set to jdk, but i guess in slackware both jre and jdk get installed in same folder. having both installed caused this problem. i uninstalled both, and reinstalled jdk (to be safe) and it fixed it.
Add this dependecy in pom.xml file.
in the <systemPath> property you have to write your JDK lib path.
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
<scope>system</scope>
<systemPath>C:/Program Files/Java/jdk1.6.0_30/lib/tools.jar</systemPath>
</dependency>
I also had a similar issue and fixed int the following way.
Go to lib directory of JDK installed path in command prompt. Execute the below command to install to install tools.jar. $mvn install:install-file -DgroupId=sun.jdk -DartifactId=tools -Dpackaging=jar -Dversion=1.6 -Dfile=tools.jar
http://parameshk.blogspot.in

mvn tomcat:run doesn't start Tomcat

I am trying to deploy and run my webapplication using maven and its tomcat plugin.
I have set it up in project's pom.xml, but when I'm calling it from command line:
mvn tomcat:run
all that I get is:
[root#ovz6022 trunk]# mvn -e tomcat:run
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - com.gotbrains.breeze:breeze:jar:1.0
[INFO] task-segment: [tomcat:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing tomcat:run
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/trunk/src/main/resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [tomcat:run {execution: default-cli}]
[INFO] Skipping non-war project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24 seconds
[INFO] Finished at: Thu Jul 23 14:34:31 MDT 2009
[INFO] Final Memory: 7M/14M
[INFO] ------------------------------------------------------------------------
And that's all. Tomcat hasn't been launched but I don't see any errors here.
Does anybody knows what's happening?
As mentioned before, you should use war packaging. However, if you can't because you're using OSGI or some other reason, you can tell the Tomcat plugin to deploy anyway even if it isn't war packaging by using the ignorePackaging option:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<ignorePackaging>true</ignorePackaging>
The clue is in the line:
[INFO] Skipping non-war project
The tomcat:run goal is intended to work with war projects, I'm guessing yours is a jar project.
You need to change the packaging of your project to war, you may also need to provide some additional configuration for the war to actually do anything.
Note: I'd recommend having a separate war project to your jar projects, then adding the jars as dependencies to the war.
if you're using Roo, and haven't yet invoked the controller command then your configuration is not yet set to generate a WAR file.

Categories

Resources