使用db2 jars

时间:2015-12-09 03:28:16

标签: maven junit containers openjpa embeddable

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

enter image description here

我在DAO oeprations的测试中也需要DB2 jar,我将这些jar提供为:

enter image description here

我终于可以运行我的junits了。

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

    <!--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:类型&#34; x.y.z.MyEntity&#34;没有得到加强。

我已尝试过所有方法,但无法对此问题进行排序。 请帮帮我。

的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:类型&#34;类com.test.febe.model.OrgUnit&#34;没有得到加强。 引起:org.apache.openjpa.persistence.ArgumentException:类型&#34;类com.test.febe.model.OrgUnit&#34;没有得到加强。     在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.getMetaDataInternal(MetaDataRepository.java:414)     在org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:387)     在org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1246)     在org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:316)     在org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:485)     在com.ibm.ws.jpa.management.JPATxEmInvocation.find(JPATxEmInvocation.java:223)     在com.ibm.ws.jpa.management.JPAEntityManager.find(JPAEntityManager.java:195)     在com.test.febe.commons.FebeGenericDAOImpl.find(FebeGenericDAOImpl.java:60)     at com.test.febe.org.dao.EJSLocal0SLOrgUnitDAOImpl_8ea44002.find(EJSLocal0SLOrgUnitDAOImpl_8ea44002.java)     在com.test.febe.org.service.OrgUnitServiceImpl.findOrgUnit(OrgUnitServiceImpl.java:33)     at com.test.febe.org.service.EJSLocal0SLOrgUnitServiceImpl_d9270681.findOrgUnit(EJSLocal0SLOrgUnitServiceImpl_d9270681.java)     在com.test.febe.org.resouces.OrgUnitResource.findOrgUnit(OrgUnitResource.java:44)     at com.test.febe.org.resouces.EJSLocalNSLOrgUnitResource_94f17fdf.findOrgUnit(EJSLocalNSLOrgUnitResource_94f17fdf.java)     在com.test.febe.test.org.OrgUnitTest.testGetOrgUnit(OrgUnitTest.java:141)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     在java.lang.reflect.Method.invoke(Method.java:597)     在org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:45)     在org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)     在org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)     在org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)     在org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)     在org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)     在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)     在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)     在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:231)     在org.junit.runners.ParentRunner $ 1.schedule(ParentRunner.java:60)     在org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)     在org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:50)     在org.junit.runners.ParentRunner $ 2.evaluate(ParentRunner.java:222)     在org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)     在org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)     在org.junit.runners.ParentRunner.run(ParentRunner.java:300)     在org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)     在org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)     在org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)     在org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)     在org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)     在org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)     在org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

测试运行:2,失败:0,错误:2,跳过:0,经过时间:8.693秒&lt;&lt;&lt;失败! - 在com.test.febe.test.org.OrgUnitTest中 testGetAllOrgUnits(com.test.febe.test.org.OrgUnitTest)经过的时间:2.541秒&lt;&lt;&lt;错误! javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBException:参见嵌套异常;嵌套异常是:org.apache.openjpa.persistence.ArgumentException:类型&#34;类com.test.febe.model.OrgUnit&#34;没有得到加强。     在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.getMetaDataInternal(MetaDataRepository.java:414)     在org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:387)     在org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:188)     在org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:153)     在org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:243)     在org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:213)     at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:206)     在org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access $ 200(JPQLExpressionBuilder.java:81)     在org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder $ ParsedJPQL.populate(JPQLExpressionBuilder.java:2461)     在org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:61)     在org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:162)     at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:673)     at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:654)     在org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:620)     在org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:682)     在org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:589)     在org.apache.openjpa.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:996)     在com.ibm.ws.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:107)     在com.ibm.ws.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:86)     在com.ibm.ws.persistence.EntityManagerImpl.createQuery(EntityManagerImpl.java:34)     在com.ibm.ws.jpa.management.JPATxEmInvocation.createQuery(JPATxEmInvocation.java:204)     在com.ibm.ws.jpa.management.JPAEntityManager.createQuery(JPAEntityManager.java:299)     在com.test.febe.commons.FebeGenericDAOImpl.findAll(FebeGenericDAOImpl.java:69)     at com.test.febe.org.dao.EJSLocal0SLOrgUnitDAOImpl_8ea44002.findAll(EJSLocal0SLOrgUnitDAOImpl_8ea44002.java)     在com.test.febe.org.service.OrgUnitServiceImpl.getAllOrgUnits(OrgUnitServiceImpl.java:46)     at com.test.febe.org.service.EJSLocal0SLOrgUnitServiceImpl_d9270681.getAllOrgUnits(EJSLocal0SLOrgUnitServiceImpl_d9270681.java)     在com.test.febe.org.resouces.OrgUnitResource.getAllOrgUnits(OrgUnitResource.java:56)     at com.test.febe.org.resouces.EJSLocalNSLOrgUnitResource_94f17fdf.getAllOrgUnits(EJSLocalNSLOrgUnitResource_94f17fdf.java)     在com.test.febe.test.org.OrgUnitTest.testGetAllOrgUnits(OrgUnitTest.java:117)

testGetOrgUnit(com.test.febe.test.org.OrgUnitTest)经过的时间:1.904秒&lt;&lt;&lt;错误! javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBTransactionRolledbackException:嵌套异常是:javax.ejb.EJBException:参见嵌套异常;嵌套异常是:org.apache.openjpa.persistence.ArgumentException:类型&#34;类com.test.febe.model.OrgUnit&#34;没有得到加强。     在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.getMetaDataInternal(MetaDataRepository.java:414)     在org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:387)     在org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1246)     在org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:316)     在org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:485)     在com.ibm.ws.jpa.management.JPATxEmInvocation.find(JPATxEmInvocation.java:223)     在com.ibm.ws.jpa.management.JPAEntityManager.find(JPAEntityManager.java:195)     在com.test.febe.commons.FebeGenericDAOImpl.find(FebeGenericDAOImpl.java:60)     at com.test.febe.org.dao.EJSLocal0SLOrgUnitDAOImpl_8ea44002.find(EJSLocal0SLOrgUnitDAOImpl_8ea44002.java)     在com.test.febe.org.service.OrgUnitServiceImpl.findOrgUnit(OrgUnitServiceImpl.java:33)     at com.test.febe.org.service.EJSLocal0SLOrgUnitServiceImpl_d9270681.findOrgUnit(EJSLocal0SLOrgUnitServiceImpl_d9270681.java)     在com.test.febe.org.resouces.OrgUnitResource.findOrgUnit(OrgUnitResource.java:44)     at com.test.febe.org.resouces.EJSLocalNSLOrgUnitResource_94f17fdf.findOrgUnit(EJSLocalNSLOrgUnitResource_94f17fdf.java)     在com.test.febe.test.org.OrgUnitTest.testGetOrgUnit(OrgUnitTest.java:141)

0 个答案:

没有答案