users@glassfish.java.net

JNDI lookup for a local EJB fails

From: <forums_at_java.net>
Date: Wed, 21 Dec 2011 11:15:11 -0600 (CST)

Hi everyone,

I got in troubles with jndi lookup for a local EJB on Glassfish 3.1.1. 
Actual lookup code looks like the following:
 *
InitialContext().lookup("java:global/trans/data-module/UserManagementEJB");*

I got a reference but not to the EJB, but to a proxy object and once I'm
trying to call an EJB method, I'm getting the following stacktrace:

java.lang.ClassCastException: $Proxy294 cannot be cast to
com.sjs.trans.data.service.UserManagementEJB
    at
com.sjs.trans.common.converter.UserConverter.getAsObject(UserConverter.java:38)
    at
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:171)
    at
com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectOneValue(MenuRenderer.java:202)
    at
com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:319)
    at
org.primefaces.component.selectonemenu.SelectOneMenuRenderer.getConvertedValue(SelectOneMenuRenderer.java:34)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
    at javax.faces.component.UIInput.validate(UIInput.java:960)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
    at javax.faces.component.UIInput.processValidators(UIInput.java:698)
    at
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    at
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    at
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    at
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    at
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
    at javax.faces.component.UIForm.processValidators(UIForm.java:253)
    at
com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:508)
    at
com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
    at javax.faces.component.UIForm.visitTree(UIForm.java:354)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
    at
com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:376)
    at
com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:252)
    at
javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:183)
    at
org.richfaces.context.ExtendedPartialViewContextImpl.processPartial(ExtendedPartialViewContextImpl.java:199)
    at
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1170)
    at
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
    at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at
com.sjs.trans.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:32)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    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 com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:232)
    at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    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:662)
 

*My EJB is
*

@Stateless
public class UserManagementEJB extends BaseServiceImpl<User> implements
UserManagement {
    @PersistenceContext(unitName = PERSISTENT_UNIT_NAME)
    protected EntityManager entityManager;
........

}

*EJB's local interface*

@Local
public interface UserManagement extends BaseListManagement<User> {
    User login(String userName, String password) throws EntityException;

............
}

I also tried to make a lookup with interface name. Anyway I got the same
error. I also tried the same on glassfish v3.1 with the same result. I do
lookup from JSF converter. EJB and JSF converter are in different modules of
the same .ear file.  Could anyone, please, tell me what is wrong with my
code?

Thanks, Pavel


--
[Message sent by forum member 'apostle']
View Post: http://forums.java.net/node/876340