Thursday 7 May 2009

SIMPLE AND COMPLETE DATA SOURCE EXAMPLE WITH WEBLOGIC

Please refer to ‘SIMPLE AND COMPLETE DATA SOURCE EXAMPLE’ at
http://tekne-techne.blogspot.com/2009/04/1-simple-and-complete-data-source.html
where I have created a simple httpServlet names Dstest and used the context.xml to access to the MySQL database from Apache Tomcat application server.

This time, I used the same httpservlets but changed the web.xml and added weblogic.xml, I also used
The datasource definition and its JNDI reference that I had created at
http://tekne-techne.blogspot.com/2009/05/5-how-to-develop-container-managed.html
You can find the jndi.properties at
http://tekne-techne.blogspot.com/2009/05/6-how-to-develop-container-managed.html

Here are web.xml and weblogic.xml files:

FILE web.xml
<?xml version = '1.0' encoding = 'windows-1254'?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">

<display-name>
Test ARS data source
</display-name>

<servlet>
<servlet-name>RequestDisplay</servlet-name>
<servlet-class>dsweb.RequestDisplay</servlet-class>
</servlet>
<servlet>
<servlet-name>DStest</servlet-name>
<servlet-class>dsweb.DStest</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RequestDisplay</servlet-name>
<url-pattern>/RequestDisplay</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DStest</servlet-name>
<url-pattern>/DStest</url-pattern>
</servlet-mapping>

<resource-ref>
<res-ref-name>jdbc/MySQLDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

<!--welcome-file-list>
<welcome-file>Welcome.html</welcome-file>
</welcome-file-list-->
</web-app>

FILE weblogic.xml
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app
xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app
http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">

<!--!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 10.0//EN"
"http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd"-->
<session-descriptor></session-descriptor>
<jsp-descriptor></jsp-descriptor>
<container-descriptor></container-descriptor>
<context-root>/</context-root>
<servlet-descriptor>
<servlet-name>RequestDisplay</servlet-name>
</servlet-descriptor>
<resource-description>
<res-ref-name>jdbc/MySQLDB</res-ref-name>
<jndi-name>styejbDB</jndi-name>
</resource-description>
</weblogic-web-app>

This works, if it does not please do not hesitate to contact me at arsaral [at] yahoo.com
with your relevant data.