Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-311

roo does not create jndi reference in context.xml for jndi lookup objects

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.0.0.RC2
    • Fix Version/s: None
    • Component/s: PERSISTENCE, WEB MVC
    • Labels:
      None
    • Environment:
      all

      Description

      when building a web application with roo, jndi references in the ${webapp}/META-INF/context.xml are not created even if jpa is set up with a jndi datasource.

      Steps to reproduce:
      (in roo)
      1) project --topLevelPackage com.example.test
      2) persistence setup --provider HIBERNATE --database POSTGRESQL --jndiDataSource java:comp/env/jdbc/testDataSource
      3) entity --name Ent1
      4) field string name
      5) controller all --package com.example.test

      (in maven)
      6) mvn clean install -Dmaven.test.skip=true

      7) configure tomcat with the proper jndi config to match the database drivers and credentials of the jdbc/testDataSource
      8) copy resulting war file from step 6 to the tomcat/webapps dir
      9) start tomcat

      expected behavior is that tomcat should start without errors. actual behavior is that tomcat complains about the jndi name not being bound.
      "nested exception is javax.naming.NameNotFoundException: Name xxxxxxxx is not bound in this Context"

      A simple fix is to copy the following text into the webapp/META-INF/context.xml file:
      <Context path="/test"
      debug="5"
      reloadable="true" crossContext="true" privileged="true">

      <!-- Link to the user database we will get roles from -->
      <ResourceLink name="jdbc/testDataSource" global="jdbc/testDataSource"
      type="javax.sql.DataSource"/>

      </Context>

      repeat steps 6 thru 9 and you will see that tomcat no longer complains about the datasource. If the above file is simply created as part of the scaffolding, this issue can be completely avoided.

        Attachments

          Activity

            People

            • Assignee:
              sschmidt Stefan Schmidt
              Reporter:
              solid Matt Young
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: