Problème de JNDI lookup avec EJB3
Bonjour.
Jusqu'à présent je travaillais avec jboss. Maintenant je dois utiliser weblogic (10.3).
Et je m'arrache les cheveux.
J'ai bien créé un domaine et démarré le serveur.
Je voudrais tester avec un ejb (qui fonctionne tel quel dans jboss).
Code:
1 2 3 4 5 6 7 8 9 10
|
package server;
import javax.ejb.Remote;
@Remote
public interface TestBeanRemote
{
int Add(int x,int y);
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
package server;
import javax.annotation.PostConstruct;
import javax.ejb.Stateless;
@Stateless()
public class TestBean implements TestBeanRemote
{
public int Add(int x, int y)
{
System.out.println("Adding "+x+" and "+y);
return x + y;
}
@PostConstruct()
public void debut() {
System.out.println("Starting " + this);
}
} |
et le client
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
package client;
import javax.naming.Context;
import javax.naming.InitialContext;
import server.TestBeanRemote;
public class Test1
{
public static void main(String[] args)
{
System.out.println("Test Ejb1 Wl");
try
{
Context context = new InitialContext();
TestBeanRemote tb = (TestBeanRemote)context.lookup("TestBean/remote");
System.out.println("Resultat : " + tb.Add(5,3));
}
catch (Exception e)
{
e.printStackTrace();
}
}
} |
avec jndi.properties
Code:
1 2
| java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://127.0.0.1:7001 |
Dans jboss ça marche tout seul. (avec un jndi.properties différent bien entendu).
Mais ici j'ai
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| [java] Test Ejb1 Wl
[java] javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
[java] java.io.EOFException]
[java] at weblogic.jrmp.Context.lookup(Context.java:189)
[java] at weblogic.jrmp.Context.lookup(Context.java:195)
[java] at javax.naming.InitialContext.lookup(Unknown Source)
[java] at client.Test1.main(Test1.java:15)
[java] Caused by: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
[java] java.io.EOFException
[java] at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
[java] at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
[java] at sun.rmi.server.UnicastRef.newCall(Unknown Source)
[java] at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
[java] at weblogic.jrmp.Context.lookup(Context.java:185)
[java] ... 3 more
[java] Caused by: java.io.EOFException
[java] at java.io.DataInputStream.readByte(Unknown Source)
[java] ... 8 more |
Qu'est-ce qui cloche ?
Edit : si je regarde dans la console web, le nom jndi est
_appsdir_ejb1_jarejb1_jarTestBean_TestBeanRemote
J'ai don essayé avec
TestBeanRemote tb = (TestBeanRemote)context.lookup("_appsdir_ejb1_jarejb1_jarTestBean_TestBeanRemote");
mais ça ne change rien.
Et question subsidiaire : avec jboss, quand je déploie un jar la console m'affiche des infos sur le déploiement mais avec weblogic rien. Il y a moyen de configurer le log de la console ?