开发者

Eclipse does not deploy jars into WEB-INF/lib directory

To integrate JSF with Spring I have added these lines in web.xml:

<context-param>  
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>  
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>  
    <listener-cla开发者_运维技巧ss>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

And I have added all the spring dependencies using Maven, but when I run the project I receive the following error messages:

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.request.RequestContextListener

When I took a glance at the folder /WEB-INF/lib I have found no JAR files, although dependencies are declared in the pom.xml.

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>${spring.version}</version>
</dependency>

I think that the problem that the JAR's are not packaged with the draft. Do you have an idea how to fix it?


eclipse project right click -> Properties -> Deployment Assembly -> Add -> Java Build Path Entry will do.


If the library which was not added to lib folder is being developed in the same workspace, I would suggest to enable the "Utility Module" facet in project properties of the library project. Sometimes Eclipse doesn't copy a jar into WEB-INF/lib folder even if everything else configured properly.


Maven dependencies are stored at ~/.m2. If you run mvn install and deploy directly (with Jetty or Tomcat plugin) there wont be any jar files at WEB-INF/lib.

On the other hand, if you run mvn package to build a WAR, the WAR should contain all the required jars to deploy your app. You can uncompress this WAR file with unzip <file.war> and check if your jars are there.

As for me, I got this very same error and I noticed I was missing a dependency in my pom.xml

<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>${spring.version}</version>
</dependency>


Did a maven force update and then installed the build and ran on tomcat as able to find the jars in webapp/libs.

right click on the project choose maven > updateproject > select force update snapshots > OK.


You have update the project by selecting theproject in project exlorer and select Run Maven->Update Project...

Make sure that after the updated, by selecting the project properties, in the Depluyment assembly you have Maven Dependencies as source linked to WEB-INF as Deploy path. If not, just add it by clicking the Add... button, selecting Java Buid Path Entries, clicking the next button and selecting the Maven Dependences.

Then Eclipse has to deploy the libs in the server.


And I have added all the spring dependencies using Maven, but when I run the project I receive the following error messages (...)

How do you run the project? Do you use m2eclipse? How did you create the project? Did you import an existing Maven project into Eclipse?

When I took a glance at the folder /WEB-INF/lib I have found no JAR files, although dependencies are declared in the pom.xml

The dependencies looks fine but... What WEB-INF/lib folder? Where exactly? AFAIK, m2eclipse won't really "deploy" the jars into WEB-INF/lib (but it will create a custom class path including them).

I think that the problem that the JAR's are not packaged with the draft. Do you have an idea how to fix it?

I'm not sure I understood what you mean. What do you get when running mvn install? Does the war look ok? Could you actually show your pom.xml?


Both org.springframework.web.context.ContextLoaderListener and org.springframework.web.context.request.RequestContextListener are present in the spring-web package, at least on version 2.5 which is the most common.

Also, make sure you're including the following in your pom.xml

    <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring</artifactId>
         <version>${your.spring.version}</version>
    </dependency> 


old question but i had this issue. Fixed by switching to JDK instead of JRE!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜