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 Aljosa Mohorovic <al...@gmail.com> on 2006/12/07 17:58:00 UTC

torque runtime and ibm db2

generator works without problems using ant:
ant -f build-torque.xml
ant -f build-torque.xml create-db
ant -f build-torque.xml insert-sql
ant -f build-torque.xml jdbc

all targets end with "BUILD SUCCESSFUL"

but when using runtime in web application:
>>>
org.apache.jasper.JasperException: Exception in JSP: /index.jsp:26

23:         <%@ page
import="org.apache.commons.beanutils.*,org.apache.torque.*,torque.generated.*"
%>
24:         <%
25:
26:         Torque.init("C:\\Projects\\db2.properties");
27:
28:         %>
<<<

db2.properties:
>>>
torque.database.default = torquetest
torque.database.torquetest.adapter = db2

#Using commons-dbcp
torque.dsfactory.torquetest.factory =
org.apache.torque.dsfactory.SharedPoolDataSourceFactory
torque.dsfactory.torquetest.connection.driver = com.ibm.db2.jcc.DB2Driver
torque.dsfactory.torquetest.connection.url =
jdbc:db2://127.0.0.1:50000/torquetest
torque.dsfactory.torquetest.connection.user = aljosa
torque.dsfactory.torquetest.connection.password = aljosa
<<<

tomcat - root cause:
>>>
java.lang.NullPointerException
	java.lang.Class.forName0(Native Method)
	java.lang.Class.forName(Class.java:164)
	org.apache.torque.adapter.DBFactory.create(DBFactory.java:165)
	org.apache.torque.TorqueInstance.initAdapters(TorqueInstance.java:254)
	org.apache.torque.TorqueInstance.initialize(TorqueInstance.java:157)
	org.apache.torque.TorqueInstance.init(TorqueInstance.java:464)
	org.apache.torque.TorqueInstance.init(TorqueInstance.java:444)
	org.apache.torque.Torque.init(Torque.java:138)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:65)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
<<<

anyone here using ibm db2? any ideas why i have this problem?

-- 
Aljosa Mohorovic

http://www.revolucija.hr
Ivana Lucica 5
10000 Zagreb, Croatia

+385 (0)1 616 8414

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


RE: torque runtime and ibm db2

Posted by Greg Monroe <Gr...@DukeCE.com>.
Hmm, we need some better docs / error handling here.  This is
because db2 is not a valid adaptor name because there are three
flavors of DB2.  These are:

  db2net : "used to connect via the NET-Driver"
  db2app : "used to connect via the Application-Driver"
  as400  : "for DB2/400 on the IBM AS400 platform"

You need to use one of these adaptor names.

Also, at a minimum, you will want to wrap your Torque.init(..)
call with a check to see if Torque has been initialized.  Eg.

if ( ! Torque.isInit() ) {
	Torque.init(...)
}

FYI - A good way to initialize Torque to create a 
ServletContextListener implimentation and use the 
contextInitialized method to set up your webapp (including 
initializing Torque).  Add this as a <listener>  in your web.xml 
file and anytime the server is started (or context reloaded) 
Torque will be initialized.

> -----Original Message-----
> From: Aljosa Mohorovic [mailto:aljosa.mohorovic@gmail.com] 
> Sent: Thursday, December 07, 2006 11:58 AM
> To: Apache Torque Users List
> Subject: torque runtime and ibm db2
> 
> generator works without problems using ant:
> ant -f build-torque.xml
> ant -f build-torque.xml create-db
> ant -f build-torque.xml insert-sql
> ant -f build-torque.xml jdbc
> 
> all targets end with "BUILD SUCCESSFUL"
> 
> but when using runtime in web application:
> >>>
> org.apache.jasper.JasperException: Exception in JSP: /index.jsp:26
> 
> 23:         <%@ page
> import="org.apache.commons.beanutils.*,org.apache.torque.*,tor
> que.generated.*"
> %>
> 24:         <%
> 25:
> 26:         Torque.init("C:\\Projects\\db2.properties");
> 27:
> 28:         %>
> <<<
> 
> db2.properties:
> >>>
> torque.database.default = torquetest
> torque.database.torquetest.adapter = db2
> 
> #Using commons-dbcp
> torque.dsfactory.torquetest.factory =
> org.apache.torque.dsfactory.SharedPoolDataSourceFactory
> torque.dsfactory.torquetest.connection.driver = 
> com.ibm.db2.jcc.DB2Driver 
> torque.dsfactory.torquetest.connection.url = 
> jdbc:db2://127.0.0.1:50000/torquetest
> torque.dsfactory.torquetest.connection.user = aljosa 
> torque.dsfactory.torquetest.connection.password = aljosa <<<
> 
> tomcat - root cause:
> >>>
> java.lang.NullPointerException
> 	java.lang.Class.forName0(Native Method)
> 	java.lang.Class.forName(Class.java:164)
> 	org.apache.torque.adapter.DBFactory.create(DBFactory.java:165)
> 	
> org.apache.torque.TorqueInstance.initAdapters(TorqueInstance.java:254)
> 	
> org.apache.torque.TorqueInstance.initialize(TorqueInstance.java:157)
> 	org.apache.torque.TorqueInstance.init(TorqueInstance.java:464)
> 	org.apache.torque.TorqueInstance.init(TorqueInstance.java:444)
> 	org.apache.torque.Torque.init(Torque.java:138)
> 	org.apache.jsp.index_jsp._jspService(index_jsp.java:65)
> 	
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> 	
> org.apache.jasper.servlet.JspServletWrapper.service(JspServlet
> Wrapper.java:332)
> 	
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet
> .java:314)
> 	
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> 	
> org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter
> (MonitorFilter.java:368)
> <<<
> 
> anyone here using ibm db2? any ideas why i have this problem?
> 
> --
> Aljosa Mohorovic
> 
> http://www.revolucija.hr
> Ivana Lucica 5
> 10000 Zagreb, Croatia
> 
> +385 (0)1 616 8414
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 

Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed.  If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you  please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately.  Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited.



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