Hi Bruce,
        ok i got the MBean, thanx.
i got a little problem now: i got the picture that after i
register the MBean with the MBean server, the task is not over yet,
i guess i have to specify the JNDI name via jmx console (or i can hardcode
it in the code..).
But there is another method that 'intrigues' me: the setConfiguration(String dbConf)


do i have to set as value of it the database.xml file?
My guess is yes, but i just wanted you to confirm that...

with best regards
        marco


> -----Original Message-----
> From: ext Bruce Snyder [mailto:[EMAIL PROTECTED]
> Sent: 28 August, 2003 18:30
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] help in using castor in J2EE application
> 
> 
> This one time, at band camp, [EMAIL PROTECTED] said:
> 
> > hi all
> >     although i have browsed the castor list and although i have read
> >castor JDO docs, i still can't figure out how to use Castor 
> in a web application.
> >
> >i have writtten the database.xml and mapping.xml.
> >i am using jboss3.2.1, and i have written a webapp that is 
> supposed to insert
> >one object into mysql database.
> >
> >here is my database.xml file
> >
> ><!DOCTYPE databases PUBLIC "-//EXOLAB/Castor JDO 
> Configuration DTD Version 1.0//EN"
> >                           "http://castor.exolab.org/jdo-conf.dtd";>
> ><database name="menagerie" engine="mysql">
> > <jndi name="MySqlDS"/> 
> > <mapping href="mapping.xml"/>
> ></database>
> >
> >that is t he jndi name registered with jboss.
> >when i use this database.xml file, i got following exception :
> >org.exolab.castor.jdo.DatabaseNotFoundException: The JNDI 
> name MySqlDS does not map to a JDBC DataSource
> >
> >
> >in my webapp, i use a reference name for the jndi name 
> declared in jboss, 
> >
> ><resource-ref>
> >  <res-ref-name>jdbc/myDataSource</res-ref-name>
> >  <res-type>javax.sql.DataSource</res-type>
> >  <res-auth>Container</res-auth>
> ></resource-ref>
> >
> >
> >so, i have tried also to write the following database.xml
> >
> ><database name="menagerie" engine="mysql">
> > <jndi name="jdbc/myDataSource"/> 
> > <mapping href="mapping.xml"/>
> ></database>
> >
> >but i got following exception:
> >org.exolab.castor.jdo.DatabaseNotFoundException: No 
> configuration loaded for database test -- use the JDO 
> interface to load a configurat
> >ion for this database
> >
> >and that i guess is why castor docs say to use the following 
> when using JDO in a  J2EE application.
> >db = (Database) ctx.lookup( "java:comp/env/jdo/mydb" ); 
> >now i have a  question:
> >if the object to store in the JNDI tree is of type Database, 
>  how can i declare it in a webapp? i m not sure that the 
> web.xml allow me
> > to store that kind of type
> >how can i store such kind of object in a JNDI tree?
> >any help would be greatly appreciated.
> >i am assuming that castor JDO works already in J2EE 
> environment, although JDO pages say that 'we are planning 
> support for J2EE app'
> 
> Marco, 
> 
> OK, first of all, the exception is occurring because Castor 
> cannot locate
> the DataSource that you've specified to found in 'jdbc/myDataSource'. 
> What you should actually be fetching is the JDO instance. The 
> JDO instance is
> made available by the CastorJDOMBean which can be found here: 
> 
>     
> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/contrib/c
astorjdo/src/main/org/jboss/jdo/castor/

This needs to be compiled, jar'd and placed in the deploy directory in
order to start up an instance of Castor JDO and store the JDO object in
JNDI under the namespace you specify using the setJndiName() method in
the CastorJDOImpl.

Second, the example you note above (which comes from here:
http://www.castor.org/jdo.html#J2EE-Application) is simply general
information for a J2EE app. What you should really be fetching is the
JDO instance and use it get a Database instance.

There is an old example of using Castor with JBoss 2.x available here:

    ftp://ftp.exolab.org/pub/castor/examples/CastorJDO/

See src/rooms/util/CastorHelper.java in the rooms2.zip file for an
example of how the JDO instance can be fetched from JNDI and used to
get a Database object.

Also, I'll try to get a copy of the JBoss MBean for Castor posted
there soon.

Bruce
-- 
perl -e 'print unpack("u30","<0G)[EMAIL PROTECTED]&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'

The Castor Project 
http://www.castor.org/

Apache Geronimo 
http://incubator.apache.org/projects/geronimo.html

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to