[jboss-user] [EJB 3.0] - Invalid invocation of local interface (null container)

piscean do-not-reply at jboss.com
Wed Jul 25 19:09:59 EDT 2007


I am a newbie to EJB3. I have some experience with EJB2, but having hardtime with EJB3. I am trying to write one very simple stateless session bean. The files are,
1. ejb.hello.HelloBean.java
2. ejb.hello.HelloLocal.java
3. WEB-INF/jndi.properties

The files contents are,

ejb.hello.HelloBean.java
----------------------------
/**
 * 
 */
package ejb.hello;

import javax.ejb.Stateless;

@Stateless
public class HelloBean implements HelloRemote, HelloLocal {

	private String greeting = "Hello";
	/* (non-Javadoc)
	 * @see ejb.hello.Hello#hello()
	 */
	public String hello() {
		return "Hello";
	}
	/**
	 * @return the greeting
	 */
	public String getGreeting() {
		return greeting;
	}
	/**
	 * @param greeting the greeting to set
	 */
	public void setGreeting(String greeting) {
		this.greeting = greeting;
	}

}


ejb.hello.HelloLocal.java
----------------------------
/**
 * 
 */
package ejb.hello;

import javax.ejb.Local;

@Local
public interface HelloLocal {
	public String hello();
}


WEB-INF/jndi.properties
----------------------------
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:1099


My client is HelloTest.java
------------------------------
package ejb.web;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;

import ejb.hello.HelloLocal;
import ejb.hello.HelloRemote;


public class HelloTest {
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			InitialContext ctx = new InitialContext();
			HelloLocal hellol = (HelloLocal) ctx.lookup("HelloBean/local");
			if (hellol == null) {
				System.out.println("Hello is null");
			}
			System.out.println("Output = " + hellol.hello());
		}
		catch (Exception ex) {
			System.out.println("Error in main");
			ex.printStackTrace();
		}
	}
}


I get errors
--------------

Error in main
javax.ejb.EJBException: Invalid invocation of local interface (null container)
	at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:77)
	at $Proxy0.hello(Unknown Source)
	at ejb.web.HelloTest.main(HelloTest.java:24)


When I start jboss server, it did display following lines in logs so I assume, the bean got deployed allright..
-----------------------------------------------------------------------
18:01:02,203 INFO  [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=EHello.jar,name=HelloBean,service=EJB3 with dependencies:
18:01:02,484 INFO  [EJBContainer] STARTED EJB: ejb.hello.HelloBean ejbName: HelloBean
18:01:02,578 INFO  [EJB3Deployer] Deployed: file:/C:/jboss-4.2.0.GA/server/default/deploy/EHello.jar

I assume, ejb-jar.xml, jboss.xml files are not needed with EJB3, Am I right? What am I doing wrong?

Please help....

Thanks.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067625#4067625

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067625



More information about the jboss-user mailing list