db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b.v.we...@valbosoft.com
Subject init question
Date Tue, 16 Sep 2008 19:09:55 GMT




Hi,

I'm using torque 3.1.1 in combination with turbine. I'm setting up some
testcases with Cactus.

I wanted to reset the torque configuration for the test cases
programmatically.

I proceeded with the following code:

            String confFile = config.getServletContext().getRealPath(
                        "WEB-INF/conf/Torque.properties");
            PropertiesConfiguration torqueConf =
                  new PropertiesConfiguration();
            torqueConf.load(confFile);

            Torque.shutdown();

            Torque.init(torqueConf);

(I understood that Torque.init(confFile) wouldn't work)

This works to work for a simple query like
            Criteria criteria = new Criteria();
            List l = null;

            criteria.add(AnuncioPeer.CADUCADO, (Object) "Y", Criteria.
NOT_EQUAL);

            l=AnuncioPeer.doSelect (criteria);

But it doesn't work anymore for this:

            Criteria criteria = new Criteria();
            List l = null;

            criteria.add(AnuncioPeer.CADUCADO, (Object) "Y", Criteria.
NOT_EQUAL);
            criteria.addDescendingOrderByColumn(AnuncioPeer.FECHA);

            l=AnuncioPeer.doSelect (criteria);

It throws the following error:
org.apache.torque.TorqueException: java.lang.NullPointerException
      at org.apache.torque.util.BasePeer.throwTorqueException(
BasePeer.java:200)
      at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1204)
      at es.embajadapaisesbajos.om.BaseAnuncioPeer.doSelectVillageRecords(
BaseAnuncioPeer.java:396)
      at es.embajadapaisesbajos.om.BaseAnuncioPeer.doSelectVillageRecords(
BaseAnuncioPeer.java:369)
      at es.embajadapaisesbajos.om.BaseAnuncioPeer.doSelect(
BaseAnuncioPeer.java:337)
      at es.embajadapaisesbajos.test.EmbajadaTestCase.setUp(
EmbajadaTestCase.java:164)
      at junit.framework.TestCase.runBare(TestCase.java:125)
      at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(
AbstractCactusTestCase.java:155)
      at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(
AbstractWebTestCaller.java:120)
      at
org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(
AbstractWebTestController.java:94)
      at
org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(
AbstractWebTestController.java:225)
      at
org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(
AbstractWebTestController.java:1)
      at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(
ServletTestRedirector.java:102)
      at
org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(
ServletTestRedirector.java:225)
      at org.apache.cactus.server.ServletTestRedirector.doPost(
ServletTestRedirector.java:1)
      at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(
ServletTestRedirector.java:73)
      at
org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(
ServletTestRedirector.java:225)
      at org.apache.cactus.server.ServletTestRedirector.doGet(
ServletTestRedirector.java:1)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:269)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:188)
      at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:210)
      at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:174)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
AuthenticatorBase.java:433)
      at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:117)
      at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:108)
      at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:151)
      at org.apache.coyote.http11.Http11Processor.process(
Http11Processor.java:870)
      at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
Http11BaseProtocol.java:665)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
PoolTcpEndpoint.java:528)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
LeaderFollowerWorkerThread.java:81)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.java:685)
      at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.NullPointerException
      at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:1148)
      at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1221)
      at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1198)
      ... 33 more

So adding criteria.addDescendingOrderByColumn(AnuncioPeer.FECHA) breaks it.
When I debug, I can see that the criteria is no longer able to create a
String representation of its state so far. When I do normal execution
(without having shut down Torque) this query works fine and the criteria
shows the query it's about to execute.

After diving a bit into the Torque source I also added AnuncioPeer.
getMapBuilder(AnuncioMapBuilder.CLASS_NAME) after init() as it seems it
cannot get a table mapping from the table map. This doesn't resolve
anything, though.

Am I doing something wrong here?
I tried to see if I could upgrade to Torque 3.3, but Turbine is complaining
in some ways.

Regards, Bo


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message