Fixed it!  Yay!

Gary, I tried it again per the suggestion you forwarded from support,
but this time by removing the <resource-ref> from my web.xml and coding
my Java as you noted: "jdbc/etc".  Also fixed the startup problem by
removing a transparently stupid syntax error from data-sources.xml.

In case anybody else has been following this thread, here's the working
<data-source> and a code fragment:

<data-source
    name="Oracle data source"
    class="com.evermind.sql.ConnectionDataSource"
    location="jdbc/OracleDS"
    pooled-location="jdbc/OraclePooledDS"
    xa-location="jdbc/xa/OracleXADS"
    ejb-location="jdbc/OracleEJBDS"
    url="jdbc:oracle:thin:@dracula.smartmonsters.com:1521:DEV"
    connection-driver="oracle.jdbc.driver.OracleDriver"
    username="foo"
    password="bar"
    schema="database-schemas/oracle.xml"
/>

InitialContext cxt = new InitialContext();
// WRONG: DataSource ds = (DataSource)
cxt.lookup("java:comp/env/OracleDS");
DataSource ds = (DataSource) cxt.lookup("jdbc/OracleEJBDS"); // RIGHT
Connection  c = ds.getConnection();

So the moral of the story seems to be, don't use the syntax
"java:comp/env/myDS"; rather, use "jdbc/myDS".

Note I've substituted "OracleEJBDS" per the note from support which Gary
included earlier in the thread.

Finally -- 'cause I'm personally done with this thread for a while, ;-)
-- if any of the Evermind folks are taking note, I'd very much like to
be able to choose to use networked LDAP for objects such as
DataSources.  Please consider this an enhancement suggestion.

Thanks Gary, Allen and Deepak!

--Mark

===========================

Thanks Allen.

The answers to your questions are yes, and yes.  Earlier messages in
this thread contained complete listings for the data-sources.xml and
web.xml files, plus a code snippet.  I'll append them to this reply in
case they're helpful.

You'll note that the data-sources definitions are slightly different
than what you suggest below.  Your suggestion is similar to the first
half of Deepak's example, that is, what he considers to be a non-pooled
version.  After reading your message I tried it with your configuration
and the test tag handler blows up in exactly the same spot.

--Mark

=====================

Excerpted from thread history:

Gary, I'm running 1.3.8.

Per your research into the Orion JNDI namespace, could there be an
undocumented quirk in Orion's implementation?  I've been using JNDI/LDAP

pretty extensively the last couple months and have been super impressed
with its ease and speed.  But, that environment is under my programmatic

control, including the namespace design.  In fact what I'd really like
to be able to do is throw a configuration switch enabling a networked
LDAP server as an alternative to using the Orion JNDI namespace.  If
there were a JNDI.xml file or something like that, perhaps it would be
possible to organize the namespace in a way that makes best sense for
your enterprise application architecture; and of course other servers
would be able to share centralized resources.  To my thinking
DataSources kind of cry out for this approach.  Seems to be the J2EE
"way", although, I dunno, I'm still learning.

In case it helps, below are the entries in my data-sources.xml and
web.xml files, and a code example. These are taken directly from
Deepak's earlier posts.  With these I'm able to get a non-null
Connection reference from the DataSource.  But note this isn't to
declare victory: still have a strange bug to figure out.  My tag handler

blows up with a NullPointerException when I call
Connection.createStatement() on the Connection reference.  Have no idea
if this is related to the config below, or what, but the Exception is
being caught by Orion, not by my tag handler, which at first glance
points to Orion's implementation of the pooled Connection object.

Note to Mike Cannon-Brookes: based on the quantity of questions posted
to the mailing list, I'd suggest that proper configuration of
DataSources and also the workings of the Orion JNDI namespace are two
good candidates for your super-FAQ suggestion.  :-)

--Mark

>From data-sources.xml:

 <!-- NON-POOLED Oracle data source -->
 <data-source
      class="com.evermind.sql.DriverManagerDataSource"
      name="OracleNP"
      location="jdbc/OracleNP"
      xa-location="jdbc/xa/OracleXANP"
      ejb-location="jdbc/OracleNP"
      connection-driver="oracle.jdbc.driver.OracleDriver"
      username="foo"
      password="bar"
      url="jdbc:oracle:thin:@test:1521:DEV"
      inactivity-timeout="30"
      schema="database-schemas/oracle.xml"
 />

 <!-- POOLED Oracle data source -->
 <data-source
      class="com.evermind.sql.OrionPooledDataSource"
      name="OracleDS"
      location="jdbc/OracleDS"
      xa-location="jdbc/xa/OracleXADS"
      ejb-location="jdbc/OracleDS"
      max-connections="10"
      source-location="jdbc/OracleNP"
      pooled-location="jdbc/OracleDS"
      connection-driver="oracle.jdbc.driver.OracleDriver"
      username="foo"
      password="bar"
      url="jdbc:oracle:thin:@test:1521:DEV"
      inactivity-timeout="30"
      schema="database-schemas/oracle.xml"
 />

>From web.xml:

<context-param>
    <param-name>OracleDS</param-name>
    <param-value>jdbc/OracleDS</param-value>
</context-param>
<resource-ref>
    <description>Oracle pooled data source</description>
    <res-ref-name>OracleDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

>From the tag handler:

try {

    InitialContext cxt = new InitialContext();
    DataSource ds = (DataSource) cxt.lookup("java:comp/env/OracleDS");

    Connection c = ds.getConnection();
    if (c == null)
        System.out.println("==> Connection is null");
    else System.out.println("Connection is not null");

    /*     Blows up here with NullPointerException caught by Orion --
            NOT caught by the enclosing try/catch block.  Is this a bug
            in the Connection object, which I assume is Orion's
            implementation of a pooled version?  Should I post all this
            to Buzilla?  Dunno!:
*/
    Statement s = c.createStatement();
    if (s == null)
        System.out.println("==> Statement is null");
    else System.out.println("Statement is not null");

} catch  (Exception e) {
    System.err.println("==> Caught: " + e);
}

======================

Mark, what version of Orion are you using?  I wrote a little utility
that traverses the JNDI namespace, just looking for Context objects
and displaying what's in them.  I found an env Context but it was
empty!  I did eventually discover, due to a chance remark of someone
on the list, that there is in fact another Context which my scheme
did not find, namely jdbc/*.  I'm feeling pretty stupid about JNDI
these days, since I can't even figure out how to search the space,
despite the spec's indication that (as best I can tell) it's a
purely heirarchical namespace!

   Gary

On Today, Mark ([EMAIL PROTECTED]) wrote:

> Dunno if this is any help, but I found through experimentation that,
if
> you're using the deployment approach suggested by Deepak Goel in the
> thread "ANSWER: how to use pooled connections in Orion", the parameter

> to pass to InitialContext.lookup() is, as he notes,
> "java:comp/env/d123DS", not "java:comp/env/jdbc/d123DS".  That is,
> there's no "jdbc" in that String.  Just pointing that out because I
> missed it at first.
>
> (Yes, it seems to take a while for messages to get out to the list!)
>
> --Mark

=======================================


Are your Drivers available? is your Datasource defined correctly? Here
is my
file and it works fine for me....

<?xml version="1.0"?>
<!DOCTYPE data-sources PUBLIC "Orion data-sources"
"http://www.orionserver.com/dtds/data-sources.dtd">

<data-sources>
 <!--
  An example/default DataSource that uses an ordinary
  JDBC-driver (in this case hsql) to create the connections.
  This tag creates all the needed kinds
  of data-sources, transactional, pooled and EJB-aware sources.
  The source generally used in application code is the "EJB"
  one - it provides transactional safety and connection pooling.
 -->
 <data-source
  class="com.evermind.sql.DriverManagerDataSource"
  name="Oracle"
  location="jdbc/RedbookDS"
  xa-location="jdbc/xa/RedbookXADS"
  ejb-location="jdbc/RedbookDS"
  connection-driver="oracle.jdbc.driver.OracleDriver"
  username="user"
  password="password"
  url="jdbc:oracle:thin:@enterprise:1521:database"
  inactivity-timeout="30"
 />
</data-sources>

With of course the exception of changing the user and password  and
databse
schema. :)



----- Original Message -----
From: "Mark" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Monday, October 23, 2000 5:16 PM
Subject: Re: Data Sources Help


> Thanks Gary.
>
> Well I gave it a shot.  First thing to note is that the instructions
you
> were given by support seem to be self contradictory.  While suggesting

> you should use com.evermind.OrionConnectionDataSource with Oracle, the

> example <data-source> uses com.evermind.sql.ConnectionDataSource.  So
I
> tried them both, and at least in my environment they blow up with
> identical errors when the server is started:
>
> Result with com.evermind.sql.ConnectionDataSource:
>
> java -jar orion.jar
> java.lang.NullPointerException
>         at com.evermind.server.deployment.EnterpriseArchive.ajv(JAX)
>         at com.evermind.server.deployment.EnterpriseArchive.bx(JAX)
>         at com.evermind.xml.XMLConfig.bs(JAX)
>         at com.evermind.xml.XMLConfig.ay(JAX)
>         at com.evermind.xml.XMLConfig.ay(JAX)
>         at com.evermind.server.ServerComponent.ay(JAX)
>         at com.evermind.server.XMLApplicationServerConfig.ak9(JAX)
>         at com.evermind.server.XMLApplicationServerConfig.by(JAX)
>         at com.evermind.xml.XMLConfig.ay(JAX)
>         at com.evermind.xml.XMLConfig.ay(JAX)
>         at com.evermind.server.hc.run(JAX)
>         at java.lang.Thread.run(Thread.java:498)
>         at com.evermind.util.f.run(JAX)
>
> Result with com.evermind.OrionConnectionDataSource:
>
> java -jar orion.jar
> java.lang.NullPointerException
>         at com.evermind.server.deployment.EnterpriseArchive.ajv(JAX)
>         at com.evermind.server.deployment.EnterpriseArchive.bx(JAX)
>         at com.evermind.xml.XMLConfig.bs(JAX)
>         at com.evermind.xml.XMLConfig.ay(JAX)
>         at com.evermind.xml.XMLConfig.ay(JAX)
>         at com.evermind.server.ServerComponent.ay(JAX)
>         at com.evermind.server.XMLApplicationServerConfig.ak9(JAX)
>         at com.evermind.server.XMLApplicationServerConfig.by(JAX)
>         at com.evermind.xml.XMLConfig.ay(JAX)
>         at com.evermind.xml.XMLConfig.ay(JAX)
>         at com.evermind.server.hc.run(JAX)
>         at java.lang.Thread.run(Thread.java:498)
>         at com.evermind.util.f.run(JAX)
>
> So...  hmmm...
>
> Will keep trying as time permits.
>
> --Mark
>
>



Reply via email to