如果我的模型类导入HttpServletRequest,Datanucleus增强器会抛出NoClassDefFoundError

时间:2011-08-11 22:37:02

标签: jdo datanucleus

如果正在增强的模型类导入HttpServletRequest类,是否存在Datanucleus设置以防止增强器抛出错误?

Aug 11, 2011 11:06:34 PM org.datanucleus.enhancer.asm.JdoClassAdapter visitEnd
WARNING: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
        at java.lang.Class.getDeclaredConstructors(Unknown Source)
        at java.io.ObjectStreamClass.computeDefaultSUID(Unknown Source)
        at java.io.ObjectStreamClass.access$100(Unknown Source)
        at java.io.ObjectStreamClass$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.io.ObjectStreamClass.getSerialVersionUID(Unknown Source)
        at org.datanucleus.enhancer.asm.JdoClassAdapter.visitEnd(JdoClassAdapter.java:338)
        at org.objectweb.asm.ClassReader.accept(Unknown Source)
        at org.objectweb.asm.ClassReader.accept(Unknown Source)
        at org.datanucleus.enhancer.asm.ASMClassEnhancer.enhance(ASMClassEnhancer.java:355)
        at org.datanucleus.enhancer.DataNucleusEnhancer.enhanceClass(DataNucleusEnhancer.java:974)
        at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:570)
        at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1252)
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 15 more

1 个答案:

答案 0 :(得分:0)

您可以限制正在增强的类,因此只需增强可持久的类。如果不这样做,就必须搜索注释,这样做需要加载类定义,如果你的类路径中没有依赖项,Java的类加载器会抱怨