开发者

Referenced libraries not being deployed by Eclipse

开发者 https://www.devze.com 2023-02-15 01:39 出处:网络
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 with

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 开发者_如何学JAVAEclipse to run? A build script that will copy my libraries to the war dir's lib folder?


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.


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.


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.

0

精彩评论

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

关注公众号