[prev in list] [next in list] [prev in thread] [next in thread]
List: jboss-user
Subject: [jboss-user] [EJB 3.0] - New to EJB3 -- Please help
From: chensquare <do-not-reply () jboss ! com>
Date: 2007-04-30 21:21:55
Message-ID: 1185100.1177968115981.JavaMail.jboss () colo-br-02 ! atl ! jboss ! com
[Download RAW message or body]
Hi all,
I'm new to EJB. I'm writing a toy EJB, and having problem running the client (bean \
can be deployed successfully in Eclipse) When running the client, it generates \
javax.naming.NameNotFoundException: HelloBean not bound.
Please help. THANKS A LOT!!!
my config:
IDE: Eclipse
JBOSS: 4.0.5
//INTERFACE:
package examples.session.stateless;
import javax.ejb.*;
public interface Hello {
public String hello() ; //throws java.rmi.RemoteException;
}
//BEAN CLASS
package examples.session.stateless;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.*;
@Stateless
@Remote(Hello.class)
public class HelloBean implements Hello {
public String hello () {
System.out.println("in hello()...");
return "Hello, World!";
}
}
EJB-JAR.XML
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee"
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/ejb-jar_2_1.xsd"> JBoss Hello World Application
<display-name>HelloBean</display-name>
<enterprise-beans>
<ejb-name>HelloBean</ejb-name>
</enterprise-beans>
</ejb-jar>
CLIENT
package examples.session.stateless;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
public class HelloEJBClient {
public static void main( String [] args )
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, \
"org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, \
"localhost:1099");
env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); \
try
{
InitialContext ctx = new InitialContext(env);
Hello hello = (Hello) ctx.lookup( "HelloBean" );
System.out.println(hello.hello());
}
catch ( Exception e )
{
e.printStackTrace();
System.out.println( "Chen - Exception: " + e.getMessage() );
}
}
}
View the original post : \
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4041983#4041983
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4041983
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic