Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Creating Eclipse Dynamic Web Project from Maven
Creating Eclipse Dynamic Web Project from Maven [message #661421] Thu, 24 March 2011 15:16 Go to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

First, I apologize for the "Mavenness" of this question. And the length.
But this appears now to be mostly a "what exactly is a Dynamic Web
Project" question. I'm trying to bridge the gap in my understanding
between Maven and Eclipse.

I have a working or mostly working POM that fetches all and exactly just
the JARs that interest me for writing a Facelets application. I'm using
m2eclipse. When I import the newly Maven-created application, it comes
in cleanly and more or less as expected, however, it is not like a
Dynamic Web Project in that when I try to run it, it offers no Run As ->
Run on Server option.

I have studied other Maven-generated Eclipse projects that do work (but
don't come set up with the JAR combination I want) in the sense that
they can be run on Server. For example, this one from m2eclipse works,
but it's not got the JARs I want:

mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp \
-DgroupId=com.mytutorial -DartifactId=simpleWeb

Do I need to create a custom archetype artifactId in imitation of the
....-DarchetypeArtifactId=maven-archetype-webapp... I see in in the
command above and, if so, how?

Or is it merely a function of the filesystem set up by that archetype? I
see that the project I've generated (webapp1--Run on Server doesn't show
up after Run As)...

webapp1
|-- src
| `-- main
| |-- java
| |-- resources
| `-- webapp
| `-- WEB-INF
`-- target
`-- classes`

.... has different content than one generated using
maven-archetype-webapp, but I don't know how to force mvn eclipse:clean
eclipse:eclipse to generate that (or whether that's what's telling
Eclipse this is a web application and it should set up for Run As -> Run
on Server).

simpleWeb
|-- src
| `-- main
| |-- java
| | `-- com
| | `-- mytutorial
| |-- resources
| | `-- com
| | `-- mytutorial
| `-- webapp
| |-- META-INF
| |-- pages
| `-- WEB-INF
`-- target
|-- classes
| `-- com
| `-- mytutorial
|-- maven-archiver
|-- META-INF
| `-- maven
| `-- com.mytutorial
| `-- simpleWeb
|-- pages
|-- simpleWeb
| |-- META-INF
| |-- pages
| `-- WEB-INF
| |-- classes
| | `-- com
| | `-- mytutorial
| `-- lib
|-- surefire
|-- test-classes
`-- WEB-INF
|-- classes
| `-- com
| `-- mytutorial
`-- lib

Profuse thanks to anyone who can launch me on the path of enlightenment.

Russ

P.S. Here's my mostly working pom.xml that produces a good project, but
not a Dynamic Web Project.

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.etretatlogiciels.webapp1</groupId>
<artifactId>webapp1</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>webapp1 Maven Webapp</name>
<url>http://maven.apache.org</url>

<properties>
<commons-beanutils-version>1.8.3</commons-beanutils-version >
<commons-codec-version>1.4</commons-codec-version>
<commons-collections-version>3.2.1</commons-collections-version >
<commons-digester-version>2.1</commons-digester-version>
<commons-discovery-version>0.4</commons-discovery-version>
<commons-logging-version>1.1.1</commons-logging-version>
<jsf-facelets-version>1.1.15</jsf-facelets-version>
<myfaces-version>2.0.4</myfaces-version>
<richfaces-version>3.3.3.Final</richfaces-version>
</properties>

<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>

<url> https://repository.jboss.org/nexus/content/groups/public-jbo ss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>

<dependencies>
<!-- Apache Commons -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>${commons-beanutils-version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec-version}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons-collections-version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>${commons-digester-version}</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>${commons-discovery-version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging-version}</version>
</dependency>

<!-- Facelets -->
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>${jsf-facelets-version}</version>
</dependency>

<!-- MyFaces -->
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>${myfaces-version}</version>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>${myfaces-version}</version>
</dependency>

<!-- RichFaces -->
<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-api-jsf2</artifactId>
<version>${richfaces-version}</version>
</dependency>
<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-impl-jsf2</artifactId>
<version>${richfaces-version}</version>
</dependency>
<dependency>
<groupId>org.richfaces.framework</groupId>
<artifactId>richfaces-ui-jsf2</artifactId>
<version>${richfaces-version}</version>
</dependency>

<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>webapp1</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>richfaces</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>maven2.repository</id>
<name>Repository for Maven by Maven</name>
<url>http://repo2.maven.org/maven2</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/1</url>
<layout>legacy</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<repository>
<id>JBoss Repository Old</id>
<name>Repository for Maven by JBoss</name>
<url>http://repository.jboss.org/maven2</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<repository>
<id>JBoss Repository Nexus</id>
<name>Repository for Maven by JBoss</name>

<url> http://repository.jboss.org/nexus/content/groups/public-jbos s</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
</repositories>
</profile>
</profiles>

</project>
Re: Creating Eclipse Dynamic Web Project from Maven [message #661448 is a reply to message #661421] Thu, 24 March 2011 17:22 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
I know almost nothing about the integration between Maven and Eclipse,
so I won't be of much help there. I can say for sure that for a webapp
project, you won't see "Run on Server" unless it's a Dynamic Web
Project. When creating a Dynamic Web Project, you must choose a Target
Runtime. That, along with other choices, establish which servers this
project can and can't be run on.

From what I can tell, Maven and Eclipse each have their own "build" and
"assembly" systems. The "build" system supports the declaration of
dependencies and is responsible for compiling stuff. The "assembly"
system is responsible for assembling the "application" into usable
form. How one keeps these systems in sync within a project so they
create effectively the same result, someone with more maven knowledge
will have to answer. I assume your statement about "but it's not got
the JARs I want" is possibly related to this. If you could be more
specific about what's not right about the jars in the
"maven-archetype-webapp" generated project, maybe I can provide some
additional help.

Cheers,
Larry

On 3/24/2011 11:16 AM, Russell Bateman wrote:
> First, I apologize for the "Mavenness" of this question. And the length.
> But this appears now to be mostly a "what exactly is a Dynamic Web
> Project" question. I'm trying to bridge the gap in my understanding
> between Maven and Eclipse.
>
> I have a working or mostly working POM that fetches all and exactly just
> the JARs that interest me for writing a Facelets application. I'm using
> m2eclipse. When I import the newly Maven-created application, it comes
> in cleanly and more or less as expected, however, it is not like a
> Dynamic Web Project in that when I try to run it, it offers no Run As ->
> Run on Server option.
>
> I have studied other Maven-generated Eclipse projects that do work (but
> don't come set up with the JAR combination I want) in the sense that
> they can be run on Server. For example, this one from m2eclipse works,
> but it's not got the JARs I want:
>
> mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp \
> -DgroupId=com.mytutorial -DartifactId=simpleWeb
>
> Do I need to create a custom archetype artifactId in imitation of the
> ...-DarchetypeArtifactId=maven-archetype-webapp... I see in in the
> command above and, if so, how?
>
> Or is it merely a function of the filesystem set up by that archetype? I
> see that the project I've generated (webapp1--Run on Server doesn't show
> up after Run As)...
>
> webapp1
> |-- src
> | `-- main
> | |-- java
> | |-- resources
> | `-- webapp
> | `-- WEB-INF
> `-- target
> `-- classes`
>
> ... has different content than one generated using
> maven-archetype-webapp, but I don't know how to force mvn eclipse:clean
> eclipse:eclipse to generate that (or whether that's what's telling
> Eclipse this is a web application and it should set up for Run As -> Run
> on Server).
>
> simpleWeb
> |-- src
> | `-- main
> | |-- java
> | | `-- com
> | | `-- mytutorial
> | |-- resources
> | | `-- com
> | | `-- mytutorial
> | `-- webapp
> | |-- META-INF
> | |-- pages
> | `-- WEB-INF
> `-- target
> |-- classes
> | `-- com
> | `-- mytutorial
> |-- maven-archiver
> |-- META-INF
> | `-- maven
> | `-- com.mytutorial
> | `-- simpleWeb
> |-- pages
> |-- simpleWeb
> | |-- META-INF
> | |-- pages
> | `-- WEB-INF
> | |-- classes
> | | `-- com
> | | `-- mytutorial
> | `-- lib
> |-- surefire
> |-- test-classes
> `-- WEB-INF
> |-- classes
> | `-- com
> | `-- mytutorial
> `-- lib
>
> Profuse thanks to anyone who can launch me on the path of enlightenment.
>
> Russ
>
> P.S. Here's my mostly working pom.xml that produces a good project, but
> not a Dynamic Web Project.
>
> <project xmlns="http://maven.apache.org/POM/4.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/maven-v4_0_0.xsd">
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.etretatlogiciels.webapp1</groupId>
> <artifactId>webapp1</artifactId>
> <packaging>war</packaging>
> <version>1.0-SNAPSHOT</version>
> <name>webapp1 Maven Webapp</name>
> <url>http://maven.apache.org</url>
>
> <properties>
> <commons-beanutils-version>1.8.3</commons-beanutils-version >
> <commons-codec-version>1.4</commons-codec-version>
> <commons-collections-version>3.2.1</commons-collections-version >
> <commons-digester-version>2.1</commons-digester-version>
> <commons-discovery-version>0.4</commons-discovery-version>
> <commons-logging-version>1.1.1</commons-logging-version>
> <jsf-facelets-version>1.1.15</jsf-facelets-version>
> <myfaces-version>2.0.4</myfaces-version>
> <richfaces-version>3.3.3.Final</richfaces-version>
> </properties>
>
> <pluginRepositories>
> <pluginRepository>
> <id>jboss-public-repository-group</id>
> <name>JBoss Public Maven Repository Group</name>
>
> <url> https://repository.jboss.org/nexus/content/groups/public-jbo ss/</url>
> <layout>default</layout>
> <releases>
> <enabled>true</enabled>
> <updatePolicy>never</updatePolicy>
> </releases>
> <snapshots>
> <enabled>true</enabled>
> <updatePolicy>never</updatePolicy>
> </snapshots>
> </pluginRepository>
> </pluginRepositories>
>
> <dependencies>
> <!-- Apache Commons -->
> <dependency>
> <groupId>commons-beanutils</groupId>
> <artifactId>commons-beanutils</artifactId>
> <version>${commons-beanutils-version}</version>
> </dependency>
> <dependency>
> <groupId>commons-codec</groupId>
> <artifactId>commons-codec</artifactId>
> <version>${commons-codec-version}</version>
> </dependency>
> <dependency>
> <groupId>commons-collections</groupId>
> <artifactId>commons-collections</artifactId>
> <version>${commons-collections-version}</version>
> <optional>true</optional>
> </dependency>
> <dependency>
> <groupId>commons-digester</groupId>
> <artifactId>commons-digester</artifactId>
> <version>${commons-digester-version}</version>
> </dependency>
> <dependency>
> <groupId>commons-discovery</groupId>
> <artifactId>commons-discovery</artifactId>
> <version>${commons-discovery-version}</version>
> </dependency>
> <dependency>
> <groupId>commons-logging</groupId>
> <artifactId>commons-logging</artifactId>
> <version>${commons-logging-version}</version>
> </dependency>
>
> <!-- Facelets -->
> <dependency>
> <groupId>com.sun.facelets</groupId>
> <artifactId>jsf-facelets</artifactId>
> <version>${jsf-facelets-version}</version>
> </dependency>
>
> <!-- MyFaces -->
> <dependency>
> <groupId>org.apache.myfaces.core</groupId>
> <artifactId>myfaces-api</artifactId>
> <version>${myfaces-version}</version>
> </dependency>
> <dependency>
> <groupId>org.apache.myfaces.core</groupId>
> <artifactId>myfaces-impl</artifactId>
> <version>${myfaces-version}</version>
> </dependency>
>
> <!-- RichFaces -->
> <dependency>
> <groupId>org.richfaces.framework</groupId>
> <artifactId>richfaces-api-jsf2</artifactId>
> <version>${richfaces-version}</version>
> </dependency>
> <dependency>
> <groupId>org.richfaces.framework</groupId>
> <artifactId>richfaces-impl-jsf2</artifactId>
> <version>${richfaces-version}</version>
> </dependency>
> <dependency>
> <groupId>org.richfaces.framework</groupId>
> <artifactId>richfaces-ui-jsf2</artifactId>
> <version>${richfaces-version}</version>
> </dependency>
>
> <!-- JUnit -->
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>3.8.1</version>
> <scope>test</scope>
> </dependency>
> </dependencies>
>
> <build>
> <finalName>webapp1</finalName>
> <resources>
> <resource>
> <directory>src/main/java</directory>
> <includes>
> <include>**/*.java</include>
> </includes>
> </resource>
> <resource>
> <directory>src/main/resources</directory>
> <excludes>
> <exclude>**/*.java</exclude>
> </excludes>
> </resource>
> </resources>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <version>2.0</version>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <version>2.0.2</version>
> <configuration>
> <source>1.5</source>
> <target>1.5</target>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
> <profiles>
> <profile>
> <id>richfaces</id>
> <activation>
> <activeByDefault>true</activeByDefault>
> </activation>
> <repositories>
> <repository>
> <id>maven2.repository</id>
> <name>Repository for Maven by Maven</name>
> <url>http://repo2.maven.org/maven2</url>
> <layout>default</layout>
> <releases>
> <enabled>true</enabled>
> <updatePolicy>always</updatePolicy>
> </releases>
> </repository>
> <repository>
> <id>maven2-repository.dev.java.net</id>
> <name>Java.net Repository for Maven</name>
> <url>http://download.java.net/maven/1</url>
> <layout>legacy</layout>
> <releases>
> <enabled>true</enabled>
> <updatePolicy>always</updatePolicy>
> </releases>
> </repository>
> <repository>
> <id>JBoss Repository Old</id>
> <name>Repository for Maven by JBoss</name>
> <url>http://repository.jboss.org/maven2</url>
> <layout>default</layout>
> <releases>
> <enabled>true</enabled>
> <updatePolicy>always</updatePolicy>
> </releases>
> </repository>
> <repository>
> <id>JBoss Repository Nexus</id>
> <name>Repository for Maven by JBoss</name>
>
> <url> http://repository.jboss.org/nexus/content/groups/public-jbos s</url>
> <layout>default</layout>
> <releases>
> <enabled>true</enabled>
> <updatePolicy>always</updatePolicy>
> </releases>
> </repository>
> </repositories>
> </profile>
> </profiles>
>
> </project>
Re: Creating Eclipse Dynamic Web Project from Maven [message #661458 is a reply to message #661448] Thu, 24 March 2011 17:55 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 24-Mar-11 11:22, Larry Isaacs wrote:
> I know almost nothing about the integration between Maven and Eclipse,
> so I won't be of much help there. I can say for sure that for a webapp
> project, you won't see "Run on Server" unless it's a Dynamic Web
> Project. When creating a Dynamic Web Project, you must choose a Target
> Runtime. That, along with other choices, establish which servers this
> project can and can't be run on.
>
> From what I can tell, Maven and Eclipse each have their own "build" and
> "assembly" systems. The "build" system supports the declaration of
> dependencies and is responsible for compiling stuff. The "assembly"
> system is responsible for assembling the "application" into usable form.
> How one keeps these systems in sync within a project so they create
> effectively the same result, someone with more maven knowledge will have
> to answer. I assume your statement about "but it's not got the JARs I
> want" is possibly related to this. If you could be more specific about
> what's not right about the jars in the "maven-archetype-webapp"
> generated project, maybe I can provide some additional help.
>
> Cheers,
> Larry


Thanks, Larry. This is helpful.
Re: Creating Eclipse Dynamic Web Project from Maven [message #664650 is a reply to message #661458] Mon, 11 April 2011 14:01 Go to previous messageGo to next message
David Carver is currently offline David CarverFriend
Messages: 174
Registered: July 2009
Senior Member
If you are using m2Eclipse, there is a wtp-webtools extension and project configurator that will allow Maven to be used and for M2Eclipse to be able to understand the structure. Take a look at the Sonatype Extras plugins.

http://www.sonatype.com/books/m2eclipse-book/reference/insta ll-sect-marketplace.html
Re: Creating Eclipse Dynamic Web Project from Maven [message #664666 is a reply to message #664650] Mon, 11 April 2011 14:26 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 11-Apr-11 08:01, Dave Carver wrote:
> If you are using m2Eclipse, there is a wtp-webtools extension and
> project configurator that will allow Maven to be used and for M2Eclipse
> to be able to understand the structure. Take a look at the Sonatype
> Extras plugins.
>
> http://www.sonatype.com/books/m2eclipse-book/reference/insta ll-sect-marketplace.html

Thanks, Dave. I've looked at that one and it's unsatisfactory. However,
who's to say this isn't because of my own stupidity? I just saw this
morning that RichFaces 4 is out with a new archetype. I'm going to look
into that.

Yeah, this Maven stuff can be painful for the clueless and the
beginners. (Not sure which group I fall into today.)

;-)
Re: Creating Eclipse Dynamic Web Project from Maven [message #664758 is a reply to message #664666] Mon, 11 April 2011 20:45 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 11-Apr-11 08:26, Russell Bateman wrote:
> On 11-Apr-11 08:01, Dave Carver wrote:
>> If you are using m2Eclipse, there is a wtp-webtools extension and
>> project configurator that will allow Maven to be used and for M2Eclipse
>> to be able to understand the structure. Take a look at the Sonatype
>> Extras plugins.
>>
>> http://www.sonatype.com/books/m2eclipse-book/reference/insta ll-sect-marketplace.html
>>
>
> Thanks, Dave. I've looked at that one and it's unsatisfactory. However,
> who's to say this isn't because of my own stupidity? I just saw this
> morning that RichFaces 4 is out with a new archetype. I'm going to look
> into that.

As I feared, the new JBoss RichFaces stuff is WTP-agnostic. (So miserable.)
Previous Topic:Creation of .jar file of a Dynamic Web Project when building the project
Next Topic:Project not published after change
Goto Forum:
  


Current Time: Fri Mar 29 11:49:26 GMT 2024

Powered by FUDForum. Page generated in 0.03173 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top