Ahoj,
mam nasledujici kod:
public class JNDIBind
{
private final static String JNDI = "sams/book";
public static void main(String[] args) {
Properties props = new Properties();
try {
props.load(new FileInputStream("jndi.properties"));
Context ic = new InitialContext(props);
ic.rebind(JNDI,"Teach Yourself J2EE in 21 Days");
System.out.println("Bound "+JNDI);
}
catch (NamingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Ktery skonci vyjimkou:
javax.naming.NotContextException
at org.jnp.server.NamingServer.rebind(NamingServer.java:169)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at
sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.rebind(Unknown Source)
at org.jnp.interfaces.NamingContext.rebind(NamingContext.java:495)
at org.jnp.interfaces.NamingContext.rebind(NamingContext.java:462)
at javax.naming.InitialContext.rebind(InitialContext.java:367)
at JNDIBind.main(JNDIBind.java:21)
Kdyz prepisu JNDI name na cokoliv bez "/" tak vse probehne spravne.
Jak funguji hierarchicke contexty v implemntaci JNDI pod JBossem? V
tride Context jsem vhodne metody nenasel.
Diky za rady,
Lukas