|
From: Thomas R. <tri...@tr...> - 2003-05-18 19:34:21
|
Ken,
I got the app running on JBoss. Had to make a few changes:
1. Changed the petclinic\support\ClinicImpl.java class to do a JNDI
lookup in the afterPropertiesSet() method. Also added an import
statement for DataSourceUtils.
import com.interface21.jdbc.datasource.DataSourceUtils;
public void afterPropertiesSet() throws java.lang.Exception {
dataSource = DataSourceUtils.getDataSourceFromJndi
("jdbc/SpringDS");
//if(dataSource == null) {
// throw new ApplicationContextException("Must set
dataSource bean property on " + getClass());
//}
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. Commented out the "bean" entry for "dataSource" in the
applicationContext.xml - this is not needed since we do a JNDI lookup
for the datasource.
<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.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource" >
<property name="URL">jdbc:mysql://localhost/petclinic</property>
<property name="user">pc</property>
<property name="password">pc</property>
</bean>
-->
</beans>
5. Commented out the corresponding "property" entry for "dataSource"
under the "clinic" bean entry in "petclinic-servlet.xml".
<bean name="clinic" class="petclinic.support.ClinicImpl" >
<!--<property name="dataSource"
beanRef="true">dataSource</property> -->
</bean>
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 - it works like a charm. You can view all the Log4j
messages in "c:\jboss-3.2.1\server\default\log\server.log". I have
attached a zip file with the changed code.
--Thomas
>
>
> To All,
>
> I am pleased to announce that I now have ready for download a
PROTOTYPE
> of the Petclinic demo app
> <http://www.globaldialog.com/%7Ekkrebs/files/Petclinic1.zip>,
approx.
> 1.25MB.
>
> Be sure to read the file, petclinic.txt. This file contains my notes
> about the design and implementation and also raises key issues that
need
> to be resolved.
>
> I very much welcome all comments, suggestions, ideas, and
criticisms. I
> look forward to hearing from you.
>
> Ken
>
>
|