0

I am using this tutorial to learn JavaEE web app. I am using eclipse indigo for Java EE, objectdb-2.4.2_02, glassfish 3.1.2 on windows xp. When I run the program, the embedded browser opens page with this status & printing javax.ejb.EJBException. I google it but I did not find an answer for this problem.

   HTTP Status 500 - 

--------------------------------------------------------------------------------

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception 
javax.ejb.EJBException

note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.

--------------------------------------------------------------------------------

GlassFish Server Open Source Edition 3.1.2.2

server log file:

          [#|2012-08-23T15:51:38.979+0300|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=21;_ThreadName=Thread-2;|StandardWrapperValve[GuestServlet]: PWC1406: Servlet.service() for servlet GuestServlet threw exception
javax.ejb.EJBException
    at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5215)
    at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5113)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4901)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045)
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89)
    at $Proxy130.getAllGuests(Unknown Source)
    at guest.__EJB31_Generated__GuestDao__Intf____Bean__.getAllGuests(Unknown Source)
    at guest.GuestServlet.doGet(GuestServlet.java:24)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName GuestbookPU
    at com.sun.enterprise.container.common.impl.EntityManagerWrapper.init(EntityManagerWrapper.java:132)
    at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:173)
    at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:467)
    at guest.GuestDao.getAllGuests(GuestDao.java:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
    ... 30 more
|#]
ObjectDB
  • 1,312
  • 8
  • 9
enterprize
  • 1,179
  • 8
  • 29
  • 43
  • Two things: 1) version 3.0.1 is already quite old, and known to be a bit buggy. Switch to the current 3.1.2 and try again. 2) It would be most interesting to see the stack trace the error message mentions. It will be in a file called server.log in the log subdirectory of the domain directory. The fact that it gives back a 500 error code just indicates an error during processing, but not the kind of error that occurred, there can literally be 100's of kinds of causes for this problem. – fvu Aug 18 '12 at 14:27
  • I put server log file of Glassfish in OP – enterprize Aug 18 '12 at 14:41
  • The exception shows you were using 3.0.1, but the log shows you were using 3.1.2. What exactly version did you use? – Cole Aug 18 '12 at 15:11
  • There's even no info wrt the deployment so I don't think that's the domain or server you are experimenting with.... – fvu Aug 18 '12 at 15:21
  • @fvu: It's 3.1.2. I added the log file in OP. Actually eclipse downloaded one server automatically so there were two servers, one JavaEE & other installed by eclipse. Now I configured one that come with JavaEE jdk. – enterprize Aug 20 '12 at 18:32

2 Answers2

0

Only a partial answer...

The key issue is

 Caused by: java.lang.IllegalStateException: 
     Unable to retrieve EntityManagerFactory for unitName null

Which means that it failed to figure out which PersistenceUnit it should use in GuestDAO. This might indicate that GF could not find your persistence.xml file in the project, please doublecheck whether the creation of persistence.xml as described went well and whether persistence.xml exists ONCE and ONLY ONCE in the deployed project (the once part is because I've noticed Eclipselink can get quite confused when confronted with multiple persistence.xml files in one project. If all that's OK add the unit's name to the @PersistenceContext annotation in GuestsDAO, as shown below

@PersistenceContext(unitName="GuestbookPU")
private EntityManager em;

If all of this fails let me know.

fvu
  • 32,488
  • 6
  • 61
  • 79
  • I am using eclipse. There is only one persistence.xml file. I edited the annotation in ejb file & run the program. Now it gives 404 error with msg "description:The requested resource () is not available" in browser window. I updated server log. – enterprize Aug 21 '12 at 17:21
  • What page are you trying to load? Looks like you're trying to load the default web page ( yourcomputer;port/Guestbook ) but that page isn't defined in the project. yourcomputer;port/Guestbook/GuestServlet should work though. – fvu Aug 22 '12 at 22:23
  • Actually I made mistake in running the program, I ran it right clicking on project folder rather than running it by running Servlet. It is still raising same error i.e. status 500 with ejb exception. I updated the stack trace. – enterprize Aug 23 '12 at 13:05
0

In my experience it is some kind of database connection problem. Best thing to do is to login to the server and PING the data base to see if it works.