簡體   English   中英

Java + Hibernate4 + GWT + App Engine = InitialContext錯誤

[英]Java + Hibernate4 + GWT + App Engine = InitialContext error

我嘗試使用GWT + hibernate4 + Apache Tomcat開發一個簡單的Web應用程序。 現在,我已經使用GWT和休眠模式編寫了簡單的類(首次使用默認的App Engine服務器),但是在向服務器發送數據時出現錯誤,該類出現了

public class HibernateUtil {
private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;

static SessionFactory getSessionFactory() throws HibernateException {
    Configuration configuration = new Configuration();
    configuration.configure();
    serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();        
    sessionFactory = configuration.buildSessionFactory(serviceRegistry);
    return sessionFactory;
}

}

在線上的sessionFactory = configuration.buildSessionFactory(serviceRegistry); 這是堆棧跟蹤

    java.lang.NoClassDefFoundError: javax.naming.InitialContext is a restricted class. Please see the Google  App Engine developer's guide for more details.
    at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
at org.hibernate.service.jndi.internal.JndiServiceImpl.buildInitialContext(JndiServiceImpl.java:77)
at org.hibernate.service.jndi.internal.JndiServiceImpl.bind(JndiServiceImpl.java:107)
at org.hibernate.internal.SessionFactoryRegistry.addSessionFactory(SessionFactoryRegistry.java:79)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:440)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
at ru.leti.alexeeva.server.HibernateUtil.getSessionFactory(HibernateUtil.java:17)

有什么辦法嗎?

所發生的就是它所說的:

“ java.lang.NoClassDefFoundError:javax.naming.InitialContext是受限制的類。有關更多詳細信息,請參閱Google App Engine開發人員指南。”

由於Google App Engine JRE白名單,您的代碼將無法立即運行。 換句話說,您不能使用所有可以運行“獨立” Java應用程序服務器(例如Tomcat)的Java類和庫。

查看在Google App Engine上運行的應用程序中允許使用哪些Java類的精確列表:

http://code.google.com/appengine/docs/java/jrewhitelist.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM