DLOG4J部署问题

ajava 发布于 2011/06/30 10:33
阅读 3K+
收藏 1

最近想研究一款开源的BLog ,Java开源大全中选了DLOG4J,于是就当了份发布包,但是部署的时候老是报我的Hibernate配置有问题,我都按照setup.txt步骤来做的,郁闷。。。。

首先说下我的windows环境:JDK1.6 + Tomcat6.0 + Mysql 5.1

1、在MySql中创建了数据库`pdlog`(doc/dlog_mysql5.sql)我在原来基础上加了一句创建数据库代码

CREATE DATABASE /*!32312 IF NOT EXISTS*/`pdlog` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `pdlog`;

2、修改 webapp\WEB-INF\classes\下的hibernate.cfg.xml

<session-factory>
       
        <!-- ********** database relative settings ********** -->
       
        <!-- Microsoft Access (must comment the 'dscp.defaultTransactionIsolation' below) -->       
        <!--
        <property name="dialect">com.liusoft.util.db.ODBCDialect</property>
        <property name="dscp.driverClassName">sun.jdbc.odbc.JdbcOdbcDriver</property>
        <property name="dscp.url">jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ={DLOG4J}\WEB-INF\dlog.mdb</property>       
        <property name="dscp.username">admin</property>
        <property name="dscp.password"></property>
        <property name="dscp.encoding">false</property>       
        -->
        <!-- MySQL 3/4/5 -->
        <!-- ?useUnicode=true&amp;characterEncoding=GBK -->
       
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="dscp.driverClassName">com.mysql.jdbc.Driver</property>
        <property name="dscp.url">jdbc:mysql://localhost:3306/pdlog</property>               
        <property name="dscp.username">root</property>
        <property name="dscp.password">root</property>
       
       
        <!-- Microsoft SQLServer (via jTDS) -->
        <!--
        <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
        <property name="dscp.driverClassName">net.sourceforge.jtds.jdbc.Driver</property>
        <property name="dscp.url">jdbc:jtds:sqlserver://localhost:1433/dlog;useCursors=true</property>               
        <property name="dscp.username">sa</property>
        <property name="dscp.password"></property>       
        -->
       
        <!-- IBM DB2 -->
        <!--
        <property name="dialect">org.hibernate.dialect.DB2Dialect</property>
        <property name="dscp.driverClassName">com.ibm.db2.jcc.DB2Driver</property>
        <property name="dscp.url">jdbc:db2://localhost:50000/dlog</property>               
        <property name="dscp.username">db2inst1</property>
        <property name="dscp.password"></property>       
        -->
       
        <!-- Oracle -->
        <!--
        <property name="dialect">org.hibernate.dialect.OracleDialect</property>
        <property name="dscp.driverClassName">oracle.jdbc.driver.OracleDriver</property>
        <property name="dscp.url">jdbc:oracle:thin:@localhost:1521:dlog</property>               
        <property name="dscp.username">ora</property>
        <property name="dscp.password"></property>       
        -->
       
        <!-- Informix -->
        <!--
        <property name="dialect">org.hibernate.dialect.InformixDialect</property>
        <property name="dscp.driverClassName">com.informix.jdbc.IfxDriver</property>
        <property name="dscp.url">jdbc:informix-sqli://localhost:1526/dlog:informixserver=server1</property>               
        <property name="dscp.username">root</property>
        <property name="dscp.password"></property>       
        <property name="dscp.encoding">true</property>
        -->
       
        <!-- Sybase (via jTDS) -->
        <!--
        <property name="dialect">org.hibernate.dialect.SybaseDialect</property>
        <property name="dscp.driverClassName">net.sourceforge.jtds.jdbc.Driver</property>
        <property name="dscp.url">jdbc:jtds:sybase://localhost:7100/dlog;useCursors=true</property>               
        <property name="dscp.username">root</property>
        <property name="dscp.password"></property>
        -->
       
        <!-- PostgreSQL -->
        <!--
        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="dscp.driverClassName">org.postgresql.Driver</property>
        <property name="dscp.url">jdbc:postgresql://localhost:5432/dlog</property>               
        <property name="dscp.username">root</property>
        <property name="dscp.password"></property>
        -->
       
        <!-- MaxDB(SAPDB) -->
        <!--
        <property name="dialect">org.hibernate.dialect.SAPDBDialect</property>
        <property name="dscp.driverClassName">com.sap.dbtech.jdbc.DriverSapDB</property>
        <property name="dscp.url">jdbc:sapdb://localhost/dlog</property>               
        <property name="dscp.username">root</property>
        <property name="dscp.password"></property>
        -->
       
        <!-- HSQLDB -->
        <!--
        <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
        <property name="dscp.driverClassName">org.hsqldb.jdbcDriver</property>
        <property name="dscp.url">jdbc:hsqldb:hsql://localhost/dlog</property>               
        <property name="dscp.username">admin</property>
        <property name="dscp.password"></property>
        -->
       
        <!-- ********** database independence settings ********** -->
        <property name="connection.provider_class">com.liusoft.dlog4j.db.DataSourceConnectionProvider</property>
       
        <!-- Connection Pool using DBCP -->       
        <property name="dscp.datasource">org.apache.commons.dbcp.BasicDataSource</property>
        <property name="dscp.initialSize">1</property>
        <property name="dscp.maxActive">200</property>
        <property name="dscp.maxIdle">10</property>
        <property name="dscp.maxWait">2000</property>
        <property name="dscp.defaultAutoCommit">false</property>
        <property name="dscp.poolPreparedStatements">true</property>
        <property name="dscp.maxOpenPreparedStatements">1000</property>
        <!-- TRANSACTION_READ_UNCOMMITTED -->
        <!--
        <property name="dscp.defaultTransactionIsolation">1</property>       
        -->
       
        <!-- ********** global settings ********** -->
        <property name="show_sql">false</property>
        <property name="jdbc.batch_size">100</property>
        <property name="use_outer_join">false</property>
        <property name="cache.use_query_cache">true</property>
        <property name="default_batch_fetch_size">20</property>
        <property name="jdbc.use_scrollable_resultset">true</property>
        <property name="jdbc.use_reflection_optimizer">true</property>
       
        <!-- ********** beans mapping **********
       
        <mapping resource="access/dlog.hbm.xml"/>
        <mapping resource="access/core.hbm.xml"/>
        <mapping resource="access/diary.hbm.xml"/>   
        <mapping resource="access/photo.hbm.xml"/>
        <mapping resource="access/music.hbm.xml"/>       
        <mapping resource="access/bbs.hbm.xml"/>
        <mapping resource="access/query.hbm.xml"/>
        <mapping resource="access/other.hbm.xml"/>
        -->
   
        <mapping resource="com/liusoft/dlog4j/hbm/dlog.hbm.xml"/>
        <mapping resource="com/liusoft/dlog4j/hbm/core.hbm.xml"/>
        <mapping resource="com/liusoft/dlog4j/hbm/diary.hbm.xml"/>   
        <mapping resource="com/liusoft/dlog4j/hbm/photo.hbm.xml"/>
        <mapping resource="com/liusoft/dlog4j/hbm/music.hbm.xml"/>       
        <mapping resource="com/liusoft/dlog4j/hbm/bbs.hbm.xml"/>
        <mapping resource="com/liusoft/dlog4j/hbm/query.hbm.xml"/>
        <mapping resource="com/liusoft/dlog4j/hbm/other.hbm.xml"/>
       
       
    </session-factory>

把Acess的链接注释掉了,把MySql数据库链接打开、口令端口啥的都改了,并且相应的beans mapping也做了注释、打开

3、之后把webapp拷贝到Tomcat下面,命名为dlog4j,然后启动服务,访问http://localhost:8099/dlog4j/snoop.vm

报错:

DLOG4J snoop

 Database

  • Database error , check the db config (hibernate.cfg.xml)
加载中
1
红薯
红薯
你的问题就在于不应该把 tomcat 安装在一个带有空格的目录下
0
红薯
红薯
请看看 Tomcat 日志中的异常信息,这是连接不到数据库的异常,不知道用户名和口令是否正确
0
a
ajava

我看了下Tomcat日志,一启服务就报找不到hibernate.cfg.xml

直接修改dlog4j3\webapp\WEB-INF\classes下面的hibernate.cfg.xml 会造成这个问题?

 

严重: Hibernate Initialize failed.
org.hibernate.HibernateException: could not find file: D:\Program%20Files\Tomcat%206.0\webapps\dlog4j\WEB-INF\classes\hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.configure(Unknown Source)
    at com.liusoft.util.db.Hibernate.<init>(Hibernate.java:63)
    at com.liusoft.util.db.Hibernate.init(Hibernate.java:53)
    at com.liusoft.dlog4j.db.HibernateUtils.<clinit>(HibernateUtils.java:46)
    at com.liusoft.dlog4j.dao._DAOBase.getSession(DAO.java:514)
    at com.liusoft.dlog4j.dao.DAO.executeNamedQuery(DAO.java:361)
    at com.liusoft.dlog4j.dao.DAO.findNamedAll(DAO.java:392)
    at com.liusoft.dlog4j.dao.BBSReplyDAO.fetchAfter(BBSReplyDAO.java:107)
    at com.liusoft.dlog4j.plugin.BuildIndexThread.run(SearchEnginePlugIn.java:228)
Caused by: java.io.FileNotFoundException: D:\Program%20Files\Tomcat%206.0\webapps\dlog4j\WEB-INF\classes\hibernate.cfg.xml (系统找不到指定的路径。)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    ... 9 more
2011-6-30 10:58:08 com.liusoft.dlog4j.plugin.BuildIndexThread run
严重: Exception occur when buildIndexes using com.liusoft.dlog4j.dao.DiaryDAO
java.lang.NullPointerException
    at com.liusoft.dlog4j.dao.DAO.executeNamedQuery(DAO.java:362)
    at com.liusoft.dlog4j.dao.DiaryDAO.listDiaryAfter(DiaryDAO.java:839)
    at com.liusoft.dlog4j.dao.DiaryDAO.fetchAfter(DiaryDAO.java:861)
    at com.liusoft.dlog4j.plugin.BuildIndexThread.run(SearchEnginePlugIn.java:228)
2011-6-30 10:58:08 com.liusoft.dlog4j.plugin.BuildIndexThread run
严重: Exception occur when buildIndexes using com.liusoft.dlog4j.dao.MusicDAO
java.lang.NullPointerException
    at com.liusoft.dlog4j.dao.DAO.executeNamedQuery(DAO.java:362)
    at com.liusoft.dlog4j.dao.DAO.findNamedAll(DAO.java:392)
    at com.liusoft.dlog4j.dao.MusicDAO.fetchAfter(MusicDAO.java:320)
    at com.liusoft.dlog4j.plugin.BuildIndexThread.run(SearchEnginePlugIn.java:228)
2011-6-30 10:58:08 com.liusoft.dlog4j.plugin.BuildIndexThread run
严重: Exception occur when buildIndexes using com.liusoft.dlog4j.dao.BBSTopicDAO
java.lang.NullPointerException
    at com.liusoft.dlog4j.dao.DAO.executeNamedQuery(DAO.java:362)
    at com.liusoft.dlog4j.dao.DAO.findNamedAll(DAO.java:392)
    at com.liusoft.dlog4j.dao.BBSTopicDAO.fetchAfter(BBSTopicDAO.java:385)
    at com.liusoft.dlog4j.plugin.BuildIndexThread.run(SearchEnginePlugIn.java:228)
2011-6-30 10:58:08 com.liusoft.dlog4j.plugin.BuildIndexThread run
严重: Exception occur when buildIndexes using com.liusoft.dlog4j.search.DiaryReplyProvider
java.lang.NullPointerException
    at com.liusoft.dlog4j.dao.DAO.executeNamedQuery(DAO.java:362)
    at com.liusoft.dlog4j.dao.DAO.findNamedAll(DAO.java:392)
    at com.liusoft.dlog4j.dao.DiaryDAO.listDiaryRepliesAfter(DiaryDAO.java:918)
    at com.liusoft.dlog4j.search.DiaryReplyProvider.fetchAfter(DiaryReplyProvider.java:40)
    at com.liusoft.dlog4j.plugin.BuildIndexThread.run(SearchEnginePlugIn.java:228)
2011-6-30 10:58:08 com.liusoft.dlog4j.plugin.BuildIndexThread run
严重: Exception occur when buildIndexes using com.liusoft.dlog4j.search.PhotoReplyProvider
java.lang.NullPointerException
    at com.liusoft.dlog4j.dao.DAO.executeNamedQuery(DAO.java:362)
    at com.liusoft.dlog4j.dao.PhotoDAO.listPhotoRepliesAfter(PhotoDAO.java:849)
    at com.liusoft.dlog4j.search.PhotoReplyProvider.fetchAfter(PhotoReplyProvider.java:39)
    at com.liusoft.dlog4j.plugin.BuildIndexThread.run(SearchEnginePlugIn.java:228)
2011-6-30 10:58:08 com.liusoft.dlog4j.plugin.BuildIndexThread run
严重: Exception occur when buildIndexes using com.liusoft.dlog4j.dao.BBSReplyDAO
java.lang.NullPointerException
    at com.liusoft.dlog4j.dao.DAO.executeNamedQuery(DAO.java:362)
    at com.liusoft.dlog4j.dao.DAO.findNamedAll(DAO.java:392)
    at com.liusoft.dlog4j.dao.BBSReplyDAO.fetchAfter(BBSReplyDAO.java:107)
    at com.liusoft.dlog4j.plugin.BuildIndexThread.run(SearchEnginePlugIn.java:228)
2011-6-30 10:58:08 com.liusoft.dlog4j.plugin.BuildIndexThread run
严重: Exception occur when buildIndexes using com.liusoft.dlog4j.dao.PhotoDAO
java.lang.NullPointerException
    at com.liusoft.dlog4j.dao.DAO.executeNamedQuery(DAO.java:362)
    at com.liusoft.dlog4j.dao.DAO.findNamedAll(DAO.java:392)
    at com.liusoft.dlog4j.dao.PhotoDAO.fetchAfter(PhotoDAO.java:724)
    at com.liusoft.dlog4j.plugin.BuildIndexThread.run(SearchEnginePlugIn.java:228)
2011-6-30 10:58:08 org.apache.velocity.tools.view.servlet.ServletToolboxManager getInstance
信息: Using config file '/WEB-INF/conf/velocity-toolbox.xml'
2011-6-30 10:58:08 org.apache.velocity.tools.view.servlet.ServletToolboxManager getInstance
信息: Toolbox setup complete.
2011-6-30 10:58:08 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8099
2011-6-30 10:58:09 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-6-30 10:58:09 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/16  config=null
2011-6-30 10:58:09 org.apache.catalina.startup.Catalina start
信息: Server startup in 1673 ms

0
a
ajava

实际目录是有的,我重新启动了Tomcat也报这个错

0
子木007
子木007
盯着 @红薯 尽管问吧。  这个是他的作品
0
a
ajava

哎,关于中文路径、空格活造成这个问题我知道,但是就是一直没发生过,今天这个让我遇到了。。。

装Tomcat、JDK我都是按默认路径,而且可恶的是Tomcat6.0安装的时候(Tomcat 6.0  中间有空格,去掉之后才行,害我重装了2次。。。)还得把Tomcat 6.0中间空格去掉,不过最后还是跑起来了,谢谢红薯的解答

0
游客
游客

引用来自“红薯”的答案

你的问题就在于不应该把 tomcat 安装在一个带有空格的目录下
++
返回顶部
顶部