Maven Unable to deploy from within Eclipse (Mars) - java

I'm new to maven, but I have been able to figure out enough to be able to build and deploy my application from the command line with the following command:
mvn clean dependency:tree tomcat6:undeploy tomcat6:deploy
Running this command, builds and deploys my application without issue.
When I attempt to run the same command from within Eclipse (Mars), I get the following error:
[INFO] --- tomcat6-maven-plugin:2.2:undeploy (default-cli) # myapp ---
[INFO] Undeploying application at http://localhost:8080/myapp-2.3.4-SNAPSHOT
[ERROR] Tomcat return http status error: 401, Reason Phrase: Unauthorized
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
I suspect that the issue is because outside of Eclipse on I'm not using the same instance of tomcat or something...
Note: I have two instances of tomcat running on my box within eclipse for development/integrated with Eclipse(port 8080), and external/stand alone(9080).
pom.xml includes:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager</url>
<server>TomcatServer</server>
<path>/myapp-2.3.4-SNAPSHOT</path>
</configuration>
</plugin>
maven settings.xml includes:
<server>
<id>TomcatServer</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
And I've copied the contents of
$TOMCAT_HOME/conf/tomcat-users.xml
to
$ECLIPSE_WORKSAPACE_DIR/.plugins/org.eclipse.wst.server.core/tmp0/conf/tomcat-users.xml
<role rolename="admin"/>
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager,admin,manager-gui,manager-script"/>
Any assistance in resolving this issue would be greatly appreciated.
Thanks,
Kevin

Related

Tomcat maven error Server returned HTTP response code: 401 for URL

I'm trying to deploy webpage to Tomcat using the Tomcat Maven Plugin.
but i seem error
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project ReoWebPage: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/deploy?path=%2FReoWebPage&war= -> [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/MojoExecutionException
this...
If i continue to modify tomcat.xml and settings.xml, but i will get the same error.
what's the problem??
pom plug-in
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8089/manager/text</url>
<server>TomcatServer</server>
<path>/ReoWebPage</path>
</configuration>
</plugin>
settings.xml
<server>
<id>TomcatServer</id>
<username>admin</username>
<password>password</password>
</server>
tomcat-users.xml file
<role rolename="tomcat"/>
<role rolename="admin-script"/>
<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user password="password" roles="tomcat" username="admin"/>
<user password="password" roles="manager-gui" username="admin"/>
<user password="password" roles="admin,admin-script,manager-gui,manager-script,manager-jmx,manager-status" username="admin"/>
and run enviroment rivse jre -> jdk
i'm use eclipse and tomcat 8.0
please help..
thank you

IntelliJ & Eclipse: debug Java application started by Maven exec:exec

In my project I have a configuration such as
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<commandlineArgs>${additionalExecArgs} -jar ${project.build.directory}/someDir/some.jar</commandlineArgs>
<executable>java</executable>
<classpathScope>runtime</classpathScope>
</configuration>
</execution>
</executions>
</plugin>
to start an executable JAR using Maven exec:exec.
The additionalExecArgs property is empty by default.
In NetBeans I can run this goal by specifying the following action in the nbactions.xml file:
<action>
<actionName>run</actionName>
<goals>
<goal>exec:exec</goal>
</goals>
</action>
To debug this goal in NetBeans I've added the following action to the nbactions.xml file:
<action>
<actionName>debug</actionName>
<goals>
<goal>exec:exec</goal>
</goals>
<properties>
<jpda.listen>true</jpda.listen>
</properties>
<activatedProfiles>
<activatedProfile>debug</activatedProfile>
</activatedProfiles>
</action>
So in addition to running exec:exec it sets the NetBeans (?) property jpda.listen to true and activates the Maven profile debug.
I've also added the following Maven profile to my POM:
<profile>
<id>debug</id>
<properties>
<additionalExecArgs>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address}</additionalExecArgs>
</properties>
</profile>
With this configuration I can simply run the debug action from the project context menu/ toolbar.
Please note the jpda.address Maven property however. This property seems to get populated by NetBeans somehow.
If I try to run exec:exec with the debug profile in IntelliJ or Eclipse I'm getting an error, likely because the jpda.address Maven property doesn't get set.
E.g. I'm getting the following error in IntelliJ:
/usr/lib/jvm/java-8-oracle/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:42300,suspend=y,server=n -Dmaven.home=/usr/share/maven -Dclassworlds.conf=/usr/share/maven/bin/m2.conf -Dfile.encoding=UTF-8 -classpath /usr/share/maven/boot/plexus-classworlds-2.x.jar:/opt/idea-IC-141.1010.3/lib/idea_rt.jar org.codehaus.classworlds.Launcher -Didea.version=14.1.3 -Dmaven.repo.local=/home/someUser/.m2/repository exec:exec -P debug
Connected to the target VM, address: '127.0.0.1:42300', transport: 'socket'
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test-application 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:exec (default-cli) # test-application ---
ERROR: transport error 202: connect failed: Verbindungsaufbau abgelehnt
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
The port changes with every call.
I've tried and replaced jpda.address with a fixed address/ port such as 127.0.0.1:8000, but I'm getting the same error and now in NetBeans, too.
So how can I get a similar behavior in IntelliJ and Eclipse as in NetBeans and debug an exec:exec goal using a Maven run configuration directly without having to resort to a remote debugger configuration or such?
It sounds like you can set up a Remote debug configuration in intellij with a Before launch Maven Goal.
Set it up as follows:
Run/Debug Configurations -> Add Remote -> Add Before Launch -> Maven -> specify correct module and goal.

maven tomcat7 deployment Error 403

Hello
I know kind of this question was put into here several times already and I read many of the answers, unfortunately, nothing worked or me so far.
What am I using:
Windows7
Tomcat 7
Maven - plugin 'tomcat7-maven-plugin'
Application has java in backend, frontend javascript
What is working so far:
I can compile, build, ..., deploy the war manually and the webapp runs fine in localhost.
What I try now:
Build and automatically deploy the app with Maven.
Via the tomcat-plugin I planned to deploy the generated war file automatically. I hope this thought is not already wrong; if so, please let me know.
Ok let me list what I have set in the different files and what I have executed.
Settings.xml of maven:
<server>
<id>TomcatServer</id>
<username>testuser</username>
<password>testpw</password>
</server>
tomcat-users.xml:
I decided to take all, so that no role can be missed and lead to a problem. I also tried with just using "manager-gui" and with "manager-gui and admin".
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="testuser" password="passwd" roles="manager-gui, manager-script, manager-jmx, manager-status, admin-gui, admin-script"/>
pom.xml:
...
<modelVersion>4.0.0</modelVersion>
<groupId>com.mr</groupId>
<artifactId>myWebapp</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>my Web App</name>
<url>http://maven.apache.org</url>
<dependencies>
...
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://LuklHost:port/manager</url>
<server>TomcatServer</server>
<username>testuser</username>
<password>passwd</password>
<path>/myWebapp</path>
</configuration>
</plugin>
</plugins>
Step to deploy:
In powershell (opened with admin-rights)
mvn tomcat:deploy
leads to following 403 error-message:
(localhost needed to be "deleted")
[INFO] Deploying war to http://localhost:8080/TripleDictionary
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.821s
[INFO] Finished at: Sat Apr 12 13:59:37 CEST 2014
[INFO] Final Memory: 18M/223M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project TripleDictionary: Ca
nnot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2FTri
pleDictionary&war= -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:depl
oy (default-cli) on project TripleDictionary: Cannot invoke Tomcat manager
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot invoke Tomcat manager
at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:149)
at org.codehaus.mojo.tomcat.AbstractWarCatalinaMojo.execute(AbstractWarCatalinaMojo.java:70)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/deploy?path=%2
FTripleDictionary&war=
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1625)
at org.codehaus.mojo.tomcat.TomcatManager.invoke(TomcatManager.java:604)
at org.codehaus.mojo.tomcat.TomcatManager.deployImpl(TomcatManager.java:662)
at org.codehaus.mojo.tomcat.TomcatManager.deploy(TomcatManager.java:295)
at org.codehaus.mojo.tomcat.AbstractDeployWarMojo.deployWar(AbstractDeployWarMojo.java:85)
at org.codehaus.mojo.tomcat.AbstractDeployMojo.invokeManager(AbstractDeployMojo.java:85)
at org.codehaus.mojo.tomcat.AbstractCatalinaMojo.execute(AbstractCatalinaMojo.java:141)
... 22 more
[ERROR]
[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/MojoExecutionException
Question:
Why do I get this error? And of course how can I fix it?
Actually I really cannot put it exact, because I think I kind of checked everything, even what folder has which rights.
Hope for ideas and help.
Thanks in advance,
Meru
I want to add thee solution as an 'answer', due to I searched for it hell of long and maybe somebody else does not need to spend that much time on it then. As I already have written the comment 'text' is needed to be appended to the url inside the plugins-part of the plugins in the pom.xml.
Let me share what I got now:
maven>conf>settings.xml
<server>
<id>TomcatServer</id>
<username>testuser</username>
<password>testpw</password>
</server>
tomcat>conf>tomcat-users.xml
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="admin-gui"/>
<user username="testuser" password="passwd" roles="admin-gui, manager-gui,manager-script"/>
But the most important I think was changing the URL, which also is the answer to my question.
pom.xml:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<username>testuser</username>
<password>passwd</password>
<path>/myWebApp</path>
</configuration>
</plugin>
command in powershell
mvn tomcat7:deploy

Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:run

While trying to run my web applicaton, I'm getting the below mentioned error. Previously my application was running fine. But today i gave maven clean and then tried ruuning it by giving maven goal as tomcat:run, I'm getting this error
[INFO]
[INFO] BUILD FAILURE
[INFO]
[INFO] Total time: 6.754s
[INFO] Finished at: Tue Mar 11 15:09:44 IST 2014
[INFO] Final Memory: 11M/28M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:run (default-cli) on project metaDB: Could not start Tomcat: Memory database file
D:\WORK\target\tomcat\conf\tomcat-users.xml cannot be read -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
please help to over come this issue.
Delete the folder "D:\WORK\target\tomcat\" and try again, the tomcat-maven-plugin would re-create this folder and the file "tomcat-users.xml".
Create a file for Tomcat users in:
D:\WORK\target\tomcat\conf\tomcat-users.xml
and add the following:
<?xml version="1.0" encoding="UTF-8"?>
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="admin"/>
<role rolename="manager"/>
<user username="admin" password="admin" roles="tomcat,admin,manager"/>
</tomcat-users>
Use tomcat maven plugin, start the web application
Rebuild the project
Restart tomcat maven plugin.
The error must occur
Solution: Before rebuilding the project, you must stop tomcat maven plugin first.

How can I see jboss console with maven

I started jboss-5.1.0.GA server with maven2, is there a possibility that I can see what is happening in the console. I'm using eclipse plugin to run maven. Is it possible to see console in eclipse or elsewhere?
Here is what I mean by console :
Is it possible to see this output somewhere? I took this screen shot when manually running jboss.
When I start the server with maven here is what I get :
[INFO] [war:war]
[INFO] Packaging webapp
[INFO] Assembling webapp[snrf] in [C:\HOME\c0mrade\Workspaces\Eclipse 3.5 Classic\snrf\target\0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in[337 msecs]
[INFO] Building war: C:\HOME\c0mrade\Workspaces\Eclipse 3.5 Classic\snrf\target\0.0.1-SNAPSHOT.war
[INFO] [jboss:hard-deploy]
[INFO] Copying C:\HOME\c0mrade\Workspaces\Eclipse 3.5 Classic\snrf\target\0.0.1-SNAPSHOT.war to C:\jboss-5.1.0.GA\server\default\deploy\0.0.1-SNAPSHOT.war
[INFO] [jboss:start]
[INFO] Starting JBoss...
[INFO] [install:install]
[INFO] Installing C:\HOME\c0mrade\Workspaces\Eclipse 3.5 Classic\snrf\target\0.0.1-SNAPSHOT.war to C:\HOME\c0mrade\.m2\repository\org\trialofmaven\0.0.1-SNAPSHOT\0.0.1-SNAPSHOT.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
And that is it. nothing is happening..
Thank you
Is it possible to see this output somewhere? I took this screen shot when manually running jboss.
I'm don't think that the jboss-maven-plugin redirects the logs anywhere so you'll find them in
$JBOSS_HOME/server/<your_server>/log
Just in case, note that cargo has support for this (here, I'm getting the console output in cargo.log):
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>jboss5x</containerId>
<home>${jboss.home}</home>
<append>false</append>
<log>${basedir}/target/jboss5.x.logs/cargo.log</log>
<timeout>300000</timeout> <!-- 5 minutes -->
</container>
<configuration>
<type>existing</type>
<home>${jboss.home}/server/default</home>
<properties>
<cargo.jboss.configuration>default</cargo.jboss.configuration>
<cargo.rmi.port>1099</cargo.rmi.port>
<cargo.logging>high</cargo.logging>
</properties>
</configuration>
<wait>false</wait>
</configuration>
...
</plugin>
P.S.: I really wonder why you don't start JBoss with the WTP from Eclipse by the way.

Categories

Resources