title: ejb2.0, log4j and EAR project configuration
body: <p>I am posting one more question on EJB2.0. I thought my earlier question won't get any answer since EJB2.0 is pretty much outdated technology and nobody wants to work on it any more. But my <a href="https://stackoverflow.com/questions/16838495/ejb2-x-container-managed-relationship">first question</a> got answered and I am trying my luck one more time. </p>
  
  <p>I created one simple EJB 2.x entity bean. My entity bean uses another class (UniqueIdGenerator) to generate value of primary key for persistent primary key field.  UniqueIdGenerator uses log4j and JDBC connection, so I configured appropriate build path references for my EJB project. </p>
  
  <p>Added following JARS to buildpath for EJB project
  log4j-1.2.16.jar
  db2jcc.jar
  db2jcc_license_cu.jar</p>
  
  <p>Then I mapped persistent fields to database table fields. Generated code using Prepare for Deployment option in RSA (deploying on WAS). </p>
  
  <p>Created EAR project and using Project References option added EJB project (HMS) to EAR project.</p>
  
  <p>I did not set any other path/classpath.</p>
  
  <p>Started WAS, deployed EAR on WAS and launched Universal Test Client to test entity bean. Using remote interface I tried to create my first bean, I entered the values for fields and clicked on submit on Universal test client. On server side it called ejbCreate() of entity bean but failed when loading UniqueIdGenerator class with error NoClassDefFoundError</p>
  
  <p>Here is stack trace</p>
  
  <pre><code>java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
      com.ibm.ejs.container.CreateFailureException: ; nested exception is: 
      java.lang.NoClassDefFoundError: org.apache.log4j.LogManager
      at com.ibm.CORBA.iiop.UtilDelegateImpl.mapSystemException(UtilDelegateImpl.java:235)
      at com.ibm.CORBA.iiop.UtilDelegateImpl.wrapException(UtilDelegateImpl.java:743)
      at javax.rmi.CORBA.Util.wrapException(Util.java:296)
      at ejbs._EJSRemoteCMPAddressHome_824957aa_Stub.create(_EJSRemoteCMPAddressHome_824957aa_Stub.java:258)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:611)
      at com.ibm.etools.utc.model.ReflectionMethodModel.invoke(ReflectionMethodModel.java:65)
      at com.ibm.etools.utc.servlet.InvokeServlet.invoke(InvokeServlet.java:113)
      at com.ibm.etools.utc.servlet.InvokeServlet.doPost(InvokeServlet.java:374)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
      at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
      at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:864)
      at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
      at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
      at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)
  Caused by: com.ibm.ejs.container.CreateFailureException: ; nested exception is: 
      java.lang.NoClassDefFoundError: org.apache.log4j.LogManager
      at ejbs.EJSCMPAddressHomeBean_824957aa.create(EJSCMPAddressHomeBean_824957aa.java:47)
      at ejbs.EJSRemoteCMPAddressHome_824957aa.create(EJSRemoteCMPAddressHome_824957aa.java:28)
      at ejbs._EJSRemoteCMPAddressHome_824957aa_Stub.create(_EJSRemoteCMPAddressHome_824957aa_Stub.java:251)
      ... 29 more
  Caused by: java.lang.NoClassDefFoundError: org.apache.log4j.LogManager
      at utils.UniqueLongIdGenerator.(UniqueLongIdGenerator.java:40)
      at java.lang.J9VMInternals.initializeImpl(Native Method)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
      at utils.UniqueIdGenerator.(UniqueIdGenerator.java:28)
      at utils.UniqueIdGenerator.(UniqueIdGenerator.java:24)
      at java.lang.J9VMInternals.initializeImpl(Native Method)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
      at ejbs.AddressBean.ejbCreate(AddressBean.java:46)
      at ejbs.ConcreteAddress_824957aa.ejbCreate(ConcreteAddress_824957aa.java:122)
      at ejbs.EJSCMPAddressHomeBean_824957aa.create(EJSCMPAddressHomeBean_824957aa.java:33)
      ... 31 more
  Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager
      at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
      at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:191)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
      at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:111)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
      at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
      at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
      at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:509)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
      ... 41 more
  </code></pre>
  
  <p>Have I missed anything in the configuration. Do I need to add all the jar files somewhere in EAR project. Isn't it sufficient to set them in the build path for EJB project?</p>