File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Generate Dynamic Web Project Maven Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Generate Dynamic Web Project Maven" Watch "Generate Dynamic Web Project Maven" New topic
Author

Generate Dynamic Web Project Maven

Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
Hi Guys,

Basically i can add a server such as Jboss, Tomcat to eclipse perfectly fine, and if i create a Dynamic Web Project it can be seen by the server and added to it for hot deployments etc, All works great

So heres the prob, I found in order to create a War file with maven, it expects the project to be in a certain structure eg

src/java/main
src/java/resources
src/java/webapp

And you put all your jsps, WEB_INF ect in the webapp folder.

Which is different to the Dynamic Web Project structure

src/java/main
WebContext

WebContext or what ever you call the folder is basicaly on the same level as src and you can put the jsps here etc.

Now a project with the maven structure can not be seen by the embedded server in eclipse and so the project cant be added for hot deploments through eclipse, instead i need to do builds etc with maven and drop the war into Tomcat myself or with a script, Anyone know how to get a mavinised Web project added as a project to a server added to eclipse

I have tried both tomcat 6.0, Jboss 4.2 and Jetty-Launcher.

Ok sorry, with further investigation, i now know that it is actually when you use the mvn eclipse:eclipse command to generate source code into an eclipse project that the embedded server in eclipse cant see the project and the eclispe project cant generate a war, Anybody know how to get maven to generate an eclipse Dynamic Web project that can be imported into eclipse and still be seen by a server and still be able to geneartae war from within the ide

Best
mark
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5778
    
    7

Change the pom.xml to use the dynamic web directory structure. Something like this might work:

<blockquote>code:
<pre name="code" class="core"> <resources>
<resource>
<directory>src/main/java</directory>
<filtering>true</filtering>
</resource>
</resources>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>WebContext</webappDirectory>
</configuration>
</plugin>
</pre>
</blockquote>


JBoss In Action
Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
Hey Peter,

Thanks for that but Maven did not like the <resources> tag and gave an error.

org.apache.maven.reactor.MavenExecutionException: Parse error reading POM. Reason: Unrecognised tag: 'resources'

Best
Mark
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5778
    
    7

The <resources> tag goes within <build> tags.
[ July 17, 2008: Message edited by: Peter Johnson ]
Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
cool, i added that to the build tag but and it built ok but i still could not add it as a project to my server in eclipse, have to build war with maven and drop it into tomcat manually still
Anadi Misra
Ranch Hand

Joined: Jun 03, 2008
Posts: 69
Hi,

If you still haven't found a solution it is worth trying the maven tomcat plugin, works with maven 2. I am using Maven-2.0.9, Eclipse-3.3 and tomcat -5.5.28, it works good.

http://mojo.codehaus.org/tomcat-maven-plugin/deployment.html


Anadi Mishra.
Jerome Chin
Greenhorn

Joined: Sep 23, 2008
Posts: 1
Hi,

I too has that problem and just found a solution.
I installed the "Maven Integration for WTP", and the Maven project in eclipse allow you to add the project to the server inside eclipse.
The maven project is able to synchronize with the server, and it works as if it is a normal Dynamic Web Project but in a different file structure.
Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
Thanks teh Maven Integration for WTP worked great
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generate Dynamic Web Project Maven
 
Similar Threads
Adding maven projects to Servers added to Eclipse 3.4
Importing Maven project in Eclipse?
Using Eclipse for Web App
Make a project be dynamic web project
Maven - Building a single war file from multiple modules