stevebot
stevebot

Reputation: 24005

Referenced libraries not being deployed by Eclipse

I setup a Google App Engine project in Eclipse. I added a root level folder to contain libraries for my project. I added all of these libraries to the build path for my project. The code compiles without any errors. When I run the project, I get startup errors NoClassDef errors. When I add these libraries manually to the war directory's lib folder, these errors disappear.

Why isn't Eclipse deploying the libraries on my build path for me? Do I need to have a build script in place for Eclipse to run? A build script that will copy my libraries to the war dir's lib folder?

Upvotes: 4

Views: 9824

Answers (3)

30thh
30thh

Reputation: 11376

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 the Deployment Assembly and everything else was configured properly.

Upvotes: 2

Eugene Ryzhikov
Eugene Ryzhikov

Reputation: 17359

For standard Java EE project libraries have to be under {web-app}/WEB-INF/lib folder. GAE requires them to be there too to upload to the engine with your code.

Alternatively you can use Maven to define your dependencies and deploy to GAE

UPDATE: GAE project follows standard Java EE project structure to build and deploy a war file. The convention is that your lib folder is in {web-app}/WEB-INF/lib. Google plugin automatically generates such a structure (example from plugins docs):

MyTestProject
  src/
    log4j.properties
    META-INF/
      jdoconfig.xml
    com/
      mytestproject/
        MyTestProjectServlet.java
  war/  
    index.html
    WEB-INF/
      appengine-web.xml
      web.xml
      logging.properties
      classes/
      lib/
       ...App Engine JARs... 

The plugin does allow to change location for your "war" directory, but not the location of your libraries since it should follow the Java EE standard.

Upvotes: 3

Robby Pond
Robby Pond

Reputation: 73484

You can add the libraries to your war/lib directly, and then right click on the libraries to add them to your build path.

Not sure why it doesn't deploy libs on your build path, but I have been working with Eclipse for years and have always done it the way I described. Then I just deploy through eclipse and don't use a build script.

Upvotes: 2

Related Questions