我有一個Web應用程序(GWT/Vaadin爲主),它到現在爲止我通過持久性配置問題
MVN碼頭推出:運行
現在我要到其他Web服務器上運行(也Jetty),並獲得數據庫連接問題。
在WAR文件中沒有persistence.xml文件。這可能是失敗的原因嗎?
如果是的話,我應該如何配置持久,如果
а)我使用的Java DB(德比),
B)Hibenate和
c)現在配置數據庫連接如下所示
?
在此先感謝
德米特里
private void tryToOpenSession(final String aConnectionString)
throws Throwable {
...
state = PersistenceState.OPENING_CONNECTION;
final Configuration cnf = new Configuration();
cnf.setProperty(Environment.DRIVER,
"org.apache.derby.jdbc.EmbeddedDriver");
cnf.setProperty(Environment.URL, aConnectionString);
cnf.setProperty(Environment.DIALECT, DerbyDialect.class.getName());
cnf.setProperty(Environment.SHOW_SQL, "true");
cnf.setProperty(Environment.HBM2DDL_AUTO, "update");
cnf.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");
cnf.addResource("persistence/Entity1.hbm.xml");
cnf.addResource("persistence/Entity2.hbm.xml");
...
cnf.addResource("persistence/EntityN.hbm.xml");
sessionFactory = cnf.buildSessionFactory();
session = getSession();
...
state = PersistenceState.CONNECTION_OPEN;
}
UPD:這裏的例外:
java.lang.NoClassDefFoundError: Could not initialize class org.apache.derby.jdbc.EmbeddedDriver at java.lang.Class.forName0(Native Method) ~[na:1.6.0_20] at java.lang.Class.forName(Class.java:186) ~[na:1.6.0_20] at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:80) ~[hibernate-core-3.6.0.Final.jar:3.6.0.Final] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:143) ~[hibernate-core-3.6.0.Final.jar:3.6.0.Final] at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:84) ~[hibernate-core-3.6.0.Final.jar:3.6.0.Final] at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:459) ~[hibernate-core-3.6.0.Final.jar:3.6.0.Final] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:91) ~[hibernate-core-3.6.0.Final.jar:3.6.0.Final] at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2833) ~[hibernate-core-3.6.0.Final.jar:3.6.0.Final] at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2829) ~[hibernate-core-3.6.0.Final.jar:3.6.0.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1840) ~[hibernate-core-3.6.0.Final.jar:3.6.0.Final]
你可以顯示堆棧跟蹤嗎? – axtavt 2011-04-01 15:18:17
我將堆棧跟蹤添加到問題文本中。 – 2011-04-01 15:53:34
你有沒有想過這個問題?我有同樣的問題。 – 2011-04-10 00:54:51