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.



Reply via email to