Skip to Content
author's profile photo Former Member
Former Member

Problem with InitialContest bind method

I have a servlet that do a bind to the InitialContextm but i'm not able to retrieve it from the ejb.

All is in a Enterprise Application (EAR).

in the web.xml:

....

<resource-env-ref>

<description>Unique Identification for cache</description>

<resource-env-ref-name>cache/UniqueId</resource-env-ref-name>

<resource-env-ref-type>java.lang.String</resource-env-ref-type>

</resource-env-ref>

...

in the web-j2ee-engine.xml:

...

<resource-env-ref>

<resource-env-ref-name>cache/UniqueId</resource-env-ref-name>

<jndi-name>com.dat.abs.run.ABSCache</jndi-name>

</resource-env-ref>

...

In my Servlet:

...

new InitialContext().bind("com.dat.abs.run.ABSCache", "MyTextValue");

...

in a stateless ejb session:

...

String vName = (String) (new InitialContext()).lookup("java:comp/env/cache/UniqueId");

...

But ejb cannot retrieve it, a name not found exception.

i try also to execute the bind in the same stateless ejb session, but the same problem occurs.

I get a look to the JNDI registry.

When i execute the bind from the Servlet, the bind is done under the webContainer context and when i do it in the EJB

the bind is done under the stateless ejb session context.

Instead i would like to register this bind as "server" root, like all other EJB (entity and session).

Bindig from the servlet works fine in JBoss and Websphere, but not in SAP NetWeaver Sneak Preview 6.40 SR1.

Is this a bug or there is another way to obtain this result?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 18, 2005 at 09:04 AM

    Hi Roberto,

    to get the JNDI root you need to set the "domain" parameter to "true" when creating the InitialContext. If you do not set it, then the application will get the root context of its namespace (in your case, the servlet get the context relative to the webContainer namespace.)

    This is also described in the J2EE Engine's documentation:

    http://help.sap.com/saphelp_nw04/helpdata/en/8d/41ee1b22797c4b9d9b7ad67aa7333f/frameset.htm

    Hope that helps!

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.