db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shin Ohkubo" <sh.ok...@po1.iftc.co.jp>
Subject [ Error using criteria: java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl ]
Date Tue, 06 May 2003 06:06:28 GMT
Hi all,

I am currently trying the bookstore tutorial on the apache site.
However, every time I try to execute a second query by a Criteria, an
error occurs.
java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl

For instance:
-------------
 Criteria crit = new Criteria();
 List booklist = BookPeer.doSelect(crit);			//First
query.
 printBooklist(booklist);					//Prints
with no problem.
 crit = new Criteria();
 booklist = BookPeer.doSelect(crit);		//2nd query: Error
occurs.
 printBooklist(booklist);
-------------
This would not work properly.
-------------
 Criteria crit = new Criteria();
 List booklist = BookPeer.doSelect(crit);			//First
query.
 printBooklist(booklist);					//Prints
with no problem.
 Criteria crit2 = new Criteria();
 List booklist2 = BookPeer.doSelect(crit2);		//2nd query:
Error occurs.
 printBooklist(booklist2);
-------------
I thought this may work, but the same error occurs. Then I tried clear()
:
-------------
 Criteria crit = new Criteria();
 List booklist = BookPeer.doSelect(crit);
 printBooklist(booklist);
 crit.clear();
 List booklist2 = BookPeer.doSelect(crit);		//Error occurs.
 printBooklist(booklist2);
-------------
However, all did not work.

has anyone experienced the same trouble?
I would truly appreciate your help.
I will attach the log and the source below.

Regards,
Shin Ohkubo
---------------------------------------
[ simple source sample ]
package com.netpotlet.purple;
import java.util.*;
import com.netpotlet.purple.*;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.*;

public class SelectBookstore{
	public static void main(String[] args){
		try{
			/*
			 * Torque Initializing
			 */
			Torque.init("Torque.properties");

			System.out.println("first Full booklist:\n");
			selectAll();
			
			System.out.println("second booklist:\n");
			selectIsbn();

			System.out.println("third Join booklist");
			selectJoin();			
		}catch (Exception e){
			e.printStackTrace();
		}
	}
	
	private static void selectAll() throws TorqueException{
		Criteria crit = new Criteria();
		List booklist = BookPeer.doSelect(crit);
		printBooklist(booklist);
	}

	private static void selectIsbn() throws TorqueException{
		Criteria crit2 = new Criteria();
		crit2.add(BookPeer.ISBN, "0-618-12902-2");
		List booklist2 = BookPeer.doSelect(crit2);
		printBooklist(booklist2);
	}
	
	private static void selectJoin() throws TorqueException{
		Criteria crit3 = new Criteria();
		System.out.println("Booklist (SQL: select title,
book_id, isbn from book, pub, author where a.author_id =
book.author_id):\n");
		crit3.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID);
		List booklist3 = BookPeer.doSelect(crit3);
		printBooklist(booklist3);
	}
	/*
	* Helper method to print a booklist to standard out.
	*/
	private static void printBooklist(List booklist) throws
TorqueException{
		Iterator i = booklist.iterator();
		while (i.hasNext()){
			Book book = (Book) i.next();
			System.out.println(book);
		}
	}
}

[ this is the log file. after the final line, the NoClassDefFoundError
occurs. ]
2003-05-06 14:55:17,824 [main] INFO  org.apache.torque.Torque - Logging
has been configured by Torque.
2003-05-06 14:55:17,854 [main] DEBUG org.apache.torque.Torque - Starting
initAdapters
2003-05-06 14:55:19,166 [main] DEBUG org.apache.torque.Torque - Starting
initDSF
2003-05-06 14:55:19,166 [main] DEBUG org.apache.torque.Torque - handle:
bookstore DataSourceFactory:
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
2003-05-06 14:55:19,236 [main] DEBUG
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory - Starting
initCPDS
2003-05-06 14:55:19,326 [main] DEBUG
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory - Setting
datasource property: driver
2003-05-06 14:55:20,468 [main] DEBUG
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory - Setting
datasource property: url
2003-05-06 14:55:20,588 [main] DEBUG
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory - Setting
datasource property: user
2003-05-06 14:55:20,598 [main] DEBUG
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory - Setting
datasource property: password
2003-05-06 14:55:20,598 [main] DEBUG
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory - Starting
initTorqueClassic
2003-05-06 14:55:21,029 [main] DEBUG
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory - Setting
datasource property: defaultMaxActive
2003-05-06 14:55:21,079 [main] DEBUG
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory - Setting
datasource property: testOnBorrow
2003-05-06 14:55:21,089 [main] DEBUG
org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory - Setting
datasource property: validationQuery
2003-05-06 14:55:21,089 [main] DEBUG org.apache.torque.Torque - Adding a
dummy entry for default, mapped onto bookstore
2003-05-06 14:55:22,200 [Thread-1] DEBUG org.apache.torque.oid.IDBroker
- IDBroker thread was started.
2003-05-06 14:55:27,047 [main] DEBUG org.apache.torque.util.BasePeer -
SELECT book.BOOK_ID, book.TITLE, book.ISBN, book.PUBLISHER_ID,
book.AUTHOR_ID FROM book
2003-05-06 14:55:27,178 [main] DEBUG org.apache.torque.util.BasePeer -
Elapsed time=121 ms
2003-05-06 14:55:27,408 [main] DEBUG org.apache.torque.util.BasePeer -
SELECT book.BOOK_ID, book.TITLE, book.ISBN, book.PUBLISHER_ID,
book.AUTHOR_ID FROM book WHERE book.ISBN='0-618-12902-2'
2003-05-06 14:55:27,438 [main] DEBUG org.apache.torque.util.BasePeer -
Elapsed time=0 ms

[ This is what I see in the command prompt ]
C:\Torque\torque-3.0\torque-3.0>ant -f build-torque.xml Select
Buildfile: build-torque.xml

Select:
     [java] 2644 [main] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  -
Setting datasource property: url
     [java] 2764 [main] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  -
Setting datasource property: user
     [java] 2774 [main] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  -
Setting datasource property: password
     [java] 2774 [main] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  -
Starting initTorqueClassic
     [java] 3205 [main] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  -
Setting datasource property: defaultMaxA
ctive
     [java] 3255 [main] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  -
Setting datasource property: testOnBorro
w
     [java] 3265 [main] DEBUG dsfactory.Jdbc2PoolDataSourceFactory  -
Setting datasource property: validationQ
uery
     [java] 3265 [main] DEBUG torque.Torque  - Adding a dummy entry for
default, mapped onto bookstore
     [java] Full booklist:

4376 [Thread-1] DEBUG oid.IDBroker  - IDBroker thread was started.
     [java] 9223 [main] DEBUG util.BasePeer  - SELECT book.BOOK_ID,
book.TITLE, book.ISBN, book.PUBLISHER_ID,
book.AUTHOR_ID FROM book
     [java] 9354 [main] DEBUG util.BasePeer  - Elapsed time=121 ms
     [java] Title:    SiteFlash Introduction!gY
     [java] ISBN:     0-618-12902-2
     [java] Publisher:  1580
     [java] Author:   1580

     [java] Title:    SiteFlash Introduction!gY
     [java] ISBN:     0-618-12902-2
     [java] Publisher:  1590
     [java] Author:   1590

     [java] Title:    ELECOM Book
     [java] ISBN:     0-618-12902-2
     [java] Publisher:  1600
     [java] Author:   1600

     [java] Title:    ELECOM Book
     [java] ISBN:     0-618-12902-2
     [java] Publisher:  1610
     [java] Author:   1610

     [java] Title:    ELECOM Book
     [java] ISBN:     0-618-12922-2
     [java] Publisher:  1610
     [java] Author:   1610

     [java] SecondFull booklist:

     [java] 9584 [main] DEBUG util.BasePeer  - SELECT book.BOOK_ID,
book.TITLE, book.ISBN, book.PUBLISHER_ID,
book.AUTHOR_ID FROM book WHERE book.ISBN='0-618-12902-2'
     [java] 9614 [main] DEBUG util.BasePeer  - Elapsed time=0 ms
     [java] java.lang.NoClassDefFoundError:
sun/reflect/ConstructorAccessorImpl

BUILD SUCCESSFUL
Total time: 23 seconds


Mime
View raw message