2009-04-09 66 views
0

我是新來的堅持,我做了helloWorld教程,非常令人印象深刻的順便說一句,但我現在試圖連接到一個真正的postgres數據庫,發現自己努力讓司機認識到,當我有它應該的感覺簡單死了。堅持不懈的數據源驅動

我放棄了所有的JDBC驅動程序的Postgres我不得不在持之以恆/ lib文件夾:

  • PostgreSQL相關8.3-603.jdbc2ee.jar
  • PostgreSQL相關8.3-603.jdbc2.jar
  • PostgreSQL相關8.3-603.jdbc3.jar
  • PostgreSQL相關8.3-603.jdbc4.jar

然而,當我開始用命令 「persvr」 沒有申辯持之以恆從我的項目文件夾彪我收到以下錯誤信息:

java.lang.ClassNotFoundException: org.postgresql.Driver 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251) 
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:379) 
    at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:341) 
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Class.java:169) 
    at org.persvr.datasource.DatabaseDataSource.initParameters(Unknown Source) 
    at org.persvr.datasource.DatabaseTableDataSource.initParameters(Unknown Source) 
    at org.persvr.data.DataSourceManager.initSource(Unknown Source) 
    at org.persvr.data.DataSourceManager.<clinit>(Unknown Source) 
    at org.persvr.data.Identification.idForString(Unknown Source) 
    at org.persvr.Persevere.load(Unknown Source) 
    at org.persvr.job.SampleData.execute(Unknown Source) 
    at org.persvr.job.Upgrade.execute(Unknown Source) 
    at org.persvr.remote.PersevereFilter.init(Unknown Source) 
    at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:620) 
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) 
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1234) 
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517) 
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:460) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) 
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 
    at org.mortbay.jetty.Server.doStart(Server.java:222) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50) 
    at org.persvr.util.JettyStart.main(Unknown Source) 

實際上,我試圖擴大HelloWorld項目作爲exercize,所以我在我的helloWorld/WEB-INF添加一個postgres.json文件/ config文件夾。下面是該文件的內容:

{"id":"postgres.json", 
"sources":[ 
     {"name":"addressTable", 
       "sourceClass":"org.persvr.datasource.DatabaseTableDataSource", 
       "connection":"jdbc:postgresql://hostname:5432/pnp?user=user1&pass=mypassword", 
       "driver":"org.postgresql.Driver", 
       "camelCaseColumnNames": false, 
       "table":"addr", 
       "idColumn":"addr_id", 
       "dataColumns":["addr_stat_cd","addr1","addr2","city","state","zip","zip_ext","cntry_cd","last_upd_uid","last_upd_dttm","create_uid","create_dt 
tm"], 
     "schema":{ 
       "data":{"$ref":"../addressTable/"} 
     } 
}] 
} 

有誰能告訴我爲什麼persevere不能找到postgres驅動程序嗎?

謝謝, Lancelot。

回答

0

想通了。 postgres驅動程序jar實際上應該進入該文件夾:persevere/WEB-INF/lib而不是persevere/lib。