Problem with Maven Dependency.
Hello All,
This is in reference to my earlier post Error with Jboss while deploying a jsp/servlet web app "com.sun.faces.config.ConfigureListener" Error
When i dont build via maven and export the project as a war ( I use Eclipse for J2EE ) and deploy it to Jboss6 via its admin console it runs fine, whereas if i build via maven using mvn clean install and copy the war built by maven to my /deploy directory (Jboss) i get the following error
2011-05-10 14:41:57,509 INFO [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (HDScanner) deploy, ctxPath=/UltimateSMS-1 2011-05-10开发者_如何学编程 14:41:57,681 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/UltimateSMS-1]] (HDScanner) Error configuring application listener of class com.sun.faces.config.ConfigureListener: java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener at java.net.URLClassLoader$1.run(URLClassLoader.java:217) [:1.6.0_20] at java.security.AccessController.doPrivileged(Native Method) [:1.6.0_20] at java.net.URLClassLoader.findClass(URLClassLoader.java:205) [:1.6.0_20]
And the deployment of war fails.
Heres a section of my pom
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-j2ee</artifactId>
<version>4.0.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
</dependency>
No where in my web.xml have a configured a faces listener and it doesnot have any references to JSF
P.S: My project is a simple JSP/Servlet J2EE project with no references to JSF what so ever I use JDK 1.6 and Maven -> Apache Maven 3.0.3
I have narrowed down the error and i think the problem is in my pom.xmlPlease Advise. Thanks
I've experienced the same problem. You should replace in pom.xml
:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
and :
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
</dependency>
by :
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
According to maven doc you should set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes.
provided This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
精彩评论