我們正在將java blazeds hibernate與flex項目集成在一起。首先,我們在eclipse中測試了純java的hibernate,它執行的很好。但是,當我們把同樣的東西放在tomcat中與blazeds進行flex集成時,它會顯示以下錯誤。這是唯一的錯誤。休眠屬性找不到
Jan 24, 2013 11:31:31 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.6
Jan 24, 2013 11:31:31 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Jan 24, 2013 11:31:31 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
Jan 24, 2013 11:31:31 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Jan 24, 2013 11:31:31 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Jan 24, 2013 11:31:31 AM org.hibernate.cfg.Configuration getConfigurationInputSt
ream
INFO: Configuration resource: /hibernate.cfg.xml
這是hibernate.cfg.xml中(要識別的hibernate.cfg.xml是否沒有找到和我測試刪去.cfg.xml的DOCTYPE然後Tomcat的輸出顯示的說根元素是找不到的。 ..這意味着它是能夠找到hibernate.cfg.xml的(我認爲)
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost/test</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<mapping class="com.model.User" />
<mapping class="com.model.UserDetails" />
<mapping class="com.model.LoanDetails" />
<mapping class="com.model.BorrowerDetails" />
</session-factory>
</hibernate-configuration>
這是hiberutil.java
public class HibernateUtil
{
private static SessionFactory sessionFactory=configureSessionFactory();
private static ServiceRegistry serviceRegistry;
private static SessionFactory configureSessionFactory() throws HibernateException {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
public static SessionFactory getSessionFactory()
{
return sessionFactory;
}
}
爲什麼錯誤顯示?控制從柔性到來並執行Java方法的起點...但是當涉及到休眠的東西執行,它顯示這個錯誤在tomcat ...
但是,當我執行java + hibernate作爲純java應用程序它執行得很好。 。
有人可以幫我嗎?
感謝
EDIT 1通過@Andremoniy建議修改後,並把在src文件夾的.cfg.xml這裏也是日食它是工作,但沒有與彎曲的tomcat
以下錯誤來
org.hibernate.MappingException: An AnnotationConfiguration instance is required
to use <mapping class="com.model.User"/>
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.jav
a:1606)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.jav
a:1561)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1540)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1514)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1434)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1420)
at com.sample.HibernateUtil.configureSessionFactory(HibernateUtil
.java:26)
at com.sample.HibernateUtil.<clinit>(HibernateUtil.java:20)
at com.sample.App.checkUser(App.java:34)
嗨,你原來的問題是什麼錯誤?在你粘貼的堆棧中,我只能看到'hibernate.properties not found',這不是錯誤。 –
在我的原始問題,執行停止通過打印我粘貼堆棧,然後沒有執行查詢和沒有output..it結束像這樣...我把show_sql是真實的,但是不打印。 –
你檢查連接到你的數據庫? –