Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring GenericJDBCException:无法打开连接_Spring_Jpa_Persistence_Glassfish 3 - Fatal编程技术网

Spring GenericJDBCException:无法打开连接

Spring GenericJDBCException:无法打开连接,spring,jpa,persistence,glassfish-3,Spring,Jpa,Persistence,Glassfish 3,我有一个问题,这让我非常恼火。在本地主机上一切正常,但当我将应用程序部署到主机(Jelast)服务器(glassfish 3.1.1)上时 使用: 春季3.1.1 玻璃鱼3.1.1 JSF2.0 JPA2.0 收到此(较短版本): javax.persistence.PersistenceException:org.hibernate.exception.genericjdbception: 无法打开连接 原因:org.hibernate.exception.genericjdbceptio

我有一个问题,这让我非常恼火。在本地主机上一切正常,但当我将应用程序部署到主机(Jelast)服务器(glassfish 3.1.1)上时

使用:

  • 春季3.1.1
  • 玻璃鱼3.1.1
  • JSF2.0
  • JPA2.0
收到此(较短版本):

javax.persistence.PersistenceException:org.hibernate.exception.genericjdbception: 无法打开连接

原因:org.hibernate.exception.genericjdbception: 无法打开连接

原因:javax.resource.spi.ResourceAllocationException:分配连接时出错。 原因:无法分配连接,因为:握手错误

。。。关于糟糕的握手和倒下的其他类似说法:

原因:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: 握手不好

仅提及-在localhost上一切正常:


/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>
<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>
<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>

org.hibernate.ejb.HibernatePersistence
jdbc/shopJNDI
com.jelastic.adiso87.Shop.entity.UserDetailEntity
com.jelastic.adiso87.Shop.entity.ProductEntity
com.jelastic.adiso87.Shop.entity.CategoryEntity
applicationContext.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>
<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>
<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>
xlmns适用于所有3.0

<!-- 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

<?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>
<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>
<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>

我的应用程序
myprojectweb.xml
index.jsf
javax.faces.PROJECT_阶段
发展
上下文配置位置
/WEB-INF/applicationContext.xml
org.springframework.web.context.ContextLoaderListener
org.springframework.web.context.request.RequestContextListener
log4jConfigLocation
/WEB-INF/log4j.properties
log4jRefreshInterval
1000
org.springframework.web.util.Log4jConfigListener
javax.faces.DEFAULT_后缀
.xhtml
faces config.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>
<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>
<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>

com.jelastic.adiso87.international.messages
味精
pl
EN
org.springframework.web.jsf.el.SpringBeanFacesELResolver
在glassfish中,我已经对池和资源进行了与本地主机相同的配置。我只更改了有关数据库的信息。因此,在管理面板中,我有Ping success


有人能帮我吗?

我相信这就是这个bug的情况:


解决方案是升级散列密码(错误中提供了指南的链接:)

我相信这就是错误的情况:


解决方案是升级散列密码(错误中提供了指南的链接:)

很抱歉回答得太晚。现在一切正常。我想问题出在我这边。无论如何,谢谢你的时间。很抱歉迟了回答。现在一切正常。我想问题出在我这边。无论如何,谢谢你抽出时间。