Quantcast
Channel: SCN : Discussion List - SAP HANA Cloud Platform Developer Center
Viewing all articles
Browse latest Browse all 3131

JNDI lookups in an EJB

$
0
0

Hi everyone,

 

I'm having a problem with JNDI-lookups from the context of an EJB. I think this question is related to this topic http://scn.sap.com/thread/3417030 , but there was no solution provided.

 

Basically I want to create a HttpDestination like this:

 

Context ctx = new InitialContext();

HttpDestination destination = (HttpDestination) ctx.lookup("java:comp/env/connect");

HttpClient createHttpClient = destination.createHttpClient();

 

web.xml:

 

  <resource-ref> 

    <res-ref-name>connect</res-ref-name> 

    <res-type>com.sap.core.connectivity.api.http.HttpDestination</res-type>

  </resource-ref> 

 

 

Everything works fine, when I make the lookup in a Servlet. But in the context of an EJB (annotated with @Stateless) this lookup fails with a NameNotFoundException. The lookup for java:comp/env works, but "connect" seems to be missing in the context. I also have this issue with the UserProvider.

 

 

As a workaround I can use UserManagementAccessor.getUserProvider() for the UserProvider, which works fine. There is also a factory-method for the HttpDestination:

 

com.sap.core.connectivity.httpdestination.api.HttpDestinationFactory.getHttpDestination("connect");

 

This is potentially working, but the api is deprecated.

 

 

 

For the JNDI-lookups I feed I'm generally missing something.

Is there a way to make these lookups work, or is there a recommended workaround for the HttpDestination?

 

Thanks in advance


Viewing all articles
Browse latest Browse all 3131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>