1

GWT + hibernate4 +ApacheTomcatを使用して簡単なWebアプリを開発しようとしています。これで、GWTとHibernateを使用して(デフォルトの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)

回避策はありますか?

4

1 に答える 1

1

何が起こっているのかはまさにそれが言っていることです:

「java.lang.NoClassDefFoundError:javax.naming.InitialContextは制限付きクラスです。詳細については、GoogleAppEngine開発者ガイドをご覧ください。」

Google App Engine JREホワイトリストが原因で、コードはそのままではこのように実行されません。つまり、Tomcatのような「スタンドアロン」Javaアプリサーバーを実行できるすべてのJavaクラスとライブラリを使用できるわけではありません。

GoogleAppEngineで実行されているアプリケーションで使用できるJavaクラスの正確なリストをご覧ください。

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

于 2012-03-13T14:07:19.863 に答える