1

I have problem trying to deploy Java Enterprise web application with EJB and JSF web module. Application builds successfully but when it gets deployed to Glassfish 4 server, I get this exception

javax.ejb.EJBException
at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy325.vratiSveRelacije(Unknown Source)
at kontroler.KontrolerPrevoznika.vratiSveRelacije(KontrolerPrevoznika.java:275)
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:606)
at javax.el.ELUtil.invokeMethod(ELUtil.java:326)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:536)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
at com.sun.el.parser.AstValue.getValue(AstValue.java:136)
at com.sun.el.parser.AstValue.getValue(AstValue.java:204)

Any suggestions?

3 Answers 3

1

I have worked recently with EJB and I can tell you to check the JNDI that you are setting to connect to the EJB.

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "*hostname*");
props.setProperty("org.omg.CORBA.ORBInitialPort", "*3700*");//default port
InitialContext ctx = new InitialContext(props);
FirstBeanRemote bean = (FirstBeanRemote) ctx.lookup("java:global/*EARNAME/EJBJARNAME*/FirstBean!*fullyqualifiedpackage*.FirstBeanRemote");
  1. The most important thing is to check if you are setting the ctx.lookup argument.

  2. Check also the EJB jar if is deploying correctly.

  3. I don't know If its a bug, but in Eclipse and Glassfish, The EJB can't have external jars

4
  • Sorry if it's a dumb question, but where this code should be? I'm really a beginner with java ee Aug 21, 2013 at 22:33
  • 1
    Well, I suppose you have two projects, a client or consumer (could be a web project or a desktop app) and an EJB project, this code should be in the client or consumer side. Why? Because this code looks up for a connection that is outside the client
    – Jessai
    Aug 21, 2013 at 22:39
  • I have JSF and EJB modules inside Enterprise Application but I don't know where to put code like this. Should it be in Configuration files or in Source packages or somewhere else. Aug 21, 2013 at 22:47
  • 1
    I assume you have .xhtml or .jsf files communicating to a Managed Bean, you can start your tests inside a Managed Bean. At the end the code that I suggest you can be executed from a Java class so If you are with JSF, use a Managed (Backing) Bean or if you want to test from a desktop application, put the code inside a main method.
    – Jessai
    Aug 22, 2013 at 2:40
0

I resolved this problem. My exception looks:

    javax.ejb.EJBException
        at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:748)
        at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:698)
        at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
        at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4566)

And that because my EJB method throws an exception declared in another .jar file used by application as external library and that .jar library is in domain1/lib directory.

Try to throw another exceptions from EJB method and you will see the result.

1
  • I'n getting the same error. Can u please tell me how do u solve this error.
    – Md. Yusuf
    Aug 10, 2016 at 9:43
0

I had the same issue, and it turns out that the cause was in Payara/Glassfish, not in the app. The admin portal - http://localhost:4848/ asked for login credentials all of a sudden, that was not the case before. Setting up a new domain / glassfish instance resolved this issue for me. Might not work for everybody, but I hope it will save some of you some time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.