1

我的 hibernate.cfg.xml 有问题,实际上它可以工作,但是在我卸载 webnms 并重新安装它之后,运行它时代码有错误。这是我的 hibernate.cfg.xml 文件:

<hibernate-configuration>

<session-factory>

<!--property name="connection.driver_class">com.p6spy.engine.spy.P6SpyDriver</property-->       

<!--For MYSQL,Starts From Here-->
<!--
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/WebNmsDB?dumpQueriesOnException=true&amp;jdbcCompliantTruncation=false</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="databasename">MYSQL</property>
<property name="engineType">InnoDB</property>
-->
<!--End Of MYSQL-->

<!--For Using Oracle DB , Uncomment the below tags -->

<!--<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:WebNmsDB</property>
<property name="connection.username">DslamUser</property>
<property name="connection.password">dslam</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="databasename">ORACLE</property>-->

<!-- End of ORACLE ,Uncomment till here-->

<!--For Using Sybase ASA DB , Uncomment the below tags -->
<!--
<property name="connection.driver_class">com.sybase.jdbc3.jdbc.SybDriver</property>
<property name="connection.url">jdbc:sybase:Tds:localhost:2638/WebNmsDB</property>
<property name="connection.username">dba</property>
<property name="connection.password">sql</property>
<property name="dialect">org.hibernate.dialect.SybaseAnywhereDialect</property>
<property name="databasename">SYBASE</property>
-->
<!--END of SYBASE ASA ,Uncomment till here-->



<!--For Postgresql,Starts From Here-->

<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost/WebNmsDB</property>
<property name="connection.username">postgres</property>
<property name="connection.password">postgres</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="databasename">POSTGRESQL</property>
<property name="connection.schemaname">public</property>

<!--End Of Postgresql Uncomment till here-->


<!--For MSSQL,Starts From Here-->
<!--
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.url">jdbc:sqlserver://localhost:1433;databaseName=WebNmsDB</property>
<property name="connection.username">admin</property>
<property name="connection.password">public</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="databasename">MSSQL</property>
-->
<!--End Of MSSQL Uncomment till here-->

<!--Use Given Schema name for Qualified Tables -->
<!--
<property name="hibernate.default_schema">userName</property>
-->
<!-- JDBC connection pool (use the built-in) -->
<!--property name="hibernate.connection.pool_size">6</property-->
<property name="hibernate.c3p0.min_size">6</property>
<property name="hibernate.c3p0.max_size">15</property>
<property name="nontransaction.connection">3</property>
<property name="hibernate.connection.autocommit">true</property>
<!--property name="hibernate.c3p0.max_statements">1000</property-->
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.jdbc.batch_size">1000</property>
<property name="hibernate.connection.isolation">2</property>
<property name="enablecache">true</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<!--<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>-->
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.cache.use_query_cache">true</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<!-- used internally by WebNMS and also used for database re-connection-->
<property name="testQuery">select HOSTADDRESS from BEFailOver</property>
<!-- c3p0 DB-Reconnection Properties -->
<!--
<property name="hibernate.c3p0.acquireRetryAttempts">100</property>
<property name="hibernate.c3p0.acquireRetryDelay">3000</property>
<property name="hibernate.c3p0.breakAfterAcquireFailure">false</property>
-->
<!-- End of c3p0 DB-Reconnection Properties. For more details:http://www.mchange.com/projects/c3p0/index.html#configuring_recovery-->

<!-- ************************************** -->
<!-- TOPOLOGY MODULE OBJECT MAPPING ENTRIES -->
<!-- ************************************** -->
<mapping resource="com/adventnet/nms/topodb/ManagedObject.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/TopoObject.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/Network.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/IpAddress.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/Node.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/SnmpNode.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/SnmpInterface.hbm.xml"/>
<mapping resource="test/SwitchObject.hbm.xml"/>
<mapping resource="test/PortObject.hbm.xml"/>
<mapping resource="test/Printer.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/tl1/TL1Node.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/tl1/TL1Interface.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/ManagedGroupObject.hbm.xml"/>
<mapping resource="com/adventnet/nms/topodb/corba/CORBANode.hbm.xml"/>
<!-- *********************************** -->
<!-- FAULT MODULE OBJECT MAPPING ENTRIES -->
<!-- *********************************** -->
<mapping resource="com/adventnet/nms/eventdb/Event.hbm.xml"/>
<mapping resource="com/adventnet/nms/alertdb/Alert.hbm.xml"/>
<mapping resource="com/adventnet/nms/alertdb/AlertHistory.hbm.xml"/>

<!-- ***************************************** -->
<!-- PERFORMANCE MODULE OBJECT MAPPING ENTRIES -->
<!-- ***************************************** -->
<mapping resource="com/adventnet/nms/poll/PolledData.hbm.xml"/>

<!-- ******************************** -->
<!-- MAP MODULE OBJECT MAPPING ENTRIES -->
<!-- ******************************** -->
<mapping resource="com/adventnet/nms/mapdb/MapContainer.hbm.xml"/>
<mapping resource="com/adventnet/nms/mapdb/MapSymbol.hbm.xml"/>
<mapping resource="com/adventnet/nms/mapdb/MapLink.hbm.xml"/>
<mapping resource="com/adventnet/nms/mapdb/MapGroup.hbm.xml"/>
<mapping resource="com/adventnet/nms/mapdb/MapDB.hbm.xml"/>
<mapping resource="com/adventnet/nms/mapdb/GMapSymbol.hbm.xml"/>
<mapping resource="com/tetra/nms/ems/topodb/slot.hbm.xml"/>
<mapping resource="com/tetra/nms/ems/topodb/combiner.hbm.xml"/>
<mapping resource="com/tetra/nms/ems/topodb/multiCoupler.hbm.xml"/>
<mapping resource="com/tetra/nms/ems/topodb/duplexer.hbm.xml"/>
<mapping resource="com/tetra/nms/ems/topodb/baseBoard.hbm.xml"/>
<mapping resource="com/tetra/nms/ems/topodb/pc.hbm.xml"/>
<mapping resource="com/tetra/nms/ems/topodb/trxBoard.hbm.xml"/>
<mapping resource="com/tetra/nms/ems/topodb/board.hbm.xml"/>
<mapping resource="com/tetra/nms/ems/topodb/baseStation.hbm.xml"/>
</session-factory>

</hibernate-configuration>

这是我的堆栈跟踪:

Windows XP
log4j:WARN No appenders could be found for logger (org.hibernate.util.DTDEntityResolver).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation failed.org.hibernate.MappingNotFoundException: resource: com/adventnet/nms/topodb/ManagedObject.hbm.xml not found
Exception in thread "NmsMainBE" java.lang.ExceptionInInitializerError
    at com.adventnet.nms.util.hbn.HibernateUtil.<clinit>(HibernateUtil.java:60)
    at jdbc.CreateSchema.init(CreateSchema.java:94)
    at com.adventnet.nms.startnms.NmsMainBE.main(NmsMainBE.java:354)
    at com.adventnet.launcher.nms.StartNmsJdbc.run(StartNmsJdbc.java:492)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.MappingNotFoundException: resource: com/adventnet/nms/topodb/ManagedObject.hbm.xml not found
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1593)
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1561)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1540)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1529)
    at com.adventnet.nms.util.hbn.HibernateUtil.<clinit>(HibernateUtil.java:54)
    ... 4 more

怎么了?

4

1 回答 1

3

它说resource: com/adventnet/nms/topodb/ManagedObject.hbm.xml not found。仔细检查它是否在那里。也许整个拓扑模块都不见了

于 2012-05-08T08:04:52.757 回答