Question

Despite all the controversy with equals/hashCode and JPA I'm dealing with a problem reminds me "What was 1st? The egg or the hen?

I'm using JPA for implementing my persistence layer, and JUnit 4 for testin it, the problem is if I override equals and hashCode methods, JUnit test raises an exception I can't understand.

For some time I've ignored those 2 method, but if i need to use @Embeded classes I must override them. So, if I ignore those 2 method I can't use @Embeded classes, and if I use those 2 method I can't success run my tests... does anybody know the solution?

My Test:

//my package
import static org.junit.Assert.*;
import java.util.Properties;
import javax.ejb.embeddable.EJBContainer;
import javax.naming.Context;
import javax.naming.NamingException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
//own import 

public class LanguageTest {
    private Context context;
    private LanguageBO lbo;

    /*========================================TESTS SETUP========================================*/
    @Before
    public void mockDB() throws NamingException {
        Properties p = Mock.MockDB();
        EJBContainer container = EJBContainer.createEJBContainer(p);
        context = container.getContext();
        lbo = (LanguageBO) context.lookup("java:global/policymodel.SIP.JPA2/LanguageBO");
    }

    /**
     * Closes the simulated DB
     * @throws NamingException
     *      If NamingException is encountered
     */
    @After
    public void closeMockedDB() throws NamingException{
        if(context != null){
            context.close();
        }
    }

    /*========================================TESTS========================================*/
    @Test
    public void readAllOK() {       
        //Scenario setup
        WSResult wsr_l = lbo.removeAllLanguages();
        assertEquals(wsr_l.getErrorNumber(), ErrorCodes.OK.errorCode);
        Language l_es = new Language("Spanish", "ES");
        WSCreateResult wscr_l_es = lbo.addLanguage(l_es);
        assertEquals(wscr_l_es.getErrorNumber(), ErrorCodes.OK.errorCode);
        Language l_en = new Language("English", "EN");
        WSCreateResult wscr_l_en = lbo.addLanguage(l_en);
        assertEquals(wscr_l_en.getErrorNumber(), ErrorCodes.OK.errorCode);
        Language l_it = new Language("Italian", "IT");
        WSCreateResult wscr_l_it = lbo.addLanguage(l_it);
        assertEquals(wscr_l_it.getErrorNumber(), ErrorCodes.OK.errorCode);
        //Operations under test
        WSGetLanguagesResult wsglr = lbo.getAllLanguages();
        //Expected results
        assertEquals(wsglr.getErrorNumber(), ErrorCodes.OK.errorCode);
        assertEquals(wsglr.getLanguages().size(), 3);
        assertTrue(Compare.languageEquals(l_es, wsglr.getLanguages().get(0)));
        assertTrue(Compare.languageEquals(l_en, wsglr.getLanguages().get(1)));
        assertTrue(Compare.languageEquals(l_it, wsglr.getLanguages().get(2)));
    }
//...
}

Mock.java:

package eu.superhub.wp4.pfws.policymaking.bo;

import java.util.Properties;

public class Mock {

    public static Properties MockDB(){
        final Properties p = new Properties();
        p.put("policyMaking", "new://Resource?type=DataSource");
        p.put("policyMaking.JdbcDriver", "org.hsqldb.jdbcDriver");
        p.put("policyMaking.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
        return p;
    }

}

I know it says something about my own classes, but when I tested it without @Embedable entities and without hashCode/equals methods, the tests worked.

Thank you in advance! :)

Eclipse solution done... now try it on Maven... but how?

Well, after been trying lots of things I fixed the issue through Eclipse as I commented on Rick's answer. The big trouble now is we need Maven to deploy the project on the final environment, so Eclipse solutions is only worth it for developing.

My entities are inside the package eu.superhub.wp4.pfws.policymaking.entity inside the source folder src/main/java

My persistence.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="policyMakingPU">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <jta-data-source>policyMaking</jta-data-source>
    <non-jta-data-source>movieDatabaseUnmanaged</non-jta-data-source>    
    <class>eu.superhub.wp4.pfws.policymaking.entity.Language</class>
    <class>eu.superhub.wp4.pfws.policymaking.entity.PolicyObjectLocalization</class>
    <class>eu.superhub.wp4.pfws.policymaking.entity.PolicyNamedObject</class>
    <class>eu.superhub.wp4.pfws.policymaking.entity.TemplateParameter</class>
    <class>eu.superhub.wp4.pfws.policymaking.entity.Template</class>
    <class>eu.superhub.wp4.pfws.policymaking.entity.TemplateInstance</class>
    <class>eu.superhub.wp4.pfws.policymaking.entity.TemplateParameterValue</class>
    <class>eu.superhub.wp4.pfws.policymaking.entity.TemplateParameterValuePK</class>       
  </persistence-unit>
</persistence>

And my pom.xml:

    ...
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <target>1.7</target>
                        <source>1.7</source>
                    </configuration>
                </plugin>               
                <!-- Needed plugin for JPA enhancer, if not tests will fail when entities 
                    override "hashCode" and "equals" methods -->
                <plugin>
                    <!-- <groupId>org.codehaus.mojo</groupId> -->
                    <groupId>org.apache.openjpa</groupId>
                    <artifactId>openjpa-maven-plugin</artifactId>
                    <version>2.2.0-SNAPSHOT</version>
                    <configuration>
                        <includes>**/entity/*.class</includes>
                        <!-- <includes>**/entity/*.class</includes> -->
                        <!-- <excludes>**/entity/XML*.class</excludes> -->
                        <addDefaultConstructor>true</addDefaultConstructor>
                        <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
                    </configuration>
                    <executions>
                        <!-- If <plugin> section is no inside a <pluginManagement> section, 
                            this tag will raise an error -->
                        <execution>
                            <id>enhancer</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>enhance</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.openjpa</groupId>
                            <artifactId>openjpa</artifactId>
                            <!-- set the version to be the same as the level in your runtime -->
                            <version>2.2.0</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
        ...
    <dependencies>
        ...
        <!-- JUnit4 and EJB testing dependences -->     
        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>openejb-core</artifactId>
            <version>4.5.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>tomee-embedded</artifactId>
            <version>1.5.2</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.openejb</groupId>
            <artifactId>openejb-core</artifactId>
            <version>4.6.1-SNAPSHOT</version>
            <scope>test</scope>
        </dependency>
        <!-- OpenJPA Dependences -->
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa</artifactId>
            <!-- set the version to be the same as the level in your runtime -->
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-all</artifactId>
            <version>2.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.openjpa</groupId>
            <artifactId>openjpa-maven-plugin</artifactId>
            <!-- set the version to be the same as the level in your runtime -->
            <version>2.2.0</version>
        </dependency>
    </dependencies>
</project>

And I'm getting the next output on the console (Exception included):

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running eu.superhub.wp4.pfws.policymaking.bo.LanguageTest
Información - ********************************************************************************
Información - OpenEJB http://openejb.apache.org/
Información - Startup: Fri Mar 07 13:43:12 CET 2014
Información - Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved.
Información - Version: 4.6.1-SNAPSHOT
Información - Build date: 20140307
Información - Build time: 04:10
Información - ********************************************************************************
Información - openejb.home = C:\SuperHUB\coderepo\wp4\policymodel.SIP.JPA2
Información - openejb.base = C:\SuperHUB\coderepo\wp4\policymodel.SIP.JPA2
Información - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@2ed4e99c
Información - Succeeded in installing singleton service
Información - Using 'javax.ejb.embeddable.EJBContainer=true'
Información - openejb configuration file is 'C:\SuperHUB\coderepo\wp4\policymodel.SIP.JPA2\etc\openejb.xml'
Información - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
Información - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
Información - Configuring Service(id=My DataSource, type=Resource, provider-id=Default JDBC Database)
Información - Configuring Service(id=My Unmanaged DataSource, type=Resource, provider-id=Default JDBC Database)
Información - Configuring Service(id=policyMaking, type=Resource, provider-id=Default JDBC Database)
Información - Configuring Service(id=My Singleton Container, type=Container, provider-id=Default Singleton Container)
Información - Configuring Service(id=My Stateful Container, type=Container, provider-id=Default Stateful Container)
Información - Configuring Service(id=My Stateless Container, type=Container, provider-id=Default Stateless Container)
Advertencia - File error: <Deployments dir="apps/"> - Does not exist: C:\SuperHUB\coderepo\wp4\policymodel.SIP.JPA2\apps
Información - Creating TransactionManager(id=Default Transaction Manager)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/gmartinez/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/gmartinez/.m2/repository/org/slf4j/slf4j-jdk14/1.7.5/slf4j-jdk14-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Información - Creating SecurityService(id=Default Security Service)
Información - Creating Resource(id=My DataSource)
Información - Creating Resource(id=My Unmanaged DataSource)
Información - Creating Resource(id=policyMaking)
Información - Creating Container(id=My Singleton Container)
Información - Creating Container(id=My Stateful Container)
Información - Using directory C:\Users\GMARTI~1\AppData\Local\Temp for stateful session passivation
Información - Creating Container(id=My Stateless Container)
Información - Found EjbModule in classpath: c:\superhub\coderepo\wp4\policymodel.sip.jpa2\target\classes
Información - Beginning load: c:\superhub\coderepo\wp4\policymodel.sip.jpa2\target\classes
Información - Configuring enterprise application: C:\SuperHUB\coderepo\wp4\policymodel.SIP.JPA2
Información - Auto-deploying ejb PolicyNamedObjectBO: EjbDeployment(deployment-id=PolicyNamedObjectBO)
Información - Auto-deploying ejb LanguageBO: EjbDeployment(deployment-id=LanguageBO)
Información - Auto-deploying ejb PolicyObjectLocalizationBO: EjbDeployment(deployment-id=PolicyObjectLocalizationBO)
Información - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container)
Información - Auto-creating a container for bean eu.superhub.wp4.pfws.policymaking.bo.LanguageTest: Container(type=MANAGED, id=Default Managed Container)
Información - Creating Container(id=Default Managed Container)
Información - Using directory C:\Users\GMARTI~1\AppData\Local\Temp for stateful session passivation
Información - Configuring PersistenceUnit(name=policyMakingPU, provider=org.apache.openjpa.persistence.PersistenceProviderImpl)
Información - Auto-creating a Resource with id 'policyMakingNonJta' of type 'DataSource for 'policyMakingPU'.
Información - Configuring Service(id=policyMakingNonJta, type=Resource, provider-id=policyMaking)
Información - Creating Resource(id=policyMakingNonJta)
Información - Adjusting PersistenceUnit policyMakingPU <non-jta-data-source> to Resource ID 'policyMakingNonJta' from 'movieDatabaseUnmanaged'
Información - Enterprise application "C:\SuperHUB\coderepo\wp4\policymodel.SIP.JPA2" loaded.
Información - Assembling app: C:\SuperHUB\coderepo\wp4\policymodel.SIP.JPA2
Advertencia - JAVA AGENT NOT INSTALLED. The JPA Persistence Provider requested installation of a ClassFileTransformer which requires a JavaAgent.  See http://tomee.apache.org/javaagent.html
Información - OpenJPA dynamically loaded a validation provider.
Información - PersistenceUnit(name=policyMakingPU, provider=org.apache.openjpa.persistence.PersistenceProviderImpl) - provider time 288ms
Información - Jndi(name="java:global/policymodel.SIP.JPA2/PolicyNamedObjectBO!eu.superhub.wp4.pfws.policymaking.bo.PolicyNamedObjectBO")
Información - Jndi(name="java:global/policymodel.SIP.JPA2/PolicyNamedObjectBO")
Información - Jndi(name="java:global/policymodel.SIP.JPA2/LanguageBO!eu.superhub.wp4.pfws.policymaking.bo.LanguageBO")
Información - Jndi(name="java:global/policymodel.SIP.JPA2/LanguageBO")
Información - Jndi(name="java:global/policymodel.SIP.JPA2/PolicyObjectLocalizationBO!eu.superhub.wp4.pfws.policymaking.bo.PolicyObjectLocalizationBO")
Información - Jndi(name="java:global/policymodel.SIP.JPA2/PolicyObjectLocalizationBO")
Información - Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@2ed4e99c
Información - OpenWebBeans Container is starting...
Información - Adding OpenWebBeansPlugin : [CdiPlugin]
Información - Adding OpenWebBeansPlugin : [OpenWebBeansJsfPlugin]
Información - All injection points were validated successfully.
Información - OpenWebBeans Container has started, it took 126 ms.
Información - Created Ejb(deployment-id=PolicyNamedObjectBO, ejb-name=PolicyNamedObjectBO, container=My Stateless Container)
Información - Created Ejb(deployment-id=PolicyObjectLocalizationBO, ejb-name=PolicyObjectLocalizationBO, container=My Stateless Container)
Información - Created Ejb(deployment-id=LanguageBO, ejb-name=LanguageBO, container=My Stateless Container)
Información - Started Ejb(deployment-id=PolicyNamedObjectBO, ejb-name=PolicyNamedObjectBO, container=My Stateless Container)
Información - Started Ejb(deployment-id=PolicyObjectLocalizationBO, ejb-name=PolicyObjectLocalizationBO, container=My Stateless Container)
Información - Started Ejb(deployment-id=LanguageBO, ejb-name=LanguageBO, container=My Stateless Container)
Información - Deployed Application(path=C:\SuperHUB\coderepo\wp4\policymodel.SIP.JPA2)
Información - Starting OpenJPA 2.2.0
Información - Using dictionary class "org.apache.openjpa.jdbc.sql.HSQLDictionary" (HSQL Database Engine 2.3.0 ,HSQL Database Engine Driver 2.3.0).
Grave - EjbTransactionUtil.handleSystemException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
eu.superhub.wp4.pfws.policymaking.entity.PolicyObjectLocalization
eu.superhub.wp4.pfws.policymaking.entity.TemplateParameterValue
eu.superhub.wp4.pfws.policymaking.entity.Language
eu.superhub.wp4.pfws.policymaking.entity.TemplateInstance
eu.superhub.wp4.pfws.policymaking.entity.PolicyNamedObject
eu.superhub.wp4.pfws.policymaking.entity.TemplateParameterValuePK
eu.superhub.wp4.pfws.policymaking.entity.TemplateParameter
eu.superhub.wp4.pfws.policymaking.entity.Template".
<openjpa-2.2.0-r422266:1244990 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "
eu.superhub.wp4.pfws.policymaking.entity.PolicyObjectLocalization
eu.superhub.wp4.pfws.policymaking.entity.TemplateParameterValue
eu.superhub.wp4.pfws.policymaking.entity.Language
eu.superhub.wp4.pfws.policymaking.entity.TemplateInstance
eu.superhub.wp4.pfws.policymaking.entity.PolicyNamedObject
eu.superhub.wp4.pfws.policymaking.entity.TemplateParameterValuePK
eu.superhub.wp4.pfws.policymaking.entity.TemplateParameter
eu.superhub.wp4.pfws.policymaking.entity.Template".
    at org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:115)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:314)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:238)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:212)
    at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
    at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createEntityManager(ReloadableEntityManagerFactory.java:160)
    at org.apache.openejb.persistence.JtaEntityManagerRegistry.getEntityManager(JtaEntityManagerRegistry.java:117)
    at org.apache.openejb.persistence.JtaEntityManager.getEntityManager(JtaEntityManager.java:95)
    at org.apache.openejb.persistence.JtaEntityManager.typedProxyIfNoTx(JtaEntityManager.java:330)
    at org.apache.openejb.persistence.JtaEntityManager.createNamedQuery(JtaEntityManager.java:378)
    at eu.superhub.wp4.pfws.policymaking.dao.LanguageDAO.getAllLanguages(LanguageDAO.java:19)
    at eu.superhub.wp4.pfws.policymaking.bo.LanguageBO.removeAllLanguages(LanguageBO.java:122)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:190)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:172)
    at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:180)
    at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:99)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:190)
    at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:172)
    at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:84)
    at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:232)
    at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:197)
    at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:307)
    at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:302)
    at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:91)
    at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:307)
    at eu.superhub.wp4.pfws.policymaking.bo.LanguageBO$$LocalBeanProxy.removeAllLanguages(eu/superhub/wp4/pfws/policymaking/bo/LanguageBO.java)
    at eu.superhub.wp4.pfws.policymaking.bo.LanguageTest.readAllOK(LanguageTest.java:82)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
    at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
    at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.066 sec <<< FAILURE!

Results :

Tests in error: 
  readAllOK(eu.superhub.wp4.pfws.policymaking.bo.LanguageTest): The bean encountered a non-application exception; nested exception is: 

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.563s
[INFO] Finished at: Fri Mar 07 13:43:15 CET 2014
[INFO] Final Memory: 20M/182M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project policymodel.SIP.JPA: There are test failures.
[ERROR] 
[ERROR] Please refer to C:\SuperHUB\coderepo\wp4\policymodel.SIP.JPA2\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

What am I missing to making it run with Maven?

Thank you in advance!

Was it helpful?

Solution

Start out by disabling openjpa.RuntimUnenhancedClasses and then enhance your Entities with one of the recommended approaches.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top