0 Replies Latest reply on Aug 7, 2002 3:50 PM by fisheim

    Connecting a JSP to a database using JBoss 3.0

    fisheim

      I downloaded the Track+ Project Management tool from sourceforge, and am trying to get it to work with JBoss 3.0. I dropped the WAR file in the %JBOSS_HOME%/server/default/deploy directory, and am able to get the login page if I go to "http://localhost:8080/track-130". The problem I'm having now is connecting to the database that is sitting on a Firebird Database Server.

      Inside the track-130.war file, I've changed the WEB-INF/web.xml file so the JdbcURL param to point to the db file, like so:
      <init-param>
      <param-name>jdbcURL</param-name>
      <param-value>jdbc:interbase://localhost/C:/Java/database/Firebird/TRACK.gdb</param-value>
      </init-param>

      Inside the %JBOSS_HOME%/server/default/deploy directory, I?ve added the firebird-service.xml file and the firebirdsql.rar file.

      I've also modified the %JBOSS_HOME%/server/default/conf/standardjbosscmp-jdbc.xml file.

      Here is how the files look:
      ---- firebird-service.xml ---------------------------------------------------
      <?xml version="1.0" encoding="UTF-8"?>

      <!-- ==================================================================== -->
      <!-- New ConnectionManager setup for firebird dbs using jca-jdbc xa driver-->
      <!-- Build jmx-api (build/build.sh all) and view for config documentation -->
      <!-- ==================================================================== -->



      <!--FBManager can be used to create and drop databases.
      Drop is especially useful during testing, since it
      assures a clean start next time. -->

      localhost/3050:C:/Java/database/Firebird/TRACK.gdb
      sysdba
      masterkey
      true
      false



      <!--make the rar deploy - A BIG HACK till xslt based deployment is written-->
      jboss.jca:service=RARDeployer

      <depends optional-attribute-name="ManagedConnectionFactoryName">

      <!--more hack-->
      <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=Firebird Database Connector


      <!--config-property>
      <config-property-name>Server</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>localhost</config-property-value>
      </config-property>
      <config-property>
      <config-property-name>Port</config-property-name>
      <config-property-type>java.lang.Integer</config-property-type>
      <config-property-value>3050</config-property-value>
      </config-property-->
      <config-property>
      <config-property-name>Database</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>localhost/3050:C:/Java/database/Firebird/TRACK.gdb</config-property-value>
      </config-property>
      <config-property>
      <config-property-name>UserName</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>sysdba</config-property-value>
      </config-property>
      <config-property>
      <config-property-name>Password</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>masterkey</config-property-value>
      </config-property>


      DefaultDS



      <depends optional-attribute-name="ManagedConnectionPool">


      0
      50
      5000
      15
      <!--criteria indicates if Subject (from security domain) or app supplied
      parameters (such as from getConnection(user, pw)) are used to distinguish
      connections in the pool. Choices are
      ByContainerAndApplication (use both),
      ByContainer (use Subject),
      ByApplication (use app supplied params only),
      ByNothing (all connections are equivalent, usually if adapter supports
      reauthentication)-->
      ByContainer


      <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
      <!-- Include a login module configuration named FirebirdDBRealm.
      Update your login-conf.xml, here is an example for a
      ConfiguredIdentityLoginModule:

      <application-policy name = "FirebirdDBRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
      <module-option name = "principal">sysdba</module-option>
      <module-option name = "userName">sysdba</module-option>
      <module-option name = "password">masterkey</module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=XaTxCM,name=DefaultDS</module-option>
      </login-module>

      </application-policy>

      NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the
      module-option name = "managedConnectionFactoryName"
      must match the object name of the ConnectionManager you are configuring here.
      -->
      <!--comment out this line if you want component managed security or want
      to use the default values in the ManagedConnectionFactoryProperties -->
      FirebirdDBRealm

      <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:name=JaasSecurityManager

      java:/TransactionManager



      --------------------------------------------------------------------------------
      ---- standardjbosscmp-jdbc.xml ------------------------------------------
      <?xml version="1.0" encoding="UTF-8"?>


      <!-- ===================================================================== -->
      <!-- -->
      <!-- Standard JBossCMP-JDBC Configuration -->
      <!-- -->
      <!-- ===================================================================== -->

      <!-- $Id: standardjbosscmp-jdbc.xml,v 1.23.2.5 2002/05/21 14:51:41 starksm Exp $ -->

      <jbosscmp-jdbc>

      java:/DefaultDS
      <datasource-mapping>InterBase</datasource-mapping>
      <create-table>true</create-table>
      <remove-table>false</remove-table>
      <read-only>false</read-only>
      <pk-constraint>true</pk-constraint>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>


      <type-mappings>
      <type-mapping>
      InterBase
      ...
      </jbosscmp-jdbc>
      --------------------------------------------------------------------------------

      Here is some of the output from when I start the server:

      ...
      11:42:50,197 INFO [Jetty] Registered jboss.web:Jetty=0,JBossWebApplicationContext=0,context=/track-130
      11:42:50,438 INFO [Jetty] Checking Resource aliases
      11:42:50,458 INFO [Jetty] Delete existing temp dir C:\DOCUME~1\fisheim\LOCALS~1\Temp\Jetty__8080___track-130 for WebApplicationContext[/track-130,jar:file:/C:/Java/jboss-3.0.0/server/default/tmp/deploy/server/default/deploy/track-130.war/59.track-130.war!/]
      11:42:50,478 INFO [Jetty] Created temp dir C:\DOCUME~1\fisheim\LOCALS~1\Temp\Jetty__8080___track-130 for WebApplicationContext[/track-130,jar:file:/C:/Java/jboss-3.0.0/server/default/tmp/deploy/server/default/deploy/track-130.war/59.track-130.war!/]
      11:42:50,488 INFO [Jetty] Extract jar:file:/C:/Java/jboss-3.0.0/server/default/tmp/deploy/server/default/deploy/track-130.war/59.track-130.war!/ to C:\DOCUME~1\fisheim\LOCALS~1\Temp\Jetty__8080___track-130\webapp
      11:42:55,355 INFO [Jetty] Started SecurityHandler in WebApplicationContext[/track-130,jar:file:/C:/Java/jboss-3.0.0/server/default/tmp/deploy/server/default/deploy/track-130.war/59.track-130.war!/]
      11:42:55,365 INFO [Jetty] Started WebInfProtect
      11:42:55,365 INFO [Jetty] Started FilterHandler in WebApplicationContext[/track-130,jar:file:/C:/Java/jboss-3.0.0/server/default/tmp/deploy/server/default/deploy/track-130.war/59.track-130.war!/]
      11:42:55,365 INFO [Jetty] Started ServletHandler in WebApplicationContext[/track-130,jar:file:/C:/Java/jboss-3.0.0/server/default/tmp/deploy/server/default/deploy/track-130.war/59.track-130.war!/]
      11:42:55,375 INFO [Jetty] ResourceHandler started in file:/C:/Documents and Settings/fisheim/Local Settings/Temp/Jetty__8080___track-130/webapp/
      11:42:55,375 INFO [Jetty] Started ResourceHandler in WebApplicationContext[/track-130,jar:file:/C:/Java/jboss-3.0.0/server/default/tmp/deploy/server/default/deploy/track-130.war/59.track-130.war!/]
      11:42:55,375 INFO [Jetty] Started NotFoundHandler in WebApplicationContext[/track-130,jar:file:/C:/Java/jboss-3.0.0/server/default/tmp/deploy/server/default/deploy/track-130.war/59.track-130.war!/]
      11:42:56,096 INFO [Jetty] JSP: init
      11:42:58,109 INFO [Jetty] database: init
      11:43:02,144 INFO [STDOUT] Cannot connect to database.
      ...
      11:43:06,130 ERROR [MainDeployer] could not start deployment: file:/C:/Java/jboss-3.0.0/server/default/deploy/track-130.war
      org.jboss.deployment.DeploymentException: Cannot create connection pool: (class: interbase/interclient/ErrorKey, method: _$372 signature: (Ljava/lang/String;Ljava/lang/String;I)V) Expecting to find unitialized object on stack; - nested throwable: (javax.servlet.UnavailableException: Cannot create connection pool: (class: interbase/interclient/ErrorKey, method: _$372 signature: (Ljava/lang/String;Ljava/lang/String;I)V) Expecting to find unitialized object on stack)
      at org.jboss.jetty.Jetty.deploy(Jetty.java:423)
      at org.jboss.jetty.JettyService.performDeploy(JettyService.java:244)
      ...

      I'm pretty green with JBoss, so I'm sure I'm just doing something stupid. Any help would be appreciated.