我在 openshif 中有一个项目,我正在尝试使用 mysql 数据源配置模块。但它不起作用。
这是代码hibernate.cfg
:
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="connection.datasource">datasources/MysqlDS</property>
<property name="current_session_context_class">thread</property>
<property name="show_sql">false</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="com.wavetech_st.usuario.Usuario" />
</session-factory>
</hibernate-configuration>
这是代码applicationContext-security.xml
:
<authentication-manager>
<authentication-provider>
<password-encoder hash="sha" />
<jdbc-user-service data-source-ref="homeDataSource"
authorities-by-username-query="SELECT u.emailUsuario, p.permissao FROM Usuario u, permissaoUsuario p WHERE u.codigoUsuario = p.usuario AND u.emailUsuario = ?"
users-by-username-query="SELECT emailUsuario, senhaUsuario, ativoUsuario FROM Usuario WHERE emailUsuario = ?"/>
</authentication-provider>
</authentication-manager>
这是代码applicationContext.xml
:
<bean id="homeDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>datasources/MysqlDS</value>
</property>
</bean>
它的配置是standalone.xml
:
<datasource jta="false" jndi-name="java:jboss/datasources/MysqlDS" enabled="true" use-java-context="true" pool-name="MysqlDS" use-ccm="false">
<connection-url>jdbc:mysql://127.5.211.129:3306/testehome</connection-url>
<driver>mysql</driver>
<security>
<user-name>user</user-name>
<password>mypassword</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<driver name="mysql" module="com.mysql.jdbc">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
我用 ssh 访问了我的项目。检查文件 teste.war.failed。我可视化了这个文件:
{"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.web.deployment.default
-host./testehome" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./testehome: JBAS018040: Failed to start context"}}}}
我在路径中配置了一个 mysql 模块jbossas-7/jbossas-7/modules/com/mysql/jdbc/main/
:
module.xml mysql-connector-java-5.1.18-bin.jar
这是配置module.xml
:
<module xmlns="urn:jboss:module:1.0" name="com.mysql.jdbc">
<resources>
<resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
请帮忙!