Ciao,
sto cercando di fare un hello world con EJB3 tramite un client standalone(remoto):
Ho creato due progetti HelloEJB e HelloClient.
HelloEJB:
package com.myexample;
import javax.ejb.Remote;
@Remote
public interface HelloWorldBeanRemote {
String sayHelloWorld();
}
-------------------------------------------------------
package com.myexample;
import javax.ejb.Stateless;
@Stateless
public class HelloWorldBean implements HelloWorldBeanRemote {
public String sayHelloWorld() {
return "TEst";
}
}
HelloClient(includo come librerie il progetto HelloEJB + appserv-rt.jar + javaee.jar):
package helloclient;
import com.myexample.HelloWorldBeanRemote;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class Main {
public static void main(String[] args) {
try
{
Properties properties = new Properties();
properties.put("org.omg.CORBA.ORBInitialHost", "127.0.0.1}");
properties.put("org.omg.CORBA.ORBInitialPort", "26208");
properties.put("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactor y");
Context ctx = new InitialContext(properties);
HelloWorldBeanRemote helloBean = (HelloWorldBeanRemote)
ctx.lookup("com.myexampl.HelloWorldBeanRemote");
System.out.println(helloBean.sayHelloWorld());
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
Il deploy dell'applicazione Enterprise JavaBeans (HelloEJB) avviene correttamente sull'application server GlassFish v3
Quando faccio partire il client HelloClient viene sollevato il seguente errore durate l'esecuzione del lookup:
Jun 14, 2010 9:56:45 PM com.sun.enterprise.transaction.JavaEETransactionMa nagerSimplified initDelegates
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransacti onManagerJTSDelegate as the delegate
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemExcepti on.connectFailure(ORBUtilSystemException.java:3431 )
at com.sun.corba.ee.impl.logging.ORBUtilSystemExcepti on.connectFailure(ORBUtilSystemException.java:3452 )
at com.sun.corba.ee.impl.transport.SocketOrChannelCon nectionImpl.<init>(SocketOrChannelConnectionImpl.j ava:256)
at com.sun.corba.ee.impl.transport.SocketOrChannelCon nectionImpl.<init>(SocketOrChannelConnectionImpl.j ava:269)
at com.sun.corba.ee.impl.transport.SocketOrChannelCon tactInfoImpl.createConnection(SocketOrChannelConta ctInfoImpl.java:125)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestD ispatcherImpl.beginRequest(CorbaClientRequestDispa tcherImpl.java:188)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegate Impl.request(CorbaClientDelegateImpl.java:186)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegate Impl.is_a(CorbaClientDelegateImpl.java:352)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl .java:112)
at org.omg.CosNaming.NamingContextHelper.narrow(Namin gContextHelper.java:69)
at com.sun.enterprise.naming.impl.SerialContext.narro wProvider(SerialContext.java:355)
at com.sun.enterprise.naming.impl.SerialContext.getRe moteProvider(SerialContext.java:327)
at com.sun.enterprise.naming.impl.SerialContext.getPr ovider(SerialContext.java:271)
at com.sun.enterprise.naming.impl.SerialContext.looku p(SerialContext.java:430)
at javax.naming.InitialContext.lookup(InitialContext. java:392)
at helloclient.Main.main(Main.java:33)
Caused by: java.lang.RuntimeException: java.nio.channels.UnresolvedAddressException
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFa ctory.createSocket(IIOPSSLSocketFactory.java:340)
at com.sun.corba.ee.impl.transport.SocketOrChannelCon nectionImpl.<init>(SocketOrChannelConnectionImpl.j ava:239)
... 13 more
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:30)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannel Impl.java:487)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocke tChannel(ORBUtility.java:106)
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFa ctory.createSocket(IIOPSSLSocketFactory.java:325)
... 14 more
javax.naming.NamingException: Lookup failed for 'com.myexampl.HelloWorldBeanRemote' in SerialContext targetHost=192.168.0.98},targetPort=26208,orb'sIni tialHost=localhost,orb'sInitialPort=3700 [Root exception is javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext targetHost=192.168.0.98},targetPort=26208,orb'sIni tialHost=localhost,orb'sInitialPort=3700 [Root exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No]]
at com.sun.enterprise.naming.impl.SerialContext.looku p(SerialContext.java:442)
at javax.naming.InitialContext.lookup(InitialContext. java:392)
at helloclient.Main.main(Main.java:33)
Caused by: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext targetHost=192.168.0.98},targetPort=26208,orb'sIni tialHost=localhost,orb'sInitialPort=3700 [Root exception is org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No]
at com.sun.enterprise.naming.impl.SerialContext.getPr ovider(SerialContext.java:276)
at com.sun.enterprise.naming.impl.SerialContext.looku p(SerialContext.java:430)
... 2 more
Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemExcepti on.connectFailure(ORBUtilSystemException.java:3431 )
at com.sun.corba.ee.impl.logging.ORBUtilSystemExcepti on.connectFailure(ORBUtilSystemException.java:3452 )
at com.sun.corba.ee.impl.transport.SocketOrChannelCon nectionImpl.<init>(SocketOrChannelConnectionImpl.j ava:256)
at com.sun.corba.ee.impl.transport.SocketOrChannelCon nectionImpl.<init>(SocketOrChannelConnectionImpl.j ava:269)
at com.sun.corba.ee.impl.transport.SocketOrChannelCon tactInfoImpl.createConnection(SocketOrChannelConta ctInfoImpl.java:125)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestD ispatcherImpl.beginRequest(CorbaClientRequestDispa tcherImpl.java:188)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegate Impl.request(CorbaClientDelegateImpl.java:186)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegate Impl.is_a(CorbaClientDelegateImpl.java:352)
at org.omg.CORBA.portable.ObjectImpl._is_a(ObjectImpl .java:112)
at org.omg.CosNaming.NamingContextHelper.narrow(Namin gContextHelper.java:69)
at com.sun.enterprise.naming.impl.SerialContext.narro wProvider(SerialContext.java:355)
at com.sun.enterprise.naming.impl.SerialContext.getRe moteProvider(SerialContext.java:327)
at com.sun.enterprise.naming.impl.SerialContext.getPr ovider(SerialContext.java:271)
... 3 more
Caused by: java.lang.RuntimeException: java.nio.channels.UnresolvedAddressException
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFa ctory.createSocket(IIOPSSLSocketFactory.java:340)
at com.sun.corba.ee.impl.transport.SocketOrChannelCon nectionImpl.<init>(SocketOrChannelConnectionImpl.j ava:239)
... 13 more
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:30)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannel Impl.java:487)
at com.sun.corba.ee.impl.orbutil.ORBUtility.openSocke tChannel(ORBUtility.java:106)
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFa ctory.createSocket(IIOPSSLSocketFactory.java:325)
... 14 more
Durante l'esecuzione del client ho controllato se ci fossero delle connessione verso il server, ma ho notato che non ne vengono aperte:
netstat -n | grep 26208
Oltre a questo ho controllato il log del server Glassfish v3, ma non risultano connessioni sull'application server.
Come mai non si connette ne anche al server? Quali parametri devo dare per far si che si connetti correttamente al server? Quale JNDI devo fornirgli?
Grazie mille
Rino