1

I have a multi-module Maven project. Here is how it is structured:

  1. cca-workflow (parent project)
  2. cca-commons (jar)
  3. cca-models (jar)
  4. cca-wsclient (jar)
  5. cca-business (jar)
  6. cca-web (war)

The war project depends on the jar projects. In my parent project, I have a Maven properties file which at build time replaces some of my Spring properties e.g. web_service_url, port, wsdl etc. The project builds correctly with all the properties getting resolved.

The problem is when I try using Tomcat from within Eclipse using the maven-eclipse-plugin. This configures the project to be able to be deployed in tomcat, however it is not resolving the Maven properties into my Spring properties file which causes the deployment to fail.

Mike Partridge
  • 5,128
  • 8
  • 35
  • 47
Rakesh Sinha
  • 19
  • 1
  • 6

3 Answers3

2

You need to use m2eclipse, then you can use WTP with Tomcat.

Michael-O
  • 18,123
  • 6
  • 55
  • 121
  • However keep in mind that m2eclipse and the maven eclipse plugin are not compatible, so you need to undo any configuration changes performed by the latter. – Nicola Musatti Jul 29 '11 at 15:32
  • I already have m2eclipse but the pom.properties replacement is not happening for me... – Rakesh Sinha Jul 29 '11 at 16:51
  • Confused...there is no pom.properties in Maven. If you want to active some profile to deploy to tomcat, this probably won't work. What I did is, I defined a special module for development purpose only which works in eclipse. Other modules are for deployment and such. Even though, the Spring property placeholder should work anyway. – Michael-O Jul 29 '11 at 18:54
  • Hi Michael...i could get this fixed for me...sorry for the confusion but i meant pom properties and not pom.properties. What i have now is properties plugin which sets properties in pom, then based on activated profile, i copy the env specific files in resources folder. From spring property holder i refered resources file to set the properties. Now the problem i see is whenever i make changes in web project it is hot deployed but if i change any files in the dependent projects (jar), i doesn't gets deployed until i install it... – Rakesh Sinha Aug 01 '11 at 01:01
  • Eclipse can only hot deploy on watched classpath folders. Some of yours aren't. What you can do is invoke `mvn compile` and it will copy changes resources. Eclipse should detect the change in the output folder and trigger a hot update. Try that. – Michael-O Aug 01 '11 at 08:40
  • Thank you Michael, I could finally get this working with some tweaks. Here is what I did: 1) Added jar projects as project dependencies in eclipse. 2) Added jar projects target/classes folder to war project build path in eclipse. 3) In war project deployment assembly, I added the jar projects class path entry to be copied in war project classes folder instead of being picked up as jar artefacts from maven repository. With this making any changes in war project deploys instantly and changes to jar project requires a publish, which is a quick thing and i like it. Thanks for your inputs. – Rakesh Sinha Aug 02 '11 at 16:20
0

I have the same problem. For solving this issue. I have deleted the tomcat server configured in eclipse and added back again then issue got resolved.

Hope this helps.

0

Have you tried the maven tomcat plugin?

Edit: The plugin is painfully easy to use.

1) Add the plugin to your POM.

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>
  <version>1.1</version>
  <configuration>
    <warFile>target/myapp.war</warFile>
    <url>http://localhost:8080/manager</url>
    <username>username</username>
    <password>password</password>
  </configuration>
</plugin>

2) Ensure the username and password are good for the manager app. Tomcat has no admin users set up by default. You can add them by editing your conf/tomcat-users.xml file;

<tomcat-users>
  <role rolename="manager"/>
  <user password="password" roles="manager" username="username"/>
</tomcat-users>

3) Deploy using the maven goal tomcat:deploy.

Notes
Only use this on dev/test boxes, never on production/live. You should have a proper change management system on live. It also not a great idea to allow access to the manager app on live. You also should choose a proper username and password.

Qwerky
  • 18,217
  • 6
  • 44
  • 80