我尝试使用GWT + hibernate4 + Apache Tomcat开发一个简单的try应用程序。现在我已经用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)有什么办法可以绕过去吗?
发布于 2012-03-13 22:07:20
所发生的事情就是它所说的:
"java.lang.NoClassDefFoundError: javax.naming.InitialContext是一个受限制的类。有关详细信息,请参阅Google App Engine开发人员指南。“
由于Google App Engine JRE白名单的存在,您的代码不会像这样运行。换句话说,您不能使用可以运行Tomcat这样的“独立”Java应用服务器的所有Java类和库。
查看允许在Google App Engine上运行的应用程序中使用哪些Java类的精确列表:
http://code.google.com/appengine/docs/java/jrewhitelist.html
https://stackoverflow.com/questions/9685264
复制相似问题