Ota*_*vio 13 java gwt google-app-engine
当我尝试在我的GWT/App Engine应用程序的本地JDO数据存储上执行查询时,我随机获取了org.datanucleus.exceptions.ClassNotPersistableException.这只发生在我在托管模式下运行应用程序时.当我将其部署到Google App Engine时,一切都很完美.
堆栈跟踪:
org.datanucleus.exceptions.ClassNotPersistableException: The class "com.wayd.server.beans.WinePost" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:305)
at org.datanucleus.ObjectManagerImpl.getExtent(ObjectManagerImpl.java:3700)
at org.datanucleus.jdo.JDOPersistenceManager.getExtent(JDOPersistenceManager.java:1515)
at com.wayd.server.WinePostServiceImpl.getPosts(WinePostServiceImpl.java:212)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
... 25 more
Caused by: org.datanucleus.exceptions.ClassNotPersistableException: The class "com.wayd.server.beans.WinePost" is not persistable. This means that it either hasnt been enhanced, or that the enhanced version of the file is not in the CLASSPATH (or is hidden by an unenhanced version), or the Meta-Data/annotations for the class are not found.
at org.datanucleus.ObjectManagerImpl.assertClassPersistable(ObjectManagerImpl.java:3830)
at org.datanucleus.ObjectManagerImpl.getExtent(ObjectManagerImpl.java:3693)
... 32 more)
Run Code Online (Sandbox Code Playgroud)
WinePost类是一个非常简单的JDO持久化类:
@PersistenceCapable(identityType = IdentityType.APPLICATION)public class WinePost {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private User author;
@Persistent
private String grape;
@Persistent
private String comment;
public WinePost(final User author, final String grape,
final String comment) {
super();
this.grape = grape;
this.comment = comment;
}
public User getAuthor() {
return author;
}
public void setAuthor(final User author) {
this.author = author;
}
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public String getGrape() {
return grape;
}
public void setGrape(final String grape) {
this.grape = grape;
}
public String getComment() {
return comment;
}
public void setComment(final String comment) {
this.comment = comment;
}
public String getUserNickname() {
String retVal = null;
if (author != null) {
retVal = author.getNickname();
}
return retVal;
}
public WinePostModel getWinePostModel() {
final WinePostModel winePostModel = new WinePostModel(grape, vintage, getUserNickName());
return winePostModel;
}
Run Code Online (Sandbox Code Playgroud)
}
数据存储区查询通过以下方法执行:
public ArrayList<WinePostModel> getPosts() {
final ArrayList<WinePostModel> posts = new ArrayList<WinePostModel>();
final PersistenceManager persistenceManager = PMF.get()
.getPersistenceManager();
final Extent<WinePost> winePostExtent = persistenceManager.getExtent(
WinePost.class, false);
for (final WinePost winePost : winePostExtent) {
posts.add(winePost.getWinePostModel());
}
winePostExtent.closeAll();
return posts;
}
Run Code Online (Sandbox Code Playgroud)
Mo'*_*ers 15
我很确定您的代码没有任何问题.您收到此错误的原因是Datanucleus增强器出现问题.
如果您看到此错误,请退出Jetty并检查Eclipse中的控制台(您需要在控制台窗口上方的小工具栏中选择正确的控制台).它应该说:
DataNucleus Enhancer(版本1.1.4):类的增强DataNucleus Enhancer已成功完成X类.计时:输入= 547毫秒,增强= 76毫秒,总计= 623毫秒.有关详细信息,请参阅日志
...其中X是它处理的类数.该数字应该等于您定义的"实体"数量.
但有时,由于某种原因,它会说0,这就是为什么你得到ClassNotPersistableException错误.
要修复,打开实体类并更改某些内容(添加空格或其他内容)并保存.检查控制台,直到它说它已经增强了所有实体类.然后重新启动调试器并再试一次.
尽管这是一个旧线程,但是为任何遇到同样问题的人发布以供将来参考.
我遇到了"同样"的问题,发现我的classpath有多个datanucleus-appengine-1.0.7.final.jar实例.我从日志中了解到这一点,这是在我尝试构建工作区时提示的.这是日志内容.
java.lang.RuntimeException:com.google.appengine.toolsr.Enhancer.execute(Enhancer.java:59)在com.google.appengine.tools.enhancer.Enhance.(Enhance.java:60)处出现意外异常在sun.reflect.NativeMethodAccessorImpl.invoke在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)java.lang.reflect.InvocationTargetException:com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:41)引起的(NativeMethodAccessorImpl.java:39)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)在java.lang.reflect.Method.invoke(Method.java:597)在com.google.appengine.tools.enhancer. Enhancer.execute(Enhancer.java:57)... 2更多引起:org.datanucleus.exceptions.NucleusException:插件(Bundle)"org.datanucleus.store.appengine"已经注册.确保类路径中没有相同插件的多个JAR版本.该URL的"file:/ G:/eclipse/plugins/com.google.appengine.eclipse.sdkbundle.1.3.4_1.3.4.v201005212032/appengine-java-sdk-1.3.4/lib/user/orm/datanucleus-appengine -1.0.7.final.jar"已被注册,并且您尝试注册位于URL相同的插件"文件:/ G:/WS_Quotemandu/quotemandu/war/WEB-INF/lib/datanucleus-appengine-1.0. 7.final.jar".org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:434)org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:340)org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(NonManagedPluginRegistry.java:222) )在处org.datanucleus.OMFContext org.datanucleus.plugin.PluginManager.registerExtensionPoints(PluginManager.java:82)org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensionPoints(NonManagedPluginRegistry.java:153).(OMFContext.java:160)在org.datanucleus.enhancer.DataNucleusEnhancer.(DataNucleusEnhancer.java:172)在org.datanucleus.enhancer.DataNucleusEnhancer.(DataNucleusEnhancer.java:150)在org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1157)..还有7个
G:/eclipse/plugins/com.google.appengine.eclipse.sdkbundle.1.3.4_1.3.4.v201005212032/appengine-java-sdk-1.3.4/lib/user/orm/datanucleus-appengine-1.0.7.final .罐
文件:/ G:/WS_Quotemandu/quotemandu/war/WEB-INF/lib/datanucleus-appengine-1.0.7.final.jar
希望这可以帮助!
归档时间: |
|
查看次数: |
10483 次 |
最近记录: |