Hibernate Problem 4.3 with Glassfish 3.1

Asked

Viewed 111 times

1

My application with Hibernate 4.3 wheel normally with Glassfish 4, installed together with the IDE NetBeans. However, the server where I need to deploy the application, has the Glassfish 3.1.

On this server the application is not running and unfortunately I cannot find out what is causing this error.

Follow part of my codes:

glassfish-Resources.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
    <jdbc-resource enabled="true" jndi-name="jdbc/forcaVendasWeb" object-type="user" pool-name="forcaVendasWebPool">
        <description>Accesses the database that provides data for the ForcaVendasWeb application</description>
    </jdbc-resource>
    <jdbc-connection-pool 
        allow-non-component-callers="false" 
        associate-with-thread="false" 
        connection-creation-retry-attempts="0" 
        connection-creation-retry-interval-in-seconds="10" 
        connection-leak-reclaim="false" 
        connection-leak-timeout-in-seconds="0" 
        connection-validation-method="auto-commit" 
        datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" 
        fail-all-connections="false" idle-timeout-in-seconds="300" 
        is-connection-validation-required="false" 
        is-isolation-level-guaranteed="true" 
        lazy-connection-association="false" 
        lazy-connection-enlistment="false" 
        match-connections="false" 
        max-connection-usage-count="0" 
        max-pool-size="32" 
        max-wait-time-in-millis="60000" 
        name="forcaVendasWebPool" 
        non-transactional-connections="false" 
        pool-resize-quantity="2" 
        res-type="javax.sql.ConnectionPoolDataSource" 
        statement-timeout-in-seconds="-1" 
        steady-pool-size="8" 
        validate-atmost-once-period-in-seconds="0" 
        wrap-jdbc-objects="false">

        <property name="URL" value="jdbc:mysql://IPdoMeuServidor:3306/planf571_PORTAL?zeroDateTimeBehavior=convertToNull"/>
        <property name="User" value="planf571_root"/>
        <property name="Password" value="minhaSenha"/>
    </jdbc-connection-pool>
</resources>

Hibernateutil

public class HibernateUtil {

    private static final SessionFactory factory = buildSessionFactory();

    public static SessionFactory getFactory() {
        return factory;
    }

    private static SessionFactory buildSessionFactory() {
        try {
            Configuration configuration = new Configuration().configure();
            StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();
            serviceRegistryBuilder.applySettings(configuration.getProperties());

            ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();

            System.out.println("Abre sessão Hibernate");
            SessionFactory session = configuration.buildSessionFactory(serviceRegistry);
            return session;

        } catch (HibernateException ex) {
            System.err.println("Criação da SessionFactory failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

web xml.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <display-name>Planfor - Força de Vendas</display-name>
    <servlet>
        <servlet-name>AutenticadorFVController</servlet-name>
        <servlet-class>br.com.forcavendasweb.controller.AutenticadorFVController</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>ClientesFVController</servlet-name>
        <servlet-class>br.com.forcavendasweb.controller.ClientesFVController</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>PedidosFVController</servlet-name>
        <servlet-class>br.com.forcavendasweb.controller.PedidosFVController</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>TabelasFVController</servlet-name>
        <servlet-class>br.com.forcavendasweb.controller.TabelasFVController</servlet-class>
    </servlet>

    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <resource-ref>
        <res-ref-name>jdbc/forcaVendasWeb</res-ref-name>
        <res-type>javax.sql.ConnectionPoolDataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
</web-app>

The mistakes

Advertência: StandardWrapperValve[AutenticadorFVController]: PWC1406: Servlet.service() for servlet AutenticadorFVController threw exception
java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
    at org.hibernate.cfg.annotations.EntityBinder.processComplementaryTableDefinitions(EntityBinder.java:936)
    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:824)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3790)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3744)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1410)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844)
    at br.com.portalserver.factory.HibernateUtil.buildSessionFactory(HibernateUtil.java:30)
    at br.com.portalserver.factory.HibernateUtil.<clinit>(HibernateUtil.java:15)
    at br.com.portalserver.dao.UsuariosFVDAO.autenticarUsuarioFV(UsuariosFVDAO.java:237)
    at br.com.forcavendasweb.controller.AutenticadorFVController.doPost(AutenticadorFVController.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:748)



Advertência: 4ba4da36]-HelperThread-#0;|com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@134e3b69 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: 
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: User planf571_root already has more than 'max_user_connections' active connections
    at sun.reflect.GeneratedConstructorAccessor308.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.Util.getInstance(Util.java:408)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:873)
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1710)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2191)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2222)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2017)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:779)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.GeneratedConstructorAccessor162.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
    at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
    at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)

I’ve been trying to decipher this for over 10 days and I can’t get anywhere. Please, if anyone can help me.

  • There are two exceptions. I believe the first is because Glassfish 3.1 does not support JPA 2.1, such as the method javax.persistence.Table.indexes() only added in this version of JPA, this error occurs. A user in stackoverflow.com posted this answer with a possible solution. As for the second, it seems that you have defined as many connections in the glassfish-resources.xml like 32, but the database user is only allowed to create 30.

  • Hello @Marine-Friendly. As for the users issue, it’s been solved. The JPA issue, unfortunately not yet. I will do some more tests and put the answer. Thank you very much for your help.

  • Guys, I’ve solved the problem by updating Glassfish to 4.0. Thank you so much for your attention.

1 answer

0

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: User planf571_root already has more than 'max_user_connections' active connections

It says that the User you are using, is at the limit of connections, see his permissions in the banks and increase the amount of connections as you use

  • the problem of the number of users. Unfortunately the other problem I could not solve yet. Thank you very much.

  • which server is using? AWS?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.