Using JNDI to bind any object

Hi,
I intend to bind a few objects in JNDI context so that they can later be just looked up and then used.
I can use code like this:
=========
Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL, SOME_PROVIDER_URL);
env.put(Context.SECURITY_PRINCIPAL, "user");
env.put(Context.SECURITY_CREDENTIAL, "passwd");
Context ctx = new InitialContext(env);
context.bind("name", object);
=========
This object can later be looked up. So far so good. However, this will bind the object in the same VM "only".
Is there any way of calling something like:
====
someOC4JClass.getNamingService().bind("name", object);
===
so that the underlying naming service takes care of making this object available across JVMs?
Any help/pointers will be highly appreciated.
Thanks,
Ravi

Ravi -- Currently OC4J's internal JNDI is not a global JNDI shared by all OC4Js. One way to approach this problem would be to bind the objects in some global / common JNDI like OID.
Thanks -- Jeff

Similar Messages

  • How to get LDAP sub-error code using JNDI (MD5 or any other SASL mechanism)

    Hi All,
    My objective is to find out if a user name exists in LDAP/Active Directory. I understand that there are specific sub error codes, like below:
    · 525 - user not found
    · 52e - invalid credentials
    · 530 - not permitted to logon at this time
    · 532 - password expired
    · 533 - account disabled
    · 701 - account expired
    · 773 - user must reset password
    · 775 - account locked.
    When I tried with "simple" authentication, I am able to get exact reason code from which I can understand what went wrong.
    Here's the code snippet:
         Hashtable<String, Object> env = new Hashtable<String, Object>();
              env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    *     env.put(Context.SECURITY_AUTHENTICATION,"simple");*
              env.put(Context.SECURITY_PRINCIPAL, "myUser");
              env.put(Context.SECURITY_CREDENTIALS, "mySecret");
              env.put(Context.PROVIDER_URL, "ldap://10.10.10.10:389/");
              env.put("com.sun.jndi.ldap.trace.ber", System.err); //debug trace
              DirContext ctx = null;
         try {
                   ctx = new InitialLdapContext(env, null);
              } catch (javax.naming.AuthenticationException ae) {
                   System.out.println("Message: "+ae.getMessage());
                   ae.printStackTrace();
    Output:
    [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, *data 525*, vece_
    From above output it's clear that the sub error code is 525, that means User Not Found
    If I want to achieve the same thing with Digest-MD5 algorithm, I am always getting sub error code as 0 from which I am not at all able to understand what went wrong.
    Here's my code snippet:
                 Hashtable<String, Object> env = new Hashtable<String, Object>();
              env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
            *     env.put(Context.SECURITY_AUTHENTICATION,"Digest-MD5");*
              env.put(Context.SECURITY_PRINCIPAL, "myUser");
              env.put(Context.SECURITY_CREDENTIALS, "mySecret");
              env.put(Context.PROVIDER_URL, "ldap://10.10.10.10:389/");
              env.put("com.sun.jndi.ldap.trace.ber", System.err); //debug trace
              DirContext ctx = null;
                     try {
                   ctx = new InitialLdapContext(env, null);
              } catch (javax.naming.AuthenticationException ae) {
                   System.out.println("Message: "+ae.getMessage());
                   ae.printStackTrace();
    Output:
    [LDAP: error code 49 - 8009030C: LdapErr: DSID-0C09043E, comment: AcceptSecurityContext error, *data 0*, vece_
    From the above sub error code 0, it's very difficult to understand what went wrong with the credentails.
    Can any one help me out to find out what I am missing? Any help in this regard is highly appreciated.
    Please let me know if there's any other way to check if the user exists in  LDAP/Active Directory.
    Thanks a lot,
    Siva.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Thank you,
    As i was trying to obtain the input to UI from an xml file by which the axis converts to java objects and inturn have to get the reply as xml file . The error was in the jar files ,when i loaded the jar files another time my code started working.

  • What Datatype Should I Use to Change the "lockoutTime" attribute using JNDI

    I am able to use JNDI to modify an object's String valued attributes in ADAM.
    However, now I want to modify lockoutTime which has a datatype of LargeInteger/interval
    According to the documentation for AD, I can set the lockoutTime as:
    new BasicAttribute("lockoutTime", Integer.toString(0)));But with ADAM this throws the exception:
    [LDAP: error code 53 - 00000057: LdapErr: DSID-0C090A4C, comment: Error in attribute conversion operation, data 0, vece_What datatype do you suggest I use, to set lockoutTime to 0 using java/JNDI?
    What datatype does LargeInteger/interval map to in java?

    As both are equivalent to "0" it is impossible to believe that that solved your problem.

  • How to bind an object to JNDI tree in iAS?

    Hi all,
    When I try to bind a string object to jndi tree, the following exception
    occurs:
    javax.naming.NamingException: Unable to get object instance from reference.
    Roo
    t exception is javax.naming.NamingException: Can't bind instance of class
    java.lang.String
    at com.netscape.server.jndi.RootContext.bindCtx(Unknown Source)
    at com.netscape.server.jndi.RootContext.rebind(Unknown Source)
    at com.netscape.server.jndi.RootContext.rebind(Unknown Source)
    at javax.naming.InitialContext.rebind(InitialContext.java:385)
    at jsp.APPS.bmx.test2._jspService(test2.java:76)
    at jsp.APPS.bmx.test2.service(test2.java:42)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at
    com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source)
    The code fragment is:
    Context ctx = new InitialContext();
    String str = "hell,every one!";
    ctx.rebind("abc", str);
    Can anyone give some help? Thanks in advance.
    Johnson

    To bind an object into the JNDI tree check the documentation here:
    http://e-docs.bea.com/wls/docs81/jndi/jndi.html#475702
    If this is to be used by all your applications that you deploy on the server check out the startup/shutdown class documentation here:
    http://edocs.bea.com/wls/docs81/ConsoleHelp/startup_shutdown.html
    Cheers
    IV

  • Querying deleted objects container in Active Directory using JNDI

    Hi,
    I am trying to query deleted objects container using JNDI which fails with error 64.
    Has anyone seen this or knows how to query AD using binary data in JNDI.
    Seems to me there is some problem with the search base.
    search base: <GUID=18E2EA80684F11D2B9AA00C04F79F805,dc=engserver,dc=com>.
    filter: objectclass=*
    search scope: subtree
    This is the error:
    Search example failed.
    javax.naming.InvalidNameException: <GUID=18E2EA80684F11D2B9AA00C04F79F805,dc=eng
    server,dc=com>: [LDAP: error code 64 - 00000057: LdapErr: DSID-0C090563, comment
    : Error processing name, data 0, v893 ]; remaining name '<GUID=18E2EA80684F11D2B
    9AA00C04F79F805,dc=engserver,dc=com>'
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2802)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2616)
    at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1744)
    at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1667)
    at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirCon
    text.java:368)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCom
    positeDirContext.java:328)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCom
    positeDirContext.java:313)
    at javax.naming.directory.InitialDirContext.search(InitialDirContext.jav
    a:245)
    at jSearch.main(jSearch.java, Compiled Code)
    Thanks,
    Chetan

    I thought I had posted one of these. How remiss of me !/**
    * deleted.java
    * 5 July 2001
    * Sample JNDI application to search for deleted objects
    * Modified December 2004 to add Win2K3 lastKnownParent
    import java.util.Hashtable;
    import javax.naming.*;
    import javax.naming.ldap.*;
    import javax.naming.directory.*;
    import com.sun.jndi.ldap.ctl.*;
    class DeletedControl implements Control {
         public byte[] getEncodedValue() {
              return new byte[] {};
         public String getID() {
              return "1.2.840.113556.1.4.417";
         public boolean isCritical() {
              return true;
    public class deleted     {
         public static void main (String[] args)     {
              Hashtable env = new Hashtable();
              String adminName = "CN=Administrator,CN=Users,DC=ANTIPODES,DC=COM";
              String adminPassword = "XXXXXX";
              String ldapURL = "ldap://mydc.antipodes.com:389";
              env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
              //set security credentials, note using simple cleartext authentication
              env.put(Context.SECURITY_AUTHENTICATION,"simple");
              env.put(Context.SECURITY_PRINCIPAL,adminName);
              env.put(Context.SECURITY_CREDENTIALS,adminPassword);
              //connect to my domain controller
              env.put(Context.PROVIDER_URL,ldapURL);
              try {
                   //Create the initial directory context
                   LdapContext ctx = new InitialLdapContext(env,null);
                   //Create the search controls           
                   SearchControls searchCtls = new SearchControls();
                   //Specify the attributes to return
                   String returnedAtts[]={"distinguishedName","lastKnownParent"};
                   searchCtls.setReturningAttributes(returnedAtts);
                   //Specify the search scope
                   searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
                   //specify the LDAP search filter
                   String searchFilter = "(&(objectClass=user)(isDeleted=TRUE))";
                   //Specify the Base for the search
                   String searchBase = "DC=antipodes,DC=com";
                   //initialize counter to total the results
                   int totalResults = 0;
                   //specify the Deleted control
                   Control[] rqstCtls = new Control[] {new DeletedControl()};
                   ctx.setRequestControls(rqstCtls);
                   //Search for objects using the filter
                   NamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);
                   //Loop through the search results
                   while (answer.hasMoreElements()) {
                        SearchResult sr = (SearchResult)answer.next();
                        totalResults++;
                        System.out.println(totalResults + ". " + sr.getName().toString());
                        // Print out some of the attributes, catch the exception if the attributes have no values
                        Attributes attrs = sr.getAttributes();
                        if (attrs != null) {
                             try {
                                  for (NamingEnumeration ae = attrs.getAll();ae.hasMore();) {
                                       Attribute attr = (Attribute)ae.next();
                                       System.out.println("Attribute: " + attr.getID());
                                       for (NamingEnumeration e = attr.getAll();e.hasMore();System.out.println("   " + e.next().toString()));
                             catch (NullPointerException e)     {
                             System.err.println("Problem listing attributes: " + e);
                   System.out.println("Deleted objects: " + totalResults);
                   ctx.close();
              catch (NamingException e) {
              System.err.println("Problem searching directory: " + e);
    }

  • I am using illustrator CC there are not showing scale size pointer in any object?

    I am using illustrator CC there are not showing scale size pointer in any object? Anyone tell me why it was does it? And how i can come again on that position?

    Or maybe Cmd(Ctrl)-U which is the toggle for Smart Guides?

  • Using JNDI to retrieve a far objects

    hi every body,
    my question is how using JNDI in order to retrieve far "java objects" (in another machine in the same network)
    thanks,

    I can't see where can i find help !!!
    which provider url can i use (or which protocol to use) : RMI, Ldap, file system... ?

  • Bind RMI object to JNDI

    InitialContext ctx = new InitialContext ();
    ctx.rebind ("wwlhp", remoteObject);Does the JNDI tree and remoteObject reside in the same JVM?
    Can i use JNDI without J2EE platform?
    Can some one give me a piece of code illustrating rebinding in server side and looking up in client side.

    import javax.naming.*;
    import java.util.*;
    public class Server{
    public static void main(String[]args){
    try{
    Hashtable env=new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.rmi.registry.RegistryContextFactory");
    env.put(Context.PROVIDER_URL,"rmi://servername");
    Context ctx=new InitialContext(env);
    //create an instance of remote object
    RemoteIF i=new RemoteImpl();
    ctx.rebind("common name",ri);
    }catch(Exception ex){}
    The client needs to create a context as well, as above, the lookup
    RemoteIF ri=(RemoteIF)ctx.lookup("common name");
    The Stub classes must be available to the client as well
    start rmiregistry
    start the server
    off you go with the client

  • Bind remote object to JNDI tree

    I want to create a JNDI tree in the same JVM with remote object, and then I have two problem:
    1> Should I bind remote object or its stub to the JNDI tree?
    2> How to look up the JNDI tree to get the binded stub from the client side? (Suppose server ip is 192.168.99.42)
    I hope a gentleman would give me a piece of code, so i would be much clearer. Thanks a lot!

    Hi,
    Refer http://java.sun.com/products/jndi/tutorial/objects/storing/remote.html
    -amol

  • Binding custom objects in weblogic JNDI

    I noticed that if I bind a custom object, the object is not available after the weblogic
    restart. Is there anyway to bind an object permanently in the weblogic JNDI..

    In article <[email protected]>, [email protected] says...
    Murali <[email protected]> wrote:
    I noticed that if I bind a custom object, the object is not available after the weblogic
    restart. Is there anyway to bind an object permanently in the weblogic JNDI..No.
    Perhaps what your trying to accomplish could be handled via a startup
    class that did the bind for you.
    Bob

  • Binding huge object to the jndi tree.

    Hi we are loading all the master tables in to objects at the app server startup (SUN ONE 7) and then binding the whole object to the jndi tree. All the tables data in text files comes to about 5 MB and the serilized object with data to about 8 MB. But when the app server tries to bind the object the app server process consumes over 500MB of ram and gives OutOfmemoryError as the total ram is 512MB. why is it consuming so much memory. It does bind an object of about 5 MB but when trying to lookup subsequent to the first lookup it fails. Is this a bug or what??? the same thing works perfectly with Weblogic and Websphere and also Weblogic is very efficient in memory consumption and response time is amazing. For a 5 MB object the lookup takes about 5Secs in Weblogic and about 15Mins in Sun One. We might have to drop the Sun One App Srv and go for Weblogic though we dont want. This same thing is working with about 4MB object in Sun One but takes about 45 Mins to 1 Hour to finish the serialization etc for jndi .Kindly provide some guidance.Thanks in advance.

    True. At the end I configured the value as a "server property". The cool thing about configuring the jndi tree is that it is replicated in a cluster.
    Obviously the values that I inserted affected all the applications, like the url of our SOA server.

  • Connecting through Data Source using JNDI

    I would like to connect my application to sql server database through data
    source using JNDI. But when i try to bind the data source object with the
    logical name, i am getting following exception. How can i ger rid of this
    error ? How can i provide the initial context ? I thought Java would create the default initial context by itself. But it doesn't seem to be true. Any type of help would be appreciated.
    -Prashant
    Exception :
    Naming Exception :Need to specify class name in environment or system
    property, or as an applet parameter, or in an application resource file:
    java.naming.factory.initial
    javax.naming.NoInitialContextException: Need to specify class name in
    environment or system property, or as an applet parameter, or in an
    application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:651)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246)
    at
    javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:283)
    at javax.naming.InitialContext.bind(InitialContext.java:358)
    at RegDataSource.regDataSource(RegDataSource.java:30)
    at RegDataSource.main(RegDataSource.java:52)
    Source code :
    public class RegDataSource
    public RegDataSource()
    private void regDataSource()
    try
    com.microsoft.jdbcx.sqlserver.SQLServerDataSource sds =
    new
    com.microsoft.jdbcx.sqlserver.SQLServerDataSource();
    sds.setServerName("servername13");
    sds.setDatabaseName("test");
    Context ctx = new InitialContext();
    ctx.bind("jdbc/EmployeeDB", sds);
    catch(NamingException e)
    System.out.println("Naming Exception :" + e.getMessage()
    //+ "\n" + e.getExplanation()
    //+ "\n" + e.getResolvedObj()
    //+ "\n" + e.getResolvedName()
    e.printStackTrace();
    catch(Exception e)
    System.out.println("Exception :" + e.getMessage());
    public static void main(String[] args)
    RegDataSource regDataSource1 = new RegDataSource();
    regDataSource1.regDataSource();

    Thanks you very very much for your prompt reply and helping me out. I have following questions.
    1) Now i am able to bind data source object to the logical name. But the problem is that whenever i try to look up the data source object by providing logical name (i.e. DataSource ds = (DataSource)ctx.lookup("jdbc/EmployeeDB") ), it returns always null. I don't know why it doesn't return the correct data source object ?
    Following is the code used to bind datasource with the logical name
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.fscontext.RefFSContextFactory");
    env.put(Context.PROVIDER_URL, "file:/TEMP/jndi");
    Context ctx = new InitialContext(env);
    //Properties p = new Properties();
    //p.put(Context.INITIAL_CONTEXT_FACTORY,
    // "com.sun.jndi.fscontext.RefFSContextFactory");
    //Context ctx = new InitialContext(p);
    ctx.bind("jdbc/EmployeeDB", sds);
    Following is the code used to look up for the bound object
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.fscontext.RefFSContextFactory");
    env.put(Context.PROVIDER_URL, "file:/TEMP/jndi");
    Context ctx = new InitialContext(env);
    DataSource ds = (DataSource)ctx.lookup("jdbc/EmployeeDB");
    2) I am writing client server application in which my client is going to access the SQL Server 2000 to read/write database related data. The reason behind using the JNDI is that i don't want my client application to kwon which driver (sql) and database i am using. It is going to provide the great flexibility whenever i can make my application to use other database like Oracel, sybase, etc. without changing any code most probably. In this situation, which JNDI service provider to use ? I am not sure about "File System" service provider be the ideal choice for this type of situation. so please let me know which JNDI service provider is the ideal for this situation.
    Any type of help would be appreacited.

  • Conflict start: You tried to bind an object under the name abc.Scheduler

    I have deployed my application on the WLS which is configured for clustred with 2 managed server and one admin server in the same machine. I see the below error on both of the managedServer consoles. can any one please help me resolving this issue.
    <Conflict start: You tried to bind an object under the name abc.Scheduler in the JNDI tree. The object from -2433108061996587758S:192.168.0.61:[7014,7014,-1,-1,-1,-1,-1]:SingleDomainClusterTake2:ManagedServer1 is non-clusterable, and you have tried to bind more than once from two or more servers. Such objects can only be deployed from one server.>
    Regards
    Suresh.

    Hi Jay,
    Below is the code snippet where I am binding the Schedular Object to a JNDI abc.Schedular and I got the above error message when I trying to deploy the application in clustered environment.
    Code Snippet where binding the Schedular Object
    private static final String JNDI_NAME = "abc/Scheduler";
    Hashtable ht=new Hashtable ();
    InitialContext context = new InitialContext();
    scheduler = new Scheduler();
    scheduler.setStorage(new DatabaseSchedulerStorage());
    context.bind(JNDI_NAME, scheduler);
    Code Snippet for looking up the schedular object
    protected Scheduler getScheduler() throws NamingException {
    if (scheduler != null) {
    return scheduler;
    Scheduler s=null;
    if(workaround){
    s=((ThreadManager)SchedulingServlet.getThreadManager()).getScheduler();
    }else{
    InitialContext context = new InitialContext();
    s = (Scheduler) context.lookup("reactor/Scheduler");
    if (s.getStorage() == null) {
    s.setStorage(new DatabaseSchedulerStorage());
    scheduler=s;
    return scheduler;
    I have added "ht.put(WLContext.REPLICATE_BINDINGS, "false");" to get rid of the conflict error but I what this object to be clustrable and you please let me know how do I make this object clustrable.
    I am using quartz schedular.
    Regards
    Suresh.

  • Creating and Binding View Objects dynamically : Oracle Jdeveloper 11g

    Hello,
    We are trying to create and bind view objects dynamically to adf data visualization components.
    The view object is a result of multiple tables.
    We are using Oracle JDeveloper 11g Technical Preview. ( can't upgrade to TP2 or TP3 now).
    We have found this : http://radio.weblogs.com/0118231/stories/2003/07/15/creatingUpdateableMultientityViewObjectDefinitionsDynamically.html on our search for the same.
    The sample application however, is in 10g , hence required migration.
    Also, it was a standalone application with the TestClient.java having a main() method.
    Our requirement is for Web Application; we use Adf+jsf .
    Guidance of any sort is very much appreciated.
    Thanks in advance.
    -Anil Golla

    Hi,
    there also exist a forum for JDeveloper 11: JDeveloper and OC4J 11g Technology Preview
    What you are trying todo is not trivial because you need to not only dynamically create the VO, you would also dynamically need to create the binding meta data for it (assuming you use ADF). Not sure if the API to modify the binding is public, so posting it on the JDeveloper 11 forum bears a glimpse of hope for an answer
    In JDeveloper 10.1.3 you can't do this
    Frank

  • PI 7.11 JMS adapter using JNDI weblogic server issue

    Hi SAP experts,
    I have a scenario to integrate to a application using JMS adapters. we use SAP PI 7.11 version.
    We have deployed JMS drivers successfully and We face issue here to connect to weblogic server
    We are using JMS adapter using JNDI to connect to weblogic server version 10.3.
    Can anyone help with the exact format to be used in JMS properties table and additional parameters table in JMS communication channel. Your quick help will be appreciated.
    A channel error occurred. The detailed error (if any) : com.sap.aii.adapter.jms.api.connector.ConnectorException: Error looking up destination: AccrualDetailsQueue for profile:  ConnectionProfile of channel: CC_SND_JMS on node: 3010950 having object id: 673696a9fe8c39fdab32213f0930afb3: javax.naming.NameNotFoundException: Unable to resolve 'AccrualDetailsQueue'. Resolved ''<br> at com.sap.aii.adapter.jms.core.connector.JndiConnectorImpl.createDestination(JndiConnectorImpl.java:168)<br

    Hi Padmini,
    Refer to the following link:
    http://help.sap.com/saphelp_nw04/helpdata/en/24/4cad3baabd4737bab64d0201bc0c6c/content.htm
    It was very helpful to me, for configuring the additional parameters in the communication Channel JMS.
    I leave you some screenshots of the settings that I did.
    I seize the opportunity to ask you, where do I can get the drivers (.Jar) for Weblogic?
    Regards.
    Rodrigo.

Maybe you are looking for