ejb+jboss+erreur de context - Java - Programmation
MarshPosté le 20-05-2006 à 12:47:29
Bonjour,
J'essaie dans le cadre d'un tme, d'utiliser les ejb avec jboss.
J'ai une erreur quand j'essaie d'insérer des données dans la base qui est celle ci:
---------------------------------------------------------------------------------------------- ^[[Athierry@debian:~/Master/CPS/tme6$ ant db-insert-client Buildfile: build.xml
db-insert-client: [java] Exception in thread "main" javax.naming.NameNotFoundException: Client not bound [java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:514) [java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:522) [java] at org.jnp.server.NamingServer.getObject(NamingServer.java:528) [java] at org.jnp.server.NamingServer.lookup(NamingServer.java:281) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294) [java] at sun.rmi.transport.Transport$1.run(Transport.java:153) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at sun.rmi.transport.Transport.serviceCall(Transport.java:149) [java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460) [java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701) [java] at java.lang.Thread.run(Thread.java:595) [java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247) [java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223) [java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126) [java] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source) [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610) [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572) [java] at javax.naming.InitialContext.lookup(InitialContext.java:351) [java] at client.ClientTest.testClient(ClientTest.java:28) [java] at client.ClientTest.main(ClientTest.java:23)
Je comprends pas trop l'erreur du ctx.lookup vu que "Client" correspond au nom que j'ai donné en jndi-name dans mon jboss.xml, et donc je comprends pas du tout mon erreur :-(.
Marsh Posté le 20-05-2006 à 12:47:29
Bonjour,
J'essaie dans le cadre d'un tme, d'utiliser les ejb avec jboss.
J'ai une erreur quand j'essaie d'insérer des données dans la base qui est celle ci:
----------------------------------------------------------------------------------------------
^[[Athierry@debian:~/Master/CPS/tme6$ ant db-insert-client
Buildfile: build.xml
db-insert-client:
[java] Exception in thread "main" javax.naming.NameNotFoundException: Client not bound
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
[java] at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
[java] at org.jnp.server.NamingServer.lookup(NamingServer.java:281)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
[java] at sun.rmi.transport.Transport$1.run(Transport.java:153)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
[java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
[java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
[java] at java.lang.Thread.run(Thread.java:595)
[java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
[java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
[java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
[java] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
[java] at javax.naming.InitialContext.lookup(InitialContext.java:351)
[java] at client.ClientTest.testClient(ClientTest.java:28)
[java] at client.ClientTest.main(ClientTest.java:23)
BUILD FAILED
/home/thierry/Master/CPS/tme6/build.xml:122: Java returned: 1
---------------------------------------------------------------------------------------------
Voila le contenu de ma cible dans mon build.xml:
<target name="db-insert-client">
<java classname="client.ClientTest"
classpathref="classpath"
fork="yes"
failonerror="yes">
</java>
</target>
-----------------------------------------------------
Voila le contenu de mon fichier ClientTest.java (la ligne 28 étant celle en gras)
package client;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.*;
public class ClientTest {
public static void main(String[] args) throws Exception {
/* Setup properties for JNDI initialization.
* These properties will be read-in from
* the command-line. */
Properties props = System.getProperties();
props.put(Context.PROVIDER_URL,"jnp://localhost:1099" );
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory" );
props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client" );
ClientTest test = new ClientTest();
test.testClient(props);
}
public void testClient (Properties props) throws Exception {
Context ctx = new InitialContext(props);
Object obj = ctx.lookup("Client" );
ClientHome home = (ClientHome) javax.rmi.PortableRemoteObject.narrow(obj, ClientHome.class);
/* Creation de clients */
Client client1 = home.create(new Integer(1),"B","Thierry", "thierry@xxx.xx", new Double(100));
Client client2 = home.create(new Integer(2),"M","PA", "pa@yyy.yy",new Double (200));
}
}
-------------------------------------------------------------------------------------------------
mon Jboss.xml
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<session>
<ejb-name>GestionClient</ejb-name>
<jndi-name>GestionClient</jndi-name>
</session>
<entity>
<ejb-name>Client</ejb-name>
<jndi-name>Client</jndi-name>
<local-jndi-name>ClientLocal</local-jndi-name>
</entity>
</enterprise-beans>
</jboss>
------------------------------------------------------------------------------------------------
Je comprends pas trop l'erreur du ctx.lookup vu que "Client" correspond au nom que j'ai donné en jndi-name dans mon jboss.xml, et donc je comprends pas du tout mon erreur :-(.
Merci :-)
A+