我有一个问题真的让我大吃一惊。在 localhost 上一切正常,但是当我在托管( jelastic)服务器(glassfish 3.1.1)上部署我的应用程序时
使用:
- 春天 3.1.1
- 玻璃鱼 3.1.1
- JSF 2.0
- JPA 2.0
收到这个(较短的版本):
javax.persistence.PersistenceException:org.hibernate.exception.GenericJDBCException:无法打开连接
引起:org.hibernate.exception.GenericJDBCException:无法打开连接
原因:javax.resource.spi.ResourceAllocationException:分配连接时出错。原因:无法分配连接,因为:握手错误
......关于BAD HANDSHAKE的其他一些类似的行并深入了解:
引起:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Bad handshake
只是提到-在本地主机上一切正常:
/WEB-INF/classes/META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
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">
<persistence-unit name="shopPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/shopJNDI</jta-data-source>
<class>com.jelastic.adiso87.Shop.entity.UserDetailEntity</class>
<class>com.jelastic.adiso87.Shop.entity.ProductEntity</class>
<class>com.jelastic.adiso87.Shop.entity.CategoryEntity</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
</properties>
</persistence-unit>
</persistence>
应用程序上下文.xml
适用于所有 3.0 的 xlmns
<!-- CONTEXT CONFIGURATRION -->
<context:component-scan base-package="com.jelastic.adiso87.Shop" />
<context:annotation-config />
<!-- PERSISTENCE AND TRANSACTION CONFIGURATION -->
<jee:jndi-lookup id="myEmf" jndi-name="persistence/shopPU" />
<jee:jndi-lookup id="dataSource" jndi-name="shopJNDI" />
<bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManagerName" value="java:appserver/TransactionManager" />
</bean>
<tx:annotation-driven transaction-manager="txManager" />
<!-- END OF CONFIGURATION -->
<!-- BEANS -->
<bean id="userDetailDao" class="com.jelastic.adiso87.Shop.dao.UserDetailDaoImpl"/>
web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>My App</display-name>
<description>MyProject web.xml</description>
<!-- Welcome files -->
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<!-- Project Stage -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- SPRING FRAMEWORK INTEGERATION -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- Log4j CONFIGURATION -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>1000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- Use Documents Saved as *.xhtml -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
面孔-config.xml
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<resource-bundle>
<base-name>com.jelastic.adiso87.international.messages</base-name>
<var>msg</var>
</resource-bundle>
<locale-config>
<default-locale>pl</default-locale>
<supported-locale>en</supported-locale>
</locale-config>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
在 glassfish 中,我已经对池和资源进行了与本地主机相同的配置。我只更改了有关数据库的信息。所以在管理面板中我有Ping Succeed
有人可以帮助我吗?