on 08-18-2016 6:21 AM
Hi Guys,
I am using @WebServiceRef in my EJB WebModule,
@WebServiceRef (name="DataBrowserOB") DataBrowserService service;
When it is invoked from the same EJB it gets Executed, But when it is triggered from another EJB the "service" is null, Service is not getting Instantiated.
Could anyone let me know is there any other way we could Instantiate?
Thanks,
Nagishetty
Hi,
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public String businessMethodFromOtherEJB(Strig someFancyInput){
//TODO implement; call webServiceRef injected service
return null
}
Regards,
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have to lookup the name of the service in the JNDI Browser (JNDI Browser - Developing Java EE 5 Applications - SAP Library) the call itself can be done as described here: Looking up Objects - Developing Java EE 5 Applications - SAP Library
(Main Documentation: Naming and Directory Services (JNDI) - Developing Java EE 5 Applications - SAP Library)
Regards,
Christian
Hi Christian,
I have the below Logic,
@WebServiceRef(name = "dataBrowser_OB")
private DataBrowserOBService dataBrowserOBService;
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void cedbCallPI(){
InitialContext ctx;
try {
ctx = new InitialContext();
DataBrowserOBService dataBrowserOBService = (DataBrowserOBService) ctx
.lookup("java:comp/env/com.Sample.gmmd.databrowser.pi.ejb.DataBrowserPIBean/dataBrowserOBService");
dataBrowserOBService.getPort(DataBrowserOB.class);
dataBrowserOBService.getHTTP_Port().dataBrowserOB();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
But I get a NameNotFoundException.
Regards,
Nagishetty
Hi again,
You're using all variants - stick to the JNDI approach.
The remaining method should be correct.
public void cedbCallPI(){
InitialContext ctx;
try {
ctx = new InitialContext();
DataBrowserOBService dataBrowserOBService = (DataBrowserOBService) ctx
.lookup("java:comp/env/com.Sample.gmmd.databrowser.pi.ejb.DataBrowserPIBean/dataBrowserOBService");
dataBrowserOBService.getPort(DataBrowserOB.class);
dataBrowserOBService.getHTTP_Port().dataBrowserOB();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
The only thing i'm not sure is if your lookup value is correct. What does the JNDI Browser return if you search for "DataBrowserOBService"?
Regards,
Christian
i see.
you say you've also tried it with the full object name (which should work) "ejbContexts/com.XXXXXXXXgmmd~databrowser~pi~ejb~app/com.XXXXXXXX~gmmd~databrowser~pi~ejb~ejbjar.jar/DataBrowserPIBean/java:comp/env/dataBrowser_OB" - what does the error message say? is it something like "com.sap.engine.services.jndi.persistent.exceptions720.NameNotFoundException: Path to object does not exist. First missing component is" or something else?
regars,
Christian
Yeah,
/**
* Session Bean implementation class DataBrowserPIBean
*/
@WebService(endpointInterface = "com.xxxxxx.gmmd.databrowser.pi.ejb.DataBrowserPIBeanLocal", portName = "DataBrowserPIBeanPort", serviceName = "DataBrowserPIService", targetNamespace = "http://xxxxxx.com/gmmd/databrowser/pi/ejb/")
@Stateless
public class DataBrowserPIBean implements DataBrowserPIBeanLocal {
/**
* Default constructor.
*/
public DataBrowserPIBean() {
}
@Override
public void cedbCallPI(String fileName, String userID) {
InitialContext ctx;
try {
ctx = new InitialContext();
DataBrowserOBService dataBrowserOBService = (DataBrowserOBService) ctx
.lookup("ejbContexts/com.xxxxxx/gmmd~databrowser~pi~ejb~app/com.xxxxxx~gmmd~databrowser~pi~ejb~ejbjar.jar/DataBrowserPIBean/java:comp/env/dataBrowser_OB");
dataBrowserOBService.getPort(DataBrowserOB.class);
DataBrowser_UD dB = new DataBrowser_UD();
UserDetails uD = new UserDetails();
uD.setTableName(fileName);
uD.setUserID(userID);
dB.setUserDetails(uD);
dataBrowserOBService.getDataBrowser_OB_Port().dataBrowserOB(dB);
} catch (NamingException e) {
// TODO Auto-generated catch block
System.err.println("NameNotFoundException : " + e);
}
}
}
Regards,
Nagishetty
Hi Christian,
1. The method "cedbCallPI" is being called by another EJB method, I could able to call this method from different EJB method, But the only problem is with Service class object which is Null [Not Instantiated] when Invoked.
2. Both EJB's are deployed in the same Container.
3. Am working with 7.31 PI version.
And with @WebServiceRef i could able to Execute Successfully from Web Service Navigator, But now with the JNDI approach i get Exception even from Web Service Navigator.
Thanks & Regards,
Nagishetty
what does the exception say?
have you published your web service? i'm not working with SAP PI but SAP Portal and here we have to publish the WS first (otherwise the WS Navigator test fails) ref: Publishing Web Services from the SAP NetWeaver Administrator - Administration - SAP Library
regards,
Christian
Have you verified that your service is up and running. Maybe check if can finde and execute it in the WSNavigator.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.