Précédent   Forum du club des développeurs et IT Pro > Java > Serveurs, conteneurs, et Java EE > Weblogic
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 09/02/2011, 15h00   #1
tweetysat
Invité régulier
 
Inscription : septembre 2008
Messages : 80
Détails du profil
Informations forums :
Inscription : septembre 2008
Messages : 80
Points : 7
Points : 7
Par défaut 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 ?
tweetysat est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/02/2011, 13h19   #2
tweetysat
Invité régulier
 
Inscription : septembre 2008
Messages : 80
Détails du profil
Informations forums :
Inscription : septembre 2008
Messages : 80
Points : 7
Points : 7
Personne pour m'aider ?

Si l'un d'entre vous utilise weblogic, pourrait-il écrire un tout simple ejb du même style pour que je puisse voir si le problème vient de mon serveur ?

Merci.
tweetysat est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/02/2011, 14h55   #3
Mobius
Membre éprouvé
 
Avatar de Mobius
 
Inscription : avril 2005
Messages : 461
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 461
Points : 419
Points : 419
Étrange ton erreur, je n'ai jamais eut ce type d'erreur.

Tu peux regarder le fichier "servers/AdminServer/logs/AdminServer.log" dans ton domaine.
Des logs doivent être ajouté a ce fichier lors de chaque redéploiement de ton ejb.
Le mieux est quand meme de préciser explicitement le nom jndi de ton ejb car sinon c'est weblogic qui en génère un (et pas forcément ce qu'il y a de plus clair)
__________________
Librairie d'accès LDAP en Java : LdapBeans
et pensez au tag
Mobius est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/02/2011, 18h28   #4
manblaizo
Membre éprouvé
 
Inscription : janvier 2006
Messages : 351
Détails du profil
Informations personnelles :
Localisation : Maroc

Informations forums :
Inscription : janvier 2006
Messages : 351
Points : 448
Points : 448
Citation:
Envoyé par Mobius Voir le message
Le mieux est quand meme de préciser explicitement le nom jndi de ton ejb car sinon c'est weblogic qui en génère un (et pas forcément ce qu'il y a de plus clair)
Oui, c'est bien, avec weblogic il vaut mieux spécifier le nom jdni :
Code :
1
2
3
4
@Stateless(mappedName="MonTestBean")
public class TestBean implements TestBeanRemote {
...
Ensuite on fait le lookup sur <MappedName#package.RemoteName> :
Code :
1
2
 
TestBeanRemote tb = (TestBeanRemote)context.lookup("MonTestBean#" + TestBeanRemote.class.getName());
Tous ces problèmes de noms jndi incompatibles entre serveurs d'applications ont été résolus dans EJB 3.1 qui standardise les global jndi names. Mais bon, il n'y a pas encore de weblogic compatible Java EE 6; au courant de l'année peut-être.
__________________
SCJP 5 / SCBCD 1.3 Certified
manblaizo est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/03/2012, 16h32   #5
ayoubkira
Nouveau Membre du Club
 
Ayoub Ayb
Inscription : août 2010
Messages : 78
Détails du profil
Informations personnelles :
Nom : Ayoub Ayb

Informations forums :
Inscription : août 2010
Messages : 78
Points : 34
Points : 34
j'ai le meme probleme ..

voila mes differentes classes :
Code :
1
2
3
4
5
6
7
8
9
package com.ayoub;
 
 
import javax.ejb.Remote;
 
@Remote
public interface PremierEJB3 {
   public String ditBonjour(String aQui);
}
Code :
1
2
3
4
5
6
7
8
9
10
11
12
 
package com.ayoub;
 
 
import javax.ejb.Stateless;
 
@Stateless(name="PremierEJB3Bean",mappedName="PremierEJB3Bean") 
public class PremierEJB3Bean implements PremierEJB3 {
   public String ditBonjour(String aQui) {
      return "Bonjour " + aQui + " !!!";
   }
}
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
26
 
package com.ayoub;
import java.util.Properties;
 
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
 
public class Test {
 
   public static void main(String[] args) {
 
	   Properties p=new Properties();
	      p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
	      p.put(Context.PROVIDER_URL,"t3://localhost:7001");
	   try {
 
	         Context context = new InitialContext(p);
	         PremierEJB3 beanRemote = (PremierEJB3) context.lookup("PremierEJB3Bean#"+com.ayoub.PremierEJB3.class.getName());
	         System.out.println(beanRemote.ditBonjour("Test"));
	      } catch (NamingException e) {
	         e.printStackTrace();
	      }
	   }
 
   }
et l erreur qui s'affiche sur la console est :

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
javax.naming.NameNotFoundException: While trying to lookup 'PremierEJB3Bean#com.ayoub.PremierEJB3' didn't find subcontext 'PremierEJB3Bean#com'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'PremierEJB3Bean#com.ayoub.PremierEJB3' didn't find subcontext 'PremierEJB3Bean#com'. Resolved '']; remaining name 'PremierEJB3Bean#com/ayoub/PremierEJB3'
	at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
	at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
	at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
	at weblogic.jndi.internal.ServerNamingNode_1034_WLStub.lookup(Unknown Source)
	at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:423)
	at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:411)
	at javax.naming.InitialContext.lookup(InitialContext.java:392)
	at com.ayoub.Test.main(Test.java:18)
Caused by: javax.naming.NameNotFoundException: While trying to lookup 'PremierEJB3Bean#com.ayoub.PremierEJB3' didn't find subcontext 'PremierEJB3Bean#com'. Resolved ''
	at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
	at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
	at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
	at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
	at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
	at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:667)
	at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
	at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
	at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
	at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
	at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
	at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
ayoubkira est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 18h20.


 
 
 
 
Partenaires

Hébergement Web