[jboss-user] [EJB 3.0] - JNDI in Jboss EJB3 Embeddable Container: Naming Problem
unsavory
do-not-reply at jboss.com
Wed Apr 18 21:53:09 EDT 2007
Hopefully someone can help me out with this.
I'm running the JBoss EJB3 embeddable server inside Tomcat 6. Everything seems happy enough when booting. I'm trying to access a simple stateless bean named TestBean from within a struts servlet.
I'm getting the following exception:
javax.naming.NameNotFoundException: scrumster not bound
org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
Here is the Bean and interface:
import javax.ejb.Stateless;
| import javax.persistence.*;
| import java.util.List;
|
| @Stateless
| public class TestBean implements TestInterface {
|
| @PersistenceContext
| EntityManager em;
|
| public void saveMessages() {
| em.persist("test");
| }
|
| public void showMessages() {
| List messages =
| em.createQuery("select m from Message m order by m.text asc")
| .getResultList();
| System.out.println(messages.size() + " message(s) found:");
| System.out.println("test");
| }
| }
public interface TestInterface {
| public void saveMessages();
| public void showMessages();
| }
And here is the calling code:
public String execute() throws Exception {
|
| Hashtable props = new Hashtable();
| props.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
| props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
|
| InitialContext initialContext = new InitialContext(props);
|
| TestInterface msgHandler = (TestInterface) initialContext
| .lookup("TestBean/local");
|
| msgHandler.saveMessages();
| msgHandler.showMessages();
|
| return SUCCESS;
| }
How do I even know my bean has loaded into the JBoss container? Is there something I need to do to get it to be detected?
Thanks again for any help. I'm having a terrible time getting this setup so I can actually write some code.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4038690#4038690
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4038690
More information about the jboss-user
mailing list