I was testing with an Application with two Layers.
- Middleware Layer runs un first Server
- Frontend Layer runs on second Server
both container are jboss 6.0.0.CR1
Frontend server communicate with middleware using Remote EJB. For that I added to it follow configuration to the fronend server:
<mbean code="org.jboss.naming.ExternalContext"
name="jboss.jndi:service=ExternalContext,jndiName=middlewareServices">
<attribute name="JndiName">middlewareServices</attribute>
<attribute name="Properties">
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=jnp://myMiddleware:1099
</attribute>
<attribute name="InitialContext">javax.naming.InitialContext</attribute>
<attribute name="RemoteAccess">true</attribute>
</mbean>
Further, I added a naming alias for my remote middleware bean to inject it in my frontend bean.
<mbean code="org.jboss.naming.NamingAlias"
name="DefaultDomain:service=NamingAlias,fromName=SessionService">
<attribute name="FromName">services/SessionService</attribute>
<attribute name="ToName">middlewareServices/SessionService</attribute>
</mbean>
My Frontend EJB looks like:
@Stateless
public class CreateSessionActionBean implement CreateSessionAction
{
@EJB(mappedName="service/SessionService"
private SessionService sessionService;
/**
- create session action
*/
public createSession()
{
sessionService.login();
}
}
Wenn I run my frontend, I get following exception:
Caused by: java.lang.NullPointerException
at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:185) [:1.0.11]
at $Proxy321.createSesssion(Unknown Source) at CreateSessionActionBean.createSession(CreateSessionActionBean.java:20) [:]