OutOfMemory doing a JUnit using OpenEJB Embedded

View: New views
13 Messages — Rating Filter:   Alert me  

OutOfMemory doing a JUnit using OpenEJB Embedded

by PatLaPatate :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Here's the context : I get the following error when trying to run a JUnit test:
java.lang.OutOfMemoryError: Java heap space

Here is the context of my problem:
Under RAD 7.5
Using Hibernate, JUnit, JPA, openEJB

JUnit code:
public class CGEServiceTest extends TestCase {

        private InitialContext initialContext;
       
        public void setUp() throws Exception {
       Properties properties = new Properties();
       properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
       properties.put("db2x070", "new://Resource?type=DataSource");
       properties.put("db2x070.JdbcDriver", "com.ibm.db2.jcc.DB2Driver");
       properties.put("db2x070.JdbcUrl", "jdbc:db2://db2d070n0:50127/db2d070");
       properties.put("db2x070.UserName", "xxxxx");
       properties.put("db2x070.Password", "xxxxxx");      
       initialContext = new InitialContext(properties);

        }
        public void testAjouterApplication() throws Exception {
               
                Object object = initialContext.lookup("ejb/CGEService");
                CGEService service = (CGEService) object;
                try {
                        Application a = new Application();
                        a.setName("fat/ECS");
                        service.ajouterApplication(a);
                       
                } catch (CGEPersistenceException e) {
                        fail();
                }
        }
}


/////////////////////////////////////////////////////////////////////////////////////////////

My service class :

package com.desj.visa.srv.cge;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.PersistenceUnit;

import com.desj.visa.srv.cge.beans.Application;

@Stateless (name="ejb/CGEService")
public class CGEServiceImpl implements CGEService {

        @PersistenceUnit
        private EntityManagerFactory emf;
       
        public void setEmf(EntityManagerFactory emf) {
                this.emf = emf;
        }

        public void ajouterApplication(Application application) throws CGEPersistenceException {

            // Start EntityManagerFactory

            // First unit of work
            EntityManager em = emf.createEntityManager();
            EntityTransaction tx = em.getTransaction();
            tx.begin();

            em.persist(application);

            tx.commit();
            em.close();

            // Shutting down the application
            emf.close();
          }
}

///////////////////////////////////////////////////////////////////////////

My Bean :

import javax.persistence.*;

@Entity
@Table (name = "TAPPLICATION", schema="GCE")

public class Application {

        @Id @GeneratedValue
        @Column(name = "IDAPPLICATION")
        private long id;

        @Column(name = "NOMAPPLICATION")
        private String name;
       
        public Application() {
                super();
        }
       
        public Application(long id, String name) {
                super();
                this.name = name;
        }
       
        public long getId() {
                return id;
        }
        public void setId(long id) {
                this.id = id;
        }
        public String getName() {
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
}

And the result is:


Apache OpenEJB 3.1.2    build: 20091010-03:11
http://openejb.apache.org/
INFO - openejb.home = F:\Workspaces\wks_jsf\CGESrvTest
INFO - openejb.base = F:\Workspaces\wks_jsf\CGESrvTest
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=db2x070, type=Resource, provider-id=Default JDBC Database)
INFO - Found EjbModule in classpath: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
INFO - Found EjbModule in classpath: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
INFO - Beginning load: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
INFO - Beginning load: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
INFO - Configuring enterprise application: classpath.ear
FATAL - OpenEJB has encountered a fatal error and cannot be started: The Assembler encountered an unexpected error while attempting to build the container system.
java.lang.OutOfMemoryError: Java heap space
        at org.apache.xbean.asm.ClassReader.a(Unknown Source)
        at org.apache.xbean.asm.ClassReader.<init>(Unknown Source)
        at org.apache.xbean.finder.ClassFinder.readClassDef(ClassFinder.java:728)
        at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:141)
        at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:113)
        at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:422)
        at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:253)
        at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:188)
        at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:247)
        at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:601)
        at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:551)
        at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:380)
        at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:299)
        at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:278)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
        at org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:27)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)


Does anyone have a clue?

Thanks

Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by Jean-Louis MONTEIRO :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

it seems to me you are using WAS 7 API/JARS.
Some of them are very big (com.ibm.ws.runtime.jar more or less 40Mo).

To prevent OutOfMemory Exception, you should either increase the heap size (-Xmx system property) or activate OpenEJB filters (to exclude WAS jars).

I guess the second option is better for you.
Have a look here http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html.

Hope it helps.
Jean-Louis


PatLaPatate wrote:
Hi,

Here's the context : I get the following error when trying to run a JUnit test:
java.lang.OutOfMemoryError: Java heap space

Here is the context of my problem:
Under RAD 7.5
Using Hibernate, JUnit, JPA, openEJB

JUnit code:
public class CGEServiceTest extends TestCase {

        private InitialContext initialContext;
       
        public void setUp() throws Exception {
       Properties properties = new Properties();
       properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
       properties.put("db2x070", "new://Resource?type=DataSource");
       properties.put("db2x070.JdbcDriver", "com.ibm.db2.jcc.DB2Driver");
       properties.put("db2x070.JdbcUrl", "jdbc:db2://db2d070n0:50127/db2d070");
       properties.put("db2x070.UserName", "xxxxx");
       properties.put("db2x070.Password", "xxxxxx");      
       initialContext = new InitialContext(properties);

        }
        public void testAjouterApplication() throws Exception {
               
                Object object = initialContext.lookup("ejb/CGEService");
                CGEService service = (CGEService) object;
                try {
                        Application a = new Application();
                        a.setName("fat/ECS");
                        service.ajouterApplication(a);
                       
                } catch (CGEPersistenceException e) {
                        fail();
                }
        }
}


/////////////////////////////////////////////////////////////////////////////////////////////

My service class :

package com.desj.visa.srv.cge;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.PersistenceUnit;

import com.desj.visa.srv.cge.beans.Application;

@Stateless (name="ejb/CGEService")
public class CGEServiceImpl implements CGEService {

        @PersistenceUnit
        private EntityManagerFactory emf;
       
        public void setEmf(EntityManagerFactory emf) {
                this.emf = emf;
        }

        public void ajouterApplication(Application application) throws CGEPersistenceException {

            // Start EntityManagerFactory

            // First unit of work
            EntityManager em = emf.createEntityManager();
            EntityTransaction tx = em.getTransaction();
            tx.begin();

            em.persist(application);

            tx.commit();
            em.close();

            // Shutting down the application
            emf.close();
          }
}

///////////////////////////////////////////////////////////////////////////

My Bean :

import javax.persistence.*;

@Entity
@Table (name = "TAPPLICATION", schema="GCE")

public class Application {

        @Id @GeneratedValue
        @Column(name = "IDAPPLICATION")
        private long id;

        @Column(name = "NOMAPPLICATION")
        private String name;
       
        public Application() {
                super();
        }
       
        public Application(long id, String name) {
                super();
                this.name = name;
        }
       
        public long getId() {
                return id;
        }
        public void setId(long id) {
                this.id = id;
        }
        public String getName() {
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
}

And the result is:


Apache OpenEJB 3.1.2    build: 20091010-03:11
http://openejb.apache.org/
INFO - openejb.home = F:\Workspaces\wks_jsf\CGESrvTest
INFO - openejb.base = F:\Workspaces\wks_jsf\CGESrvTest
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=db2x070, type=Resource, provider-id=Default JDBC Database)
INFO - Found EjbModule in classpath: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
INFO - Found EjbModule in classpath: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
INFO - Beginning load: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
INFO - Beginning load: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
INFO - Configuring enterprise application: classpath.ear
FATAL - OpenEJB has encountered a fatal error and cannot be started: The Assembler encountered an unexpected error while attempting to build the container system.
java.lang.OutOfMemoryError: Java heap space
        at org.apache.xbean.asm.ClassReader.a(Unknown Source)
        at org.apache.xbean.asm.ClassReader.<init>(Unknown Source)
        at org.apache.xbean.finder.ClassFinder.readClassDef(ClassFinder.java:728)
        at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:141)
        at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:113)
        at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:422)
        at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:253)
        at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:188)
        at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:247)
        at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:601)
        at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:551)
        at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:380)
        at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:299)
        at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:278)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
        at org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:27)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)


Does anyone have a clue?

Thanks

Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by PatLaPatate :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jean-Pierre,

Makes a lot of sense. Somehow the presence of these files seemed strange.

I will try that and keep you posted.

Patrick


Hi,

it seems to me you are using WAS 7 API/JARS.
Some of them are very big (com.ibm.ws.runtime.jar more or less 40Mo).

To prevent OutOfMemory Exception, you should either increase the heap size (-Xmx system property) or activate OpenEJB filters (to exclude WAS jars).

I guess the second option is better for you.
Have a look here http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html.

Hope it helps.
Jean-Louis


PatLaPatate wrote:
Hi,

Here's the context : I get the following error when trying to run a JUnit test:
java.lang.OutOfMemoryError: Java heap space

Here is the context of my problem:
Under RAD 7.5
Using Hibernate, JUnit, JPA, openEJB

JUnit code:
public class CGEServiceTest extends TestCase {

        private InitialContext initialContext;
       
        public void setUp() throws Exception {
       Properties properties = new Properties();
       properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
       properties.put("db2x070", "new://Resource?type=DataSource");
       properties.put("db2x070.JdbcDriver", "com.ibm.db2.jcc.DB2Driver");
       properties.put("db2x070.JdbcUrl", "jdbc:db2://db2d070n0:50127/db2d070");
       properties.put("db2x070.UserName", "xxxxx");
       properties.put("db2x070.Password", "xxxxxx");      
       initialContext = new InitialContext(properties);

        }
        public void testAjouterApplication() throws Exception {
               
                Object object = initialContext.lookup("ejb/CGEService");
                CGEService service = (CGEService) object;
                try {
                        Application a = new Application();
                        a.setName("fat/ECS");
                        service.ajouterApplication(a);
                       
                } catch (CGEPersistenceException e) {
                        fail();
                }
        }
}


/////////////////////////////////////////////////////////////////////////////////////////////

My service class :

package com.desj.visa.srv.cge;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.PersistenceUnit;

import com.desj.visa.srv.cge.beans.Application;

@Stateless (name="ejb/CGEService")
public class CGEServiceImpl implements CGEService {

        @PersistenceUnit
        private EntityManagerFactory emf;
       
        public void setEmf(EntityManagerFactory emf) {
                this.emf = emf;
        }

        public void ajouterApplication(Application application) throws CGEPersistenceException {

            // Start EntityManagerFactory

            // First unit of work
            EntityManager em = emf.createEntityManager();
            EntityTransaction tx = em.getTransaction();
            tx.begin();

            em.persist(application);

            tx.commit();
            em.close();

            // Shutting down the application
            emf.close();
          }
}

///////////////////////////////////////////////////////////////////////////

My Bean :

import javax.persistence.*;

@Entity
@Table (name = "TAPPLICATION", schema="GCE")

public class Application {

        @Id @GeneratedValue
        @Column(name = "IDAPPLICATION")
        private long id;

        @Column(name = "NOMAPPLICATION")
        private String name;
       
        public Application() {
                super();
        }
       
        public Application(long id, String name) {
                super();
                this.name = name;
        }
       
        public long getId() {
                return id;
        }
        public void setId(long id) {
                this.id = id;
        }
        public String getName() {
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
}

And the result is:


Apache OpenEJB 3.1.2    build: 20091010-03:11
http://openejb.apache.org/
INFO - openejb.home = F:\Workspaces\wks_jsf\CGESrvTest
INFO - openejb.base = F:\Workspaces\wks_jsf\CGESrvTest
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=db2x070, type=Resource, provider-id=Default JDBC Database)
INFO - Found EjbModule in classpath: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
INFO - Found EjbModule in classpath: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
INFO - Beginning load: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
INFO - Beginning load: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
INFO - Configuring enterprise application: classpath.ear
FATAL - OpenEJB has encountered a fatal error and cannot be started: The Assembler encountered an unexpected error while attempting to build the container system.
java.lang.OutOfMemoryError: Java heap space
        at org.apache.xbean.asm.ClassReader.a(Unknown Source)
        at org.apache.xbean.asm.ClassReader.<init>(Unknown Source)
        at org.apache.xbean.finder.ClassFinder.readClassDef(ClassFinder.java:728)
        at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:141)
        at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:113)
        at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:422)
        at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:253)
        at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:188)
        at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:247)
        at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:601)
        at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:551)
        at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:380)
        at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:299)
        at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:278)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
        at org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:27)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)


Does anyone have a clue?

Thanks


Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by David Blevins :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Good catch!  I totally missed that myself.  We should add these to our  
built-in list of excludes.

Looks like for this one you'll need to set the  
'openejb.deployments.classpath.filter.descriptors' to 'true' to get  
these jars out.

-David

On Nov 10, 2009, at 12:09 PM, Jean-Louis MONTEIRO wrote:

>
> Hi,
>
> it seems to me you are using WAS 7 API/JARS.
> Some of them are very big (com.ibm.ws.runtime.jar more or less 40Mo).
>
> To prevent OutOfMemory Exception, you should either increase the  
> heap size
> (-Xmx system property) or activate OpenEJB filters (to exclude WAS  
> jars).
>
> I guess the second option is better for you.
> Have a look here
> http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html
> http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html 
>  .
>
> Hope it helps.
> Jean-Louis
>
>
>
> PatLaPatate wrote:
>>
>> Hi,
>>
>> Here's the context : I get the following error when trying to run a  
>> JUnit
>> test:
>> java.lang.OutOfMemoryError: Java heap space
>>
>> Here is the context of my problem:
>> Under RAD 7.5
>> Using Hibernate, JUnit, JPA, openEJB
>>
>> JUnit code:
>> public class CGEServiceTest extends TestCase {
>>
>> private InitialContext initialContext;
>>
>> public void setUp() throws Exception {
>>       Properties properties = new Properties();
>>       properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>> "org.apache.openejb.client.LocalInitialContextFactory");
>>       properties.put("db2x070", "new://Resource?type=DataSource");
>>       properties.put("db2x070.JdbcDriver",  
>> "com.ibm.db2.jcc.DB2Driver");
>>       properties.put("db2x070.JdbcUrl",
>> "jdbc:db2://db2d070n0:50127/db2d070");
>>       properties.put("db2x070.UserName", "xxxxx");
>>       properties.put("db2x070.Password", "xxxxxx");
>>       initialContext = new InitialContext(properties);
>>
>> }
>> public void testAjouterApplication() throws Exception {
>>
>> Object object = initialContext.lookup("ejb/CGEService");
>> CGEService service = (CGEService) object;
>> try {
>> Application a = new Application();
>> a.setName("fat/ECS");
>> service.ajouterApplication(a);
>>
>> } catch (CGEPersistenceException e) {
>> fail();
>> }
>> }
>> }
>>
>>
>> /////////////////////////////////////////////////////////////////////////////////////////////
>>
>> My service class :
>>
>> package com.desj.visa.srv.cge;
>> import javax.ejb.Stateless;
>> import javax.persistence.EntityManager;
>> import javax.persistence.EntityManagerFactory;
>> import javax.persistence.EntityTransaction;
>> import javax.persistence.Persistence;
>> import javax.persistence.PersistenceUnit;
>>
>> import com.desj.visa.srv.cge.beans.Application;
>>
>> @Stateless (name="ejb/CGEService")
>> public class CGEServiceImpl implements CGEService {
>>
>> @PersistenceUnit
>> private EntityManagerFactory emf;
>>
>> public void setEmf(EntityManagerFactory emf) {
>> this.emf = emf;
>> }
>>
>> public void ajouterApplication(Application application) throws
>> CGEPersistenceException {
>>
>>    // Start EntityManagerFactory
>>
>>    // First unit of work
>>    EntityManager em = emf.createEntityManager();
>>    EntityTransaction tx = em.getTransaction();
>>    tx.begin();
>>
>>    em.persist(application);
>>
>>    tx.commit();
>>    em.close();
>>
>>    // Shutting down the application
>>    emf.close();
>>  }
>> }
>>
>> ///////////////////////////////////////////////////////////////////////////
>>
>> My Bean :
>>
>> import javax.persistence.*;
>>
>> @Entity
>> @Table (name = "TAPPLICATION", schema="GCE")
>>
>> public class Application {
>>
>> @Id @GeneratedValue
>> @Column(name = "IDAPPLICATION")
>> private long id;
>>
>> @Column(name = "NOMAPPLICATION")
>> private String name;
>>
>> public Application() {
>> super();
>> }
>>
>> public Application(long id, String name) {
>> super();
>> this.name = name;
>> }
>>
>> public long getId() {
>> return id;
>> }
>> public void setId(long id) {
>> this.id = id;
>> }
>> public String getName() {
>> return name;
>> }
>> public void setName(String name) {
>> this.name = name;
>> }
>> }
>>
>> And the result is:
>>
>>
>> Apache OpenEJB 3.1.2    build: 20091010-03:11
>> http://openejb.apache.org/
>> INFO - openejb.home = F:\Workspaces\wks_jsf\CGESrvTest
>> INFO - openejb.base = F:\Workspaces\wks_jsf\CGESrvTest
>> INFO - Configuring Service(id=Default Security Service,
>> type=SecurityService, provider-id=Default Security Service)
>> INFO - Configuring Service(id=Default Transaction Manager,
>> type=TransactionManager, provider-id=Default Transaction Manager)
>> INFO - Configuring Service(id=db2x070, type=Resource, provider-
>> id=Default
>> JDBC Database)
>> INFO - Found EjbModule in classpath: C:\Program
>> Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
>> INFO - Found EjbModule in classpath: C:\Program
>> Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
>> INFO - Beginning load: C:\Program
>> Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
>> INFO - Beginning load: C:\Program
>> Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
>> INFO - Configuring enterprise application: classpath.ear
>> FATAL - OpenEJB has encountered a fatal error and cannot be  
>> started: The
>> Assembler encountered an unexpected error while attempting to build  
>> the
>> container system.
>> java.lang.OutOfMemoryError: Java heap space
>> at org.apache.xbean.asm.ClassReader.a(Unknown Source)
>> at org.apache.xbean.asm.ClassReader.<init>(Unknown Source)
>> at  
>> org.apache.xbean.finder.ClassFinder.readClassDef(ClassFinder.java:
>> 728)
>> at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:141)
>> at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:113)
>> at
>> org.apache.openejb.config.AnnotationDeployer
>> $DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:422)
>> at
>> org.apache.openejb.config.AnnotationDeployer
>> $DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:253)
>> at
>> org
>> .apache
>> .openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:
>> 188)
>> at
>> org.apache.openejb.config.ConfigurationFactory
>> $Chain.deploy(ConfigurationFactory.java:247)
>> at
>> org
>> .apache
>> .openejb
>> .config
>> .ConfigurationFactory
>> .configureApplication(ConfigurationFactory.java:601)
>> at
>> org
>> .apache
>> .openejb
>> .config
>> .ConfigurationFactory
>> .configureApplication(ConfigurationFactory.java:551)
>> at
>> org
>> .apache
>> .openejb
>> .config
>> .ConfigurationFactory
>> .getOpenEjbConfiguration(ConfigurationFactory.java:380)
>> at
>> org
>> .apache
>> .openejb
>> .assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:
>> 299)
>> at
>> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:
>> 278)
>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> at java.lang.reflect.Method.invoke(Unknown Source)
>> at
>> org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:
>> 36)
>> at
>> org
>> .apache
>> .openejb
>> .client
>> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
>> at
>> org
>> .apache
>> .openejb
>> .client
>> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
>> at
>> org
>> .apache
>> .openejb
>> .client
>> .LocalInitialContextFactory
>> .getInitialContext(LocalInitialContextFactory.java:42)
>> at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
>> at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
>> at javax.naming.InitialContext.init(Unknown Source)
>> at javax.naming.InitialContext.<init>(Unknown Source)
>> at
>> com
>> .desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:27)
>> at junit.framework.TestCase.runBare(TestCase.java:125)
>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>
>>
>> Does anyone have a clue?
>>
>> Thanks
>>
>>
>
> --
> View this message in context: http://old.nabble.com/OutOfMemory-doing-a-JUnit-using-OpenEJB-Embedded-tp26289066p26289080.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by PatLaPatate :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi JL and David,

I was able to go forward. However, when I tried changing my persistence provider to hibernate :
<provider>org.hibernate.ejb.HibernatePersistence</provider>

I get the following error:
org.apache.openejb.OpenEJBException: Creating application failed: classpath.ear: javax/persistence/spi/ProviderUtil

I was wondering : Where can I find that class? I assumed it should be under JPA 2.0... but it is not...

Is openEJB looking for some class provided in the latter version of JPA?

ERROR - Application could not be deployed:  classpath.ear
org.apache.openejb.OpenEJBException: Creating application failed: classpath.ear: javax/persistence/spi/ProviderUtil
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:666)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:449)
        at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:367)
        at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:279)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
        at org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:34)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.NoClassDefFoundError: javax/persistence/spi/ProviderUtil
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
        at java.lang.Class.getConstructor0(Unknown Source)
        at java.lang.Class.newInstance0(Unknown Source)
        at java.lang.Class.newInstance(Unknown Source)
        at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:179)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:489)
        ... 32 more
Caused by: java.lang.ClassNotFoundException: javax.persistence.spi.ProviderUtil
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        ... 39 more


Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by David Blevins :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The JPA API version that we bundle is JPA 1.0.  Those classes are in  
the javaee-api.jar.  It is possible to delete that jar and then use  
the individual libraries instead.  There's a zip of them here:

    http://www.apache.org/dist/openejb/3.1.2/javaee-api-libs-3.1.2-src.zip

Then you can replace the jpa api jar with a JPA 2.0 version.  I don't  
know if it will *work* as if there are new methods in the  
EntityManager interface, then likely there'll be vm errors complaining  
that we don't implement them.  There are parts of JPA that the EJB  
container has to implement to support any @PersistenceContext injection.

So not sure if it will work, but it should be pretty quick to find  
out :)

Note, if it doesn't work, we might be able to find some sneaky way to  
support it in the next release.  Any help is certainly welcome.

-David


On Nov 12, 2009, at 1:23 PM, PatLaPatate wrote:

>
> Hi JL and David,
>
> I was able to go forward. However, when I tried changing my  
> persistence
> provider to hibernate :
> <provider>org.hibernate.ejb.HibernatePersistence</provider>
>
> I get the following error:
> org.apache.openejb.OpenEJBException: Creating application failed:
> classpath.ear: javax/persistence/spi/ProviderUtil
>
> I was wondering : Where can I find that class? I assumed it should  
> be under
> JPA 2.0... but it is not...
>
> Is openEJB looking for some class provided in the latter version of  
> JPA?
>
> ERROR - Application could not be deployed:  classpath.ear
> org.apache.openejb.OpenEJBException: Creating application failed:
> classpath.ear: javax/persistence/spi/ProviderUtil
> at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.createApplication(Assembler.java:666)
> at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.createApplication(Assembler.java:449)
> at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.buildContainerSystem(Assembler.java:367)
> at  
> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:
> 279)
> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
> at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
> at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at  
> org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:
> 36)
> at
> org
> .apache
> .openejb
> .client
> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
> at
> org
> .apache
> .openejb
> .client
> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
> at
> org
> .apache
> .openejb
> .client
> .LocalInitialContextFactory
> .getInitialContext(LocalInitialContextFactory.java:42)
> at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
> at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
> at javax.naming.InitialContext.init(Unknown Source)
> at javax.naming.InitialContext.<init>(Unknown Source)
> at  
> com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:
> 34)
> at junit.framework.TestCase.runBare(TestCase.java:125)
> at junit.framework.TestResult$1.protect(TestResult.java:106)
> at junit.framework.TestResult.runProtected(TestResult.java:124)
> at junit.framework.TestResult.run(TestResult.java:109)
> at junit.framework.TestCase.run(TestCase.java:118)
> at junit.framework.TestSuite.runTest(TestSuite.java:208)
> at junit.framework.TestSuite.run(TestSuite.java:203)
> at
> org
> .eclipse
> .jdt
> .internal
> .junit
> .runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
> at
> org
> .eclipse
> .jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at
> org
> .eclipse
> .jdt
> .internal
> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> at
> org
> .eclipse
> .jdt
> .internal
> .junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> at
> org
> .eclipse
> .jdt
> .internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> at
> org
> .eclipse
> .jdt
> .internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
> 196)
> Caused by: java.lang.NoClassDefFoundError:
> javax/persistence/spi/ProviderUtil
> at java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
> at java.lang.Class.getConstructor0(Unknown Source)
> at java.lang.Class.newInstance0(Unknown Source)
> at java.lang.Class.newInstance(Unknown Source)
> at
> org
> .apache
> .openejb
> .assembler
> .classic
> .PersistenceBuilder
> .createEntityManagerFactory(PersistenceBuilder.java:179)
> at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.createApplication(Assembler.java:489)
> ... 32 more
> Caused by: java.lang.ClassNotFoundException:
> javax.persistence.spi.ProviderUtil
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> ... 39 more
>
>
> --
> View this message in context: http://old.nabble.com/OutOfMemory-doing-a-JUnit-using-OpenEJB-Embedded-tp26289066p26326678.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by Quintin Beukes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Are you trying to use a different mode or version of Hibernate than
the standard or something? Unless I missed something which is causing
this, you should be able to run standard hibernate by adding the
following to your persistence.xml and then using the standard
hibernate-core/annotations/entitymanager and openejb libs to your
classpath.

    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
      <property name="hibernate.transaction.manager_lookup_class"
value="org.apache.openejb.hibernate.TransactionManagerLookup"/>
    </properties>

I've never seen the error you mentioned, and I'm getting all these
deps from official maven repositories for each, so I know I'm not
throwing anything non-standard in there.

Quintin Beukes



On Fri, Nov 13, 2009 at 1:35 AM, David Blevins <david.blevins@...> wrote:

> The JPA API version that we bundle is JPA 1.0.  Those classes are in the
> javaee-api.jar.  It is possible to delete that jar and then use the
> individual libraries instead.  There's a zip of them here:
>
>   http://www.apache.org/dist/openejb/3.1.2/javaee-api-libs-3.1.2-src.zip
>
> Then you can replace the jpa api jar with a JPA 2.0 version.  I don't know
> if it will *work* as if there are new methods in the EntityManager
> interface, then likely there'll be vm errors complaining that we don't
> implement them.  There are parts of JPA that the EJB container has to
> implement to support any @PersistenceContext injection.
>
> So not sure if it will work, but it should be pretty quick to find out :)
>
> Note, if it doesn't work, we might be able to find some sneaky way to
> support it in the next release.  Any help is certainly welcome.
>
> -David
>
>
> On Nov 12, 2009, at 1:23 PM, PatLaPatate wrote:
>
>>
>> Hi JL and David,
>>
>> I was able to go forward. However, when I tried changing my persistence
>> provider to hibernate :
>> <provider>org.hibernate.ejb.HibernatePersistence</provider>
>>
>> I get the following error:
>> org.apache.openejb.OpenEJBException: Creating application failed:
>> classpath.ear: javax/persistence/spi/ProviderUtil
>>
>> I was wondering : Where can I find that class? I assumed it should be
>> under
>> JPA 2.0... but it is not...
>>
>> Is openEJB looking for some class provided in the latter version of JPA?
>>
>> ERROR - Application could not be deployed:  classpath.ear
>> org.apache.openejb.OpenEJBException: Creating application failed:
>> classpath.ear: javax/persistence/spi/ProviderUtil
>>        at
>>
>> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:666)
>>        at
>>
>> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:449)
>>        at
>>
>> org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:367)
>>        at
>> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:279)
>>        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
>>        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
>>        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>        at java.lang.reflect.Method.invoke(Unknown Source)
>>        at
>> org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>>        at
>>
>> org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
>>        at
>>
>> org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
>>        at
>>
>> org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
>>        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
>>        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
>>        at javax.naming.InitialContext.init(Unknown Source)
>>        at javax.naming.InitialContext.<init>(Unknown Source)
>>        at
>> com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:34)
>>        at junit.framework.TestCase.runBare(TestCase.java:125)
>>        at junit.framework.TestResult$1.protect(TestResult.java:106)
>>        at junit.framework.TestResult.runProtected(TestResult.java:124)
>>        at junit.framework.TestResult.run(TestResult.java:109)
>>        at junit.framework.TestCase.run(TestCase.java:118)
>>        at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>        at junit.framework.TestSuite.run(TestSuite.java:203)
>>        at
>>
>> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
>>        at
>>
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>        at
>>
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>>        at
>>
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>>        at
>>
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>>        at
>>
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>> Caused by: java.lang.NoClassDefFoundError:
>> javax/persistence/spi/ProviderUtil
>>        at java.lang.Class.getDeclaredConstructors0(Native Method)
>>        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
>>        at java.lang.Class.getConstructor0(Unknown Source)
>>        at java.lang.Class.newInstance0(Unknown Source)
>>        at java.lang.Class.newInstance(Unknown Source)
>>        at
>>
>> org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:179)
>>        at
>>
>> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:489)
>>        ... 32 more
>> Caused by: java.lang.ClassNotFoundException:
>> javax.persistence.spi.ProviderUtil
>>        at java.net.URLClassLoader$1.run(Unknown Source)
>>        at java.security.AccessController.doPrivileged(Native Method)
>>        at java.net.URLClassLoader.findClass(Unknown Source)
>>        at java.lang.ClassLoader.loadClass(Unknown Source)
>>        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>>        at java.lang.ClassLoader.loadClass(Unknown Source)
>>        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>>        ... 39 more
>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/OutOfMemory-doing-a-JUnit-using-OpenEJB-Embedded-tp26289066p26326678.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>
>

Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by PatLaPatate :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Quintin,

I ran into this problem once I changed my configuration to run openEJB over JPA2.

David had warned me about this. Seems like some code is missing somewhere due to the change
of specs in JPA2.

INFO - Using 'openejb.deployments.classpath.include=com.desj.visa.*'
INFO - Using 'openejb.deployments.classpath.exclude=.*/com\.ibm\.ws\.[^/]*.jar(!/)?'
INFO - Using 'openejb.deployments.classpath.filter.descriptors=true'
WARN - Inspecting classpath for applications: 51 urls.
WARN - ADJUST THE EXCLUDE/INCLUDE!!!.  Current settings: openejb.deployments.classpath.exclude='.*/com\.ibm\.ws\.[^/]*.jar(!/)?', openejb.deployments.classpath.include='com.desj.visa.*'
INFO - Found ClientModule in classpath: F:\Workspaces\wks_jsf\CGESrvTest\lib\javassist-3.9.0.GA.jar
INFO - Found ClientModule in classpath: F:\Workspaces\wks_jsf\CGESrvTest\lib\openjpa-2.0.0-SNAPSHOT.jar
INFO - Found ClientModule in classpath: F:\Workspaces\wks_jsf\CGESrvTest\lib\xml-resolver-1.2.jar
INFO - Found EjbModule in classpath: F:\Workspaces\wks_jsf\CGEEJB\ejbModule
INFO - Found ClientModule in classpath: F:\Workspaces\wks_jsf\CGESrvTest\lib\serializer-2.7.1.jar
WARN - Searched 51 classpath urls in 9656 milliseconds.  Average 189 milliseconds per url.
WARN - Consider adjusting your openejb.deployments.classpath.exclude and openejb.deployments.classpath.include settings.  Current settings: exclude='.*/com\.ibm\.ws\.[^/]*.jar(!/)?', include='com.desj.visa.*'
INFO - Beginning load: F:\Workspaces\wks_jsf\CGESrvTest\lib\javassist-3.9.0.GA.jar
INFO - Beginning load: F:\Workspaces\wks_jsf\CGESrvTest\lib\openjpa-2.0.0-SNAPSHOT.jar
INFO - Beginning load: F:\Workspaces\wks_jsf\CGESrvTest\lib\xml-resolver-1.2.jar
INFO - Beginning load: F:\Workspaces\wks_jsf\CGEEJB\ejbModule
INFO - Beginning load: F:\Workspaces\wks_jsf\CGESrvTest\lib\serializer-2.7.1.jar
INFO - Configuring enterprise application: classpath.ear
INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean CGEServiceImpl: Container(type=STATELESS, id=Default Stateless Container)
INFO - Configuring PersistenceUnit(name=cge, provider=org.hibernate.ejb.HibernatePersistence)
INFO - Auto-creating a Resource with id 'db2x070NonJta' of type 'DataSource for 'cge'.
INFO - Configuring Service(id=db2x070NonJta, type=Resource, provider-id=db2x070)
INFO - Adjusting PersistenceUnit cge <jta-data-source> to Resource ID 'db2x070' from 'null'
INFO - Adjusting PersistenceUnit cge <non-jta-data-source> to Resource ID 'db2x070NonJta' from 'null'
INFO - Using 'openejb.validation.output.level=VERBOSE'
INFO - Enterprise application "classpath.ear" loaded.
INFO - Assembling app: classpath.ear
INFO - PersistenceUnit(name=cge, provider=org.hibernate.ejb.HibernatePersistence)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/F:/Workspaces/wks_jsf/CGESrvTest/lib/slf4j-jdk14-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/F:/Workspaces/wks_jsf/CGESrvTest/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.5.0.Beta1
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.5.0-Beta-2
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : javassist
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
13-Nov-2009 3:46:54 PM org.hibernate.annotations.common.Version <clinit>
INFO: Hibernate Commons Annotations 3.2.0-SNAPSHOT
13-Nov-2009 3:46:54 PM org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.5.0.Beta1
13-Nov-2009 3:46:54 PM org.hibernate.ejb.Ejb3Configuration configure
INFO: Processing PersistenceUnitInfo [
        name: cge
        ...]
URL: file:/F:/Workspaces/wks_jsf/CGEEJB/ejbModule/
  META-INF/orm.xml
  **/*.hbm.xml

13-Nov-2009 3:46:54 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: com/desj/visa/srv/cge/orm/config/hibernate.cfg.xml
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: com/desj/visa/srv/cge/orm/config/hibernate.cfg.xml
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.desj.visa.srv.cge.beans.Application
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.desj.visa.srv.cge.beans.Application on table TAPPLICATION
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.desj.visa.srv.cge.beans.Environnement
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.desj.visa.srv.cge.beans.Environnement on table TENVIRONNEMENT
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.desj.visa.srv.cge.beans.Parametre
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.desj.visa.srv.cge.beans.Parametre on table TPARAMETRE
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.desj.visa.srv.cge.beans.Projet
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.desj.visa.srv.cge.beans.Projet on table TPROJET
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationConfiguration applyHibernateValidatorLegacyConstraintsOnDDL
INFO: Hibernate Validator not found: ignoring
INFO - Undeploying app: classpath.ear
ERROR - Application could not be deployed:  classpath.ear
org.apache.openejb.OpenEJBException: Creating application failed: classpath.ear: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:666)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:449)
        at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:367)
        at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:279)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
        at org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:34)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:170)
        at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:76)
        at org.hibernate.cfg.AnnotationConfiguration.applyBeanValidationConstraintsOnDDL(AnnotationConfiguration.java:438)
        at org.hibernate.cfg.AnnotationConfiguration.applyConstraintsToDDL(AnnotationConfiguration.java:390)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:376)
        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1188)
        at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1291)
        at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:195)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:919)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:523)
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:157)
        at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:184)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:489)
        ... 32 more

Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by Quintin Beukes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I see. JPA2 is becoming quite the popular topic.

Quintin Beukes



On Mon, Nov 16, 2009 at 3:24 PM, PatLaPatate
<patrick.blais@...> wrote:

>
> Hi Quintin,
>
> I ran into this problem once I changed my configuration to run openEJB over
> JPA2.
>
> David had warned me about this. Seems like some code is missing somewhere
> due to the change
> of specs in JPA2.
>
> INFO - Using 'openejb.deployments.classpath.include=com.desj.visa.*'
> INFO - Using
> 'openejb.deployments.classpath.exclude=.*/com\.ibm\.ws\.[^/]*.jar(!/)?'
> INFO - Using 'openejb.deployments.classpath.filter.descriptors=true'
> WARN - Inspecting classpath for applications: 51 urls.
> WARN - ADJUST THE EXCLUDE/INCLUDE!!!.  Current settings:
> openejb.deployments.classpath.exclude='.*/com\.ibm\.ws\.[^/]*.jar(!/)?',
> openejb.deployments.classpath.include='com.desj.visa.*'
> INFO - Found ClientModule in classpath:
> F:\Workspaces\wks_jsf\CGESrvTest\lib\javassist-3.9.0.GA.jar
> INFO - Found ClientModule in classpath:
> F:\Workspaces\wks_jsf\CGESrvTest\lib\openjpa-2.0.0-SNAPSHOT.jar
> INFO - Found ClientModule in classpath:
> F:\Workspaces\wks_jsf\CGESrvTest\lib\xml-resolver-1.2.jar
> INFO - Found EjbModule in classpath: F:\Workspaces\wks_jsf\CGEEJB\ejbModule
> INFO - Found ClientModule in classpath:
> F:\Workspaces\wks_jsf\CGESrvTest\lib\serializer-2.7.1.jar
> WARN - Searched 51 classpath urls in 9656 milliseconds.  Average 189
> milliseconds per url.
> WARN - Consider adjusting your openejb.deployments.classpath.exclude and
> openejb.deployments.classpath.include settings.  Current settings:
> exclude='.*/com\.ibm\.ws\.[^/]*.jar(!/)?', include='com.desj.visa.*'
> INFO - Beginning load:
> F:\Workspaces\wks_jsf\CGESrvTest\lib\javassist-3.9.0.GA.jar
> INFO - Beginning load:
> F:\Workspaces\wks_jsf\CGESrvTest\lib\openjpa-2.0.0-SNAPSHOT.jar
> INFO - Beginning load:
> F:\Workspaces\wks_jsf\CGESrvTest\lib\xml-resolver-1.2.jar
> INFO - Beginning load: F:\Workspaces\wks_jsf\CGEEJB\ejbModule
> INFO - Beginning load:
> F:\Workspaces\wks_jsf\CGESrvTest\lib\serializer-2.7.1.jar
> INFO - Configuring enterprise application: classpath.ear
> INFO - Configuring Service(id=Default Stateless Container, type=Container,
> provider-id=Default Stateless Container)
> INFO - Auto-creating a container for bean CGEServiceImpl:
> Container(type=STATELESS, id=Default Stateless Container)
> INFO - Configuring PersistenceUnit(name=cge,
> provider=org.hibernate.ejb.HibernatePersistence)
> INFO - Auto-creating a Resource with id 'db2x070NonJta' of type 'DataSource
> for 'cge'.
> INFO - Configuring Service(id=db2x070NonJta, type=Resource,
> provider-id=db2x070)
> INFO - Adjusting PersistenceUnit cge <jta-data-source> to Resource ID
> 'db2x070' from 'null'
> INFO - Adjusting PersistenceUnit cge <non-jta-data-source> to Resource ID
> 'db2x070NonJta' from 'null'
> INFO - Using 'openejb.validation.output.level=VERBOSE'
> INFO - Enterprise application "classpath.ear" loaded.
> INFO - Assembling app: classpath.ear
> INFO - PersistenceUnit(name=cge,
> provider=org.hibernate.ejb.HibernatePersistence)
> SLF4J: Class path contains multiple SLF4J bindings.
> SLF4J: Found binding in
> [jar:file:/F:/Workspaces/wks_jsf/CGESrvTest/lib/slf4j-jdk14-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: Found binding in
> [jar:file:/F:/Workspaces/wks_jsf/CGESrvTest/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
> SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
> explanation.
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.Version <clinit>
> INFO: Hibernate Annotations 3.5.0.Beta1
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment <clinit>
> INFO: Hibernate 3.5.0-Beta-2
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment <clinit>
> INFO: hibernate.properties not found
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment buildBytecodeProvider
> INFO: Bytecode provider name : javassist
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment <clinit>
> INFO: using JDK 1.4 java.sql.Timestamp handling
> 13-Nov-2009 3:46:54 PM org.hibernate.annotations.common.Version <clinit>
> INFO: Hibernate Commons Annotations 3.2.0-SNAPSHOT
> 13-Nov-2009 3:46:54 PM org.hibernate.ejb.Version <clinit>
> INFO: Hibernate EntityManager 3.5.0.Beta1
> 13-Nov-2009 3:46:54 PM org.hibernate.ejb.Ejb3Configuration configure
> INFO: Processing PersistenceUnitInfo [
>        name: cge
>        ...]
> URL: file:/F:/Workspaces/wks_jsf/CGEEJB/ejbModule/
>  META-INF/orm.xml
>  **/*.hbm.xml
>
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.Configuration configure
> INFO: configuring from resource:
> com/desj/visa/srv/cge/orm/config/hibernate.cfg.xml
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.Configuration
> getConfigurationInputStream
> INFO: Configuration resource:
> com/desj/visa/srv/cge/orm/config/hibernate.cfg.xml
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.Configuration doConfigure
> INFO: Configured SessionFactory: null
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
> INFO: Binding entity from annotated class:
> com.desj.visa.srv.cge.beans.Application
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
> INFO: Bind entity com.desj.visa.srv.cge.beans.Application on table
> TAPPLICATION
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
> INFO: Binding entity from annotated class:
> com.desj.visa.srv.cge.beans.Environnement
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
> INFO: Bind entity com.desj.visa.srv.cge.beans.Environnement on table
> TENVIRONNEMENT
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
> INFO: Binding entity from annotated class:
> com.desj.visa.srv.cge.beans.Parametre
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
> INFO: Bind entity com.desj.visa.srv.cge.beans.Parametre on table TPARAMETRE
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
> INFO: Binding entity from annotated class:
> com.desj.visa.srv.cge.beans.Projet
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
> INFO: Bind entity com.desj.visa.srv.cge.beans.Projet on table TPROJET
> 13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationConfiguration
> applyHibernateValidatorLegacyConstraintsOnDDL
> INFO: Hibernate Validator not found: ignoring
> INFO - Undeploying app: classpath.ear
> ERROR - Application could not be deployed:  classpath.ear
> org.apache.openejb.OpenEJBException: Creating application failed:
> classpath.ear: Absent Code attribute in method that is not native or
> abstract in class file javax/validation/Validation
>        at
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:666)
>        at
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:449)
>        at
> org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:367)
>        at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:279)
>        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
>        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
>        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>        at java.lang.reflect.Method.invoke(Unknown Source)
>        at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>        at
> org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
>        at
> org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
>        at
> org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
>        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
>        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
>        at javax.naming.InitialContext.init(Unknown Source)
>        at javax.naming.InitialContext.<init>(Unknown Source)
>        at com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:34)
>        at junit.framework.TestCase.runBare(TestCase.java:125)
>        at junit.framework.TestResult$1.protect(TestResult.java:106)
>        at junit.framework.TestResult.runProtected(TestResult.java:124)
>        at junit.framework.TestResult.run(TestResult.java:109)
>        at junit.framework.TestCase.run(TestCase.java:118)
>        at junit.framework.TestSuite.runTest(TestSuite.java:208)
>        at junit.framework.TestSuite.run(TestSuite.java:203)
>        at
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
>        at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.lang.ClassFormatError: Absent Code attribute in method that
> is not native or abstract in class file javax/validation/Validation
>        at java.lang.ClassLoader.defineClass1(Native Method)
>        at java.lang.ClassLoader.defineClass(Unknown Source)
>        at java.security.SecureClassLoader.defineClass(Unknown Source)
>        at java.net.URLClassLoader.defineClass(Unknown Source)
>        at java.net.URLClassLoader.access$000(Unknown Source)
>        at java.net.URLClassLoader$1.run(Unknown Source)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(Unknown Source)
>        at java.lang.ClassLoader.loadClass(Unknown Source)
>        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>        at java.lang.ClassLoader.loadClass(Unknown Source)
>        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>        at java.lang.Class.forName0(Native Method)
>        at java.lang.Class.forName(Unknown Source)
>        at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:170)
>        at
> org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:76)
>        at
> org.hibernate.cfg.AnnotationConfiguration.applyBeanValidationConstraintsOnDDL(AnnotationConfiguration.java:438)
>        at
> org.hibernate.cfg.AnnotationConfiguration.applyConstraintsToDDL(AnnotationConfiguration.java:390)
>        at
> org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:376)
>        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1188)
>        at
> org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1291)
>        at
> org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:195)
>        at
> org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:919)
>        at
> org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:523)
>        at
> org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:157)
>        at
> org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:184)
>        at
> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:489)
>        ... 32 more
>
> --
> View this message in context: http://old.nabble.com/OutOfMemory-doing-a-JUnit-using-OpenEJB-Embedded-tp26289066p26371834.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>

Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by Jean-Louis MONTEIRO :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Patrick,

javax.validation.* = Bean Validation API (JSR 303).

If you decide to go to JPA 2.0 (if it works without any changes), you must update APIs (JPA with Criteria in, Bean Validation).

Jean-Louis


PatLaPatate wrote:
Hi Quintin,

I ran into this problem once I changed my configuration to run openEJB over JPA2.

David had warned me about this. Seems like some code is missing somewhere due to the change
of specs in JPA2.

INFO - Using 'openejb.deployments.classpath.include=com.desj.visa.*'
INFO - Using 'openejb.deployments.classpath.exclude=.*/com\.ibm\.ws\.[^/]*.jar(!/)?'
INFO - Using 'openejb.deployments.classpath.filter.descriptors=true'
WARN - Inspecting classpath for applications: 51 urls.
WARN - ADJUST THE EXCLUDE/INCLUDE!!!.  Current settings: openejb.deployments.classpath.exclude='.*/com\.ibm\.ws\.[^/]*.jar(!/)?', openejb.deployments.classpath.include='com.desj.visa.*'
INFO - Found ClientModule in classpath: F:\Workspaces\wks_jsf\CGESrvTest\lib\javassist-3.9.0.GA.jar
INFO - Found ClientModule in classpath: F:\Workspaces\wks_jsf\CGESrvTest\lib\openjpa-2.0.0-SNAPSHOT.jar
INFO - Found ClientModule in classpath: F:\Workspaces\wks_jsf\CGESrvTest\lib\xml-resolver-1.2.jar
INFO - Found EjbModule in classpath: F:\Workspaces\wks_jsf\CGEEJB\ejbModule
INFO - Found ClientModule in classpath: F:\Workspaces\wks_jsf\CGESrvTest\lib\serializer-2.7.1.jar
WARN - Searched 51 classpath urls in 9656 milliseconds.  Average 189 milliseconds per url.
WARN - Consider adjusting your openejb.deployments.classpath.exclude and openejb.deployments.classpath.include settings.  Current settings: exclude='.*/com\.ibm\.ws\.[^/]*.jar(!/)?', include='com.desj.visa.*'
INFO - Beginning load: F:\Workspaces\wks_jsf\CGESrvTest\lib\javassist-3.9.0.GA.jar
INFO - Beginning load: F:\Workspaces\wks_jsf\CGESrvTest\lib\openjpa-2.0.0-SNAPSHOT.jar
INFO - Beginning load: F:\Workspaces\wks_jsf\CGESrvTest\lib\xml-resolver-1.2.jar
INFO - Beginning load: F:\Workspaces\wks_jsf\CGEEJB\ejbModule
INFO - Beginning load: F:\Workspaces\wks_jsf\CGESrvTest\lib\serializer-2.7.1.jar
INFO - Configuring enterprise application: classpath.ear
INFO - Configuring Service(id=Default Stateless Container, type=Container, provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean CGEServiceImpl: Container(type=STATELESS, id=Default Stateless Container)
INFO - Configuring PersistenceUnit(name=cge, provider=org.hibernate.ejb.HibernatePersistence)
INFO - Auto-creating a Resource with id 'db2x070NonJta' of type 'DataSource for 'cge'.
INFO - Configuring Service(id=db2x070NonJta, type=Resource, provider-id=db2x070)
INFO - Adjusting PersistenceUnit cge <jta-data-source> to Resource ID 'db2x070' from 'null'
INFO - Adjusting PersistenceUnit cge <non-jta-data-source> to Resource ID 'db2x070NonJta' from 'null'
INFO - Using 'openejb.validation.output.level=VERBOSE'
INFO - Enterprise application "classpath.ear" loaded.
INFO - Assembling app: classpath.ear
INFO - PersistenceUnit(name=cge, provider=org.hibernate.ejb.HibernatePersistence)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/F:/Workspaces/wks_jsf/CGESrvTest/lib/slf4j-jdk14-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/F:/Workspaces/wks_jsf/CGESrvTest/lib/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.5.0.Beta1
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.5.0-Beta-2
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : javassist
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
13-Nov-2009 3:46:54 PM org.hibernate.annotations.common.Version <clinit>
INFO: Hibernate Commons Annotations 3.2.0-SNAPSHOT
13-Nov-2009 3:46:54 PM org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.5.0.Beta1
13-Nov-2009 3:46:54 PM org.hibernate.ejb.Ejb3Configuration configure
INFO: Processing PersistenceUnitInfo [
        name: cge
        ...]
URL: file:/F:/Workspaces/wks_jsf/CGEEJB/ejbModule/
  META-INF/orm.xml
  **/*.hbm.xml

13-Nov-2009 3:46:54 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: com/desj/visa/srv/cge/orm/config/hibernate.cfg.xml
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: com/desj/visa/srv/cge/orm/config/hibernate.cfg.xml
13-Nov-2009 3:46:54 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.desj.visa.srv.cge.beans.Application
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.desj.visa.srv.cge.beans.Application on table TAPPLICATION
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.desj.visa.srv.cge.beans.Environnement
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.desj.visa.srv.cge.beans.Environnement on table TENVIRONNEMENT
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.desj.visa.srv.cge.beans.Parametre
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.desj.visa.srv.cge.beans.Parametre on table TPARAMETRE
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: com.desj.visa.srv.cge.beans.Projet
13-Nov-2009 3:46:54 PM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity com.desj.visa.srv.cge.beans.Projet on table TPROJET
13-Nov-2009 3:46:54 PM org.hibernate.cfg.AnnotationConfiguration applyHibernateValidatorLegacyConstraintsOnDDL
INFO: Hibernate Validator not found: ignoring
INFO - Undeploying app: classpath.ear
ERROR - Application could not be deployed:  classpath.ear
org.apache.openejb.OpenEJBException: Creating application failed: classpath.ear: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:666)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:449)
        at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:367)
        at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:279)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
        at org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:34)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/validation/Validation
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:170)
        at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:76)
        at org.hibernate.cfg.AnnotationConfiguration.applyBeanValidationConstraintsOnDDL(AnnotationConfiguration.java:438)
        at org.hibernate.cfg.AnnotationConfiguration.applyConstraintsToDDL(AnnotationConfiguration.java:390)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:376)
        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1188)
        at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1291)
        at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:195)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:919)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:523)
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:157)
        at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:184)
        at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:489)
        ... 32 more

Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by BluesBrother :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for posting this solution to the OutOfMemory problem. I'm new to OpenEJB and trying to use it under NetBeans in a unit test scenario. I, too, was getting the OutOfMemory error, and was clueless as to why. However, after reading the referenced OpenEJB page, I added an "include" filter property specifying only the path of my application's classes and voila! Startup was much faster, I didn't get the OutOfMemory error, and my test case was executed. Apparently, by default (with no filtering) OpenEJB was searching for and including every JAR and class it could find! ;-)


Hi,

it seems to me you are using WAS 7 API/JARS.
Some of them are very big (com.ibm.ws.runtime.jar more or less 40Mo).

To prevent OutOfMemory Exception, you should either increase the heap size (-Xmx system property) or activate OpenEJB filters (to exclude WAS jars).

I guess the second option is better for you.
Have a look here http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html.

Hope it helps.
Jean-Louis


PatLaPatate wrote:
Hi,

Here's the context : I get the following error when trying to run a JUnit test:
java.lang.OutOfMemoryError: Java heap space

Here is the context of my problem:
Under RAD 7.5
Using Hibernate, JUnit, JPA, openEJB

JUnit code:
public class CGEServiceTest extends TestCase {

        private InitialContext initialContext;
       
        public void setUp() throws Exception {
       Properties properties = new Properties();
       properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
       properties.put("db2x070", "new://Resource?type=DataSource");
       properties.put("db2x070.JdbcDriver", "com.ibm.db2.jcc.DB2Driver");
       properties.put("db2x070.JdbcUrl", "jdbc:db2://db2d070n0:50127/db2d070");
       properties.put("db2x070.UserName", "xxxxx");
       properties.put("db2x070.Password", "xxxxxx");      
       initialContext = new InitialContext(properties);

        }
        public void testAjouterApplication() throws Exception {
               
                Object object = initialContext.lookup("ejb/CGEService");
                CGEService service = (CGEService) object;
                try {
                        Application a = new Application();
                        a.setName("fat/ECS");
                        service.ajouterApplication(a);
                       
                } catch (CGEPersistenceException e) {
                        fail();
                }
        }
}


/////////////////////////////////////////////////////////////////////////////////////////////

My service class :

package com.desj.visa.srv.cge;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import javax.persistence.PersistenceUnit;

import com.desj.visa.srv.cge.beans.Application;

@Stateless (name="ejb/CGEService")
public class CGEServiceImpl implements CGEService {

        @PersistenceUnit
        private EntityManagerFactory emf;
       
        public void setEmf(EntityManagerFactory emf) {
                this.emf = emf;
        }

        public void ajouterApplication(Application application) throws CGEPersistenceException {

            // Start EntityManagerFactory

            // First unit of work
            EntityManager em = emf.createEntityManager();
            EntityTransaction tx = em.getTransaction();
            tx.begin();

            em.persist(application);

            tx.commit();
            em.close();

            // Shutting down the application
            emf.close();
          }
}

///////////////////////////////////////////////////////////////////////////

My Bean :

import javax.persistence.*;

@Entity
@Table (name = "TAPPLICATION", schema="GCE")

public class Application {

        @Id @GeneratedValue
        @Column(name = "IDAPPLICATION")
        private long id;

        @Column(name = "NOMAPPLICATION")
        private String name;
       
        public Application() {
                super();
        }
       
        public Application(long id, String name) {
                super();
                this.name = name;
        }
       
        public long getId() {
                return id;
        }
        public void setId(long id) {
                this.id = id;
        }
        public String getName() {
                return name;
        }
        public void setName(String name) {
                this.name = name;
        }
}

And the result is:


Apache OpenEJB 3.1.2    build: 20091010-03:11
http://openejb.apache.org/
INFO - openejb.home = F:\Workspaces\wks_jsf\CGESrvTest
INFO - openejb.base = F:\Workspaces\wks_jsf\CGESrvTest
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=db2x070, type=Resource, provider-id=Default JDBC Database)
INFO - Found EjbModule in classpath: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
INFO - Found EjbModule in classpath: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
INFO - Beginning load: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
INFO - Beginning load: C:\Program Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
INFO - Configuring enterprise application: classpath.ear
FATAL - OpenEJB has encountered a fatal error and cannot be started: The Assembler encountered an unexpected error while attempting to build the container system.
java.lang.OutOfMemoryError: Java heap space
        at org.apache.xbean.asm.ClassReader.a(Unknown Source)
        at org.apache.xbean.asm.ClassReader.<init>(Unknown Source)
        at org.apache.xbean.finder.ClassFinder.readClassDef(ClassFinder.java:728)
        at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:141)
        at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:113)
        at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:422)
        at org.apache.openejb.config.AnnotationDeployer$DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:253)
        at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:188)
        at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:247)
        at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:601)
        at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:551)
        at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:380)
        at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:299)
        at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:278)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
        at org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
        at org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at com.desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:27)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)


Does anyone have a clue?

Thanks


Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by Jacek Laskowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 18, 2009 at 5:29 AM, BluesBrother <john@...> wrote:
>
> Thanks for posting this solution to the OutOfMemory problem. I'm new to
> OpenEJB and trying to use it under NetBeans in a unit test scenario. I, too,
> was getting the OutOfMemory error, and was clueless as to why. However,
> after reading the referenced OpenEJB page, I added an "include" filter
> property specifying only the path of my application's classes and voila!
> Startup was much faster, I didn't get the OutOfMemory error, and my test
> case was executed. Apparently, by default (with no filtering) OpenEJB was
> searching for and including every JAR and class it could find! ;-)

It makes two who suffered from it. If it becomes a PITA for more,
we'll have to change the approach and search for a very few only with
classpath searching disabled (it's nearly impossible to exclude jars
from those different envs where OpenEJB could be running within).

Jacek

--
Jacek Laskowski
Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl

Re: OutOfMemory doing a JUnit using OpenEJB Embedded

by David Blevins :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Nov 17, 2009, at 8:29 PM, BluesBrother wrote:

>
> Thanks for posting this solution to the OutOfMemory problem. I'm new  
> to
> OpenEJB and trying to use it under NetBeans in a unit test scenario.  
> I, too,
> was getting the OutOfMemory error, and was clueless as to why.  
> However,
> after reading the referenced OpenEJB page, I added an "include" filter
> property specifying only the path of my application's classes and  
> voila!

Fantastic!

> Startup was much faster, I didn't get the OutOfMemory error, and my  
> test
> case was executed. Apparently, by default (with no filtering)  
> OpenEJB was
> searching for and including every JAR and class it could find! ;-)

The default is actually the opposite, but what seems like is happening  
is that we still have some quirkiness in what is considered a  
ClientModule.   By default the includes/excludes don't apply to  
modules with descriptors and some jar files with "Main-Class:" in them  
were getting added to that category and slipping by (per JavaEE rules  
any jar with a Main-Class in the MANIFEST.MF should be considered a  
client module).  I had thought we fixed this so that even if jars had  
a Main-Class declaration we would still filter them out unless they  
had a META-INF/application-client.xml.

Need to check that again.

-David

> Jean-Louis MONTEIRO wrote:
>>
>> Hi,
>>
>> it seems to me you are using WAS 7 API/JARS.
>> Some of them are very big (com.ibm.ws.runtime.jar more or less 40Mo).
>>
>> To prevent OutOfMemory Exception, you should either increase the  
>> heap size
>> (-Xmx system property) or activate OpenEJB filters (to exclude WAS  
>> jars).
>>
>> I guess the second option is better for you.
>> Have a look here
>> http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html
>> http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html
>> .
>>
>> Hope it helps.
>> Jean-Louis
>>
>>
>>
>> PatLaPatate wrote:
>>>
>>> Hi,
>>>
>>> Here's the context : I get the following error when trying to run  
>>> a JUnit
>>> test:
>>> java.lang.OutOfMemoryError: Java heap space
>>>
>>> Here is the context of my problem:
>>> Under RAD 7.5
>>> Using Hibernate, JUnit, JPA, openEJB
>>>
>>> JUnit code:
>>> public class CGEServiceTest extends TestCase {
>>>
>>> private InitialContext initialContext;
>>>
>>> public void setUp() throws Exception {
>>>       Properties properties = new Properties();
>>>       properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>>> "org.apache.openejb.client.LocalInitialContextFactory");
>>>       properties.put("db2x070", "new://Resource?type=DataSource");
>>>       properties.put("db2x070.JdbcDriver",  
>>> "com.ibm.db2.jcc.DB2Driver");
>>>       properties.put("db2x070.JdbcUrl",
>>> "jdbc:db2://db2d070n0:50127/db2d070");
>>>       properties.put("db2x070.UserName", "xxxxx");
>>>       properties.put("db2x070.Password", "xxxxxx");
>>>       initialContext = new InitialContext(properties);
>>>
>>> }
>>> public void testAjouterApplication() throws Exception {
>>>
>>> Object object = initialContext.lookup("ejb/CGEService");
>>> CGEService service = (CGEService) object;
>>> try {
>>> Application a = new Application();
>>> a.setName("fat/ECS");
>>> service.ajouterApplication(a);
>>>
>>> } catch (CGEPersistenceException e) {
>>> fail();
>>> }
>>> }
>>> }
>>>
>>>
>>> /////////////////////////////////////////////////////////////////////////////////////////////
>>>
>>> My service class :
>>>
>>> package com.desj.visa.srv.cge;
>>> import javax.ejb.Stateless;
>>> import javax.persistence.EntityManager;
>>> import javax.persistence.EntityManagerFactory;
>>> import javax.persistence.EntityTransaction;
>>> import javax.persistence.Persistence;
>>> import javax.persistence.PersistenceUnit;
>>>
>>> import com.desj.visa.srv.cge.beans.Application;
>>>
>>> @Stateless (name="ejb/CGEService")
>>> public class CGEServiceImpl implements CGEService {
>>>
>>> @PersistenceUnit
>>> private EntityManagerFactory emf;
>>>
>>> public void setEmf(EntityManagerFactory emf) {
>>> this.emf = emf;
>>> }
>>>
>>> public void ajouterApplication(Application application) throws
>>> CGEPersistenceException {
>>>
>>>    // Start EntityManagerFactory
>>>
>>>    // First unit of work
>>>    EntityManager em = emf.createEntityManager();
>>>    EntityTransaction tx = em.getTransaction();
>>>    tx.begin();
>>>
>>>    em.persist(application);
>>>
>>>    tx.commit();
>>>    em.close();
>>>
>>>    // Shutting down the application
>>>    emf.close();
>>>  }
>>> }
>>>
>>> ///////////////////////////////////////////////////////////////////////////
>>>
>>> My Bean :
>>>
>>> import javax.persistence.*;
>>>
>>> @Entity
>>> @Table (name = "TAPPLICATION", schema="GCE")
>>>
>>> public class Application {
>>>
>>> @Id @GeneratedValue
>>> @Column(name = "IDAPPLICATION")
>>> private long id;
>>>
>>> @Column(name = "NOMAPPLICATION")
>>> private String name;
>>>
>>> public Application() {
>>> super();
>>> }
>>>
>>> public Application(long id, String name) {
>>> super();
>>> this.name = name;
>>> }
>>>
>>> public long getId() {
>>> return id;
>>> }
>>> public void setId(long id) {
>>> this.id = id;
>>> }
>>> public String getName() {
>>> return name;
>>> }
>>> public void setName(String name) {
>>> this.name = name;
>>> }
>>> }
>>>
>>> And the result is:
>>>
>>>
>>> Apache OpenEJB 3.1.2    build: 20091010-03:11
>>> http://openejb.apache.org/
>>> INFO - openejb.home = F:\Workspaces\wks_jsf\CGESrvTest
>>> INFO - openejb.base = F:\Workspaces\wks_jsf\CGESrvTest
>>> INFO - Configuring Service(id=Default Security Service,
>>> type=SecurityService, provider-id=Default Security Service)
>>> INFO - Configuring Service(id=Default Transaction Manager,
>>> type=TransactionManager, provider-id=Default Transaction Manager)
>>> INFO - Configuring Service(id=db2x070, type=Resource, provider-
>>> id=Default
>>> JDBC Database)
>>> INFO - Found EjbModule in classpath: C:\Program
>>> Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
>>> INFO - Found EjbModule in classpath: C:\Program
>>> Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
>>> INFO - Beginning load: C:\Program
>>> Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.runtime.jar
>>> INFO - Beginning load: C:\Program
>>> Files\IBM\SDP75\runtimes\base_v7\plugins\com.ibm.ws.admin.core.jar
>>> INFO - Configuring enterprise application: classpath.ear
>>> FATAL - OpenEJB has encountered a fatal error and cannot be  
>>> started: The
>>> Assembler encountered an unexpected error while attempting to  
>>> build the
>>> container system.
>>> java.lang.OutOfMemoryError: Java heap space
>>> at org.apache.xbean.asm.ClassReader.a(Unknown Source)
>>> at org.apache.xbean.asm.ClassReader.<init>(Unknown Source)
>>> at
>>> org.apache.xbean.finder.ClassFinder.readClassDef(ClassFinder.java:
>>> 728)
>>> at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:141)
>>> at org.apache.xbean.finder.ClassFinder.<init>(ClassFinder.java:113)
>>> at
>>> org.apache.openejb.config.AnnotationDeployer
>>> $DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:422)
>>> at
>>> org.apache.openejb.config.AnnotationDeployer
>>> $DiscoverAnnotatedBeans.deploy(AnnotationDeployer.java:253)
>>> at
>>> org
>>> .apache
>>> .openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:
>>> 188)
>>> at
>>> org.apache.openejb.config.ConfigurationFactory
>>> $Chain.deploy(ConfigurationFactory.java:247)
>>> at
>>> org
>>> .apache
>>> .openejb
>>> .config
>>> .ConfigurationFactory
>>> .configureApplication(ConfigurationFactory.java:601)
>>> at
>>> org
>>> .apache
>>> .openejb
>>> .config
>>> .ConfigurationFactory
>>> .configureApplication(ConfigurationFactory.java:551)
>>> at
>>> org
>>> .apache
>>> .openejb
>>> .config
>>> .ConfigurationFactory
>>> .getOpenEjbConfiguration(ConfigurationFactory.java:380)
>>> at
>>> org
>>> .apache
>>> .openejb
>>> .assembler
>>> .classic.Assembler.getOpenEjbConfiguration(Assembler.java:299)
>>> at
>>> org
>>> .apache.openejb.assembler.classic.Assembler.build(Assembler.java:
>>> 278)
>>> at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:137)
>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:286)
>>> at org.apache.openejb.OpenEJB.init(OpenEJB.java:265)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>> at
>>> org
>>> .apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
>>> at
>>> org
>>> .apache
>>> .openejb
>>> .client
>>> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:71)
>>> at
>>> org
>>> .apache
>>> .openejb
>>> .client
>>> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:53)
>>> at
>>> org
>>> .apache
>>> .openejb
>>> .client
>>> .LocalInitialContextFactory
>>> .getInitialContext(LocalInitialContextFactory.java:42)
>>> at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
>>> at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
>>> at javax.naming.InitialContext.init(Unknown Source)
>>> at javax.naming.InitialContext.<init>(Unknown Source)
>>> at
>>> com
>>> .desj.visa.app.cge.tests.CGEServiceTest.setUp(CGEServiceTest.java:
>>> 27)
>>> at junit.framework.TestCase.runBare(TestCase.java:125)
>>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>>
>>>
>>> Does anyone have a clue?
>>>
>>> Thanks
>>>
>>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/OutOfMemory-doing-a-JUnit-using-OpenEJB-Embedded-tp26289066p26402385.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>