Ja sam pokusao da uradim jedan EJB3 primjer pa sam dosao do sledece greske:
Code:
Exception in thread "main" javax.naming.NameNotFoundException: actions.IShopControlRemote not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
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:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
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.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at client.EJBClient.main(EJBClient.java:22)
Exception in thread "main" javax.naming.NameNotFoundException: actions.IShopControlRemote not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
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:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
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.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at client.EJBClient.main(EJBClient.java:22)
Server mi ne prijavljuje nikakve greske.
Koristim server JBoss 4.0 for EJB3, na serveru imam dva entity bean i jedan session bean sa nazivom ShopControl.
Kod klijenta izgleda ovako:
Code:
package client;
import javax.naming.Context;
import actions.IShopControlRemote;
public class EJBClient {
private static javax.naming.Context getInitialContext()
throws javax.naming.NamingException {
java.util.Properties props = new java.util.Properties();
props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(javax.naming.Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
props.put(javax.naming.Context.PROVIDER_URL, "jnp://localhost:1099");
return new javax.naming.InitialContext(props);
}
public static void main(String[] args) throws Exception {
Context initialContext = getInitialContext();
IShopControlRemote shop = (IShopControlRemote) initialContext.lookup("actions.IShopControlRemote");
Long id = shop.addCustomer("Novi korisnik");
System.out.println("Novi korisnik dodat ID: " + id);
}
}
package client;
import javax.naming.Context;
import actions.IShopControlRemote;
public class EJBClient {
private static javax.naming.Context getInitialContext()
throws javax.naming.NamingException {
java.util.Properties props = new java.util.Properties();
props.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(javax.naming.Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
props.put(javax.naming.Context.PROVIDER_URL, "jnp://localhost:1099");
return new javax.naming.InitialContext(props);
}
public static void main(String[] args) throws Exception {
Context initialContext = getInitialContext();
IShopControlRemote shop = (IShopControlRemote) initialContext.lookup("actions.IShopControlRemote");
Long id = shop.addCustomer("Novi korisnik");
System.out.println("Novi korisnik dodat ID: " + id);
}
}
Ja sam nov u java programskom jeziku (kao i na forumu) ali se dugo godina bavim programiranjem u drugim jezicima. Tako da jos uvijek lutam i trazim alat u kome cu pisati javu...