Ok, I have defined a mapping.xml entry. It is still getting that error. I am guessing it does not scan and check the validity of all mapping entries (checking for existence of database tables and columns) the first time it loads the mapping.xml. The getConnection(db) sounds a like a tangential call to all this. Anyways, It still throws the NullPointer, am I missing something in my xml files some configuration setting?
-----Original Message----- From: Bruce Snyder [mailto:ferret@;frii.com] Sent: Tuesday, October 29, 2002 10:31 PM To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Anybody used Castor with Resin's connection pooling? This one time, at band camp, Alok Pota said: Please see my comments inline. AP> Thanks, I feel like I am almost there getting this to work. AP> AP> The service() method of my testservlet looks like this. AP> AP> JDO jdo = getJDO(); AP> Database db = jdo.getDatabase(); AP> System.out.println("Database "+db.); AP> System.out.println("Scope "+db.getScope()); AP> System.out.println("Database connection "+getConnection(db)); AP> AP> private JDO getJDO() { AP> JDO jdo = new JDO(); AP> jdo.setConfiguration( getClass().getResource( AP>DatabaseFile ).toString() ); AP> jdo.setDatabaseName( "test" ); AP> return jdo; AP> } AP> AP> private Connection getConnection(Database db) throws AP>PersistenceException { AP> return (java.sql.Connection)((DatabaseImpl)db).getConnection(); AP> } AP> AP> My database.xml looks like this.. AP> AP><database name="test" engine="oracle"> AP> <jndi name="java:comp/env/jdbc/bigone"/> AP> <mapping href="mapping.xml" /> AP></database> AP> AP>My Resin.conf has the following entry AP> AP><resource-ref> AP> <res-ref-name>jdbc/bigone</res-ref-name> AP> <res-type>javax.sql.XADataSource</res-type> AP> <init-param driver-name="oracle.jdbc.driver.OracleDriver"/> AP> <init-param url="jdbc:oracle:thin:@xxxx.xxxxx.com:1521:xxxx"/> AP> <init-param user="yyyyy"/> AP> <init-param password="zzzzzzz"/> AP> <init-param max-connections="1"/> AP> <init-param enable-transaction="false"/> AP></resource-ref> AP> AP> AP>Also my mapping.xml is empty. I am just trying to get a handle to the AP>underlying JDBC connection. Castor JDO will not work without providing the mapping of objects to database tables in the mapping descriptor. I don't understand why you don't just use JDBC if don't want to map your objects and all you want is the java.sql.Connection. AP>It throws the following AP> AP>java.lang.NullPointerException AP> at org.exolab.castor.jdo.engine.DatabaseImpl.getConnection(Unknown AP>Source) AP> at CastorServletTest.getConnection(CastorServletTest.java:61) AP> at CastorServletTest.processRequest(CastorServletTest.java:36) AP> at CastorServletTest.doGet(CastorServletTest.java:70) AP> at javax.servlet.http.HttpServlet.service(HttpServlet.java:126) AP> AP>After looking at the code for DatabaseImpl I am guessing. _ctx is null AP>because I print out the _scope (& its not null). AP> AP>return _ctx.getConnection( _scope.getLockEngine() ); AP> AP>Any idea why? The TransactionContext object in DatabaseImpl is not instantiated until a transaction is initiated via a call to db.begin(). Because no transaction has been started the _ctx object is null. I suggest that you take a look at the Castor JDO examples to see how to work with Castor JDO before going any further. They are located in src/examples/jdo and src/examples/myapp. There is also information about executing them here: http://www.castor.org/examples.html Bruce -- perl -e 'print unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");' ----------------------------------------------------------- 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
