Results 1 to 2 of 2
Thread: calling EJB method
-
calling EJB method
Hi All,
I have never worked with EJBs so I am kind of stuck with one problem.
I have to make use of one existing EJB project through my external standard java class. The existing EJB project makes use to some other packages which are also EJB projects and I am not allowed to change any functionality of the EJB project but to use them as it is.
I am just initilizing the class object of the EJB project and calling its method. Within the EJB project there is a method which is calling another method of the EJB class.
The problem is I dont see the EJB objects getting initilized first and then calling its method as it happens in a normal scenario, hence when that method gets called i get a null pointer execption.
Let me give you some idea by posting some code snippet.
I get an error message before the sequence reaches loadProfile(..), which in my sense is due to the fact that 'profileService' never was initilized in the EJB project.Java Code:@WebService(targetNamespace = "http://www.ttt.de/ota") @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.BARE) // standard EJB3 annotations @Local(AMSAgencyWSPortType.class) @Stateless @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) // jboss propriatary annotations @WebContext(transportGuarantee = "NONE", secureWSDLAccess = false) public class AMSProfileServiceBean extends AbstractProfileBuilder implements AMSAgencyWSPortType { private static Log log = LogFactory.getLog(AMSMappingServiceBean.class); @EJB(mappedName = "PotsdamProfileService/local") private PotsdamProfileService profileService; private Security security; @EJB private OTAProfileBuilder otaProfileBuilder; ... ... @Override public OTATTProfileReadRS otaTTReadRQ(Holder<Security> wsseHeader, OTATTReadRQ request) { security = wsseHeader.value; BigDecimal requestVersion = request.getVersion(); OTATTProfileReadRS otaProfileReadRS = new OTATTProfileReadRS(); otaProfileReadRS.setVersion(requestVersion); PotsdamInstanceKey profileIntanceKey; try { profileIntanceKey = getKeyHandler(requestVersion).buildUserKey(wsseHeader); PotsdamInstance userInstance = loadProfileFromPotsdam(profileIntanceKey); ... ... private PotsdamInstance loadProfileFromPotsdam(PotsdamInstanceKey userCredentials) throws PotsdamException { PotsdamInstance potsdamInstance = null; try{ Holder<com.traveltainment.potsdam.common.messages.Security> wsseHeader = buildWsseHeader(security); ProfileResponse potsdamInstanceRS = profileService.loadProfile(wsseHeader, userCredentials); ...
profileService is object of another EJB project, which looks somethign like this:
Java Code:@Stateless @LocalBinding(jndiBinding = "PotsdamProfileService/local") // jboss 4.2 @org.jboss.annotation.ejb.LocalBinding(jndiBinding = "PotsdamProfileService/local") public class PotsdamProfileServiceBean implements PotsdamProfileService { private static Log log = LogFactory.getLog(PotsdamProfileServiceBean.class); @EJB private CacheProfileService cacheProfileService; @EJB(mappedName = "/PersistenceUnitsManagerBean/local") private PersistenceUnitsManager persistenceUnitsManager; @EJB private PotsdamService potsdamService; public ProfileResponse loadProfile(Holder<Security> wsseHeader, PotsdamInstanceKey cacheInstanceKey) { log.debug("inside loadProfile"); ...
Now I am calling the main EJB like this:
Java Code:... PotsdamotaTTReadRQ(); ... public OTATTProfileReadRS PotsdamotaTTReadRQ() { AMSProfileServiceBean a = new AMSProfileServiceBean(); Holder<Security> wsseHeader = new Holder<Security>(); ... ... OTATTProfileReadRS response = a.otaTTReadRQ(wsseHeader, request); return response; }
So my confusion is how can I make use of profileService.loadProfile(wsseHeader, userCredentials); ??
I tried to initilize:but I get jndi binding and lots of other exception.Java Code:PotsdamProfileServiceBean profileService = new PotsdamProfileServiceBean();
Please help.Last edited by sbutt; 07-04-2012 at 03:48 PM.
-
Re: calling EJB method
One post is enough. Locking this one.
Similar Threads
-
calling EJB method
By sbutt in forum Enterprise JavaBeans (EJB)Replies: 0Last Post: 07-04-2012, 03:32 PM -
Thread problem, calling method in run method
By majk in forum Threads and SynchronizationReplies: 4Last Post: 09-27-2010, 11:40 AM -
Calling The main method from another method
By SwissR in forum New To JavaReplies: 3Last Post: 07-27-2010, 11:03 AM -
calling method from main method
By bob_bee in forum New To JavaReplies: 4Last Post: 10-02-2009, 05:30 PM -
Calling a method in a different class from within a method problem
By CirKuT in forum New To JavaReplies: 29Last Post: 09-25-2008, 07:55 PM


LinkBack URL
About LinkBacks

Bookmarks