You have to lookup your SLSB remote home interface from within your MDB via a
'special' context ( not a context retrieved via new InitialContext() ) to get a
'marshalled' HA-aware SLSB (home) proxy, and not an optimized local
In-JVM-reference.
Read the javadoc comments of the helper class for more details. Maybe this will
help.
Regards
Ulf
| /********************************************************************
| * Helper class for JBoss specific lookup of a marshalled naming
| * context required for inter-EAR remote EJB lookups in case of an
| * isolated EAR classloader server configuration
| */
| public class MarshalledContext
| {
| /***************************************
| * Get an initial JNDI context that returns lookup results as marshalled
| * objects instead of simple object references even for in-JVM lookups.
| * <p>
| * Such an initial context is required for inter-EAR remote EJB lookups
in
| * case of an isolated EAR classloader server configuration. Usage of
the
| * standard server-side InitialContext (created via <code>new
InitalContext()
| * </code>) in this situation will cause ClassCastExceptions.
| * <p>
| * As the required local JNDI port might has be changed dynamically by
the
| * service binding manager in case of a multi-JBoss-instance server
setup,
| * we have to query the actual port number of the local JNDI naming
service
| * (default 1099) via JBoss JMX RMI adaptor.
| * </p>
| *
| * @param rInitialContext initial context for RMI adaptor
lookup
| */
| public static Context getContext( Context rInitialContext )
|
| throws Exception
| {
| RMIAdaptor rAdapter = (RMIAdaptor)
rInitialContext.lookup("jmx/invoker/RMIAdaptor");
| Integer nPort = null;
|
| // get actual port number (default 1099) of the local naming service
| ObjectName rService = new ObjectName("jboss:service=Naming");
|
| nPort = (Integer) rAdapter.getAttribute(rService, "Port");
|
| Properties aProps = new Properties();
|
| aProps.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
| aProps.put(Context.PROVIDER_URL, "localhost:" + nPort.toString());
|
| return new InitialContext(aProps);
| }
|
| /***************************************
| * Get an initial HAJNDI context that returns lookup results as
marshalled
| * objects instead of simple object references even for in-JVM lookups.
| * <p>
| * <bold>ATTENTION</bold>
| * </p><p>
| * For this to work the local JBoss naming service has to be configured
for
| * <bold>CallByValue</bold> semantics, as otherwise HAJNDI to local JNDI
| * delegated lookups would still return by default a simple object
references
| * for in-JVM lookups instead of an marshalled object!
| * </p><p>
| * To enable "CallByValue" semantics the following attribute entry has
to be
| * added to the naming service mbean definition in
'conf/jboss-service.xml'
| * <code>
| * <mbean code="org.jboss.naming.NamingService"
name="jboss:service=Naming">
| * ......
| * <!-- force marshalling of the lookup which is required in case of
| * isolated EAR classloader (see also
jboss.j2ee:service=EARDeployer) -->
| * <attribute name="CallByValue">true</attribute>
| * .....
| * </mbean>
| * </code>
| * </p><p>
| * As the required local HAJNDI port might has be changed dynamically
by the
| * service binding manager in case of a multi-JBoss-instance server
setup,
| * we have to query the actual port number of the local JNDI naming
service
| * (default 1100) via JBoss JMX RMI adaptor.
| * </p>
| *
| * @param rInitialContext initial context for RMI adaptor
lookup
| */
| public static Context getClusterContext( Context rInitialContext )
|
| throws Exception
| {
| RMIAdaptor rAdapter = (RMIAdaptor)
rInitialContext.lookup("jmx/invoker/RMIAdaptor");
| Integer nPort = null;
|
| // get actual port number (default 1100) of the local HAJNDI service
| ObjectName rService = new ObjectName("jboss:service=HAJNDI");
|
| nPort = (Integer) rAdapter.getAttribute(rService, "Port");
|
| Properties aProps = new Properties();
|
| aProps.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
| aProps.put(Context.PROVIDER_URL, "localhost:" + nPort.toString());
|
| return new InitialContext(aProps);
| }
| }
|
|
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3872144#3872144
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3872144
-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/info/Sentarus/hamr30
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user