1 Reply Latest reply on Jul 15, 2009 11:47 AM by peterj

    Problem with JBoss and DataSource

    gabry86

      Hi!!

      I've a problem. i'm developing an application with Google Web Toolkit run on server JBoss 4.2.2. I'm using a DataSource, and it´s good. The problem is that i modify the file web.xml to add the datasource:

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" 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-app_2_5.xsd">

      Conecta con la BD oracle
      <servlet-name>ComunicaBD</servlet-name>
      <servlet-class>org.yournamehere.server.ComunicaBDImpl</servlet-class>

      <servlet-mapping>
      <servlet-name>ComunicaBD</servlet-name>
      <url-pattern>/ComunicaBD</url-pattern>
      </servlet-mapping>
      <session-config>
      <session-timeout>
      30
      </session-timeout>
      </session-config>
      <welcome-file-list>
      <welcome-file>welcomeGWT.html</welcome-file>
      </welcome-file-list>
      <jboss-web>
      <context-root>Asignacion</context-root>
      </jboss-web>
      <resource-ref>
      <res-ref-name>portalDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      </web-app>

      the lines in bold are new. If i remove this lines, the aplication runs, but if i put it, the server don't executes the aplication. This is wrong??

      Help and Thanks

        • 1. Re: Problem with JBoss and DataSource
          peterj

          The issue is that once you place a resource-ref into web.xml, then the app expects to find the resource in the local naming context (java:/comp/env/portalDS). But you need to tell JBoss AS to map the name back to the java: namespace. To do that, place an entry for the datasource in WEB-INF/jboss-web.xml:

          <jboss-web>
           <resource-ref>
           <res-ref-name>portalDS</res-ref-name>
           <jndi-name>java:portalDS</jndi-name>
           </resource-ref>
          </jboss-web>


          Also, please use 'code' tags around your XML text - select the text and click the Code button above the editor window.