0

我正在开发一个基于 java 的 webapp,其中我使用 websphere JAX-RS 实现,EJB 作为中间层,OpenJPA 作为 DAO 层,后端使用 DB2 来实现数据持久性。我还为代码编写 junits。我在我的 eclipse 工作区中运行 junits,并且我在我的 bean 中使用依赖注入注释,所以我利用 websphere 提供的轻量级嵌入式容器 jar 来使 junit 快速启动和运行。我提供这个 jar 作为 java 代理,如下所示:

在此处输入图像描述

因为我在 DAO 操作的测试中还需要 DB2 jars,所以我将这些 jars 提供为:

在此处输入图像描述

我终于能够运行我的junits了。

但是当我单独运行一个junit时,我会遵循这种方法。现在我计划在 maven 构建过程(maven install -e)中运行我所有的 junit。我提供了所需的依赖项:

    <!--added for junit testing -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.websphere</groupId>
        <artifactId>was-embeddableContainer</artifactId>
        <version>8.0.0</version>
        <scope>test</scope>         
    </dependency>   
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc</artifactId>
        <version>8.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc_license_cu</artifactId>
        <version>8.1.1</version>
        <scope>test</scope>         
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc4</artifactId>
        <version>8.1.1</version>
        <scope>test</scope>
    </dependency>   
    <!-- end -->

但是在 maven 构建中,junits 失败并出现奇怪的问题:org.apache.openjpa.persistence.ArgumentException:“xyzMyEntity”类型没有得到增强。

我已经尝试了所有方法,但无法解决我们的这个问题。请在这里帮助我。

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- THIS PRODUCT CONTAINS RESTRICTED MATERIALS OF IBM 5724-H88, 5724-J08, 
5724-I63, 5655-W65, COPYRIGHT International Business Machines Corp., 2013 
All Rights Reserved * Licensed Materials - Property of IBM US Government 
Users Restricted Rights - Use, duplication or disclosure restricted by GSA 
ADP Schedule Contract with IBM Corp. -->
<project xmlns="http://maven.apache.org/POM/4.0.0"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  http://maven.apache.org/xsd/maven-4.0.0.xsd">

<licenses>
    <license>
        <name>IBM International License Agreement for Non-Warranted Programs</name>
        <url>http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/licenses/L-JTHS-8SZMHX/HTML/</url>
        <distribution>repo</distribution>
        <comments>Additional notices http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/licenses/L-JTHS-8SZMHX/HTML/notices.html</comments>
    </license>
</licenses>

<modelVersion>4.0.0</modelVersion>

<groupId>com.test.febe</groupId>
<artifactId>FebeApplication</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>

<name>FebeApplication</name>
<url>http://maven.apache.org</url>

<properties>
    <was_home>${env.WAS8_HOME}</was_home>
</properties>

<dependencies>
    <!-- <dependency> <groupId>com.ibm.tools.target</groupId> <artifactId>was</artifactId> 
        <version>8.5.5</version> <type>pom</type> <scope>provided</scope> </dependency> -->

    <!-- added for websphere JPA -->
    <dependency>
        <groupId>com.ibm.websphere.ws</groupId>
        <artifactId>com.ibm.ws.jpa</artifactId>
        <version>8.0.0-FixPack-07</version>
        <scope>provided</scope>
    </dependency>
    <!-- end -->

    <!-- added for websphere j2ee -->
    <dependency>
        <groupId>com.ibm.websphere.j2ee</groupId>
        <artifactId>j2ee</artifactId>
        <version>8.0.0-FixPack-07</version>
        <scope>provided</scope>
    </dependency>
    <!-- end -->

    <!-- added for IBM PAI logging -->
    <dependency>
        <groupId>com.dcx.pai</groupId>
        <artifactId>logging</artifactId>
        <version>5.0.5</version>
    </dependency>
    <dependency>
        <groupId>com.dcx.pai</groupId>
        <artifactId>monitoring</artifactId>
        <version>5.0.5</version>
    </dependency>
    <dependency>
        <groupId>com.dcx.pai</groupId>
        <artifactId>usersecuritycontext</artifactId>
        <version>5.0.5</version>
    </dependency>
    <dependency>
        <groupId>com.dcx.pai</groupId>
        <artifactId>util</artifactId>
        <version>5.0.5</version>
    </dependency>
    <!-- end -->

    <!--added for dozer mapping -->
    <dependency>
        <groupId>net.sf.dozer</groupId>
        <artifactId>dozer</artifactId>
        <version>5.4.0</version>
    </dependency>
    <!-- end -->

    <!--added for junit testing -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.websphere</groupId>
        <artifactId>was-embeddableContainer</artifactId>
        <version>8.0.0</version>
        <scope>test</scope>         
    </dependency>   
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc</artifactId>
        <version>8.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc_license_cu</artifactId>
        <version>8.1.1</version>
        <scope>test</scope>         
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc4</artifactId>
        <version>8.1.1</version>
        <scope>test</scope>
    </dependency>   
    <!-- end -->

    <!--added for JSON Ignore -->
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.7.1</version>
    </dependency>
    <!-- end -->

    <!--added for DBSetUP -->
    <dependency>
        <groupId>com.ninja-squad</groupId>
        <artifactId>DbSetup</artifactId>
        <version>1.6.0</version>
    </dependency>
    <!--end -->

    <dependency>
        <groupId>javax.batch</groupId>
        <artifactId>javax.batch-api</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-openjpa</artifactId>
        <version>0.1</version>
    </dependency>

    <dependency>
        <groupId>org.infinispan</groupId>
        <artifactId>infinispan-embedded</artifactId>
        <version>7.0.0.Final</version>
    </dependency>

</dependencies>

<build>
    <finalName>${project.name}</finalName>
    <outputDirectory>${project.basedir}\src\main\webapp\WEB-INF\classes</outputDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <!-- plugin added to skip test -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <skipTests>false</skipTests>
            </configuration>
        </plugin>
        <!-- end -->

    </plugins>
</build>

错误跟踪:

引起:javax.ejb.EJBException:见嵌套异常;嵌套异常是:org.apache.openjpa.persistence.ArgumentException:类型“com.test.febe.model.OrgUnit”尚未增强。原因:org.apache.openjpa.persistence.ArgumentException:类型“com.test.febe.model.OrgUnit”没有增强。在 org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1827) 在 org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1801) 在 org.apache.openjpa.meta.MetaDataRepository.processBuffer (MetaDataRepository.java:825) 在 org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:722) 在 org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:646) 在 org.apache。 openjpa.meta.MetaDataRepository。

测试运行:2,失败:0,错误:2,跳过:0,经过的时间:8.693 秒 <<< 失败!- 在 com.test.febe.test.org.OrgUnitTest testGetAllOrgUnits(com.test.febe.test.org.OrgUnitTest) 经过时间:2.541 秒 <<< 错误!javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBException:见嵌套异常;嵌套异常是:org.apache.openjpa.persistence.ArgumentException:类型“com.test.febe.model.OrgUnit”尚未增强。在 org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1827) 在 org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1801) 在 org.apache.openjpa.meta.MetaDataRepository.processBuffer (MetaDataRepository.java:825) 在 org.apache.openjpa.meta。

testGetOrgUnit(com.test.febe.test.org.OrgUnitTest) 已用时间:1.904 秒 <<< 错误!javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBException:见嵌套异常;嵌套异常是:org.apache.openjpa.persistence.ArgumentException:类型“com.test.febe.model.OrgUnit”尚未增强。在 org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1827) 在 org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1801) 在 org.apache.openjpa.meta.MetaDataRepository.processBuffer (MetaDataRepository.java:825) 在 org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:722) 在 org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:

4

0 回答 0