-
1. Re: DI and annotations not working
jaikiran Sep 10, 2008 3:06 AM (in response to irinac)Please post the code where you are injecting the resources. Is it a EJB in which you are injecting the objects? If yes, how do you get hold of the EJB and invoke the EJB in your client? Post that code too.
-
2. Re: DI and annotations not working
irinac Sep 10, 2008 10:30 AM (in response to irinac)Here is the code for the java side
@Stateless @WebService(serviceName="TestService") @SOAPBinding( style=javax.jws.soap.SOAPBinding.Style.RPC, use=javax.jws.soap.SOAPBinding.Use.LITERAL) public class TestWebService extends Remote implements TestWebServiceInterface { @EJB private DomainManager domainManager; public TestWebService() { } @WebMethod public String sayHello() { String hellostring = domainManager.sayHello(); return hellostring; } } @Local public interface DomainManager { public String sayHello(); } @Stateless public class DomainManagerBean implements DomainManager{ public DomainManagerBean() { } public String sayHello() { return "Hello"; } }
I am invoking the web service from a flex application, not sure if pasting that code will help ...
Upon invokation this is the line where the null pointer is thrownString hellostring = domainManager.sayHello();
Alternatively, this is the code i was using inside the WebMethod to look up the beanInitialContext ctx = new InitialContext(); domainManager = (DomainManager) ctx.lookup("RPortal/DomainManagerBean/local");
and it works ... -
3. Re: DI and annotations not working
jaikiran Sep 11, 2008 6:16 AM (in response to irinac)I am invoking the web service from a flex application, not sure if pasting that code will help ...
The code would help. I am mainly interested in seeing how you are getting hold of the TestWebService bean in the code. -
4. Re: DI and annotations not working
irinac Sep 11, 2008 11:06 AM (in response to irinac)The client side code needed to invoke the web service (TestService.as and others) were generated from a wsdl url using tools in Flex Builder 3.
I am invoking the web service from my main application mxml file/** * TestService.as * This file was auto-generated from WSDL by the Apache Axis2 generator modified by Adobe * Any change made to this file will be overwritten when the code is re-generated. */ package RPortal.atl{ import mx.rpc.AsyncToken; import flash.events.EventDispatcher; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import flash.utils.ByteArray; import mx.rpc.soap.types.*; /** * Dispatches when a call to the operation sayHello completes with success * and returns some data * @eventType SayHelloResultEvent */ [Event(name="SayHello_result", type="RPortal.atl.SayHelloResultEvent")] /** * Dispatches when the operation that has been called fails. The fault event is common for all operations * of the WSDL * @eventType mx.rpc.events.FaultEvent */ [Event(name="fault", type="mx.rpc.events.FaultEvent")] public class TestService extends EventDispatcher implements ITestService { private var _baseService:BaseTestService; /** * Constructor for the facade; sets the destination and create a baseService instance * @param The LCDS destination (if any) associated with the imported WSDL */ public function TestService(destination:String=null,rootURL:String=null) { _baseService = new BaseTestService(destination,rootURL); } //stub functions for the sayHello operation /** * @see ITestService#sayHello() */ public function sayHello():AsyncToken { var _internal_token:AsyncToken = _baseService.sayHello(); _internal_token.addEventListener("result",_sayHello_populate_results); _internal_token.addEventListener("fault",throwFault); return _internal_token; } /** * @see ITestService#sayHello_send() */ public function sayHello_send():AsyncToken { return sayHello(); } /** * @see ITestService#addsayHello() */ public function addsayHelloEventListener(listener:Function):void { addEventListener(SayHelloResultEvent.SayHello_RESULT,listener); } RPortal.mxml <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" borderStyle="none"> <mx:Script> <![CDATA[ import RPortal.atl.*; [Bindable] private var testService:TestService = new TestService(); private function testWebService():void { // Attach the event handler testService.addsayHelloEventListener(handleWebServiceResult); // Invoke the service call testService.sayHello(); } private function handleWebServiceResult(event:SayHelloResultEvent):void { trace(event.result); } ]]> </mx:Script>
please let me know if this level of detail is enough or if I need to post anything else.
I feel like I'm making a silly mistake somewhere in deployment but don't know where to look ... -
5. Re: DI and annotations not working
jaikiran Sep 11, 2008 11:13 AM (in response to irinac)I'm not yet used to web services. But based on what i see, because of the way webservice TestWebService (which also is a EJB) is being constructed and invoked, the dependency injection never kicks in. My understanding is that the dependency injection will kick in only when the TestWebService is used as a EJB.
Someone with a better web services experience, here, might be able to help you understand the exact problem.