Caching initial contexts

I have read the posts about caching initial context lookups and have
implemented the solution and seen some benefits.
I am dealing with a third party application that I cannot change.
When I put my InitialContextFactory in the architecture I also logged
how many getInitialContext() calls were being made - I was absolutely
shocked - often 4+ per user transaction. I suspect that the code gets
one, does a call and dereferences all over the place.
90% of InitialContexts had the same environment passed to the getIC()
call so it struck me that what I should do is create a pool of IC, and
in my factory just serve one from the pool.
So, the question is, what is the best way of detecting when the IC has
been dereferenced so I know I can serve it again from my pool?
I presume this is a generic pool problem when you can't guarantee that
your client's will be good citizens and call a close() method or
similar.
I've posted here as it is performance related; also, is there any
reason why what I am doing is not a good idea?
Can the client do something with the IC which means it is not suitable
for use by another client? If so, can I detect this so I may discard?
As always, many thanks in advance.
Presuming I can get it to work I will post the code so that we can all
share ;-)
Cheers
Ed

Why don't you instrument your factory then to give out your own
implementation of InitialContext that will in fact only wrap a "loaner"
InitialContext every time a method is invoked on it and before returning
the value to the caller will put the real InitialContext back to the
pool to be reused by another one.
Then your clients can do whatever they want with those ICs and still
would not cause so big performance hits.
It's just an idea that just came to mind and I haven't tested it so it
might have flaws but it looks viable.
--dejan
Ed Barrett wrote:
The application is a third-party product that cannot be changed.
By introducing the factory you gave below (thanks!) we put the application
back under the load test and saw minimal improvements (like 1% response
time).
I then instrumented the factory with a system.out on finalize and noticed
that a factory instance is created for each call to getInitialContext() - is
this the way that WLS/J2EE works? I would have hoped that factories were
shared or something. What we did see is that for one user request a number
(sometimes 5!) ICs were being created ;-( Obviously the lookup cache is a
class instance and shared across the lot.
So then I started to think about pre-creating ICs and haveing a pool for the
default ones (environment specifies URL and no security details or the
like). Trouble is how to implement such when you cannot change the client
code to call a factory return method (such as returnToPool()).
Any ideas would be appreciated
"Dimitri I. Rakitine" <[email protected]> wrote in message
news:[email protected]...
I've ran into this problem while porting 5.1 application (JNDI lookups
were
super-cheap) to 6.1 (where they are not so cheap due to
serialization/deserialization)
and did this test to see if this indeed was the problem. As you saw I
didn't bother to
cache InitialContext's - I just cached JNDI lookups and that resulted in
very significant
performance improvements.
Which application are you testing it with?
Graham <[email protected]> wrote:
Dimitri,
We did this but did not see that much improvement over the default way -
we
are using 6.1 sp2.
We put some messages in our factory and found that the client code often
created over 4 ICs for one user click - aaggghhhh!! As I say we cannot
change their code but if we could take the time to create an IC away
from
the online response we feel we would save some time.
We also observed a new instance of the IC factory being created every
time a
new IC was created - is this what you would expect?
I think this is what NamingManager.getInitialContext() is supposed to do.
Cheers
Ed
"Dimitri I. Rakitine" <[email protected]> wrote in message
news:[email protected]...
Caching InitialContext's will probably not quite solve the problem,
because lookup()'s are expensive (in 6.x), so, caching lookup results
will result in performance improvements.
If you cannot change the 3'rd party code and all it does is:
... DataSource ds = (DataSource)new InitialContext().lookup(".....");
or similar, you can add caching by implementing your own InitialContext
factory,
for example: (extremely simplistic)
Startup class :
System.setProperty("java.naming.factory.initial",
"myjndi.InitialContextFactory");
where
myjndi.InitialContextFactory is :
public class InitialContextFactory implements
javax.naming.spi.InitialContextFactory {
public Context getInitialContext(Hashtable env) throws
NamingException
Context ctx = new
weblogic.jndi.WLInitialContextFactory().getInitialContext(env);
return
(Context)Proxy.newProxyInstance(ctx.getClass().getClassLoader(),
new Class[]
{ Context.class },
new
ContextHandler(ctx));
and myjndi.ContextHandler is:
public class ContextHandler implements InvocationHandler {
Context ctx;
static Hashtable cache = new Hashtable();
public ContextHandler(Context ctx) {
this.ctx = ctx;
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
try {
Object retVal;
if("lookup".equals(method.getName()) && args[0] instanceof
String) {
retVal = cache.get(args[0]);
if(retVal == null) {
retVal = method.invoke(ctx, args);
cache.put(args[0], retVal);
} else {
retVal = method.invoke(ctx, args);
return retVal;
} catch(InvocationTargetException oops) {
throw oops.getTargetException();
Ed <[email protected]> wrote:
Adarsh,
We agree it is a brilliant idea - now just to work out how to do it.
As you cannot always guarantee to be able to change the client code
you cannot use normal pooling techniques:
getObjectFromPool()
// do work
returnObjectToPool()
So, the client code needs an InitialContext. We can put in our own
Factory and intercept the getInitialContext() calls. This method
must
return class javax.naming.Context - therefore the only way I can see
to spot when the class is dereferenced is to extend the class and add
a finalize() method that notifies the factory.
The trouble I believe is that the class cannot be "rescued" in the
finalize() method (i.e. "I'm dying - take me back" ;-). If it simply
told the factory to add another one to its pool this would mean that
the new IC create "hit" would be in garbage collection (i.e. the
users
will pay somewhere along the line) - is this correct?
Anyone any ideas on a solution? I have discovered out code create
HUNDREDS of contexts in an hour and discards them very quickly. Be
nice to be able to cache them!
Cheers
Ed
"Adarsh Dattani" <[email protected]> wrote in message
news:<[email protected]>...
Ed,
This a brilliant idea. We are planning something similar too. We
first
want to create a pool of LDAP connections as apps make extensive
calls
to
LDAP. Did you check-out the object pooling api at Jakarta Commons.
It
deserves a close look.
http://jakarta.apache.org/commons/pool/index.html
Thanks,
Adarsh
"Ed" <[email protected]> wrote in message
news:[email protected]...
I have read the posts about caching initial context lookups and
have
implemented the solution and seen some benefits.
I am dealing with a third party application that I cannot change.
When I put my InitialContextFactory in the architecture I also
logged
how many getInitialContext() calls were being made - I was
absolutely
shocked - often 4+ per user transaction. I suspect that the code
gets
one, does a call and dereferences all over the place.
90% of InitialContexts had the same environment passed to the
getIC()
call so it struck me that what I should do is create a pool of IC,
and
in my factory just serve one from the pool.
So, the question is, what is the best way of detecting when the IC
has
been dereferenced so I know I can serve it again from my pool?
I presume this is a generic pool problem when you can't guarantee
that
your client's will be good citizens and call a close() method or
similar.
I've posted here as it is performance related; also, is there any
reason why what I am doing is not a good idea?
Can the client do something with the IC which means it is not
suitable
for use by another client? If so, can I detect this so I may
discard?
As always, many thanks in advance.
Presuming I can get it to work I will post the code so that we can
all
share ;-)
Cheers
Ed
Dimitri
Dimitri

Similar Messages

  • Security stack and caching initial context

    We are using weblogic60 sp2, when we using Optimizeit tool to profile weblogic
    server and we found build up initial context is very expensive, can we cache the
    initial context? Is it thread safe? I know there is a issue related with security
    stack, to work around this, could we just do this, cache the initial context,
    and before call any remote method, we just push a valid user to the stakc of current
    thread, could this scheme work?
    Thanks

    We are using weblogic60 sp2, when we using Optimizeit tool to profile weblogic
    server and we found build up initial context is very expensive, can we cache the
    initial context? Is it thread safe? I know there is a issue related with security
    stack, to work around this, could we just do this, cache the initial context,
    and before call any remote method, we just push a valid user to the stakc of current
    thread, could this scheme work?
    Thanks

  • Servlet - EJB, caching home & context problem

    Hello,
    I just run into the following problem:
    I created a thin client which accesses the EJB's via a servlet.
    In this servlet I cached the InitialContext und and the reference
    to the Home interface. While creating the initial context I provided
    login/password to access the EJB so it can't be accessed from the guest
    user.
    The first method call works as expected, any further call results
    in a RemoteException - Insufficent permissions.
    Any hints? I'm using 5.1, SP6.
    Zhanxs in advance
    Marcel

    The security creditials you suppplied to the IntialContext are only applied
    to the thread that created the InitialContext. I have only found one
    work-around - Construct an otherwise useless IntialContext each time a
    thread attempts to use and EJB or its home. This is inefficient and almost
    (not quite) destroys the advantage of caching the stubs.
    Is there any other solution? Any thing coming down the pike?
    Chuck McCorvey
    "Marcel Zielinski" <[email protected]> wrote in message
    news:[email protected]..
    Hello,
    I just run into the following problem:
    I created a thin client which accesses the EJB's via a servlet.
    In this servlet I cached the InitialContext und and the reference
    to the Home interface. While creating the initial context I provided
    login/password to access the EJB so it can't be accessed from the guest
    user.
    The first method call works as expected, any further call results
    in a RemoteException - Insufficent permissions.
    Any hints? I'm using 5.1, SP6.
    Zhanxs in advance
    Marcel

  • EJB initial Context

    Any one have set their initial context for EJB for J2eesdk kit similar to Weblogic initial context please mail me i will be grateful to you
    mail:[email protected]

    Have a look at the ServiceLocator pattern, this caches references found and has a method getInitialContext() which instantiates an InitialContext and sets it as a member value of the ServiceLocator which itself is a Singelton.

  • Reusing the Initial Context Object

    Hi all
    Environment: Weblogic 452
    JNDI implementation of Weblogic 452 is based on Javasoft JNDI 1.1 and
    SPI specifications.(refer: Developer docs for 452).Javadoc of
    InitialContext for JNDI 1.1 says (refer -
    http://java.sun.com/products/jndi/javadoc/index.html)
    An InitialContext instance is not synchronized against concurrent access
    by multiple threads. Multiple threads each manipulating their own
    InitialContext
    instances need not synchronize. Threads that need to access a single
    InitialContext instance concurrently should synchronize amongst
    themselves
    and provide the necessary locking
    1. Does reusing the InitialContext object accross threads for lookup and
    then execution of remote methods cause any problems? or should we
    synchronize access?
    How weblogic 452 handles this.
    2. Let say i do this
    a. get InitialContext
    b. do lookup
    c. get remote reference
    d. close context
    e. execute methods on the remote reference got in step c.
    does doing d ie..closing context cause problems in step e or later
    on....
    3. What happens if we dont close the intial context...
    Does WLS 452 intelligently garbage collect them and release any
    resources held internally by the initial context object?
    How much is the overhead?
    Is Initial Context heavy ie.. holds resources like sockets/etc...?
    thanks in advance

    I do not have an exact answer for most of your questions. From my
    experience and from research, I would suggest that the following is safe:
    Within an HTTP request, instantiate an InitialContext and using it for the
    duration of the request only (i.e. same auth info, same thread). I believe
    the same holds true for home interfaces. That is within the "web
    container", though. The choice of "caching" the context in the "ejb
    container" is a even easier for threads (ejb guarantee -- only one thread
    with access to your ejb at a time), but harder due to lack of clear spec on
    auth issues.
    Cameron Purdy, LiveWater
    "S Rajesh" <[email protected]> wrote in message
    news:[email protected]...
    Hi all
    Environment: Weblogic 452
    JNDI implementation of Weblogic 452 is based on Javasoft JNDI 1.1 and
    SPI specifications.(refer: Developer docs for 452).Javadoc of
    InitialContext for JNDI 1.1 says (refer -
    http://java.sun.com/products/jndi/javadoc/index.html)
    An InitialContext instance is not synchronized against concurrent access
    by multiple threads. Multiple threads each manipulating their own
    InitialContext
    instances need not synchronize. Threads that need to access a single
    InitialContext instance concurrently should synchronize amongst
    themselves
    and provide the necessary locking
    1. Does reusing the InitialContext object accross threads for lookup and
    then execution of remote methods cause any problems? or should we
    synchronize access?
    How weblogic 452 handles this.
    2. Let say i do this
    a. get InitialContext
    b. do lookup
    c. get remote reference
    d. close context
    e. execute methods on the remote reference got in step c.
    does doing d ie..closing context cause problems in step e or later
    on....
    3. What happens if we dont close the intial context...
    Does WLS 452 intelligently garbage collect them and release any
    resources held internally by the initial context object?
    How much is the overhead?
    Is Initial Context heavy ie.. holds resources like sockets/etc...?
    thanks in advance

  • Can I get a weblogic Initial context without importing all weblogic classes ?

    can I get a weblogic Initial context (with weblogic.jndi.WLInitialContextFactory)
    without importing all weblogic classes ?

    I ran my client through all its functions.
    I then took the access.log file and parsed out a list of all the class
    files that were downloaded and built a script to create my
    weblogiclient.jar file.
    Before running the client we had to:
    With WL5.1 I think we had to unjar the weblogicaux.jar file into the
    serverclasses directory so the client could load them all individually.
    Make sure you clean up after you are done with this.
    With WL 6 we did not have to do that.
    The access.log file is the key to building your own client jar file.
    We also require the use of the Java 1.3 plug-in by our clients (for
    Applets) so we can do multiple Jar caching.
    Tom
    Dominique Jean-Prost wrote:
    Hello tom
    What do you mean by "use the Weblogic class loader" ?
    Could you explain whath you exactly did to find all the classes you need ?
    regards.
    dom
    <nospam@nospam> a écrit dans le message news: 3ABF3EC2.9010200@nospam...
    You need the classes one way or another. BUT you do not have to
    redistribute the whole Weblogic.jar file. Use the Weblogic class
    loader then run your program. The weblogic access.log should have a
    listing of all the classes you need to use and you can build your own
    sub-jar. My experience is that this new jar is significantly smaller.
    Ours is around 600K instead of 15MB.
    Tom
    Dimitri Rakitine wrote:
    Yes, if, for example, you can network classload from WebLogic. Talking
    to a WebLogic
    server means WebLogic RMI (unless you use RMI/IIOP in which case youdont need any
    WebLogic classes) which needs WebLogic-specific classes, so you clientapplication needs
    to get them from somewhere - local classpath or remote WebLogic server.
    David Dahan <[email protected]> wrote:
    I mean without a classpath to all weblogic classes.
    can I get a weblogic Initial context (with
    weblogic.jndi.WLInitialContextFactory)
    without importing all weblogic classes ?

  • How to get Initial context of Local Interface in weblogic 8.1

    I have developed a local entity bean but i wouldnt able to initial context of that bean
    CAN ANYBODY HELP ME
    bean deployment descriptor
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
    <!--
    ** This file was automatically generated by EJBGen 2.16
    ** Build: 20031001-1049
    -->
    <ejb-jar>
    <enterprise-beans>
    <entity>
    <ejb-name>CabinBean</ejb-name>
    <home>my.CabinRemoteHome</home>
    <remote>my.CabinRemote</remote>
    <ejb-class>my.CabinBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Integer</prim-key-class>
    <reentrant>True</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>CabinBean</abstract-schema-name>
    <cmp-field>
    <field-name>bedCount</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>deckLevel</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>id</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>shipId</field-name>
    </cmp-field>
    <primkey-field>id</primkey-field>
    <security-identity>
    <use-caller-identity/>
    </security-identity>
    </entity>
    <entity>
    <ejb-name>CabinLocal</ejb-name>
    <local-home>my.CabinLocalHome</local-home>
    <local>my.CabinLocalLocal</local>
    <ejb-class>my.CabinLocal</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Integer</prim-key-class>
    <reentrant>True</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>CabinLocal</abstract-schema-name>
    <cmp-field>
    <field-name>bedCount</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>deckLevel</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>id</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>shipId</field-name>
    </cmp-field>
    <primkey-field>id</primkey-field>
    <ejb-local-ref>
    <ejb-ref-name>LocalCabin</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>CabinLocalHome</local-home>
    <local>CabinLocal</local>
    <ejb-link>LocalCabin</ejb-link>
    </ejb-local-ref>
    <security-identity>
    <use-caller-identity/>
    </security-identity>
    </entity>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>CabinLocal</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
    <method>
    <ejb-name>CabinBean</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    <ejb-client-jar>EjbClient</ejb-client-jar>
    </ejb-jar>
    ************************************** Client Code****************
    package com;
    import my.CabinBean;
    import my.CabinRemoteHome;
    import my.CabinRemote;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import java.rmi.RemoteException;
    import java.util.Properties;
    import javax.rmi.PortableRemoteObject;
    import weblogic.jndi.Environment;
    public class Test
        public static void main(String args[])
            try{
                 Context context = getInitialContext();
                          Object cab = context.lookup("CabinLocalHome");
                ///**********-- Exception is thrown at this point -******************
                System.out.println("============ done====");
                Context ct = getInitialContext();
                Object ref = ct.lookup("CabinHomeRemote");
                CabinRemoteHome home = (CabinRemoteHome)PortableRemoteObject.narrow(ref,CabinRemoteHome.class);
                //CabinRemote cab = home.create(new Integer(1));
                //cab.setName("Master Suite");
                //cab.setDeckLevel(new Integer(1));
                //cab.setShipId(new Integer(1));
                //cab.setBedCount(new Integer(1));
                Integer pk = new Integer(1);
                CabinRemote cab1 = home.findByPrimaryKey(pk);
                System.out.println("--->>>>>>>> "+cab1.getName());
                System.out.println("--->>>>>>>>  "+cab1.getShipId());
                System.out.println("--->>>>>>>>"+cab1.getBedCount());
                System.out.println("--->>>>>>>>"+cab1.getDeckLevel());
                System.out.println("---");  
          }catch(java.rmi.RemoteException e){e.printStackTrace();}
           catch(javax.naming.NamingException e){e.printStackTrace();}
           //catch(javax.ejb.CreateException e){e.printStackTrace();}
           catch(javax.ejb.FinderException e){e.printStackTrace();}
        public static Context getInitialContext() throws javax.naming.NamingException
           Properties p = new Properties();
           p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
           p.put(Context.PROVIDER_URL,"t3://localhost:7001");
           return new javax.naming.InitialContext(p);
    } ************************************** Error ***********************
    javax.naming.LinkException: [Root exception is javax.naming.LinkException:  [Root exception is javax.naming.NameNotFoundException: remaining name: /app/ejb/myejb.jar#CabinLocal/local-home]; Link Remaining Name: 'null']; Link Remaining Name: 'java:app/ejb/myejb.jar#CabinLocal/local-home'
         at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
         at weblogic.jndi.internal.ServerNamingNode_813_WLStub.lookup(Unknown Source)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:369)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:357)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at com.Test.main(Test.java:27)
    Caused by: javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining name: /app/ejb/myejb.jar#CabinLocal/local-home]; Link Remaining Name: 'null'
         at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:98)
         at weblogic.jndi.internal.ServerNamingNode.resolveObject(ServerNamingNode.java:292)
         at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:771)
         at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
         at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
         at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: javax.naming.NameNotFoundException: remaining name: /app/ejb/myejb.jar#CabinLocal/local-home
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:39)
         at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:57)
         at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:62)
         at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)
         at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:96)

    Hi,
    from what I gather, u have two jars
    1. EJBClient - this will have remote and home interfaces and will be used by the client
    2. myEJB - this iwll have all the classes - remote & home interfaces, the bean class and all the other classes required by the bean.
    Now, the question is, who is acting as the client of your EJB ? There are 3 possibilities
    1. A servlet
    2. Another EJB
    3. a simple java program.
    In the first 2 cases, you can go for Local Interfaces (more so in the second case than the first). The reason being that the the client and server will be in the same JVM. Thus, in the first case, if the Web container and the ejb container are in the same app server, EJBs can be local.
    However, in the third case, it is unlikey that you will have the client runnng and the same jvm as the server, because the server is using the jvm provided by weblogic.
    Thus, you cannot use local interfaces in this 3rd case. I have a feeling that this is what you are doing. If so, change the local interfaces to remote.
    See if this helps. Else, I will mail you some sample code. But I am afraid, sample code wont be of much help bcoz this seems to be a design problem.
    regards

  • Error in JMS receiver adapter: "Error creating initial context with environment"

    Hello,
    I have some trouble with a JMS receiver adapter (access to JMS-provider with JNDI).
    The message in adapter monitoring is:
    A channel error occurred. Detailed error (if any) :
    com.sap.aii.adapter.jms.api.connector.ConnectorException: Fatal Error looking up connection factoryJMSQueueConnectionFactory, for profile: ConnectionProfile of channel: CC_JMS_RCV_XLIMI00001on node: 503473150 having object id: 5b424f2f79b6350ca636ab35d528cfdd:
    ConnectorException: Error creating initial context with environment: java.naming.provider.url=wcsefdev.example.com:9064; java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory; for profile: ConnectionProfile of channel:
    CC_JMS_RCV_XLIMI00001on node: 503473150 having object id: 5b424f2f79b6350ca636ab35d528cfdd: javax.naming.NoInitialContextException:
    Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory<br> at com.sap.aii.adapter.jms.core.connector.JndiConnectorImpl.createConnectionFactory
    (JndiConnectorImpl.java:152)<br> ....
    Message processing failed. Cause:
    com.sap.aii.adapter.jms.core.fsm.DFA$InvalidTransitionException: No transition found from state: ERROR, on event: process_commence for DFA: CC_JMS_RCV_XLIMI00001:5b424f2f79b6350ca636ab35d528cfdd
    The third party assured me that the specified JNDI parameters are right and everything is configured on their site, so it should work...
    Might there be a problem with the JMS drivers?
    Regards,
    Marcus

    Hi Marcus,
    Have a look at below thread
    Connecting to PI 7.11 JMS Queue from other PI 7.11 Server

  • Error creating initial context with environment

    Hi,
    Currently we are working on a scenarios, where we need to integrate XI and webmethods using JMS.
    It was working fine. But recently they have restarted the webmethods server. After that we re getting an error message like,
    In Adapter Monitoring:
    Channel error occurred; detailed error description: com.sap.aii.adapter.jms.api.connector.ConnectorException: Error creating initial context with environment: {java.naming.provider.url=server:port, java.naming.factory.initial=com.sap.engine.services.jndi.InitialContextFactoryImpl, java.naming.security.principal=XYZ, java.naming.security.credentials=ABC}for profile: ConnectionProfile of channel: CC_RCV_JMS_INon node: 3010950 having object id: ABCXYZ: NamingException: Error getting the server-side naming service functionality during getInitialContext operation.
    at com.sap.aii.adapter.jms.core.connector.JndiConnectorImpl.createInitialContext(JndiConnectorImpl.java:66)
    In RWB
    MP: Exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: No transition found from state: STARTING, on event: process_commence for DFA: C_RCV_JMS_IN:e4413a5265a436459e271d5e0dd4859b
    Can one please tell me what the problem is?
    Thanks in advance.
    Regards,
    Prasad Babu.

    Hi,
    Check this link looks like same problem
    Re: file to JMS(for MQ series)
    Thanks
    Vikranth

  • Help on Initial Context in Weblogic 10

    Please see the following thread
    Exception in Initial Context Weblogic 10
    thx in adv.

    Hy!
    Your Code is right without webstart!
    With webstart you must insert befor 'ctx = new InitialContext(ht)';
    Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    By,
    Martin

  • Error in getting Initial Context

    Hello,
    I am facing the following exception while trying to get the Initial Context. Following
    is the snippet of code that I use for getting the Context -
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");p.
    put(Context.PROVIDER_URL, url);
    if (user != null) {
    p.put(Context.SECURITY_PRINCIPAL, user);
    if (password == null)
    password = "";
    p.put(Context.SECURITY_CREDENTIALS, password);
    return new InitialContext(p);
    The following is the exception that I encounter -
    javax.naming.AuthenticationException. Root exception is java.lang.SecurityException:
    attempting to add an object which is not an instance of java.security.Principal
    to a Subject's Principal Set
    Am i missing anything. Thanks for your time.
    See the attached file for the details of the exception
    Thanks,
    Ashutosh
    [trace.txt]

    Hi Tim,
    If you are running within a browser, you will not have access to anything
    outside the sandbox which includes making RMI calls. Try signing the applet.
    You can find more information on signing applets on the sun java website.
    Regards
    Arjuna
    "Tim" <[email protected]> wrote in message
    news:3c5ab818$[email protected]..
    >
    I get the following eror when I try to get the Initial Context in anapplet:
    >
    java.lang.ExceptionInInitializerError: java.security.Acc
    ess denied (java.util.PropertyPermission * read,write)
    atjava.security.AccessControlContext.checkPermission(AccessControlConte
    xt.java:272)
    atjava.security.AccessController.checkPermission(AccessController.java:
    399)
    Does anyone have any idea what would cause this? The code works finerunning
    from an application. From what I understand there might be a problem withmy
    policy file. However, it seems to look ok. Any ideas?

  • How OSB pass Initial Context parameters to EJB

    For security reasons I have to pass a ticket (through initial context) to legacy system from OSB for calling EJB, below is a code
    Hashtable env = new Hashtable(2);
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL, connectionUrl);
    env.put(javax.naming.Context.SECURITY_PRINCIPAL, ticket);
    env.put(javax.naming.Context.SECURITY_CREDENTIALS, "");
    InitialContext ctx = new InitialContext(env);
    Object homeRef = ctx.lookup("com.cih.services.contact.interfaces.IContactServiceRemote");
    IContactServiceRemoteHome home = (IContactServiceRemoteHome) javax.rmi.PortableRemoteObject
    .narrow(homeRef, IContactServiceRemoteHome.class);
    IContactServiceRemote ejb = home.create();
    Please let me know how we can pass Initial context parameter from Business service or proxy service to legacy system.
    Thanks

    Hi Russ
    Yes, I've done this too. Basic SQL though will not allow the updating of a table inside a function, so we have to get clever. The trick is to use the PRAGMA AUTONOMOUS TRANSACTION command. Here's an example:
    FUNCTION UPDATE_MYTABLE(P_VALUE IN NUMBER)
    RETURN VARCHAR2 IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    UPDATE SCHEMA_OWNER.MY_TABLE SET MY_VALUE = P_VALUE;
    COMMIT;
    RETURN('Done');
    END UPDATE_TABLE;
    When the update has been completed the Discoverer worksheet will respond with 'Done'.
    Everyone: don't forget to grant EXECUTE on this function to all of the necessary users, including the EUL owner, and also don't forget to import the function using the Admin edition so that it is available for the users. You will also need to make sure that all necessary users have been granted the UPDATE privilege on the table.
    I hope this helps
    Regards
    Michael

  • Getting Initial context

    Here is some debug output from a simple test I run against a WL6.1
    Server. Notice the 35 secs. it takes to get Initial Context.
    -- Initializing bean access.
    -- Succeeded getting naming context.
    -- Execution time: 35047 ms.
    -- Succeeded looking up jndi name.
    -- Execution time: 453 ms.
    -- Succeeded casting Home interface.
    -- Execution time: 94 ms.
    Second time I run the test from the same machine I get this.
    -- Initializing bean access.
    -- Succeeded getting naming context.
    -- Execution time: 1907 ms.
    -- Succeeded looking up jndi name.
    -- Execution time: 312 ms.
    -- Succeeded casting Home interface.
    -- Execution time: 31 ms.
    The pattern is consistent. First attempt to get the Initial Context
    from any of my client boxes will take about 30 secs more than any
    consecutive attempts.
    Here is the code for getting the Context:
    long startTime = 0;
    if (logging) {
         log("Initializing bean access.");
         startTime = System.currentTimeMillis();
    try {
         //get naming context
         Context ctx = getInitialContext();
         if (logging) {
              long endTime = System.currentTimeMillis();
              log("Succeeded getting naming context.");
              log("Execution time: " + (endTime - startTime) + " ms.");
              startTime =endTime;
         //look up jndi name
         Object ref = ctx.lookup("DynamicPool");
         if (logging) {
              long endTime = System.currentTimeMillis();
              log("Succeeded looking up jndi name.");
              log("Execution time: " + (endTime - startTime) + " ms.");
              startTime =endTime;
         //cast to Home interface
         dynamicPoolHome = (DynamicPoolHome) PortableRemoteObject.narrow(ref,
    DynamicPoolHome.class);
         if (logging) {
              long endTime = System.currentTimeMillis();
              log("Succeeded casting Home interface.");
              log("Execution time: " + (endTime - startTime) + " ms.");
    catch(Exception e) {
         if (logging) {
              log("Failed initializing bean access.");
         e.printStackTrace();
    Am I missing something here ?
    Regards,
    Klaus

    My first guess would be a DNS problem.
    Also, creating an InitialContext loads a fair amount of classes. If you're
    loading them over the network, that could also account for the slow-down.
    -- Rob
    Klaus Preisler wrote:
    Here is some debug output from a simple test I run against a WL6.1
    Server. Notice the 35 secs. it takes to get Initial Context.
    -- Initializing bean access.
    -- Succeeded getting naming context.
    -- Execution time: 35047 ms.
    -- Succeeded looking up jndi name.
    -- Execution time: 453 ms.
    -- Succeeded casting Home interface.
    -- Execution time: 94 ms.
    Second time I run the test from the same machine I get this.
    -- Initializing bean access.
    -- Succeeded getting naming context.
    -- Execution time: 1907 ms.
    -- Succeeded looking up jndi name.
    -- Execution time: 312 ms.
    -- Succeeded casting Home interface.
    -- Execution time: 31 ms.
    The pattern is consistent. First attempt to get the Initial Context
    from any of my client boxes will take about 30 secs more than any
    consecutive attempts.
    Here is the code for getting the Context:
    long startTime = 0;
    if (logging) {
    log("Initializing bean access.");
    startTime = System.currentTimeMillis();
    try {
    //get naming context
    Context ctx = getInitialContext();
    if (logging) {
    long endTime = System.currentTimeMillis();
    log("Succeeded getting naming context.");
    log("Execution time: " + (endTime - startTime) + " ms.");
    startTime =endTime;
    //look up jndi name
    Object ref = ctx.lookup("DynamicPool");
    if (logging) {
    long endTime = System.currentTimeMillis();
    log("Succeeded looking up jndi name.");
    log("Execution time: " + (endTime - startTime) + " ms.");
    startTime =endTime;
    //cast to Home interface
    dynamicPoolHome = (DynamicPoolHome) PortableRemoteObject.narrow(ref,
    DynamicPoolHome.class);
    if (logging) {
    long endTime = System.currentTimeMillis();
    log("Succeeded casting Home interface.");
    log("Execution time: " + (endTime - startTime) + " ms.");
    catch(Exception e) {
    if (logging) {
    log("Failed initializing bean access.");
    e.printStackTrace();
    Am I missing something here ?
    Regards,
    Klaus

  • JNDI obj not binding to initial context--10gRel 2 issue only,works in rel3

    hi all,
    The issue I am writing about is an issue only in OAS 10g release 2 (10.1.2.0.2) and not in release 3. I have an issue where in I am trying to bind a data source object to the initial context. This data source object reference is created dynamically and is not specified in any XML file (say like web.xml or server.xml). The business requirement driving this is that for each user we need to create a data source dynamically and attach it to the JNDI and then this JNDI name is passed on to Crystal Reports which will use this data source to retrieve its data from the DB. The code for creating the data source dynamically is as below,
    private String setDataSource(String username, String password) throws NamingException {
              String prefix = "jdbc";
              InitialContext ic = new InitialContext();
              // Construct BasicDataSource reference
              Reference ref = new Reference("javax.sql.DataSource", CustomDataSourceFactory.class.getName(), null);
              ref.add(new StringRefAddr("url", xxxxxx));
              ref.add(new StringRefAddr("schema",xxxxx));
              ref.add(new StringRefAddr("xxxxxx", xxxxx));
              ref.add(new StringRefAddr("password", xxxxx));
              try {
                   ic.listBindings(prefix);
              } catch (NameNotFoundException exp) {
                   ic.createSubcontext(prefix);
              String datasourceName = prefix + "/" + oneNumber;
              ic.rebind(datasourceName, ref);
              return datasourceName;
    As you can see the reference to the data source is added dynamically. Now when I try to obtain this object by looking up the context for its JNDI name I get a object not found error. This is how I look up the object through my code,
    private void testDataSource(String dsName){
              Connection conn = null;
              Statement stmt = null;
              ResultSet rs = null;
              try {
                   InitialContext ic = new InitialContext();
                   javax.sql.DataSource ds = (javax.sql.DataSource) ic.lookup(dsName);
                   conn = ds.getConnection();
                   stmt = conn.createStatement();
                   rs = stmt.executeQuery("select sysdate from dual");
                   String result = rs.getString(1);
                   System.out.println("----YOGI----Result of query execution is AAA -----" + result);
              } catch (Exception ex ){
                   System.out.println("----YOGI----the exception from this specific block is " + ex.getLocalizedMessage());
              finally {
                   try {
                        if (null!= rs)
                             rs.close();
                        if(null !=stmt)
                             stmt.close();
                        if(null !=conn)
                             conn.close();          
                   } catch (Exception ex){
                        System.out.println("Hopeless");
    When I do this I get this exception message --> jdbc/1562 not found in MyAPP
    jdbc/1562 is the data source JNDI name I generated in the first method and "MyAPP" is the name of my application. I decided to make the JNDI globally available in the context and hence I used "java:global/jdbc/1562" for my datasource name and even that did not work even though the JNDI name is not bound to the application in specific.
    I am really at a loss here as this is a simple add/retrieve operation to a object bound to the context. Can someone tell what is wrong here? The same code works fine in release 3 OAS and also in tomcat and websphere. Any help will be appreciated.
    Regards,
    Yogi

    OK, I seem to be getting a new exception, not sure if I did any change but ran into this exception in the logs,
    11/08/24 18:45:08 ----YOGI----the exception from this specific block is javax.naming.Reference cannot be cast to javax.sql.DataSource*
    From what I read on the web, this is prevalent in glassfish and jboss. The reason could be that missing j2ee.jar in classpath or duplicate jdbc jars. I added j2ee.jar to my application library in oc4j dint resolve the issue. I removed jdbc jar from the OAS lib folder and restarted, it dint help.
    Any other clues, anyone?

  • Initial Context Problem

    I have developed local entity bean in weblogic 8.1
    but i wouldnt able to get the Initial Context of the Bean.
    It throws javax.naming.NoInitialContextException
    But in jndi tree it shows the bean..
    the problem is only for Local Bean
    Remote Beans are working fine

    G,
    One thing I would make sure of is that you are not deploying oc4j.jar file as part of you ear. Check the 'exploded' ear file under WEB-INF/lib to ensure that you do not have an oc4j.jar file under it.
    It usually happens that in your Jdev Project, if you had included the oc4j.jar library solely to compile, but when you generated the deployment profile it would by default include all the libraries that are part of the project. You can correct this by right clicking the deployment profile and editing its properties to exclude the libraries that you don't want to deploy.

Maybe you are looking for

  • "iTunes could not back up the iPhone 'my IPhone' because a session could not be started with the iPhone"

    Since 2 updates I started getting iTunes could not back up the iPhone 'my IPhone' because a session could not be started with the iPhone. This is happening with my iPad and iPhone. I see hundreds of complains on this issue starting from last year and

  • I don't understand why this recursive program is looping, or its #s.

    i put in a println around the 7th line of code to see how it is working, i dont understand how to app is getting its numbers or why it is looping without a for statement. this demonstrates recursion. the output i get is value of n is 2 value of n is

  • Bid Invitation - Delivery Schedules

    Does Bid Invitation on SRM 5.0 (SRM Server 5.5) provide for Delivery Schedules, similar to R/3 at the item level?   I can not any place to enter different Dates and Qtys at the item level.  If it does, can you provide how to do this. It is interestin

  • Laserjet Pro CP1525 color printing question

    This is a color printer, but what if I am only printing a document that is just text (black and white).  Do I need to so into my printer setting everytime and change it to grayscale just to print or worry that it will use the color to make black? I a

  • Usb charger stop working for my iphone

    I have had my Iphone since july and my charger has been working just fine. Last week my charger stopped working and i get a code 43. I have uninstalled apple products and reinstalled and still the same issue. Someone please help.