开发者

"javax.ejb.NoSuchEJBException: Could not find stateful bean: "

开发者 https://www.devze.com 2023-01-11 11:36 出处:网络
I\'m struggling futher in my adventure with Jboss and EJB 3.0. I joined Spring 3.0 with EJB. I have 3 modules - web module with Spring controllers, ejb module with my EJB beans and spring mogule with

I'm struggling futher in my adventure with Jboss and EJB 3.0. I joined Spring 3.0 with EJB. I have 3 modules - web module with Spring controllers, ejb module with my EJB beans and spring mogule with other classes like dao or some helpers. All in the ear.

So, in my Spring Controller I have the following code:

@Controller
public class IndexController {

    @EJB
    PaymentRemote paymentRemote;

    @RequestMapping(value = "/index")
    public ModelAndView index() throws Exception {
        ModelAndView mav = new ModelAndView("index/index");     

        paymentRemote.savePayment(123, "bla222");
        paymentRemote.sayGoodbye();
           return mav;
}

In my EJB module I have the following stateful bean:

@Stateful
@Interceptors( SpringBeanAutowiringInterceptor.class)
public class PaymentRemoteImpl implements PaymentRemote{

    @Autowired
    ExampleService exampleService;

    public void savePayment(long payment, String name) throws Exception {
        exampleService.savePayment(123, "kk");

    }

    @Remove
    public void sayGoodbye() {
        System.out.println("I want to finish my task here!");

    }
}

Every dependency is injected properly. When I test this code with stateless beans it works just fine. When it comes to stateful beans when I call my method sayGoodbye() I can't call again this bean. I get the exception:

javax.ejb.NoSuchEJBException: Could not find stateful bean: a74a2l-n1u5tx-gcwd0e6a-1-gcwd18fo-9h

I don't understand this situation :开发者_运维知识库/ I asked the container to remove the bean but later on I would like to use it again but it wants to find me again the same bean. I thought that although I asked to remove it it will create on my request again. Could anyone kindly help me with my problem? I'm stucked.


You can't use injection of Stateful Session Beans (SFSB) into a multi-threaded component that may be shared by multiple concurrent clients like a Servlet or a Controller. Perform a JNDI lookup instead and put the bean into the HttpSession.

See also

  • Stateless and Stateful Enterprise Java Beans
  • New Stateful session bean instance without calling lookup
0

精彩评论

暂无评论...
验证码 换一张
取 消