I’m working my way through the Lift Application Development Cookbook by Gilberto T. Garcia Jr and have run up against a problem I can’t seem to resolve. I’ve copied the source code Chap06-map-table and I’m trying to modify it to work with my IBM i (iSeries, AS/400, i5) database. I was able to make it work with the first type of connection using Squeryl Record. However, I can’t seem to figure how to get this to work using a JNDI Datasource. I’ve spent a couple of days searching the internet for examples of setting this up and have not found a good example involving a DB/400 database connection. Below is the error I get when I attempt to start the container and the code I’ve modified in an effort to make it work. Any help would be appreciated. Thanks. Bob
This is the error:
> container:start
[info] jetty-8.0.4.v20111024
[warn] Config error at <New id="dsliftbook" class="org.eclipse.jetty.plus.jndi.R
esource"><Arg/><Arg>jdbc/dsliftbook</Arg><Arg>
[warn] <New class="class com.ibm.as400.access.AS400JDBCConnectionPoolDataS
ource"><Set name="Url">"jdbc:as400://www.server.com/play2test;naming=system;erro
rs=full"</Set><Set name="User">user</Set><Set name="Password">password</Set></New>
[warn] </Arg></New>java.lang.ClassNotFoundException: class com.ibm.as400.acce
ss.AS400JDBCConnectionPoolDataSource
[warn] Failed startup of context o.e.j.w.WebAppContext{/,[file:/C:/Users/user/Lif
t26Projects/scala_210/chap06-map-table/src/main/webapp/]}
[info] Started SelectChannelConnector@0.0.0.0:8080 STARTING
[success] Total time: 0 s, completed Dec 15, 2013 12:21:59 AM
>
This is the modified jetty-env-xml file:
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty
/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<New id="dsliftbook" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/dsliftbook</Arg>
<Arg>
<New class="class com.ibm.as400.access.AS400JDBCConnectionPoolDataSource">
<Set name="Url">"jdbc:as400://www.server.com/play2test;naming=system;errors=full"
</Set>
<Set name="User">user</Set>
<Set name="Password">password</Set>
</New>
</Arg>
</New>
</Configure>
And this is the modified build.sbt file:
libraryDependencies ++= {
val liftVersion = "2.5"
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile",
"net.liftmodules" %% "lift-jquery-module_2.5" % "2.3",
"org.eclipse.jetty" % "jetty-webapp" % "8.0.4.v20111024" % "container",
"org.eclipse.jetty" % "jetty-plus" % "8.0.4.v20111024" % "container",
"ch.qos.logback" % "logback-classic" % "1.0.6",
"org.specs2" %% "specs2" % "1.14" % "test",
"net.liftweb" %% "lift-squeryl-record" % liftVersion % "compile",
"net.sf.jt400" % "jt400" % "6.7",
"org.liquibase" % "liquibase-maven-plugin" % "3.0.2"
)
}
When you define your Resource the attribute class="class com.ibm.as400.access.AS400JDBCConnectionPoolDataSource"
is incorrect. You don't need to preface the fully qualified class name with the word class
. It should read class="com.ibm.as400.access.AS400JDBCConnectionPoolDataSource"
. Fix that and as long as a jar containing com.ibm.as400.access.AS400JDBCConnectionPoolDataSource is on the classpath (is it provided by jt400?) you should be ok.