2

以前に jboss アプリケーション サーバーにデプロイしたことがありません。に Java Web アプリケーションをデプロイしようとしたときに、次のエラーが発生しましたopenshift。と を使用SpringしてJPA 2.0います。

じぶんのapplicationContext.xml

<jee:jndi-lookup id="dataSource" jndi-name="java:jboss/datasources/MysqlDS" resource-ref="true" />

じぶんの standalone.xml

<datasource jndi-name="java:jboss/datasources/MysqlDS" enabled="${mysql.enabled}" use-java-context="true" pool-name="MysqlDS">
                    <connection-url>jdbc:mysql://${env.OPENSHIFT_DB_HOST}:${env.OPENSHIFT_DB_PORT}/${env.OPENSHIFT_APP_NAME}</connection-url>
                    <driver>mysql</driver>
                    <security>
                      <user-name>${env.OPENSHIFT_DB_USERNAME}</user-name>
                      <password>${env.OPENSHIFT_DB_PASSWORD}</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="mysql" module="com.mysql.jdbc">
                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>
                </drivers>

エラー

2012/07/12 09:00:36,714 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-2) HHH000204: Processing PersistenceUnitInfo [
    name: tentacleSpotPU
   ...]
2012/07/12 09:00:37,118 WARN  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-2) HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
2012/07/12 09:00:37,139 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.persistenceunit."ROOT.war#tentacleSpotPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."ROOT.war#tentacleSpotPU": Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_24]
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_24]
   at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: tentacleSpotPU] Unable to build EntityManagerFactory
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
   at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
   at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    ... 3 more
Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
   at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:97)
 at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:67)
 at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:176)
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159)
  at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131)
 at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71)
    at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270)
  at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735)
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
   ... 9 more

2012/07/12 09:00:37,309 ERROR [org.jboss.as] (MSC service thread 1-3) JBAS015875: JBoss AS 7.1.0.Final "Thunder" started (with errors) in 75169ms - Started 401 of 720 services (203 services failed or missing dependencies, 113 services are passive or on-demand)
2012/07/12 09:00:37,440 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "ROOT.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"ROOT.war#tentacleSpotPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"ROOT.war#tentacleSpotPU\": Failed to start service"}}
2012/07/12 09:00:38,574 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment ROOT.war in 1131ms
2012/07/12 09:00:38,576 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.persistenceunit."ROOT.war#tentacleSpotPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."ROOT.war#tentacleSpotPU": Failed to start service

2012/07/12 09:00:38,609 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"ROOT.war#tentacleSpotPU\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"ROOT.war#tentacleSpotPU\": Failed to start service"}}}}

この問題を解決するにはどうすればよいですか?

4

3 に答える 3

0

JBoss が接続なしで永続コンテキストをロードできるように、hibernate.dialect プロパティを設定する必要があります (接続を使用して方言を検出できます)。アプリケーション(あなたの場合はSpring)からの接続を待ちます。

persistence.xml で設定するか、クラスパスのルート ディレクトリに配置された hibernate.properties で設定できます。

于 2012-07-13T17:29:39.337 に答える
0

プロジェクトの設定はどうですか? プロジェクトは jboss 7.1.0 Final でローカルに実行されますか? JPA 2.0 構成の EntityManagerFactory と hibernate.dialect を定義する persistence.xml ファイルを使用します。META-INF ディレクトリにあります。それが私のプロジェクトでセットアップする方法です。

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="userpersistence" transaction-type="RESOURCE_LOCAL">
    <provider>
        org.hibernate.ejb.HibernatePersistence
    </provider>
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
        <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
        <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/acctdatabase"/>
        <property name="hibernate.connection.username" value="acct-user"/>
        <property name="hibernate.connection.password" value="password"/>
    </properties>
</persistence-unit>

于 2012-07-12T18:40:58.127 に答える