You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Joris Jansen <Jo...@Cumquat.nl> on 2007/10/18 06:31:33 UTC

sql extension and JNDI

Hi there,

I looked at the sql extension a copule of times, and I like to use it in
some project.
I played around with the DB credentials inside the XSLT and it works
like a charm, but ...

Now I want to connect to a JNDI datasource in my container, an OC4J
10.1.0.2 container to be more precise.

Is there anyone who can help me on this one?


      Thanx, Joris

-- 
I couldn't afford a cool signature, so I just got this one.


joris.jansen@cumquat.nl
M +31 (0)6 1091 4504

Cumquat Information Technology BV
De Dreef 19
3706 BR  Zeist
http://www.cumquat.nl



Re: sql extension and JNDI

Posted by Joris Jansen <Jo...@Cumquat.nl>.
John, thanx for the help,

with OC4J it is enough to include the 'hint' <web-app-class-loader 
search-local-classes-first="true"  include-war-manifest-class-path="true" />
in the orion-web.xml. I guess with other containers it might be possible 
as well to use this trick.
For my project I am bound to OC4J, so the web-app-class-loader 
search-local-classes-first is ok for me for now.

In the XSLT I can get the database now by including only the JNDI name, 
without the user credentials and url, just like I want to,
there is no need to register any external connectionpool, what in my 
opinion is less neat then using the datasource via JNDI.




       regards, Joris


John Gentilin wrote:
> Hi Joris,
>
> OK there may two issues here... For the External Connection pool you
> can name the packages whatever you want them to be, as long as you
> implement the ConnectionPool interface, which I don't think has changed
> since rev1, and it will work with Xalan... So if you look at the code 
> in the source
> tree, samples\extensions\sql\ext-connection\ExternalConnection.java 
> you will
> see that it creates an instance of 
> org.apache.xalan.lib.sql.DefaultConnectionPool
> you can go into the source tree, grab a copy of that class, put it in 
> a local package,
> create an instance then register it as an external connection pool 
> with the code
>  ConnectionPoolManager pm = new ConnectionPoolManager();
>  pm.registerPool("YourPoolNameHere", cp);
> and you should be good to go..
>
> but....
>
> The problem you will run into with the older JDK is an old buggy 
> version of Xalan..
> So I attached 3 other classes...that you can use in your project... 
> One caveat is
> that your servlet will need permissions to run its own class loader.
> EndorsingClassLoader is a way to override rt.jar during runtime...
> EndorsedServlet, is a generic wrapper class that load your servlet and 
> wedge in, in
> an additive way, the ECL.
> EndorsedPServer is a class that implements the EndorsedServler.. This 
> does the work
> of adding in class directories, and jar files that you want to have a 
> higher priority than
> rt.jar, and it loads your real servlet into the wrapper. so replace
> loadServlet("com.ecs.xml.server.presentation.PServer");
> with you servlet class name... You need to create a version of the 
> EndorsedPServer,
> name it what you want to, for each Servlet you want to run.. and the 
> EndorserPServer
> will be the name you use in your web.xml specification...
>
> Hope this all makes sense...
>
> -John G
>
>
> Joris Jansen wrote:
>> Hi John (and the rest )
>>
>> This morning I was going to write:
>> I thought (and hoped ) it was that simple ... but apperently it isn't 
>> (with OC4J ) ...
>>
>>
>> But now I have to write:
>> ... well after all it is ...
>>
>> Instead of putting the xalan jars in the applib directory of OC4J,  I 
>> had to include the xalan 2.7.0 jars (xalan.jar, serializer.jar, 
>> xercesImpl.jar and xml-apis.jar) in the WEB-INF/lib of my war file. 
>> And .... I had to include the next line in my orion-web.xml:
>> <web-app-class-loader search-local-classes-first="true"  
>> include-war-manifest-class-path="true" />
>>
>> This old OC4J uses an ancient JDK, and the endored lib-trick 
>> http://xml.apache.org/xalan-j/faq.html#faq-N100D6 didn't work.
>>
>> Without this, the ancient xalan out of the JDK's rt.jar was taken, 
>> and that one doesn't know about the JNDIConnectionPool at all.
>>
>>
>>
>>       Greetings, Joris
>>
>>
>>
>> John Gentilin wrote:
>>> Hi Joris,
>>>
>>> Connecting the Xalan SQL extension to a JNDI data source should be
>>> very easy.... What you need to do is look at the source Xalan source
>>> for ConnectionPool code along with the External Connection Pool
>>> example.... The attached zip for has code that implements a JNDI
>>> connection pool... I don't remember its origin, or if it is a complete
>>> example... but I am passing it along for your reference..
>>>
>>> Regards
>>> John Gentilin
>>>
>>> Joris Jansen wrote:
>>>> Hi there,
>>>>
>>>> I looked at the sql extension a copule of times, and I like to use 
>>>> it in
>>>> some project.
>>>> I played around with the DB credentials inside the XSLT and it works
>>>> like a charm, but ...
>>>>
>>>> Now I want to connect to a JNDI datasource in my container, an OC4J
>>>> 10.1.0.2 container to be more precise.
>>>>
>>>> Is there anyone who can help me on this one?
>>>>
>>>>
>>>>      Thanx, Joris
>>>>
>>>
>>>
>>
>>
>


-- 
I couldn't afford a cool signature, so I just got this one.


joris.jansen@cumquat.nl
M +31 (0)6 1091 4504

Cumquat Information Technology BV
De Dreef 19
3706 BR  Zeist
http://www.cumquat.nl


Re: sql extension and JNDI

Posted by Joris Jansen <Jo...@Cumquat.nl>.
Hi John (and the rest )

This morning I was going to write:
I thought (and hoped ) it was that simple ... but apperently it isn't 
(with OC4J ) ...


But now I have to write:
... well after all it is ...

Instead of putting the xalan jars in the applib directory of OC4J,  I 
had to include the xalan 2.7.0 jars (xalan.jar, serializer.jar, 
xercesImpl.jar and xml-apis.jar) in the WEB-INF/lib of my war file. And 
.... I had to include the next line in my orion-web.xml:
<web-app-class-loader search-local-classes-first="true"  
include-war-manifest-class-path="true" />

This old OC4J uses an ancient JDK, and the endored lib-trick 
http://xml.apache.org/xalan-j/faq.html#faq-N100D6 didn't work.

Without this, the ancient xalan out of the JDK's rt.jar was taken, and 
that one doesn't know about the JNDIConnectionPool at all.



       Greetings, Joris



John Gentilin wrote:
> Hi Joris,
>
> Connecting the Xalan SQL extension to a JNDI data source should be
> very easy.... What you need to do is look at the source Xalan source
> for ConnectionPool code along with the External Connection Pool
> example.... The attached zip for has code that implements a JNDI
> connection pool... I don't remember its origin, or if it is a complete
> example... but I am passing it along for your reference..
>
> Regards
> John Gentilin
>
> Joris Jansen wrote:
>> Hi there,
>>
>> I looked at the sql extension a copule of times, and I like to use it in
>> some project.
>> I played around with the DB credentials inside the XSLT and it works
>> like a charm, but ...
>>
>> Now I want to connect to a JNDI datasource in my container, an OC4J
>> 10.1.0.2 container to be more precise.
>>
>> Is there anyone who can help me on this one?
>>
>>
>>      Thanx, Joris
>>
>
>


-- 
I couldn't afford a cool signature, so I just got this one.


joris.jansen@cumquat.nl
M +31 (0)6 1091 4504

Cumquat Information Technology BV
De Dreef 19
3706 BR  Zeist
http://www.cumquat.nl


Re: sql extension and JNDI

Posted by John Gentilin <ge...@eyecatching.com>.
Hi Joris,

Connecting the Xalan SQL extension to a JNDI data source should be
very easy.... What you need to do is look at the source Xalan source
for ConnectionPool code along with the External Connection Pool
example.... The attached zip for has code that implements a JNDI
connection pool... I don't remember its origin, or if it is a complete
example... but I am passing it along for your reference..

Regards
John Gentilin

Joris Jansen wrote:
> Hi there,
>
> I looked at the sql extension a copule of times, and I like to use it in
> some project.
> I played around with the DB credentials inside the XSLT and it works
> like a charm, but ...
>
> Now I want to connect to a JNDI datasource in my container, an OC4J
> 10.1.0.2 container to be more precise.
>
> Is there anyone who can help me on this one?
>
>
>      Thanx, Joris
>


-- 
--------------------------------------
John Gentilin
Eye Catching Solutions Inc.
18314 Carlwyn Drive
Castro Valley CA 94546

    Contact Info
gentijo@eyecatching.com
Ca Office 1-510-881-4821
NJ Office 1-732-422-4917