[jboss-user] [Beginners Corner] - Problem with EJB call EJB
peiguo
do-not-reply at jboss.com
Sat Apr 26 01:09:34 EDT 2008
Hi,
I was experimenting how to make a EJB to EJB call, and I started with let a EJB call itself. but no luck, could someone please help and point me to the right direction?
The EJB code (modified based on some ws code in jboss4guide):
package org.jboss.ws.hello;
|
|
| import javax.ejb.*;
|
|
| import javax.naming.*;
|
|
|
| public class HelloBean
| implements SessionBean, Hello
| {
|
| @EJB(beanName = "org.jboss.ws.hello.HelloBean")
| private HelloBean h;
|
| public int hello(int a, int b)
| {
|
| return a + b;
|
| }
|
|
| public int minus(int a, int b)
| {
| try {
|
| h.minus(2,1);
| } catch (Exception e) {
| e.printStackTrace();
| }
| return a - b;
|
| }
|
|
|
| public void ejbCreate() {
| System.out.println("create");
| };
|
| public void ejbRemove() {
| System.out.println("remove");
| };
|
|
| public void ejbActivate() {
| System.out.println("activate");
| }
|
|
| public void ejbPassivate() {
| System.out.println("passivate");
| }
|
|
| public void setSessionContext(SessionContext ctx) {}
|
| }
|
|
Here is the ejb-jar.xml (I am guessing that the ejb-ref portion is not needed if I am using @EJB annotation???):
| <?xml version="1.0" encoding="UTF-8"?>
|
| <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
|
| <display-name>chapter 12 EJB JAR</display-name>
|
| <enterprise-beans>
|
| <session>
|
| <ejb-name>HelloBean</ejb-name>
|
| <service-endpoint>org.jboss.ws.hello.Hello</service-endpoint>
|
| <ejb-class>org.jboss.ws.hello.HelloBean</ejb-class>
|
| <session-type>Stateless</session-type>
|
| <transaction-type>Container</transaction-type>
| <ejb-ref>
| <ejb-ref-name>local/HelloBean</ejb-ref-name>
| <ejb-ref-type>Session</ejb-ref-type>
| <home>org.jboss.ws.hello.HelloBean</home>
| <remote>org.jboss.ws.hello.HelloBean</remote>
| <ejb-link>HelloBean</ejb-link>
| <injection-target>local/HelloBean</injection-target>
| </ejb-ref>
|
| </session>
|
| </enterprise-beans>
|
| <assembly-descriptor>
|
| <method-permission>
|
| <unchecked/>
|
| <method>
|
| <ejb-name>HelloBean</ejb-name>
|
| <method-name>*</method-name>
|
| </method>
|
| </method-permission>
|
| <container-transaction>
|
| <method>
|
| <ejb-name>HelloBean</ejb-name>
|
| <method-name>*</method-name>
|
| </method>
|
| <trans-attribute>Required</trans-attribute>
|
| </container-transaction>
|
| </assembly-descriptor>
|
| </ejb-jar>
|
And here is the stack trace:
| 2008-04-25 21:52:54,257 ERROR [STDERR] java.lang.NullPointerException
| 2008-04-25 21:52:54,279 ERROR [STDERR] at org.jboss.ws.hello.HelloBean.minus(HelloBean.java:45)
| 2008-04-25 21:52:54,282 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| 2008-04-25 21:52:54,305 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| 2008-04-25 21:52:54,308 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| 2008-04-25 21:52:54,311 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
| 2008-04-25 21:52:54,314 ERROR [STDERR] at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
| 2008-04-25 21:52:54,316 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
| 2008-04-25 21:52:54,319 ERROR [STDERR] at org.jboss.wsf.container.jboss42.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:85)
| 2008-04-25 21:52:54,322 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
| 2008-04-25 21:52:54,325 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
| 2008-04-25 21:52:54,329 ERROR [STDERR] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
| 2008-04-25 21:52:54,332 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
| 2008-04-25 21:52:54,340 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
| 2008-04-25 21:52:54,342 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
| 2008-04-25 21:52:54,345 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
| 2008-04-25 21:52:54,347 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
| 2008-04-25 21:52:54,350 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:138)
| 2008-04-25 21:52:54,352 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
| 2008-04-25 21:52:54,388 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:960)
| 2008-04-25 21:52:54,393 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| 2008-04-25 21:52:54,396 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| 2008-04-25 21:52:54,399 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| 2008-04-25 21:52:54,411 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
| 2008-04-25 21:52:54,414 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| 2008-04-25 21:52:54,423 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| 2008-04-25 21:52:54,425 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| 2008-04-25 21:52:54,427 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| 2008-04-25 21:52:54,430 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| 2008-04-25 21:52:54,432 ERROR [STDERR] at org.jboss.wsf.container.jboss42.InvocationHandlerEJB21.invoke(InvocationHandlerEJB21.java:147)
| 2008-04-25 21:52:54,447 ERROR [STDERR] at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:220)
| 2008-04-25 21:52:54,449 ERROR [STDERR] at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:408)
| 2008-04-25 21:52:54,458 ERROR [STDERR] at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:272)
| 2008-04-25 21:52:54,463 ERROR [STDERR] at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
| 2008-04-25 21:52:54,466 ERROR [STDERR] at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
| 2008-04-25 21:52:54,474 ERROR [STDERR] at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
| 2008-04-25 21:52:54,477 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
| 2008-04-25 21:52:54,479 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| 2008-04-25 21:52:54,481 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| 2008-04-25 21:52:54,490 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| 2008-04-25 21:52:54,494 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| 2008-04-25 21:52:54,496 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| 2008-04-25 21:52:54,498 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
| 2008-04-25 21:52:54,508 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| 2008-04-25 21:52:54,510 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
| 2008-04-25 21:52:54,512 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| 2008-04-25 21:52:54,514 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
| 2008-04-25 21:52:54,524 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
| 2008-04-25 21:52:54,526 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
| 2008-04-25 21:52:54,528 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| 2008-04-25 21:52:54,530 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
| 2008-04-25 21:52:54,531 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| 2008-04-25 21:52:54,533 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
| 2008-04-25 21:52:54,535 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
| 2008-04-25 21:52:54,537 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4146967#4146967
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4146967
More information about the jboss-user
mailing list