• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 634
  • Last Modified:

maven web application

Hi,

I am trying following web application using maven on eclipse from link

http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/


I am wondering if there is some other simple applications, projects, links which talks about creating and running web applications using maven without going to the command prompt. Can I do everything in eclipse.


Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
0
gudii9
Asked:
gudii9
  • 5
  • 4
1 Solution
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
You can do basically the same as that link does, all within Eclipse... (assuming that you have the maven integration stuff installed)

Go to File/New/Other...
In the filter, type maven and then select Maven Project
Make sure 'Create a simple project' is UNticked and hit next
For 'Catalog' select 'All Catalogs'
In 'Filter' type webapp
Select the 'maven-achetype-webapp'

And from there it should be fairly similar to what is in the link you referred to (ie. providing group id and artifact id, initial package, etc)
0
 
gudii9Author Commented:
<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.mkyong.core</groupId>
      <artifactId>primefaces</artifactId>
      <packaging>war</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>primefaces Maven Webapp</name>
      <url>http://maven.apache.org</url>
      <dependencies>
            <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>3.8.1</version>
                  <scope>test</scope>
            </dependency>
      </dependencies>
      <build>
       <plugins>
            <!-- use JDK 1.6 -->
            <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <version>2.3.2</version>
                  <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                  </configuration>
            </plugin>
        </plugins>
      </build>
</project>

I modified POM.xml as above



I see application working fine now. Can you please let me know why the context name is different which is 'junit' instead of 'primefaces' as given in the link. is this is same procedure I have to follow for any maven project irrespective of web, spring, struts, hibernate, ejb etc projects. Please advise
ContextName.JPG
0
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
What did you specify as the 'artifactId' in the New Project Wizard?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
gudii9Author Commented:
I believe it is 'junit'
0
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Ok, so there you go, if you use 'junit' for the artifactId, the archetype must be using that as the context root when it creates your project. The link that you posted used 'primefaces' as the artifactId and so it's context root is 'primefaces'.

You can go to your project properties, and then in the web project settings you can change the context root. Then you will have to remove the project from the server, clean the server, and re-add the project to the server (all these options can be found by right-clicking on the server entry in the 'Servers' view in Eclipse).
0
 
gudii9Author Commented:
I just changed it to primefaces
PrimeFaces.JPG
0
 
gudii9Author Commented:
after changing junit / primefaces context names both not working. Please advise
PrimeFaces-JUnit.JPG
0
 
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Did you follow my instructions above for removing the app from the server, cleaning the server and then adding it again?
0
 
gudii9Author Commented:
I did all steps mentioned by you. Still no luck. Please advise. I posted screenshot with my previous post, is that is the location I have to change the context name right. I also changed the project name still no success.
PrimeFaces2.JPG
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now