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.(Unknown Source)
        at 
org.apache.xbean.finder.ClassFinder.readClassDef(ClassFinder.java:728)
        at org.apache.xbean.finder.ClassFinder.(ClassFinder.java:141)
        at org.apache.xbean.finder.ClassFinder.(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.(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.(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-tp26289066p26289066.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to