cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cedric Picard" <C.Pic...@kainos.com>
Subject RE: jndi datasource lookup from cocoon 2.0.3 with Borland Enterprise Server 5.1
Date Tue, 12 Aug 2003 17:15:33 GMT
Hi all,
 
I have now managed to setup cocoon 2.0.3 to use JNDI datasource within
Borland Enterprise Server 5.1.
 
For those interested, here's how it's done:
You will first of all need to create a DAR file using the deployment
descriptor editor:
    * File->new and select JNDI definitions archive,
    * Right-click the "untitled" node, and select new JDBC datasource,
    * in the popup enter the name for your datasource
(serial://datasources/MyDataSource),
    * Highlight the created datasource under "untitled", in the class
name field enter:
            - for SQLServer, com.inet.tds.PDataSource
            - for Oracle, oracle.pool.OracleConnectionPoolDataSource
 
NB: basically, you need a ConnectionPoolDataSource, whatever the
database driver you are using (I'm using inet.jar for SQLServer)
 
    * Select the driver properties tab, and add/set the following
properties:
            - serverName,
            - portNumber,
            - databaseName,
            - user,
            - password.
    * Save your DAR file.
 
Alternatively, you can simply deploy a jndi-definitions.xml file (rather
than a DAR file):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jndi-definitions PUBLIC "-//Borland Corporation//DTD
JndiDefinitions//EN"
"http://www.borland.com/devsupport/appserver/dtds/jndi-definitions.dtd">
<jndi-definitions>
    <visitransact-datasource>
        <jndi-name>serial://datasources/MyDataSource</jndi-name>
 
<driver-datasource-jndiname>serial://datasources/MyDataSourceDriver</dri
ver-datasource-jndiname>
        <property>
            <prop-name>connectionType</prop-name>
            <prop-type>Enumerated</prop-type>
            <prop-value>Direct</prop-value>
        </property>
        <property>
            <prop-name>maxPoolSize</prop-name>
            <prop-type>Integer</prop-type>
            <prop-value>0</prop-value>
        </property>
    </visitransact-datasource>
    <driver-datasource>
        <jndi-name>serial://datasources/MyDataSourceDriver</jndi-name>
 
<datasource-class-name>com.inet.tds.PDataSource</datasource-class-name>
        <log-writer>true</log-writer>
        <property>
            <prop-name>databaseName</prop-name>
            <prop-type>String</prop-type>
            <prop-value>MYDB</prop-value>
        </property>
        <property>
            <prop-name>serverName</prop-name>
            <prop-type>String</prop-type>
            <prop-value>MYSERVER</prop-value>
        </property>
        <property>
            <prop-name>user</prop-name>
            <prop-type>String</prop-type>
            <prop-value>MYUSER</prop-value>
        </property>
        <property>
            <prop-name>password</prop-name>
            <prop-type>String</prop-type>
            <prop-value>MYPASSWORD</prop-value>
        </property>
        <property>
            <prop-name>portNumber</prop-name>
            <prop-type>Integer</prop-type>
            <prop-value>MYPORTNUMBER</prop-value>
        </property>
    </driver-datasource>
</jndi-definitions>
 
Now for your web application, you need to specify how to map the JNDI
datasource in your web app:
in web.xml, you will need to define the resource reference for your
datasource (at the end of the provided sample)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <servlet>
    <servlet-name>Cocoon2</servlet-name>
 
<servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
    <init-param>
      <param-name>configurations</param-name>
      <param-value>/WEB-INF/cocoon.xconf</param-value>
    </init-param>
    <init-param>
      <param-name>init-classloader</param-name>
      <param-value>false</param-value>
    </init-param>
    <init-param>
      <param-name>logkit-config</param-name>
      <param-value>/WEB-INF/logkit.xconf</param-value>
    </init-param>
    <init-param>
      <param-name>servlet-logger</param-name>
      <param-value>access</param-value>
    </init-param>
    <init-param>
      <param-name>cocoon-logger</param-name>
      <param-value>core</param-value>
    </init-param>
    <init-param>
      <param-name>log-level</param-name>
      <param-value>DEBUG</param-value>
    </init-param>
    <init-param>
      <param-name>allow-reload</param-name>
      <param-value>yes</param-value>
    </init-param>
    <init-param>
      <param-name>load-class</param-name>
      <param-value>
        com.inet.pool.PoolDriver
        oracle.jdbc.driver.OracleDriver
      </param-value>
    </init-param>
    <init-param>
      <param-name>request-factory</param-name>
 
<param-value>org.apache.cocoon.components.request.MultipartRequestFactor
yImpl</param-value>
    </init-param>
    <init-param>
      <param-name>manage-exceptions</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>-1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Cocoon2</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Cocoon2</servlet-name>
    <url-pattern>*.pdf</url-pattern>
  </servlet-mapping>
  <error-page>
    <exception-type>ServerException</exception-type>
    <location>/Error.jsp</location>
  </error-page>
  <taglib>
    <taglib-uri>/TagLibrary.tld</taglib-uri>
    <taglib-location>/TagLibrary.tld</taglib-location>
  </taglib>
  <resource-ref>
    <description>datasource</description>
    <res-ref-name>jdbc/MyDataSource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
</web-app>
 
In addition, you also need to include a web-borland.xml file which
effectively provides the mapping between the resource reference and the
JNDI datasource:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Borland Software Corporation//DTD Web
Application 2.3//EN"
 
"http://www.borland.com/devsupport/appserver/dtds/web-app_2_3-borland.dt
d">
<web-app>
  <context-root>MYWEBAPP</context-root>
  <resource-ref>
    <res-ref-name>jdbc/MyDataSource</res-ref-name>
    <jndi-name>serial://datasources/MyDataSource</jndi-name>
  </resource-ref>
</web-app>

And in cocoon.xconf, you simply declare your J2EE datasource:
  ...
  <datasources>
    <j2ee name="MyDS">
      <dbname>MyDataSource</dbname>
    </j2ee>
  </datasources>
  ...
 
All you need to do is to deploy whatever cocoon jars you require in
bes/var/servers/<myServer>/partitions/lib
(I deploy the following: cocoon.jar, avalon-excalibur.jar,
avalon-framework.jar, logkit.jar, fop.jar [for PDF rendering],
xmlParserAPIs.jar)
 
I will be updating the wiki as soon as I can,
 
Hope that helps,
Cedric


	-----Original Message-----
	From: Grange, John [mailto:john.grange@bluefinger.com] 
	Sent: 08 August 2003 11:52
	To: 'users@cocoon.apache.org'
	Subject: RE: jndi datasource lookup from cocoon 2.0.4 on
weblogic 7
	
	

	Cedric, 

	Thanks, I will try that, but from what I understand, the jdbc/
bit is actuall just a label which is used to, ultimately, look up the
jndi datasource name defined in the weblogic.xml.  What appears to be
happening is that we get a "java:comp/env/jdbc/" prepended to the jndi
name by excalibur when it does the lookup - WL, obviously does not need
this.

	Cheers, 

	John 
	-----Original Message----- 
	From: Cedric Picard [mailto:C.Picard@kainos.com] 
	Sent: 08 August 2003 11:47 
	To: users@cocoon.apache.org 
	Subject: RE: jndi datasource lookup from cocoon 2.0.4 on
weblogic 7 


	John, 

	as far as I know, you do not need to provide "jdbc/" in the
dbname tag of the j2ee entry in cocoon.xconf (this is added
automatically to the JNDI name).

	I am currently trying to do exactly the same with JBuilder/BES
and cocoon 2.0.3 and talking to Borland about how to set things up (our
problem is that we are currently using JDBC1.x datasources which are not
shared between JARs/WARs as far as I could see).

	I guess the first thing is to find out if you are using JDBC1 or
JDBC2 datasources. 

	If you already are using JDBC2 datasources, then removing
"jdbc/" in the dbname tag *should* do the trick. 
	Otherwise, please bear with me, I'll post a message as soon as I
get this working with JDBC1 datasources (solution would appear to
require a Definitions ARchive, more to come).

	Hope that helps, 
	Cedric 
	-----Original Message----- 
	From: Grange, John [mailto:john.grange@bluefinger.com] 
	Sent: 08 August 2003 11:29 
	To: 'users@cocoon.apache.org' 
	Subject: FW: jndi datasource lookup from cocoon 2.0.4 on
weblogic 7 


	Has anybody any thoughts on this one? 
	-----Original Message----- 
	From: Grange, John [mailto:john.grange@bluefinger.com] 
	Sent: 06 August 2003 09:01 
	To: 'users@cocoon.apache.org' 
	Subject: jndi datasource lookup from cocoon 2.0.4 on weblogic 7 


	I am trying to get the j2ee jndi datasource lookup working under
weblogic 7, without success.  My xsp page fails with a null pointer
exception in EsqlQuery.java:99 and produces a malformed xml document (no
closing tags)

	Has anybody else had this problem - if so, how have they
resolved it?  If this is not the correct list to report this to, can you
please let me know where to report it.

	It appears (looking in the excalibur code) that java:comp/env is
prepended to the jndi name when performing a lookup, this is not
required under weblogic, and as such fails if it is included.

	The following code DOES NOT work under WebLogic 
	InitialContext ctx = new InitialContext(); 
	Object obj =
ctx.lookup("java:comp/env/jdbc/"+"myDataSourceName"); 
	The following code DOES work under WebLogic 
	InitialContext ctx = new InitialContext(); 
	Object obj = ctx.lookup("myDataSourceName"); 
	My setup configuration is as follows: 
	cocoon.xconf: 
	        <datasources> 
	                <j2ee name="reportDataSource"> 
	                        <dbname>jdbc/reportsDS</dbname> 
	                </j2ee> 
	        </datasources> 
	web.xml: 
	        <resource-ref> 
	       <res-ref-name>jdbc/reportsDS</res-ref-name> 
	       <res-type>javax.sql.DataSource</res-type> 
	       <res-auth>Container</res-auth> 
	   </resource-ref> 


	weblogic.xml: 
	<weblogic-web-app> 
	        <description> 
	                Cocoon App 
	        </description> 
	        <reference-descriptor> 
	                <resource-description> 
	
<res-ref-name>jdbc/reportsDS</res-ref-name> 
	
<jndi-name>com.lv.jdbc.oracle.ReportsTxDataSource</jndi-name> 
	                </resource-description> 
	        </reference-descriptor> 
	</weblogic-web-app> 



	John Grange 
	Software Team Leader 
	Tel: +44 (0) 1749 834922 
	Email: john.grange@bluefinger.com 
	BlueFinger Limited 
	Underwood Business Park, Wookey Hole Road, Wells, Somerset, BA5
1AF, UK 
	Tel: +44 (0) 1749 834900 
	Fax: +44 (0) 1749 834902 
	Mobile: +44 (0) 7876 038058 
	web: www.bluefinger.com 
	Company Reg No: 4209395 Registered Office: 2 Temple Back East,
Temple Quay, BRISTOL. BS1 6EG. 
	*** This E-mail contains confidential information for the
addressee only. If you are not the intended recipient, please notify us
immediately. You should not use, disclose, distribute or copy this
communication if received in error. No binding contract will result from
this e-mail until such time as a written document is signed on behalf of
the company. BlueFinger Limited cannot accept responsibility for the
completeness or accuracy of this message as it has been transmitted over
public networks.***

	-- 
	This e-mail is confidential and is intended for the named
recipient only. If 
	you receive it in error please destroy the message and all
copies. Kainos 
	Software Ltd. does not accept liability for damage sustained as
a result of 
	malicious software (e.g. viruses). Kainos does not accept
liability for, or 
	permit, the creation of contracts on its behalf by e-mail, the
publication of 
	any defamatory statement by its employees by e-mail, or changes
subsequently 
	made to the original message. The Company's registered office is
located at 
	4-6 Upper Crescent, Belfast, BT7 1NT, Northern Ireland, Tel +44
28 9057 1100. 



--

This e-mail is confidential and is intended for the named recipient only. If
you receive it in error please destroy the message and all copies. Kainos
Software Ltd. does not accept liability for damage sustained as a result of
malicious software (e.g. viruses). Kainos does not accept liability for, or
permit, the creation of contracts on its behalf by e-mail, the publication of
any defamatory statement by its employees by e-mail, or changes subsequently
made to the original message. The Company's registered office is located at
4-6 Upper Crescent, Belfast, BT7 1NT, Northern Ireland, Tel +44 28 9057 1100.

Mime
View raw message