• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Deploying maven-webapp-project in tomcat10

 
Ranch Hand
Posts: 87
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have generated webapp using maven:archetype selecting maven-archetype-webapp as template

and the below config inside build section of pom.xml

For tomcat in tomcat-users.xml, inside tomcat-users section

and maven settings.xml

I have checked that I am able to go to localhost:8080/ and click on manager-app and able to see Tomcat Web Application Manager

But when I run
<code>mvn clean install tomcat7:deploy </code>

I am getting the below error
```
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project my-webapp: Cannot invoke Tomcat manager: Server returned HTTP response code: 40
5 for URL: http://localhost:8080/manager/deploy?path=%2Fmy-webapp&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

```
What I am trying to do is, get maven to copy the war file and deploy into tomcat-server

P.S I am using tomat 10
 
Bartender
Posts: 2419
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you think it is helpful :
https://stackoverflow.com/questions/15410914/tomcatdeploy-cannot-invoke-tomcat-manager-connection-refused ?
 
Bhaskar Bantupalli
Ranch Hand
Posts: 87
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I have already mentioned most of those steps in original post except for <path>/<path> which also didn't work.
I tried changing plugin from tomcat7 to tomcat and also maven command from tomcat7 to tomcat , they didn't work too which I haven't mentioned in the post.
 
Saloon Keeper
Posts: 27817
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat 7 is seriously ancient at this point.

If your code is still using the javax JEE class packages, you should consider Tomcat 9. If you are using jakarta JEE class packages, use Tomcat 10 or later.

Note that the Maven archetypes are generally not well-maintained and can be unreliable at best. At this point you will probably need to take your archetype-generated project and manually update the obsolete stuff.
 
Bhaskar Bantupalli
Ranch Hand
Posts: 87
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not using tomcat 7. I am using tomcat 10. I am trying the tomcat-maven-plugin and tomcat7-maven-plugin which have tomcat7:deploy or tomcat:deploy (plugin:goal). It is in a course about maven.
 
Tim Holloway
Saloon Keeper
Posts: 27817
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would be very wary about using a "tomcat7" component and expecting things to work on Tomcat 10.

I don't use Maven to deploy or run Tomcat, but some similar services would actually be downloading a Tomcat 7 and deploying to it, not to a Tomcat you happened to have installed externally. In any event, there are differences in database connection pools, security roles and Realms between Tomcat 7 and Tomcat 10.

You can download anything from the Internet — or for that matter type it in from a book. But that doesn't mean it will still work properly years later. I must have spent half a decade admonishing people not to use features of JavaServer Faces that had been deprecated when JSF moved from experimental to production because they were getting fed stale info from their web searches.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you ever find the solution for issue? "tomcat8-maven-plugin" is the best I could find. There is not a "tomcat10-maven-plugin" and don't even know if there will be one which the devs may have a different solution or in mind.
Did you end up using a different maven archetype strictly for tomcat and jakarta conversion?
Does your project happen to use jakarta libraries?

I'm stuck on the same exact issue and struggling to clean and build mine for tomcat10.
 
Bhaskar Bantupalli
Ranch Hand
Posts: 87
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bruce, I couldn't find any solution. I was following Learning Apache Maven back then
 
Saloon Keeper
Posts: 15551
364
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a bit confusing, but the tomcat7 plugin is indeed the correct one to use if you want to deploy a web application to Tomcat 10. The name tomcat7 should be understood as tomcat7andhigher.

Things to look out for:

  • Explicitly set a version for all default plugins used in your build.
  • Use a jakarta.servlet-api or a jakarta.jakartaee-web-api version that's compatible with your application container.
  • Ensure that the tomcat7 plugin configuration refers to the correct server ID from your settings.xml.
  • Ensure that the settings.xml uses the same username and password as used in tomcat-users.xml.
  • Ensure that you have the correct roles set for your tomcat user.

  • I created a minimal POM that should work with Tomcat 10:

    My settings.xml looks similar to this:

    My tomcat-users.xml looks similar to this:
     
    Tim Holloway
    Saloon Keeper
    Posts: 27817
    196
    Android Eclipse IDE Tomcat Server Redhat Java Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Just to avoid confusion here:

    1. The pom.xml file is located at the root of the project (of course!)

    2. The settings.xml file is located in the Maven configuration directory for the developer ($HOME/.m2, for Linux users).

    3. The tomcat-users.xmlfile is located (by default) in the Tomcat configuration directory (TOMCAT_HOME/conf).

     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic