New to EJB world… Null pointer exception in EJB client

后端 未结 2 1762
小鲜肉
小鲜肉 2020-12-09 14:44

I am learning EJB and I am trying to execute the Helloworld example given in EJB In Action book.

My app server is JBoss, I created the Jar file for the bean class an

2条回答
  •  自闭症患者
    2020-12-09 14:52

    Now I created a simple client using EJB annotations, but I am getting a NullPointerException.

    Your client code looks like an Application Client and such client is supposed to be deployed on the app server and then executed in an Application Client Container (ACC) so that injection can occur. Starting the ACC requires an application server specific command.

    The following wiki explains the usage of the ACC in JBoss (how to package, deploy and launch an ACC): How to use an application client in JBoss-5.

    If you don't want to use an Application Client Container and instead just run the application client class through a java command, injection won't be possible and you'll have to perform a JNDI lookup.

    And in both cases, you'll have to provide and use a remote business interface for your bean.

    Resources

    • How to use an application client in JBoss-5
    • Creating and Running an Application Client on the GlassFish Server

    Related questions

    • application-client

提交回复
热议问题