NetBeans 8.2 - Weblogic - Ant 构建

NetBeans 8.2 - Weblogic - Ant build

当我尝试使用 ant 在 Netbeans 中构建我的企业项目时,我遇到了这个异常:

warning: Supported source version 'RELEASE_6' from annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source '1.8' Note: Creating static metadata factory ...

An annotation processor threw an uncaught exception. Consult the following stack trace for details. java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/PersistenceException

我的 ejb 模块中只有一些 entity类。

此错误被报告为 bug in NetBeans(具有已解决的状态,因为它最终被视为“用户错误”)。以下是解释问题并给出解决方案的主要评论:

"ClassFormatError: Absent Code attribute in method..." is always indication that javaee-api-6.0.jar is used for runtime execution. The jar contains only method signatures (method bodies are stripped) and is suitable only for compilation. In future versions of javac there might be better error message.

The problem here is that javaee-api-6.0.jar is on classpath before EclipseLink jars and when EclipseLink annotation processor is started classes from javaee-api-6.0.jar are used instead of classes from EclipseLink. First thing is that javaee-api-6.0.jar should be removed from classpath of EJB project - it should not be needed as EJB project has an Application server selected and the project takes EE 6 APIs from that server.

根据我对评论的理解,您应该尝试从项目,因为 EclipseLink 库应该提供注释处理器使用的正确 类。

此外,this question 似乎也解决了同样的问题。

当您使用插入代码和自动创建 bean 时,它会添加 Java EE 6 API 图书馆。我删除了库并添加了 Java EE 7 API。