java - Netbeans 8 + maven + OpenJPA 部署到 TomEE - 增强失败

标签 java maven netbeans openjpa

我在这里找到了一些关于该主题的帖子,但没有一个建议对我有用。

我正在尝试使用 Netbeans 8.0 在 TomEE 1.6.0.1 上创建一个简单的“Web 配置文件”Java EE 应用程序。只是想连接到 mysql 数据库并显示一些数据来感受一下。

我无法克服这个错误:

Failed to execute goal org.apache.openjpa:openjpa-maven-plugin:2.2.2:enhance (enhancer) on project TomEETestMaven: Execution enhancer of goal org.apache.openjpa:openjpa-maven-plugin:2.2.2:enhance failed: MetaDataFactory could not be configured (conf.newMetaDataFactoryInstance() returned null). This might mean that no configuration properties were found. Ensure that you have a META-INF/persistence.xml file, that it is available in your classpath, or that the properties file you are using for configuration is available. If you are using Ant, please see the or attributes of the task's nested element. This can also occur if your OpenJPA distribution jars are corrupt, or if your security policy is overly strict. -> [Help 1]

以下是我按照 OpenJPA 站点上的最新文档在 pom.xml 中添加增强插件的方法:

      <plugin>
        <groupId>org.apache.openjpa</groupId>
        <artifactId>openjpa-maven-plugin</artifactId>
        <version>2.2.2</version>
        <configuration>
          <includes>com/myapp/tomeetestmaven/**/*.class</includes>
        </configuration>
        <executions>
          <execution>
            <id>enhancer</id>
            <phase>process-classes</phase>
            <goals>
              <goal>enhance</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-maven-plugin</artifactId>
            <version>2.2.2</version>
          </dependency>
        </dependencies>
      </plugin>

我收到了相互矛盾的报告,有些人说这是一个错误,另一些人说 persistence.xml 文件必须位于类路径上(但由于它已经位于 src/main/resources/META-INF 中,所以它安全吗?)我尝试将其移动到 src/main/java 但错误是相同的。

经过几天的疯狂谷歌搜索和测试后,我被难住了。任何帮助将不胜感激,谢谢。

最佳答案

在与他博客上的一位乐于助人的人反复交流后,明白了。您必须将此行添加到/conf/system.properties:

openejb.jpa.deploy-time-enhancement=true

关于java - Netbeans 8 + maven + OpenJPA 部署到 TomEE - 增强失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23227132/

相关文章:

java - 使用 Spring Security 配置 Spring Boot 会使构建因引用缺少依赖项而失败

java - 在 javafx 中使用 css 设计表单

java - 当使用 UUID 命名时,为 akka actor 定义调度程序

java - 如何获取可执行 validator ? hibernate validator

java - 根据鼠标 X 坐标旋转图像

xml - 在 pom.xml 中包含另一个 xml 文件

swing - jdk 1.5 中不存在 javax.swing.grouplayout

git - 无法从 Assembla 克隆

java - 关于Java中类成员的问题

java - 将迭代器从 JSONObject 重写为 JSONArray