1

如何解决此异常?

有人可以让我知道我收到此异常的原因:

配置:

           jdk1.6
           Jboss4.2
           JPA provider: OpenJpa
           EclipseIDE

完整的堆栈跟踪:

 java.lang.reflect.InvocationTargetException
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:597)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
Caused by: java.util.MissingResourceException: org.apache.openjpa.persistence.PersistenceProductDerivation:java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
at org.apache.openjpa.lib.conf.ProductDerivations.reportErrors(ProductDerivations.java:380)
at org.apache.openjpa.lib.conf.ProductDerivations.load(ProductDerivations.java:283)
at org.apache.openjpa.lib.conf.Configurations.populateConfiguration(Configurations.java:357)
at org.apache.openjpa.enhance.PCEnhancerAgent.registerClassLoadEnhancer(PCEnhancerAgent.java:165)
at org.apache.openjpa.enhance.PCEnhancerAgent.premain(PCEnhancerAgent.java:145)
... 6 more
Caused by: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
FATAL ERROR in native method: processing of -javaagent failed
at org.apache.openjpa.persistence.PersistenceUnitInfoImpl.toOpenJPAProperties(PersistenceUnitInfoImpl.java:477)
at org.apache.openjpa.persistence.PersistenceUnitInfoImpl.toOpenJPAProperties(PersistenceUnitInfoImpl.java:359)
at org.apache.openjpa.persistence.PersistenceProductDerivation.load(PersistenceProductDerivation.java:541)
at org.apache.openjpa.persistence.PersistenceProductDerivation.load(PersistenceProductDerivation.java:360)
at org.apache.openjpa.lib.conf.ProductDerivations.load(ProductDerivations.java:274)
... 9 more
Exception in thread "main" 
4

1 回答 1

0

说明显而易见的......正在使用的 OpenJPA 版本需要 JPA2,而 JBoss 4.x 存在 JPA1 API jar......因此没有找到 JPA2 方法的异常。使用一致的 JPA 版本和 JPA 实现

于 2012-05-16T09:56:09.420 回答