7 Replies Latest reply: Nov 21, 2008 6:16 AM by jaikiran pai RSS

    Using Java 6 our datasource username is ignored

    Stephane Epardaud Newbie

      Hello,

      We recently upgraded from Java 5 to Java 6 and found that our postgresql datasources were always trying to connect with the "sa" user name no matter what we put in the datasource. Putting the username and password in the JDBC URL in the datasource fixes the issue, but this is not normal.

      We've tried both 4.2.2 and the 4.2.3 compiled for Java 6 with the same results.

      Environment:

      java version "1.6.0_10"
      Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
      Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)
      postgresql-8.3-603.jdbc4.jar
      postgresql server 8.3.4

      What can I do to help track down the problem?

        • 1. Re: Using Java 6 our datasource username is ignored
          jaikiran pai Master

          Please post your datasource configuration file.


          and found that our postgresql datasources were always trying to connect with the "sa" user name no matter what we put in the datasource.


          How did you verify this?

          While posting the logs or xml content or code, remember to wrap it in a code block using the Code button in the message editor window and please hit the Preview button to make sure your post is correctly formatted

          • 2. Re: Using Java 6 our datasource username is ignored
            Stephane Epardaud Newbie

            I got the following exception in the logs:

            Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"

            • 3. Re: Using Java 6 our datasource username is ignored
              Stephane Epardaud Newbie

               

              <?xml version="1.0" encoding="UTF-8"?>
              <datasources>
               <local-tx-datasource>
               <jndi-name>visiblelogisticsDatasource</jndi-name>
               <connection-url>jdbc:postgresql://localhost:5432/foo</connection-url>
               <driver-class>org.postgresql.Driver</driver-class>
               <user-name>foo</user-name>
               <password>foo</password>
               </local-tx-datasource>
              </datasources>
              


              • 4. Re: Using Java 6 our datasource username is ignored
                Peter Johnson Master

                I just tried on my setup. The only difference is I have PostgreSQL 8.3.3. It works for me.

                Are you sure that there si not some other database access going on, such as perhaps a login module? Or maybe someone changed the hsqldb-ds.xml file to use postgres?

                If that doesn't help, please post the full exception stack trace.

                • 5. Re: Using Java 6 our datasource username is ignored
                  Stephane Epardaud Newbie

                  Thanks for you help.

                  What do you mean some other database access?

                  This exception occurs when I log in my deployed application or when I invoke an mbean operation which uses the postgresql datasource. All this used to work before we switched to Java 6.

                  12:47:53,468 [ERROR] [JDBCExceptionReporter] Could not create connection; - nested throwable: (org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"); - nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"))
                  12:47:53,472 [ERROR] [[HtmlAdaptor] ] Servlet.service() for servlet HtmlAdaptor threw exception
                  javax.management.RuntimeMBeanException
                   at org.jboss.mx.interceptor.ReflectedDispatcher.handleInvocationExceptions(ReflectedDispatcher.java:176)
                   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:163)
                   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
                   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
                   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
                   at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
                   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
                   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
                   at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:258)
                   at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:223)
                   at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:262)
                   at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:100)
                   at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:82)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                   at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                   at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
                   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                   at java.lang.Thread.run(Thread.java:619)
                  Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
                   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
                   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
                   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
                   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
                   at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
                   at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
                   at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
                   at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
                   at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
                   at org.hibernate.search.impl.FullTextSessionImpl.beginTransaction(FullTextSessionImpl.java:254)
                   at com.foo.mbean.Configuration.reIndex(Configuration.java:221)
                   at com.foo.mbean.Configuration.initialIndex(Configuration.java:249)
                   at com.foo.mbean.Configuration.manualIndex(Configuration.java:217)
                   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                   at java.lang.reflect.Method.invoke(Method.java:597)
                   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
                   ... 33 more
                  Caused by: org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"); - nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"))
                   at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:109)
                   at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:66)
                   at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
                   ... 46 more
                  Caused by: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa")
                   at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:179)
                   at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:577)
                   at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:262)
                   at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:500)
                   at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:341)
                   at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:315)
                   at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:396)
                   at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
                   at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:103)
                   ... 48 more
                  Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"
                   at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:276)
                   at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:95)
                   at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
                   at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:124)
                   at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
                   at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:29)
                   at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
                   at org.postgresql.Driver.makeConnection(Driver.java:386)
                   at org.postgresql.Driver.connect(Driver.java:260)
                   at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:171)
                   ... 56 more
                  


                  • 6. Re: Using Java 6 our datasource username is ignored
                    Vicky Kak Master

                    Can you try a simple jsp code to see if you can get the connection from the configured datasource?

                    • 7. Re: Using Java 6 our datasource username is ignored
                      jaikiran pai Master

                       

                      at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)
                       at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
                       at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119)
                       at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
                       at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
                       at org.hibernate.search.impl.FullTextSessionImpl.beginTransaction(FullTextSessionImpl.java:2
                      54)
                       at com.foo.mbean.Configuration.reIndex(Configuration.java:221)
                      


                      And the code seems to be using Hibernate. That's adds an additional layer of configuration. Please post the hibernate configuration file (*.cfg.xml)