Ronald,
we use the following settings for GFv2 and GFv3:
final Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
// Only needed if server is running on a different host than localhost:
if (!getServerWrapper().isEmpty())
props.setProperty("org.omg.CORBA.ORBInitialHost", getServer());
// Optional. Defaults to 3700. Only needed if target orb port is not 3700.
if (!StringUtils.isEmpty(getPortNumber()))
props.setProperty("org.omg.CORBA.ORBInitialPort", getPortNumber());
props.setProperty("com.sun.appserv.iiop.orbconnections","5");
Kind regards,
- Andreas Kozma
www.ansis.com
On Jul 1, 2010, at 10:47 , Ronald Muller wrote:
> I reduced this problem to a very simple "Hello World" sample:
>
> 1) A library jar with one Remote interface (InterfaceEJB.jar):
>
> public interface SimpleEJBRemote {
>
> String hello();
>
> }
>
> 2) An Enterprise Application (ear) deployed on SERVER1 with an EJB Module (EJBModule.ear containing /lib/InterfaceEJB.jar and EJBModule.jar) and a SLSB:
>
> @Stateless
> @Remote(value=SimpleEJBRemote.class)
> public class SimpleEJBBean implements SimpleEJBRemote {
>
> @Override
> public String hello() {
> return "Hello world...";
> }
>
> }
>
> 3) A Web Application (WebRemote.war) deployed on SERVER2 containing WEB-INF/lib/InterfaceEJB.jar and a servlet, calling the remote EJB:
>
> public class SimpleServlet extends HttpServlet {
>
> private SimpleEJBRemote _remoteService;
>
> public SimpleServlet() {
> try {
> final Properties env = new Properties();
> env.setProperty("org.omg.CORBA.ORBInitialHost", 127.0.0.1");
> env.setProperty("org.omg.CORBA.ORBInitialPort", "3100");
> InitialContext context = new InitialContext(env);
> // all fail ..
> _remoteService = (SimpleEJBRemote) context.lookup(
> SimpleEJBRemote.class.getCanonicalName());
> //"SimpleEJBRemote");
> //"java:global/SimpleEJBBean");
> //"java:global/EJBModule/EJBModule-ejb/SimpleEJBBean");
> } catch (Exception ex) {
> ex.printStackTrace();
> }
> }
>
> ... standard code
> }
>
> I get the following exception:
> javax.naming.NamingException: Lookup failed for 'sample.SimpleEJBRemote' in SerialContext targetHost=127.0.0.1,targetPort=3100,orb'sInitialHost=127.0.1.1,orb'sInitialPort=4037 [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext targetHost=127.0.0.1,targetPort=3100,orb'sInitialHost=127.0.1.1,orb'sInitialPort=4037 [Root exception is java.lang.ClassCastException]]
> at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
> ...
> Caused by: java.lang.ClassCastException: Object is not of remote type com.sun.enterprise.naming.impl.SerialContextProvider
> at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:250)
>
> If i change the lookup code to:
> InitialContext context = new InitialContext();
> _remoteService = (SimpleEJBRemote) context.lookup("corbaname:iiop:127.0.0.1:3100#sample.SimpleEJBRemote");
>
> I get the following exception:
> javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
> at com.sun.jndi.cosnaming.ExceptionMapper.mapException(ExceptionMapper.java:44)
> ...
> Caused by: org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
> at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:72)
>
> If I use GF 2.1.1 for both SERVER1 and SERVER2, everthing goes well
> If I use GF 3.0.1 for both SERVER1 and SERVER2, everthing goes well
> The exceptions occurs when SERVER1 is GF 2 and SERVER2 is GF 3
>
> Who knows what I am doing wrong??
>
> Regards,
>
> Ronald
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
>
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>