You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by b....@valbosoft.com on 2008/09/16 21:09:55 UTC

init question




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


Re: init question

Posted by Boudewijn van Weert <b....@valbosoft.com>.
Forget about my last mail, I guess that's more of a Turbine thing...

Thanks, Bo

2008/9/17 Boudewijn van Weert <b....@valbosoft.com>

> Hi,
>
> I'm not sure in which state this RC1 is right now, and I'm about to install
> the production version, so I don't think it's a good idea to migrate at this
> moment. I'm using Turbine 2.3.2.
>
> What I'm trying to do is do some testing using cactus and maven 2. Another
> direction I've been investing now is to start up the application with a test
> Torque.properties from the start. A first manual test has been successful.
>
> Any good suggestions on how to do this? Would the right approach be that
> the maven 2 script copies the test Torque.properties file in place just
> before the integration tests? Has anybody had any experience with this?
>
> Regards, Bo
>
> 2008/9/17 Thomas Vandahl <tv...@apache.org>
>
> Thomas Fischer wrote:
>> > - Use Torque 3.3 (maybe using a newer Turbine ? I have no idea, whether
>> or
>> > how this works, I never worked with Turbine). Maybe someone experienced
>> > with Turbine on this list can give advice on this.
>>
>> You should upgrade to Turbine 2.3.3-RC1 and Torque 3.3 if at all
>> possible. Which version of Turbine are you currently using?
>>
>> Bye, Thomas.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>>
>>
>

Re: init question

Posted by Boudewijn van Weert <b....@valbosoft.com>.
Hi,

I'm not sure in which state this RC1 is right now, and I'm about to install
the production version, so I don't think it's a good idea to migrate at this
moment. I'm using Turbine 2.3.2.

What I'm trying to do is do some testing using cactus and maven 2. Another
direction I've been investing now is to start up the application with a test
Torque.properties from the start. A first manual test has been successful.

Any good suggestions on how to do this? Would the right approach be that the
maven 2 script copies the test Torque.properties file in place just before
the integration tests? Has anybody had any experience with this?

Regards, Bo

2008/9/17 Thomas Vandahl <tv...@apache.org>

> Thomas Fischer wrote:
> > - Use Torque 3.3 (maybe using a newer Turbine ? I have no idea, whether
> or
> > how this works, I never worked with Turbine). Maybe someone experienced
> > with Turbine on this list can give advice on this.
>
> You should upgrade to Turbine 2.3.3-RC1 and Torque 3.3 if at all
> possible. Which version of Turbine are you currently using?
>
> Bye, Thomas.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>

Re: init question

Posted by Thomas Vandahl <tv...@apache.org>.
Thomas Fischer wrote:
> - Use Torque 3.3 (maybe using a newer Turbine ? I have no idea, whether or 
> how this works, I never worked with Turbine). Maybe someone experienced 
> with Turbine on this list can give advice on this.

You should upgrade to Turbine 2.3.3-RC1 and Torque 3.3 if at all
possible. Which version of Turbine are you currently using?

Bye, Thomas.

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


RE: init question

Posted by Thomas Fischer <fi...@seitenbau.net>.
 > I'm using torque 3.1.1 in combination with turbine. 
> ...
> 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);
> 
> ...
> 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.

Torque.shutdown did not work correctly in earlier versions of Torque; it 
messed up the Table/column maps. This is fixed now (I do not remember when 
exactly, please check the change logs).
I see two options for you
- backport the fix and buld Torque 3.1.1 yourself
- Use Torque 3.3 (maybe using a newer Turbine ? I have no idea, whether or 
how this works, I never worked with Turbine). Maybe someone experienced 
with Turbine on this list can give advice on this.

    Thomas