5 Replies Latest reply on Jun 2, 2003 3:40 PM by Aaron Arnett

    Configuring posgreSQL experiencing connection timeout

    Aaron Arnett Newbie

      I have been trying to set up a single entity bean on a JBoss 3.2.0 Tomcat server connecting to a postgreSQL using the pg73jdbc3.jar driver package. I started with a whole app but since I ran into the problems described below I'm attempting a single bean as a test. I am simply trying to get anything going.

      The JBoss server is running on WinNT4 SP5 and the DB is running on RH Linux 8.0.

      Everything seems to go fine when starting the server but when I drop the bean jar file in the deploy directory I get the series of errors below.

      I'm trying to do this with two DataSources. I've not done anything with the Hypersonic setup since it is used by JMS and is local. But the postgres DB is remote so I've set up another DataSource for it I'm calling SecondaryDS. The entity bean is to use the postgres DB.

      I tried repeatedly to get this working with the remote DB and couldn't get any further. So I also set up a postgres DB on the local system but got exactly the same error.

      Does anyone know what the problem is here? Is it wrong to try to have two datasources? If so, why? I'd rather allow JMS to use a local DB reasonable since this is a very Message intensive app. What else could be the problem?

      Any help would be appreciated.

      Thanks,
      Aaron

      Below is the error trace and what I think are the relevant config segments.


      17:13:19,992 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.2.0_tomcat-4.1.24/server/default/deploy/BSII.jar
      17:14:05,318 WARN [NestedThrowable] Duplicate throwable nesting of same base type: class org.jboss.deployment.DeploymentException is assignable from: class org.jboss.deployment.DeploymentException
      17:14:05,328 ERROR [URLDeploymentScanner] Failed to deploy: org.jboss.deployment.scanner.URLDeploymentScanner$DeployedURL@e5619079{ url=file:/C:/jboss-3.2.0_tomcat-4.1.24/server/default/deploy/BSII.jar, deployedLastModified=0 }
      org.jboss.deployment.DeploymentException: exception in init of file:/C:/jboss-3.2.0_tomcat-4.1.24/server/default/deploy/BSII.jar; - nested throwable: (org.jboss.deployment.DeploymentException: Connection timed out: connect; - nested throwable: (java.net.ConnectException: Connection timed out: connect))
      at org.jboss.deployment.MainDeployer.init(MainDeployer.java:720)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:637)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:613)
      at sun.reflect.GeneratedMethodAccessor34.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
      at $Proxy7.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:280)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:421)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:200)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:211)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:190)
      Caused by: org.jboss.deployment.DeploymentException: Connection timed out: connect; - nested throwable: (java.net.ConnectException: Connection timed out: connect)
      at org.jboss.metadata.XmlFileLoader.getDocument(XmlFileLoader.java:271)
      at org.jboss.ejb.EJBDeployer.init(EJBDeployer.java:391)
      at org.jboss.deployment.MainDeployer.init(MainDeployer.java:694)
      ... 14 more
      Caused by: java.net.ConnectException: Connection timed out: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
      at java.net.Socket.connect(Socket.java:426)
      at java.net.Socket.connect(Socket.java:376)
      at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:386)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:602)
      at sun.net.www.http.HttpClient.(HttpClient.java:303)
      at sun.net.www.http.HttpClient.(HttpClient.java:264)
      at sun.net.www.http.HttpClient.New(HttpClient.java:336)
      at sun.net.www.http.HttpClient.New(HttpClient.java:317)
      at sun.net.www.http.HttpClient.New(HttpClient.java:312)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:481)
      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:472)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:574)
      at java.net.URL.openStream(URL.java:960)
      at org.apache.xerces.impl.XMLEntityManager.startEntity(XMLEntityManager.java:740)
      at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:700)
      at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:258)
      at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:811)
      at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:333)
      at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:529)
      at org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:585)
      at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:147)
      at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:221)
      at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:201)
      at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
      at org.jboss.metadata.XmlFileLoader.getDocument(XmlFileLoader.java:248)
      ... 16 more


      standardjbosscmp-jdbc.xml

      ...


      java:/SecondaryDS
      <datasource-mapping>PostgreSQL 7.2</datasource-mapping>

      <create-table>true</create-table>
      <remove-table>false</remove-table>
      <read-only>false</read-only>

      ...

      --------------

      login-config.xml

      ...

      <application-policy name = "PostgresDBRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule"
      flag = "required">
      <module-option name = "principal">xxx</module-option>
      <module-option name = "userName">xxx</module-option>
      <module-option name = "password">yyy</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=TxCM,name=SecondaryDS</module-option>
      </login-module>

      </application-policy>

      ...

      --------------

      postgres-ds.xml

      ...


      <local-tx-datasource>
      <jndi-name>SecondaryDS</jndi-name>
      <connection-url>jdbc:postgresql://myHostname/myDBName</connection-url>
      <driver-class>org.postgresql.Driver</driver-class>
      <user-name>xxx</user-name>
      yyy
      </local-tx-datasource>



      ...

        • 1. Re: Configuring posgreSQL experiencing connection timeout
          Jon Barnett Master

          What is your ejb-jar.xml? And depending on the EJB spec with which you're complying in ejb-jar.xml, what is your (EJB 2.0) standardjbosscmp-jdbc.xml or (EJB 1.2) standardjaws.xml. That will help people diagnose the problem.

          • 2. Re: Configuring posgreSQL experiencing connection timeout
            Aaron Arnett Newbie

            Below is the info you inquired about (the standardjbosscmp-jdbc.xml info was in the original posting. Is there important anything that I missed in what I posted?)

            Since the failure happens when deploying, I'm assuming that the container attempts to make a connection to the datasource at that time and for some reason the connection times out. Is this the correct sequence? This is my first time trying to set up JBoss with a datasource other than the default Hypersonic so I've no real idea what to expect.

            Thanks for any help.
            Aaron


            ejb-jar.xml

            ...

            <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
            ...


            <![CDATA[]]>

            <ejb-name>OSName</ejb-name>

            <local-home>com.mycompany.mydivision.entity.interfaces.OSNameLocalHome</local-home>
            com.mycompany.mydivision.entity.interfaces.OSNameLocal

            <ejb-class>com.mycompany.mydivision.entity.OSNameCMP</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.String</prim-key-class>
            False
            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>OSName</abstract-schema-name>
            <cmp-field >
            <![CDATA[Returns the osname]]>
            <field-name>osname</field-name>
            </cmp-field>
            <cmp-field >
            <![CDATA[Returns the description]]>
            <field-name>description</field-name>
            </cmp-field>
            <primkey-field>osname</primkey-field>


            <query-method>
            <method-name>findAll</method-name>
            <method-params>
            </method-params>
            </query-method>
            <result-type-mapping>Local</result-type-mapping>
            <ejb-ql><![CDATA[SELECT OBJECT(o) FROM OSName o]]></ejb-ql>




            ...

            -----------------

            jboss.xml

            ...


            <ejb-name>OSName</ejb-name>
            <local-jndi-name>BSII.OSNameLocalHome</local-jndi-name>

            <method-attributes>
            </method-attributes>


            ...

            -----------------
            jbosscmp-jdbc.xml


            <jbosscmp-jdbc>

            java:/SecondaryDS
            <datasource-mapping>PostgreSQL 7.2</datasource-mapping>


            <enterprise-beans>


            <ejb-name>OSName</ejb-name>
            <table-name>public.osname</table-name>

            <cmp-field>
            <field-name>osname</field-name>
            <column-name>osname</column-name>

            </cmp-field>
            <cmp-field>
            <field-name>description</field-name>
            <column-name>description</column-name>

            </cmp-field>



            </enterprise-beans>

            </jbosscmp-jdbc>

            • 3. Re: Configuring posgreSQL experiencing connection timeout
              Aaron Arnett Newbie

              Just as an experiment I removed the postgres driver from the default\lib directory and, oddly enough, I got exactly the same error. No complaints about missing drivers or anything like that. Is that what I should expect?

              Also, please note that the "jboss.jca:service=TxCM" above in the login-config.xml section is a typo, the actual entry is "jboss.jca:service=LocalTxCM".

              TIA for any help.

              Aaron

              • 4. Re: Configuring posgreSQL experiencing connection timeout
                Jon Barnett Master

                Sorry. My bad. Should have paid more attention. The connection problem seems to be with the actual deployment rather than any DS related issue.

                Nothing in the declarations seem out of order. Needs more investigation. Do other EJBs deploy ok?

                • 5. Re: Configuring posgreSQL experiencing connection timeout
                  Aaron Arnett Newbie

                  Apparently the problem was in my jboss.xml file. The doctype line referred to jboss_3_1.dtd which was being set from my build.properties file and being picked up by xdoclet. At some point, I specified jBoss 3.1 because the xdoclet documentation said it was a valid value, but xdoclet would not accept 3.2.

                  Thanks for your help.

                  Aaron