Results 1 to 1 of 1
  1. #1
    sbutt is offline Banned
    Join Date
    Apr 2009
    Rep Power

    Default 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 of 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 another EJB class.

    The problem is that I dont see this other EJB class object 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.

    Java Code:
    @WebService(targetNamespace = "")
    @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.BARE)
    // standard EJB3 annotations
    // 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;
      private OTAProfileBuilder     otaProfileBuilder;
      public OTATTProfileReadRS otaTTReadRQ(Holder<Security> wsseHeader, OTATTReadRQ request)
         security = wsseHeader.value;
         BigDecimal requestVersion = request.getVersion();
         OTATTProfileReadRS otaProfileReadRS = new OTATTProfileReadRS();
         PotsdamInstanceKey profileIntanceKey;
          profileIntanceKey = getKeyHandler(requestVersion).buildUserKey(wsseHeader);
          PotsdamInstance userInstance = loadProfileFromPotsdam(profileIntanceKey);
     private PotsdamInstance loadProfileFromPotsdam(PotsdamInstanceKey userCredentials) throws PotsdamException
    	  PotsdamInstance potsdamInstance = null;
        Holder<com.ttt.potsdam.common.messages.Security> wsseHeader = buildWsseHeader(security);
        ProfileResponse potsdamInstanceRS = profileService.loadProfile(wsseHeader, userCredentials);
    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.

    profileService is object of another EJB project, which looks somethign like this:

    Java Code:
    @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);
    	private CacheProfileService cacheProfileService;
    	@EJB(mappedName = "/PersistenceUnitsManagerBean/local")
    	private PersistenceUnitsManager persistenceUnitsManager;
    	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:
    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:
    Java Code:
    PotsdamProfileServiceBean profileService = new PotsdamProfileServiceBean();
    but I get jndi binding and lots of other exception.

    Please help.
    Last edited by sbutt; 07-04-2012 at 04:36 PM.

Similar Threads

  1. Help calling a method please
    By ctmarco3 in forum New To Java
    Replies: 3
    Last Post: 03-18-2011, 11:55 PM
  2. Thread problem, calling method in run method
    By majk in forum Threads and Synchronization
    Replies: 4
    Last Post: 09-27-2010, 12:40 PM
  3. Calling The main method from another method
    By SwissR in forum New To Java
    Replies: 3
    Last Post: 07-27-2010, 12:03 PM
  4. calling method from main method
    By bob_bee in forum New To Java
    Replies: 4
    Last Post: 10-02-2009, 06:30 PM
  5. Replies: 29
    Last Post: 09-25-2008, 08:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts