Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > BOOK: Beginning JavaServer Pages
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning JavaServer Pages
This is the forum to discuss the Wrox book Beginning JavaServer Pages by Vivek Chopra, Jon Eaves, Rupert Jones, Sing Li, John T. Bell; ISBN: 9780764574856
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaServer Pages section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 20th, 2008, 01:03 PM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pain: A touch-up on Beginning JSP Chapter 23

When reading this book, I didn’t want to use the more or less outdated software that was used by the authors at the time of writing. I boldly decided to use later versions of MySQL, Tomcat and Hibernate. Here’s a list of what was used in the book, and the versions that I decided to use:

MySQL MySQL 4.0 -> 5.0
Tomcat 5.0 -> 5.5
Hibernate 2.1 -> 3.2

Of course, one doesn’t deviate from a recommended software setup without a lot of pain. After having spent many frustrating hours of Google searches with equally frustrating trial-and-error attempts, I decided to write down the problems I encountered and the fixes that I found for them in this forum. Perhaps some of you will stumble upon the same problems and have some use for it. What’s interesting with Chapter 23 is of course that this is the first attempt in the book to access a database.

I began by installing and configuring everything according to the instructions in the book. And then it started…

1. Outdated import statements

It began easy enough. You will get a compilation error in HibernateRosterManager.java if you have switched from Hibernate 2 to Hibernate 3. Simply change all import statements beginning with net.sf.hibernate to org.hibernate in order to solve that problem.

2. Exception: Cannot create JDBC driver of class '' for connect URL 'null'"

The next problem I encountered was this:
Cannot create JDBC driver of class '' for connect URL 'null'"

First of all I changed the content of ch23.xml in order to support Tomcat 5.5 syntax. I removed <ResourceParams> and included all its elements into the <Resource> entry as you can see below. You should of course change the absolute paths below to wherever you keep your ch23 code.

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="P:/Code/Wrox/begjsp/ch23/web"
  path="/ch23"
  reloadable="true"
  workDir="P:/Code/Wrox/begjsp/ch23/work">

  <Resource name="jdbc/FootyDB"
            auth="Container"
            type="javax.sql.DataSource"
            driverClassName="com.mysql.jdbc.Driver"
            url="jdbc:mysql://localhost/footydb?autoReconnect=true"
            username="footy"
            password="footy"/>
</Context>

I followed the instructions in the book and copied this (updated) page to [CATALINA_HOME]\conf\Catalina\localhost.

Now here’s the tricky part: you additionally have to insert a new file called context.xml into web\META-INF with the content below:

<?xml version='1.0' encoding='utf-8'?>
<Context crossContext="true" debug="5"
    docBase="P:/Code/Wrox/begjsp/ch23/web"
    path="/ch23"
    reloadable="true"
    workDir="P:/Code/Wrox/begjsp/ch23/work">

   <Resource
      name="jdbc/FootyDB"
      auth="Container"
      type="javax.sql.DataSource"
      username="footy"
      password="footy"
      driverClassName="com.mysql.jdbc.Driver"
      maxWait="5000"
      url="jdbc:mysql://localhost/footydb?autoReconnect=true"
      maxActive="4"
      maxIdle="2"/>

</Context>

I found this solution described at http://www.theserverside.com/discuss...d=25459#119215. It was easy to see that I wasn’t the only one experiencing this kind of problem…

3. It works! Well, almost.

And la voilá – it started to work! Well, almost anyway. Now I was able to see the Rounds Management page filled with database content, which meant that I had a valid database connection. But the other pages weren’t working at all.

4. InvalidMappingException

I got an org.hibernate.InvalidMappingException on all three remaining jsp pages. This was easily solved by changing all references to http://hibernate.sourceforge.net/hib...apping-2.0.dtd to http://hibernate.sourceforge.net/hib...apping-3.0.dtd in all four xxx.hbm.xml files.

5. HibernateException: Dialect class not found

After that I got the following exception: org.hibernate.HibernateException: Dialect class not found: net.sf.hibernate.dialect.MySQLDialect. This was of course caused by the change from Hibernate 2 to Hibernate 3 and was also easily fixed in HibernateRosterManager.java, by changing the line:

props.put("hibernate.dialect", "net.sf.hibernate.dialect.MySQLDialect");

to:

props.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");

6. NoClassDefFoundError: org/objectweb/asm/Type

I had previously copied the Hibernate 3 versions of all files listed in required-libraries.txt stored in the WEB-INF\lib folder. In the Hibernate 3 distribution, there is no odmg-3.0.jar so don’t waste any time searching for it. It seemed that this list of files wasn’t enough, as I still got a lot of NoClassDefFoundError exceptions. Consulting the list of required files in the Hibernate 3 distribution, this is the resulting list of files that finally worked for me:

antlr-2.7.6.jar
asm.jar
asm-attrs.jar
cglib-2.1.3.jar
commons-collections-2.1.1.jar
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
ehcache-1.2.3.jar
hibernate3.jar
javassist.jar
jstl.jar
jta.jar
log4j-1.2.11.jar
standard.jar
xml-apis.jar



  #2 (permalink)  
Old January 12th, 2014, 10:59 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Exception: Cannot create JDBC driver of class '' for connect URL 'null'"

Hi,
I am facing the same issue but hte solution about context/resource didnt work. How to debug the connection error ?

Thanks,
D.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 1, Page 23 golden_drifter BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 7 July 9th, 2004 12:12 AM
Beginning JSP 2.0 chapter 2 Charles Howard JSP Basics 2 May 17th, 2004 12:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.