javax.naming.NameNotFoundException: ejbtut not bound
zielonyplot Oct 29, 2006 8:55 AMI have an interface statelessTekst.java:
package src;
import javax.ejb.Remote;
@Remote
public interface statelessTekst {
public String podajTekst(int numer);
}And a bean statelessTekstBean.java:
package src;
import javax.ejb.Stateless;
import src.statelessTekst;
public @Stateless class statelessTekstBean implements statelessTekst {
public String podajTekst(int numer)
{
return "Test 1 udany";
}
}I put this files to the jar file named ejbtut.jar.
Then I made ear file. I put to this ear file ejbtut.jar file and, to the META-INF folder, a simple application.xml file:
<?xml version="1.0" encoding="UTF-8"?> <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"> <display-name>EJBTekst1</display-name> <description>J2EE Made Easy Trail Map</description> <module> <ejb>bean.jar</ejb> </module> </application>
I put this ejbtut file to the deploy folder and I started jboss server. Everything goes OK.
Then i wrote simple client application:
import javax.naming.*;
import src.statelessTekst;
import java.util.Hashtable;
public class calculator
{
public static void main(String[] args)
{
Hashtable p = new Hashtable();
p.put(InitialContext.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
p.put(InitialContext.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
p.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
statelessTekst cal = null;
try {
InitialContext ctx = new InitialContext(p);
cal = (statelessTekst) ctx.lookup(
"ejbtut/statelessTekstBean/remote");
} catch (Exception e) {
e.printStackTrace ();
}
System.out.println(cal.podajTekst(1));
}
}Bu, when I start the client application, I get exception:
javax.naming.NameNotFoundException: ejbtut 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:267)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
(...)
What I am doing wrong?
Please, help!