https://issues.apache.org/bugzilla/show_bug.cgi?id=47396

           Summary: Ability to load & bind an external naming context
           Product: Tomcat 6
           Version: 6.0.20
          Platform: PC
        OS/Version: Windows Vista
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Catalina
        AssignedTo: [email protected]
        ReportedBy: [email protected]


Created an attachment (id=23839)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23839)
Patch to allow binding of external contexts

I have created a patch to bind an external context to the JNDI tree using the
<Resource /> tags.

For example the following Context.xml binds a remote JBoss naming context to
the "java:/comp/env/ejb"

<Context>
    <Resource name="ejb" type="javax.naming.Context"
factory="org.jnp.interfaces.NamingContextFactory"
URL="jnp://apphost:1099/myapp"/>
</Context>


The reason why I am using this instead of using the <Ejb /> references is
twofold:

1) The tomcat naming context stores the retrieved EJB in its context, returning
the same object with each lookup() call.
FROM JSR 220: NOTE: When a stateful session bean is looked up or otherwise
obtained through the explicit JNDI lookup mechanisms, the container must
provide a new stateful session bean instance, as required by the Java EE
specification (Section “Java Naming and Directory Interface (JNDI) Naming
Context” [12]).

2) After trying a quick hack to fix (1), I realised that each call it was
creating a fresh NamingContext and associated objects for each call. Which is
an unnecessary given that it should be essentially static.

************
THE PATCH
************
NamingContextListener -- looks up the resource and rebinds (so it is stored as
type=NamingEntry.CONTEXT).
NamingContext -- I needed to wack a toString() call in as JBoss's JNP starting
complaining that it wasn't a CompoundName because tomcat uses CompositeName.
Not the best solution but it works.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to