GAE : java.lang.NoClassDefFoundError: com/google/appengine/api/blobstore/BlobstoreServiceFactory

做~自己de王妃 提交于 2019-12-24 03:54:13

问题


Kindly help me with this. I am using blob store for saving images and it is working perfectly fine on my local environment. But when I deploy the same code the cloud it is throwing me the exception : java.lang.NoClassDefFoundError: com/google/appengine/api/blobstore/BlobstoreServiceFactory

I am using GAE 1.8.4


回答1:


Most likely, appengine-api.jar is missing from your war/WEB-INF/lib/ folder.

If you use Eclipse, click on the Problems tab. You may see a warning saying that this jar is not available on a server. Right click on this warning, select QuickFix, select "Copy..." option. Or copy this jar to this directory manually.




回答2:


In my case the required jar was inside the WEB-INF/lib folder but the error was still occuring... I found that this error was occuring because Jetty 9 was not done yet with class loading startup process while one of my initialization class was requiring BlobstoreService:

public class InitializeAppContextListener implements ServletContextListener {

    private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();

So I had to postpone instance variable initialization once context is fully loaded as follow:

public class InitializeAppContextListener implements ServletContextListener {
    private BlobstoreService blobstoreService;

    public void contextInitialized(ServletContextEvent event) {
        blobstoreService = BlobstoreServiceFactory.getBlobstoreService();

Then the webapp was able to start normally again. This new behavior appeared after we had upgraded from servlet-api 2.5 to 3.1 with JDK 1.8...



来源:https://stackoverflow.com/questions/25637594/gae-java-lang-noclassdeffounderror-com-google-appengine-api-blobstore-blobsto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!