Eclipse warning: XXXXXXXXXXX.jar will not be expor

2019-01-17 10:21发布

问题:

I keep getting the following error after I put the required files in my build path on Eclipse. I am working on a Spring MVC Hello World Application. I am running Eclipse Helios for Java EE developers:

Jan 16, 2012 1:25:42 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /SpringMVCTutorial threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1062)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

I have tried right clicking the server and clicking "clean". I right click the application, click "Build Path" the "Configure Build Path" and put the right .jar files in the library; however, it still doesnt acknowledge them as dependencies. What am I missing?

I have tried the advice presented in: eclipse helios: tomcat project - jar will not be exported or published. runtime ClassNotFoundExceptions may result

  1. Right Click on your web project
  2. Click Properties
  3. Select Java EE Module Dependencies
  4. Click the Web Libraries Tab
  5. Add external jars (if the jar is outside of your project). An entry will be added under Jar/Module, make sure you click on the checkbox (checked).

The problem is that when I select "Click Properties" I do not have the option of clicking Java EE Module dependencies as it doesnt appear. I downloaded any extra Java EE tools and still can't find it.

回答1:

Ok. So I figured it out. . .

In order to get it to work right, I have to "drop and drag" the files that I want in my classpath/dependencies into my WEB-INF/lib file.

It works this way.

For some reason when I try to do it the right way

build path --> configure build path --> external jars

it just doesnt take.

The trick is that I have to put the files int my Web App Libraries folder and the only way to do that (that I can see:) is to "click and drop" into my WEB-INF/lib file.

This way it automatically shows up in my Web App Libraries.



回答2:

When adding new jar files, I got two messages on Eclipse's Problems Tab: one error and one warning. I only solved this problem when combining all previous solutions with an extra step. Here's how I solved it:

  1. "Drop and drag" the files that I want in my classpath/dependencies into my WEB-INF/lib file;
  2. Right-click on your project in Package Explorer tab, and build path --> configure build path -->external jars, adding the desired files;
  3. Restarted Eclipse;
  4. Select Project --> Clean.... My system is configured to build automatically, so after this step the error message was gone, but the warning XXXXXXXXXXX.jar will not be exported or published. Runtime ClassNotFoundExceptions may result remained;
  5. Right-click on warning message --> Quick Fix;
  6. Select the option Mark the associated raw classpath entry as a publish/export dependency. (as figure below)


回答3:

right click on your project in project explorer tab, and build path --> configure build path, -->external jars

add all the jars which you want.