How to use @EJB in this local context with JBoss 6.4

我是研究僧i 提交于 2019-12-24 19:07:57

问题


I actually have problem with the annotation @EJB both with local and remote use. But in this question I would like to focus on the local use.

In this experiment I use Jboss EAP 6.4.

In the image below I try to show my EAR-structure and where the problem occurs, the red arrow.

My code in LocalCallSessionBean that should be injected looks like:

@EJB(mappedName="StatelessBean")
private static BeanLocal beanLocal;


public static String returnAString(String parameter)
{

    try
    {
        String string_2 = beanLocal.returnAString("LocalCallsBean-no-interface");

My problem is that beanLocal never get injected and I get a NullPointer at the last row above.

According to: https://docs.oracle.com/javaee/6/tutorial/doc/gipjf.html#girfl ...under section "Accessing Local Enterprise Beans That Implement Business Interfaces" I think this should work.

Do you guys see something that I have missed? Best regards Fredrik


回答1:


I have done some progress. I found three mistakes that I did.

1) I had dependencies that might have been in conflict with my target environment. Compare image below with previous one.

2) I used mappedName but I never got that to work, see image below what I did instead, for loacl I just needed @EJB.

3) I marked my ejb-member/ejb-field as static, I can not explain why but that just did just not work.

Hope this help some one.

Best regards Fredrik



来源:https://stackoverflow.com/questions/47448804/how-to-use-ejb-in-this-local-context-with-jboss-6-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!