|
From: Isabelle M. <isa...@me...> - 2003-05-19 13:37:55
|
Hi Thomas, I got Ken's demo working in Jboss using your changes. However, there is one thing I don't understand. In jboss-web, the JNDI name is java:/DefauldDS. So why is the datasource lookup done using jdbc/SpringDS? The way you do it in Weblogic is that whatever JNDI name you specify, that's waht you use for the lookup. Isabelle -- Isabelle Muszynski Software Engineer Zandweellaan 4 2660 Antwerpen Belgium Tel. 32-(0)3-830 18 54 Mobile: 32-(0)485 49 50 89 Email: isa...@me... Website: www.meta-logix.com |
|
From: Luke T. <luk...@fr...> - 2003-05-19 15:27:00
|
Isabelle Muszynski wrote: > Hi Thomas, > > I got Ken's demo working in Jboss using your changes. However, there > is one thing I don't understand. In jboss-web, the JNDI name is > java:/DefauldDS. So why is the datasource lookup done using > jdbc/SpringDS? The way you do it in Weblogic is that whatever JNDI > name you specify, that's waht you use for the lookup. > > Isabelle > It's a standard J2EE thing - jdbc/SpringDS is the container-independent name you use in your code to provide a layer of indirection, and you map it to an actual named container resource (in the JBoss case by supplying a jboss-web file). You can do the same in Weblogic: http://edocs.bea.com/wls/docs60/programming/web_xml.html#1017834 An explicit lookup would work too but would require code changes every time you change to use a different "physical" datasource or if you move to a different container. There's an equivalent syntax for use in EJBs, in the ejb-jar.xml file. Luke. -- Luke Taylor. Monkey Machine Ltd. PGP Key ID: 0x57E9523C http://www.monkeymachine.ltd.uk |
|
From: <tri...@tr...> - 2003-05-20 05:21:13
Attachments:
petclinic1_jboss_hsql_v2.zip
|
To All,
I went back to modify Ken's demo app to use Jürgen's JndiDataSourceBean and to
run with the latest version of the framework code from CVS.
Again, I had to make just a few changes, but this time I did not touch any of
Ken's original Java code. I only modified three of the deployment xml files.
This really shows how valuable a well designed framework is.
These are the changes I made to the original code from Ken's Petclinic1.zip
(Steps 2, 3 and 6 are the same as last time):
1. Removed the <servlet> entry for ContextLoaderServlet from web.xml. This
class has recently been removed from CVS. Replaced it with a <listener> entry.
<listener>
<listener-class>com.interface21.web.context.ContextLoaderListener</listener-class>
</listener>
2. Added a 'resource-ref' entry to web.xml. It goes at the end after
the <taglib> entries.
<resource-ref>
<description>The default DS</description>
<res-ref-name>jdbc/SpringDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
3. Created a jboss-web.xml file with the corresponding 'resource-ref'
entry pointing to the HSQL default datasource.
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/SpringDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/DefaultDS</jndi-name>
</resource-ref>
</jboss-web>
4. Changed the "bean" entry for "dataSource" in the
applicationContext.xml - it now uses the new JndiDataSourceBean.
<beans>
<!-- ===========================================================-->
<!-- Global Message source. For all servlets. -->
<!-- ===========================================================-->
<bean name="messageSource"
class="com.interface21.context.support.ResourceBundleMessageSource">
<property name="basename">messages</property>
</bean>
<bean name="dataSource"
class="com.interface21.jdbc.datasource.JndiDataSourceBean" >
<property name="name">jdbc/SpringDS</property>
</bean>
</beans>
5. Replaced the WEB-INF/lib/spring-full-0.8.jar with the latest version.
6. Created a "petclinic.war" directory under the
"c:\jboss-3.2.1\server\default\deploy" directory and deployed the application there.
That's it for this time.
I have attached a zip file with the changed xml files.
--Thomas
|
|
From: Ken K. <kk...@kk...> - 2003-05-20 12:35:13
|
Thomas, Thanks again for your help. I have already made the same changes in my=20 own latest working version as you describe in 1. I very much wanted to=20 retain the "dataSource" bean because it does show how easy it is to=20 switch datasources. The value of this will become even more apparent=20 when I have refactored to separate the persistence code from the=20 business logic. Ken tri...@tr... wrote: >To All, > >I went back to modify Ken's demo app to use J=FCrgen's JndiDataSourceBea= n and to >run with the latest version of the framework code from CVS. > >Again, I had to make just a few changes, but this time I did not touch a= ny of >Ken's original Java code. I only modified three of the deployment xml f= iles.=20 >This really shows how valuable a well designed framework is. > >These are the changes I made to the original code from Ken's Petclinic1.= zip >(Steps 2, 3 and 6 are the same as last time): > >1. Removed the <servlet> entry for ContextLoaderServlet from web.xml. T= his >class has recently been removed from CVS. Replaced it with a <listener>= entry. > > <listener> > =20 ><listener-class>com.interface21.web.context.ContextLoaderListener</liste= ner-class> > </listener> > > >2. Added a 'resource-ref' entry to web.xml. It goes at the end after >the <taglib> entries. > > <resource-ref> > <description>The default DS</description> > <res-ref-name>jdbc/SpringDS</res-ref-name> > <res-type>javax.sql.DataSource</res-type> > <res-auth>Container</res-auth> > </resource-ref> > > >3. Created a jboss-web.xml file with the corresponding 'resource-ref' >entry pointing to the HSQL default datasource. > ><jboss-web> > <resource-ref> > <res-ref-name>jdbc/SpringDS</res-ref-name> > <res-type>javax.sql.DataSource</res-type> > <jndi-name>java:/DefaultDS</jndi-name> > </resource-ref> ></jboss-web> > > >4. Changed the "bean" entry for "dataSource" in the >applicationContext.xml - it now uses the new JndiDataSourceBean. > ><beans> =09 > > <!-- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D--> > <!-- Global Message source. For all servlets. --> > <!-- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D--> > <bean name=3D"messageSource" >class=3D"com.interface21.context.support.ResourceBundleMessageSource">=09 > <property name=3D"basename">messages</property> =09 > </bean> > > <bean name=3D"dataSource" >class=3D"com.interface21.jdbc.datasource.JndiDataSourceBean" > > <property name=3D"name">jdbc/SpringDS</property> > </bean> > =20 ></beans> > > >5. Replaced the WEB-INF/lib/spring-full-0.8.jar with the latest version. > > >6. Created a "petclinic.war" directory under the >"c:\jboss-3.2.1\server\default\deploy" directory and deployed the applic= ation there. > > >That's it for this time. > >I have attached a zip file with the changed xml files. > > >--Thomas > > =20 > |