aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Build problem with maven and eclipse web project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Build problem with maven and eclipse web project" Watch "Build problem with maven and eclipse web project" New topic
Author

Build problem with maven and eclipse web project

Sanjib Pal
Greenhorn

Joined: Feb 08, 2010
Posts: 27
Hi All,

I am facing a big problem when building java web project with eclipse and maven. I can't successfully build this project.

when I compiling the project it gives the following error

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building quizapp Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ quizapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ quizapp ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.016s
[INFO] Finished at: Mon Nov 29 19:59:25 GMT+05:30 2010
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------

my project's pom.xml file is as

<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.dreamzi.testwebapp</groupId>
<artifactId>quizapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>quizapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>quizapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
</build>
</project>


web.xml file is as

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>Login</servlet-name>
<display-name>Login</display-name>
<description>servlet that handles the user login authentication</description>
<servlet-class>com.dreamzi.quizapps.controller.Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/Login</url-pattern>
</servlet-mapping>
</web-app>


Please give me some advice to solve the problem

Thanks in advance

Sanjib Pal

SCJP 5.0
Try unless you get the ultimate success.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16014
    
  20

That's not an "error". It quite definitely says BUILD SUCCESS!

On the other hand, it also says "no sources", which means that you probably don't have a src/main/java directory containing your Java source code.


Customer surveys are for companies who didn't pay proper attention to begin with.
Sanjib Pal
Greenhorn

Joined: Feb 08, 2010
Posts: 27
Hi Tim Holloway,

Thanks for your advice.

This is actually a web project and no class file is generating to the classes folder, even in the packaging file .war file. So when I deploy the war file in the server it is not working properly. My effective pom is as given bellow.



<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dreamzi.testwebapp</groupId>
<artifactId>quizapp</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>quizapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>D:\MyProjects\quizapp\src\main\java</sourceDirectory>
<scriptSourceDirectory>D:\MyProjects\quizapp\src\main\scripts</scriptSourceDirectory>
<testSourceDirectory>D:\MyProjects\quizapp\src\test\java</testSourceDirectory>
<outputDirectory>D:\MyProjects\quizapp\target\classes</outputDirectory>
<testOutputDirectory>D:\MyProjects\quizapp\target\test-classes</testOutputDirectory>
<resources>
<resource>
<directory>D:\MyProjects\quizapp\src\main\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>D:\MyProjects\quizapp\src\test\resources</directory>
</testResource>
</testResources>
<directory>D:\MyProjects\quizapp\target</directory>
<finalName>quizapp</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<compileSourceRoots>D:\MyProjects\quizapp\src\resources</compileSourceRoots>
<source>1.5</source>
<target>1.5</target>
</configuration>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compileSourceRoots>D:\MyProjects\quizapp\src\resources</compileSourceRoots>
<source>1.5</source>
<target>1.5</target>
</configuration>
</execution>
</executions>
<configuration>
<compileSourceRoots>D:\MyProjects\quizapp\src\resources</compileSourceRoots>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>2.0.1</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>D:\MyProjects\quizapp\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>D:\MyProjects\quizapp\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>D:\MyProjects\quizapp\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>D:\MyProjects\quizapp\target\site</outputDirectory>
</reporting>
</project>


please give me some advice to successfully compile and generate the class file in the war package.

thanks,
Sanjib Pal
Sanjib Pal
Greenhorn

Joined: Feb 08, 2010
Posts: 27
Hi Tim

When I changed my pom.xml file as given bellow it gives me build failure

pom.xml

<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.dreamzi.testwebapp</groupId>
<artifactId>quizapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>quizapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>quizapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compileSourceRoots>D:\MyProjects\quizapp\src\resources</compileSourceRoots>
<source>1.5</source>
<target>1.5</target>
</configuration>

</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
</plugin>
</plugins>
</build>
</project>


the error report is as follows


[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building quizapp Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ quizapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ quizapp ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.797s
[INFO] Finished at: Wed Dec 01 19:55:07 GMT+05:30 2010
[INFO] Final Memory: 2M/5M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project quizapp: Unable to parse configuration of mojo org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile for parameter compileSourceRoots: Cannot assign configuration entry 'compileSourceRoots' to 'interface java.util.List' from 'D:\MyProjects\quizapp\src\resources', which is of type class java.lang.String -> [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/PluginConfigurationException


please give me advice to solve this problem

thanks
sanjib
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Undo that configuration change. (The error means that you gave a string while it was expecting a list, possibly subcomponents or <compileSourceRoots>, check the docs for the plugin). You should not have to tell Maven where the java source files are located.

Where are your java source files? Based on what you posted, they should be at:

d:/MyProjects/quizapp/src/main/java

I assume you are using m2eclipse. Did you create a Maven project and specify an archetype or did you create a Dynamic Web Project and then write your own POM? If the latter, I hope that you adjusted the directory structure to match what Maven expects.


JBoss In Action
Sanjib Pal
Greenhorn

Joined: Feb 08, 2010
Posts: 27
Hi Peter Johnson,

I am using m2eclipse and created the project as a maven project. The pom.xml has automatically generated. If I doesn't specify the source file path then eclipse report that "No source to compile" error, and I noticed that the class file are not generated that I need to create the war file and deploy to run the web site. The problem which I faced with this configuration has mentioned in my first post.

My project structure is attached with it as a .jpg image

Please suggest me.

Thanks,
sanjib



[Thumbnail for project.jpg]

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Your Java source files are in the wrong location. They should be under src/main/java. Only resource file (such as properties files) go under src/main/resources.
Sanjib Pal
Greenhorn

Joined: Feb 08, 2010
Posts: 27
Hi Peter Johnson,

Thanks Peter Johnson you have done a great job for me. My project is now compiling correctly. Many many thanks to you.

thanks
sanjib
 
wood burning stoves
 
subject: Build problem with maven and eclipse web project