How to register a DataSource in JNDI

I'm having a great deal of difficulty getting JNDI to work properly.
I'm attempting to use Quartz scheduler in a test program using a Derby database to store the scheduled events. In order to do this, I must pass Quartz the JNDI name of the data source for the database connection.
Unfortunately, virtually all of the documentation I've been able to find gives half of the story, and then says something to the like of "system properties required to actually make this work not shown". GRR!
I did come across some code for setting up a service provider, but I get even more errors when I try to set up a data source:
     Hashtable<Object, Object> env = new Hashtable<Object, Object>();
     // env.put(Context.INITIAL_CONTEXT_FACTORY, "com.smardec.jndi.mirror.MirrorInitialCtxFactory");
     env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.FSContextFactory");
     env.put(Context.PROVIDER_URL, "file:/");
     Context context = new javax.naming.InitialContext(env);
     org.apache.derby.jdbc.ClientDataSource40 dataSource = new org.apache.derby.jdbc.ClientDataSource40();
     dataSource.setServerName("my_derby_database_server");
     dataSource.setDatabaseName("my_derby_database_name");
     context.bind("jdbc/quartzdb", dataSource);If I try to use MirrorJNDI, I get the following error:
javax.naming.InvalidNameException: Cannot handle all components
at com.smardec.jndi.mirror.MirrorCtx.getParsedName(MirrorCtx.java:90)
at com.smardec.jndi.mirror.MirrorCtx.bind(MirrorCtx.java:133)
at com.smardec.jndi.mirror.MirrorCtx.bind(MirrorCtx.java:160)
at javax.naming.InitialContext.bind(InitialContext.java:400)
If I try using FSContextFactory, I get the following error:
javax.naming.OperationNotSupportedException: can't bind arbitrary objects in an FSContext
at com.sun.jndi.fscontext.FSContext.bind(FSContext.java:180)
at com.sun.jndi.fscontext.FSContext.bind(FSContext.java:167)
at javax.naming.InitialContext.bind(InitialContext.java:400)
Is there some simple way to just create and register a DataSource so that Quartz can find and use it?

Hi Karl
unfortunally i think that you can not store the org.apache.derby.jdbc.ClientDataSource40 object in the file system
the problem is related to the implementation of the JNDI for the File System
reading the officila SUN documentation you can find that
"Java objects can be stored in the file system under the following conditions:"
The initial factory is RefFSContextFactory (not FSContextFactory)
The object is of type java.naming.Reference or implements java.naming.Referenceable
anyway i post the official link of the official SUN documentation:
for the SUM JNDI home page
http://java.sun.com/javase/technologies/core/jndi/index.jsp
hire the SUN SPI
http://java.sun.com/products/jndi/serviceproviders.html
where you have downloaded the jar for the File System SPI (check the doc folder... there is an exmple how to put and get objects in the file system)
Bye
Alessandro

Similar Messages

  • How to Configure the Datasource In JNDI and access it through Java Code

    I have declared under web.xml
    <resource-ref>
          <res-ref-name>MSDataSource</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
          <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    Under Jrun-resource.xml
    <data-source>
                <dbname>xxxxxxx</dbname>
                <driver>macromedia.jdbc.sqlserver.SQLServerDriver</driver>
                <url>jdbc:macromedia:sqlserver://xxx.xxx.xx.xx:1433;databaseName=xxxxxxx</url>
                <username>xxxxxxxx</username>
                <password>xxxxxxxxx</password>
                <encrypted>false</encrypted>
                <encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
                <native-results>true</native-results>
                <remove-on-exceptions>true</remove-on-exceptions>
                <pool-statements>false</pool-statements>
                <initial-connections>1</initial-connections>
                <connection-timeout>1200</connection-timeout>
                <transaction-timeout>20</transaction-timeout>
                <cache-enabled>false</cache-enabled>
                <cache-size>5</cache-size>
                <cache-refresh-interval>30</cache-refresh-interval>
                <jndi-name>MSDataSource</jndi-name>
                <poolname>Pool</poolname>
                <minimum-size>0</minimum-size>
                <maximum-size>2147483647</maximum-size>
                <user-timeout>20</user-timeout>
                <skimmer-frequency>420</skimmer-frequency>
                <shrink-by>5</shrink-by>
                <maximum-soft>true</maximum-soft>
                <debugging>false</debugging>
                <disable-pooling>false</disable-pooling>
                <isolation-level>READ_UNCOMMITTED</isolation-level>
                <description/>
         </data-source>
    Under jrun-web.xml
    <resource-ref>
          <res-ref-name>MSDataSource</res-ref-name>
          <jndi-name>MSDataSource</jndi-name>
    </resource-ref>  
    Java Code
    String dsndb="java:comp/env/MSDataSource";
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,"jrun.naming.JRunContextFactory");
    p.put(Context.PROVIDER_URL, "localhost:2932");
    InitialContext context=new InitialContext(p);
    System.out.println(context.getEnvironment());
    DataSource ds=(DataSource)context.lookup(dsndb);
    ds.getConnection();
    System.out.println(ds.getConnection().toString());
    Error is
    {java.naming.provider.url=localhost:2932, java.naming.factory.initial=jrun.naming.JRunContextFactory}
    Exception in thread "main" javax.naming.NameNotFoundException: No such binding: MSDataSource
        at jrun.naming.ContextManager.getBinding(ContextManager.java:680)
        at jrun.naming.ContextManager.getBinding(ContextManager.java:686)
        at jrun.naming.ContextManager.getObject(ContextManager.java:690)
        at jrun.naming.ContextManager.lookup(ContextManager.java:463)
        at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:501)
        at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:644)
        at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:470)
        at javax.naming.InitialContext.lookup(Unknown Source)
        at Controller.DBManager.getConnection(DBManager.java:29)
        at Controller.DBManager.main(DBManager.java:42)
    Please help me .
    Thanks in advance

    Also, try to log the username/password in your authenticator, just to be sure that credentials changeGood piece of advice, michael. Worth of it. When I changed the credentials manually, it worked correctly,but from the application, when I logout from 'a', 'a' and log in to 'b', 'b', I got a valuable information.
    I tried debugging like given below for checking from the application.
    class MyAuthenticator extends Authenticator {
        protected PasswordAuthentication getPasswordAuthentication() {
             System.out.println("userrrrrrrrr"+UtilsHTTPS.username);
             System.out.println("pwdddddddddd"+UtilsHTTPS.password);
      .........................................The information I got while debugging from the application was, the username and password does not get printed. It implies that, Authenticator.setDefault(new MyAuthenticator()); does not work as desired ie; even on calling new MyAuthenticator(), it does not get inside the MyAuthenticator class.
    Why does this happen? What is the solution for this?

  • How can I configure ang use JNDI datasource on Tomcat 4.0.x ?

    How can I configure ang use JNDI datasource on Tomcat 4.0.x ?
    Please help me , Thanks !

    Hello ,
    You need to go through the JNDI tutorial which you can access at the sun's site. It will explain all the things you need.
    By the way all you want to use JNDI datasource is JNDI class library and some naming or directory service provider, which also you can download from sun.
    Good Luck.

  • Help|| Is there any tool available to register Oracle datasource objects into JNDI

    Is there any tool available to register Oracle datasource objects into JNDI.If so please tell me where can I download.
    Thanks
    shiva

    I'd like to know the answer to this also.
    I just started reading about JNDI 2 days ago and have never used it. I'd like to use DataSource in my application with JNDI. If I can use the database as my JNDI "server", then I'd prefer to do that instead of having a seperate external server.

  • How to handle multiple datasources in a web application?

    I have a J2EE Web application with Servlets and Java ServerPages. Beside this I have a in-house developed API for certain services built using Hibernate and Spring with POJO's and some EJB.
    There are 8 databases which will be used by the web application. I have heard that multiple datasources with Spring is hard to design around. Considering that I have no choice not to use Spring or Hibernate as the API's are using it.
    Anyone have a good design spesification for how to handle multiple datasources. The datasource(database) will be chosen by the user in the web application.

    Let me get this straight. You have a web application that uses spring framework and hibernate to access the database. You want the user to be able to select the database that he wants to access using spring and hibernate.
    Hopefully you are using the Spring Framework Hibernate DAO. I know you can have more that one spring application context. You can then trying to load a seperate spring application context for each database. Each application context would have it's own configuration files with the connection parameters for each datasource. You could still use JNDi entries in the web.xml for each datasource.
    Then you would need a service locater so that when a user selected a datasource he would get the application context for that datasource which he would use for the rest of his session.
    I think it is doable. It means a long load time. And you'll need to keep the application contexts as small as possible to conserve resources.

  • How to register a webserive in NetWeaver Application Server?

    Dear All,
    Can you please explain how to register a werbservice in Netweaver Application server?
    Gafar

    Mahesh,
    Thank you for your reply.
    I have gone through the sap note 63930. I need some more details to fix my problem.
    My application flow is as follows.
    1. There is a webservice in SAP XI.
    2.The webservice is calling from a Java Web application by  
        using Java JNDI lookup.
    While calling the XI through jndi lookup,
    I am getting an exception, NameNotFoundException. This is because of the non existing/Name mismatch of JNDI lookup on Web AS.
    My question is How and Where can we check the JNDI registry? I am not familiar with Visual Administrator. Can you please help me regarding this problem.
    Abdul Gafar

  • Error in registering the datasource

    When I try to register a Global Datasource, I get "file does not have
    read permission".
    OS - Windows 2000
    Database - Oracle81
    AS - iPlanet6.0 SP3
    Let me know where I am wrong.
    c:\> iasdeploy regdatasource -verbose elms-ias-ora-type2
    "======Begin error======="
    iasdeploy for iPlanet Application Server 6.0 SP3 Test Drive
    Debug level set to on ..
    Severity 1: Inside IasDeploy.main() ...
    Connected to LDAP server on xxxxxx port 389
    Error: File elms-ias-ora-type2 does not have read permission.
    Usage: iasdeploy regdatasource [-verbose] [-instance <instance>...|
    [-user <username> -password <password>] [-host <host> -port <port>]]
    <datasource XML file>
    Where:
    <datasource XML file> -file name of datasource XML. At most one datasource
    definition is allowed per XML file.
    ============"End error"==================
    The XML file is as below
    <ias-resource>
    <resource>
    <jndi-name>jdbc/elms</jndi-name>
    <jdbc>
    <datasource>elms</datasource>
    <database>jdbc:oracle:thin:@dev3:1521:Dev8i4</database>
    <username>plateau</username>
    <password>plateau</password>
    <driver-type>type2</driver-type>
    <resource-mgr>PlateauPool</resource-mgr>
    </jdbc>
    </resource>
    </ias-resource>

    I could resolve this problem by giving the following xml.
    This is for type2 oracle driver.
    <ias-resource>
    <resource>
    <jndi-name>jdbc/DataSource/XYZ</jndi-name>
    <jdbc>
    <datasource>XYZ</datasource>
    <database>dbname</database>
    <username>id</username>
    <password>passwd</password>
    <driver-type>ORACLE_OCI</driver-type>
    </jdbc>
    </resource>
    </ias-resource>
    Chandu wrote:
    When I try to register a Global Datasource, I get "file does not have
    read permission".
    OS - Windows 2000
    Database - Oracle81
    AS - iPlanet6.0 SP3
    Let me know where I am wrong.
    c:\> iasdeploy regdatasource -verbose elms-ias-ora-type2
    "======Begin error======="
    iasdeploy for iPlanet Application Server 6.0 SP3 Test Drive
    Debug level set to on ..
    Severity 1: Inside IasDeploy.main() ...
    Connected to LDAP server on xxxxxx port 389
    Error: File elms-ias-ora-type2 does not have read permission.
    Usage: iasdeploy regdatasource [-verbose] [-instance <instance>...|
    [-user <username> -password <password>] [-host <host> -port <port>]]
    <datasource XML file>
    Where:
    <datasource XML file> -file name of datasource XML. At most one datasource
    definition is allowed per XML file.
    ============"End error"==================
    The XML file is as below
    <ias-resource>
    <resource>
    <jndi-name>jdbc/elms</jndi-name>
    <jdbc>
    <datasource>elms</datasource>
    <database>jdbc:oracle:thin:@dev3:1521:Dev8i4</database>
    <username>plateau</username>
    <password>plateau</password>
    <driver-type>type2</driver-type>
    <resource-mgr>PlateauPool</resource-mgr>
    </jdbc>
    </resource>
    </ias-resource>

  • Please help : How to configure a datasource in 9iAS

    Hello all,
    I am new at 9iAS . Can anyone tell me how we configure datasource with JNDI name in 9iAS.
    any help will be appriciated.
    Thanks a lot
    Madhukar
    null

    Do you mean from flash in a web page or do you mean
    converting the swf file format (maybe with a decompiler or
    whatever).
    If you're meaning to do it from flash in a web page:
    You can't save a movieclip from flash to svg. You could
    perhaps record drawingAPI commands and create the appropriate svg
    output in an internal xml object which you then send to the server.
    But I don't know of any pre-built classes to do that (disclaimer:
    because I don't know of any doesn't mean they don't exist).
    Going from svg to flash is doing it the other way around.
    Converting the svg paths back to actionscript drawing commands. I
    think I've seen some examples of this online somewhere.

  • Datasource via JNDI vs Driver Manager

    I am really desperate to use Datasource for connectivity to Oracle (rather than using the driver manager) in my little J2EE app (no EJB) on IBM WSAD 5.0.
    I have some example using DB2 datasource via JNDI.
    I replaced the properties with my Oracle database parameters.
    as below
    userid=scott
    password=tiger
    url=jdbc:oracle:thin:@localhost:1521:library
    driver=oracle.jdbc.OracleDriver
    lookupName=jdbc/library
    database=library
    There is an object "DB2DataSource" coming from package COM.ibm.db2.jdbc.DB2DataSource in the example code "CreateDatasource.java" I am using to create the data source.
    I have added JNDI.jar(from oracle), Naming.jar(from WSAD home), nasmingClient.jar(from WSAD home) in to the project.
    By looking at Oracle manual we need import com.evermind.sql.DriverManagerDataSource; and
    com.evermind.server to get initialContext.
    But compiler cant find them.
    Can anyone tell me what is the equivalent in Oracle?
    Thanks
    Mei

    Hold on.
    This is what I think. There will be others here who might be able to build to this and provide you the solution.
    All that you need to do is
    1. Add the Oracle driver to the WebSphere classpath.
    2. Use the Admin Console / WSAD screens to create a JDBC Driver for the Oracle Driver.
    3. Create a datasource within this driver. There is step-by-step documentation on how to do this.
    4. Specify a JNDI name for the datasource.
    5. Lookup the DataSource and cast it to a DataSource object.
    6. Call getConnection method to get a connection.
    Your coding portion is only steps 5 and 6 above.
    Steps 1 through 4 needs to happen in the Admin Console / WSAD tool. I have done it in both the places before and it is a fairly straightforward process. You do not need any of the jars that you are mentioning below or need to do anything special.
    Vijay

  • How to register the recipient when create job by function

    I am now use JOB_OPEN , JOB_SUBMIT and JOB_CLOSE to create a job in the program. And need to post the result of the report to the person by email.
    Can you tell me how to register the recipient when create the job.
    ( in sm36, it is easily to do but how to do in coding? )
    regards,
    slam

    Hi
    I think in Back ground using the above fun modules you can't send a mail to the receipient.
    see the use of the above fun modules;
      IF p_bjob = 'X'.
        CONCATENATE sy-cprog sy-datum sy-uzeit
                    INTO jobname SEPARATED BY '_'.
        CALL FUNCTION 'JOB_OPEN'
          EXPORTING
            jobname          = jobname
          IMPORTING
            jobcount         = jobcount
          EXCEPTIONS
            cant_create_job  = 1
            invalid_job_data = 2
            jobname_missing  = 3
            OTHERS           = 4.
        CALL FUNCTION 'GET_PRINT_PARAMETERS'
          IMPORTING
            out_archive_parameters = arc_params
            out_parameters         = print_params
            valid                  = valid
          EXCEPTIONS
            archive_info_not_found = 1
            invalid_print_params   = 2
            invalid_archive_params = 3
            OTHERS                 = 4.
        IF valid = chk.
          SUBMIT ybrep
                          WITH < sel Screen>
                          AND RETURN
                          USER               sy-uname
                          VIA JOB            jobname
                          NUMBER             jobcount
                          TO SAP-SPOOL
                          SPOOL PARAMETERS   print_params
                          ARCHIVE PARAMETERS arc_params
                          WITHOUT SPOOL DYNPRO.
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              jobcount             = jobcount
              jobname              = jobname
              strtimmed            = 'X'
            EXCEPTIONS
              cant_start_immediate = 1
              invalid_startdate    = 2
              jobname_missing      = 3
              job_close_failed     = 4
              job_nosteps          = 5
              job_notex            = 6
              lock_failed          = 7
              invalid_target       = 8
              OTHERS               = 9.
          IF sy-subrc <> 0.
           MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ELSE.
            MESSAGE i029 WITH jobname.
          ENDIF.
        ELSE.
          MESSAGE s000 WITH text-003.
          STOP.
        ENDIF.
      ENDIF.
    Reward points if useful
    Regards
    Anji

  • How to register multiple ipods on same email account

    how do register multiple ipods using the same email account?

    Maybe here
    How to use multiple iPods, iPads, or iPhones with one computer
    You can have an unlimited number of devices that you own or control for private use tied to one iTunes account. But you have only have five tied to one iCloud account.
    To alllow FT and Messagibng between them see:
    MacMost Now 653: Setting Up Multiple iOS Devices For Messages and FaceTime

  • How to register custom report under Custom Development Application

    Hi 2 all
    How to register custom report under the Custom Development application in R12 vision DB, and also confirm location/folder of Custom Development application in R12.
    Thanks
    Zulqarnain

    Hi,
    You may or may not need to "register" the workflow - it depends on the changes that you made and which Item Type you modified. Some applications are essentially hard-coded to use a specific item type and process, some hard-coded to use an item type but you can configure the process to use, and some allow you to specify which item type and which process to use.
    Without knowing exactly what you have done, though, there is no specific advice that anyone can give you here on what you need to do, apart from to ensure that you have saved the new definition to the database.
    HTH,
    Matt
    WorkflowFAQ.com - the ONLY independent resource for Oracle Workflow development
    Alpha review chapters from my book "Developing With Oracle Workflow" are available via my website http://www.workflowfaq.com
    Have you read the blog at http://www.workflowfaq.com/blog ?
    WorkflowFAQ support forum: http://forum.workflowfaq.com

  • A friend created 3 accounts on his iPhone 5 but forgot the passwords. He can't reset the password as yahoo address is no longer valid. Erasing the phone doesn't solve the issue. How to register the phone with Apple?

    A computer illiterate friend created 3 accounts on his iPhone 5 but forgot the passwords. He can't reset the password as his yahoo address is no longer valid. Erasing the phone doesn't solve the issue as the Apple server identifies the hardware as registered. How to register the phone with Apple?
    I helped him create a new email address and new iCloud account on my Mac but when we try to register the phone with Apple it says: Maximim accounts limit reached for this device. How can he register the phone? I read different threads and found out that only Apple care can do that. We're in Romania and don't know where to call. Any suggestions on how we fix this?

    When I checked the support site for Romania, you apparently don't have an Apple Care contact center.  You "may" try calling the US Apple care number to verify the account and have the password reset sent to a different email address.  800-694-7466

  • How to register the phone number of my friends to imessage,and i able to contact them or call them?

    I buy my ipad in qatar duty free i mean ipad4 wifi +cellular i thought i can use it for text or call by means of phone number only but im dissapoint when i used it and found out that i have to register all numbers to imessage and i cannot find how to register it.please help me to solve this matter.

    You have a password, so good move on your part.  Whether you erase it or the thief does, they still get to use the iPhone as theirs.  Which is more important (pick one), protecting your data or punishing the thief?
    Ringing occurs at the carrier.  Chances are you're going to voicemail after only two or three rings.  If you have an iCloud backup also a good move.  Re-read my question in the first paragraph.

  • How to register youtube videos on mac hard drive?

    how to register youtube videos on mac hard drive?
    iMac 21.5 po, mid 2010 .Processor Intel i3

    You cannot. Doing so would violate YouTube's Terms of Use.
    Best of luck.

Maybe you are looking for

  • Need help to open palm V files on 64 bit Win 7 i7

    I have the synced Palm V files on a backup hard drive which I am trying to access on a new laptop, which has an i7 processor with 64-bit windows 7. I tried to install the 4.1.4 desktop software but it errored out: Internal Error 2738.  I find pages a

  • Bluetooth Mouse Driver Issues after updating to SP1

    Greetings! After upgrading to SP1 my bluetooth mouse stopped working.  The dongle I'm using is being detected fine, and when I scan for the mouse I can find it, but when I try to connect to it I get a "Locate driver" message from Vista.  When I let i

  • Currency

    Hi!! I have such situatoin - in sales order currency differs from the currency of Sales Organisation. I need to see in the  pricing procedure sum in currency of sales organisatoin for information. How can i do this7 Thanks.

  • Mouse troubleshooting ideas?  Loses connection constantly.

    I have a new Mini, and I'm using a wireless Magic Mouse that I am trying to use, along with a wireless keyboard.  I don't have any issues with the keyboard, but I can't get my wireless mouse to consistently work; I keep having to fight it to move an

  • When sustaining, sound drops.

    I'm just starting to use Mainstage 2.1.3  Op 10.6.8 Unfortunatly I don't have the money for a brand new usb controller. So at the moment I'm using a Roland XV-88 via midi. Doing a gig, all's going well, and then about 40 minutes in, I'm noticing, whi