ejb@glassfish.java.net

Trying to connect to Remote ession Bean from JSF backing bean

From: Wouter van Reeven <wouter_at_van.reeven.nl>
Date: Thu, 16 Nov 2006 00:54:33 +0100

Hi everyone,


Following my onw weblog about connecting to a Remote Session Bean from Tomcat,
see

http://technology.amis.nl/blog/?p=1368

I tried to connect to a Remote Session Bean (on another machine) from Tomcat
started by NetBeans. I know the blog is kinda old, referring to NB 5.5 RC2 and
the Enterprise Pack QBuild, but the steps still are the same.
So, I created a webpage with a form that asks for a username and password and I
implemented a method called loginButton_action that is fired whenever a user
clicks the login button. So far, so good.

However, at the moment I click the button, things go wrong. I can see in the
server.log on the remote host that the actual login is successful, but somehow
an exception is thrown. The code that I run is

CultiUser cultiUser = null;
if (authenticationRemote != null) {
    String username = getUsernameField().getValueAsString(getFacesContext());
    String password = getPasswordField().getValueAsString(getFacesContext());
    cultiUser = authenticationRemote.login(username, password);
        return "Login succeeded";
    } else {
        log.debug("Login failed");
        return null;
    }
} else {
    log.debug("Problem: Could not connect to remote bean named AuthenticationRemote");
    return null;
}

where CultiUser is an Entity that is returned on succesful login. The stacktrace
I get is included at the bottom of this email. As you can see, the error is
thrown at line 337 of my code, which is the line where the login method on the
authenticationRemote session bean is called. This bean is looked up via JNDI as
described in my blog in the init() method.
Now, the funny thing is, when I do exectly the same thing from a custom servlet,
the same code works perfectly ok. As a matter of fact, I copied the code from
the servlet and adjusted the class names for the JSF situation (I use a
different Persistence Unit).
In the end I thought that maybe the instances of InitialContext and
AuthenticationRemote etc were not available at the time the button was clicked,
so I moved all the initialisation code to the actual loginbutton_action method
but to no avail. I still get stackTraces.

My question obviously is: how do I make this work?

So, here's the stacktrace. Thanks for your help,

Wouter

Nov 16, 2006 12:30:06 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
com.sun.rave.web.ui.appbase.ApplicationException: #{login.loginButton_action}:
javax.faces.el.EvaluationException: javax.ejb.EJBException: nested exception is:
java.rmi.MarshalException: CORBA MARSHAL 1398079745 Maybe; nested exception is:
        org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
        at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.cleanup(ViewHandlerImpl.java:559)
        at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:276)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:195)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
Caused by: javax.faces.FacesException: #{login.loginButton_action}:
javax.faces.el.EvaluationException: javax.ejb.EJBException: nested exception is:
java.rmi.MarshalException: CORBA MARSHAL 1398079745 Maybe; nested exception is:
        org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
        at com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:57)
        at javax.faces.component.UICommand.broadcast(UICommand.java:332)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:287)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:401)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
        ... 20 more
Caused by: javax.faces.el.EvaluationException: javax.ejb.EJBException: nested
exception is: java.rmi.MarshalException: CORBA MARSHAL 1398079745 Maybe; nested
exception is:
        org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
        at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:150)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:92)
        ... 28 more
Caused by: javax.ejb.EJBException: nested exception is:
java.rmi.MarshalException: CORBA MARSHAL 1398079745 Maybe; nested exception is:
        org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
        at nl.cultinairgenootschap.ejb.session._AuthenticationRemote_Wrapper.login(nl.cultinairgenootschap.ejb.session._AuthenticationRemote_Wrapper.java)
        at nl.cultinairgenootschap.web.jsf.login.loginButton_action(login.java:337)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
        ... 29 more

-- 
People: "If she weighs the same as a Duck, she's made of wood!"
Sir Bedevere: "And therefore...?"