File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Jboss + Spring  + Ejb (Null Pointer Exception Problem) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Jboss + Spring  + Ejb (Null Pointer Exception Problem)" Watch "Jboss + Spring  + Ejb (Null Pointer Exception Problem)" New topic

Jboss + Spring + Ejb (Null Pointer Exception Problem)

rakesh maheshwari

Joined: Apr 02, 2010
Posts: 2
Hello all. I am new to Ejb. i successfully deployed my ejb in jboss 4.0 and now trying to access session bean and getting error

(xml.XmlBeanDefinitionReader 293 ) Loading XML bean definitions from file [c:\client-spring-stateless-ejb.xml]
Exception in thread "main" java.lang.NullPointerException
at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(
at $Proxy0.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.create(
at org.springframework.ejb.access.LocalSlsbInvokerInterceptor.newSessionBeanInstance(
at org.springframework.ejb.access.LocalSlsbInvokerInterceptor.getSessionBeanInstance(
at org.springframework.ejb.access.LocalSlsbInvokerInterceptor.invoke(
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
at $Proxy1.sayHello(Unknown Source)
at com.glamour.client.EjbClient.main(

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' ''>

package com.glamour.ejb;
public interface HelloService {
public String sayHello();

package com.glamour.ejb;
import javax.ejb.CreateException;
import javax.ejb.EJBLocalHome;
public interface HelloServiceHome extends EJBLocalHome{

public HelloServiceLocal create() throws CreateException;

package com.glamour.ejb;
import javax.ejb.EJBLocalObject;
public interface HelloServiceLocal extends HelloService,EJBLocalObject {


package com.glamour.ejb;
public class HelloServiceImpl implements HelloService{

public String sayHello(){
return "hello Spring";

package com.glamour.ejb;
import javax.ejb.CreateException;
import org.springframework.beans.factory.BeanFactory;
public class HelloServiceEjb extends AbstractStatelessSessionBean implements HelloService {

private HelloService helloService;

protected void onEjbCreate() throws CreateException {
BeanFactory beanFactory = getBeanFactory();
helloService = (HelloService)beanFactory.getBean("helloService");

public String sayHello(){
return helloService.sayHello();

<?xml version="1.0"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "">
<bean id="helloService" class="com.glamour.ejb.HelloServiceImpl"></bean>
package com.glamour.client;
import com.glamour.ejb.*;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;

public class EjbClient {

public static void main(String[] args) {
BeanFactory factory = new XmlBeanFactory(new FileSystemResource("c:\\client-spring-stateless-ejb.xml"));
HelloService hs = (HelloService) factory.getBean("helloServiceBean");


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

<jee:local-slsb id="helloServiceBean"

[Thumbnail for springError.JPG]

Karthik Shiraly

Joined: Apr 04, 2009
Posts: 874

Hi Rakesh,

Can't access an EJB's local interface from another VM (that's why it's called local). Your client is a separate VM here. If you're sure your EJB's always going to be used by locally deployed components, then test using a locally deployed servlet or JSP. Else, provide a remote interface.

Also, can you please enclose all the code in [ code ] [ /code ] tags in your makes it much easier to read your post then.

rakesh maheshwari

Joined: Apr 02, 2010
Posts: 2
Hi Karthik,

I Changed local interface to remote. Now its working fine. Next time i will take care of code tag. i am too from pesit 2009. thanks a lot

I agree. Here's the link:
subject: Jboss + Spring + Ejb (Null Pointer Exception Problem)
It's not a secret anymore!