glassfish
  1. glassfish
  2. GLASSFISH-18954

Cannot create a truly global JDBC resource except by hand-editing domain.xml

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.2, 3.1.2.2
    • Fix Version/s: None
    • Component/s: jdbc
    • Labels:
      None

      Description

      I am using embedded GlassFish for testing. I am trying to set up a global JDBC resource using asadmin create-jdbc-resource (by way of the CommandRunner class).

      If I create a resource named jdbc/foo, it is created in the java:comp/env namespace. That is not what I want.

      If I try to create a resource named java:global/jdbc/foo, create-jdbc-resource will not let me do it, claiming the colon is not a permitted character. Escaping the colon has no effect.

      If I try to add the resource in via the add-resources command, I (eventually) get a runtime exception at deployment:

      java.lang.RuntimeException: Invalid resource : java:global/jdbc/H2Test__pm
      	at com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:540)
      	at com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:469)
      	at org.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)
      	at org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource(ProviderContainerContractInfoBase.java:71)
      	at org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:108)
      	at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:155)
      	at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:120)
      	at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:224)
      	at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:495)
      	at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:233)
      	at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
      	at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:871)
      	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
      	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
      	at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
      

        Activity

        Hide
        ljnelson added a comment -

        Even if this bug is not fixed, could you kindly tell me whether this should be allowed? That is, should I be able to create a JDBC resource with a java:global/ prefix using the asadmin create-jdbc-resource command?

        Show
        ljnelson added a comment - Even if this bug is not fixed, could you kindly tell me whether this should be allowed? That is, should I be able to create a JDBC resource with a java:global/ prefix using the asadmin create-jdbc-resource command?
        Hide
        Shalini added a comment -

        Its not possible to create-jdbc-resource like "java:global/jdbc/foo" . This is not allowed. However, this functionality could be achieved by means of adding the resource-ref in web.xml and glassfish-web.xml like mentioned below :

        asadmin create-jdbc-resource ... jdbc/foo

        web.xml :

        <resource-ref>
        <res-ref-name>java:global/jdbc/foo</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>

        glassfish-web.xml :

        <resource-ref>
        <res-ref-name>java:global/jdbc/foo</res-ref-name>
        <jndi-name>foo</jndi-name>
        </resource-ref>

        Hope this helps.

        Show
        Shalini added a comment - Its not possible to create-jdbc-resource like "java:global/jdbc/foo" . This is not allowed. However, this functionality could be achieved by means of adding the resource-ref in web.xml and glassfish-web.xml like mentioned below : asadmin create-jdbc-resource ... jdbc/foo web.xml : <resource-ref> <res-ref-name>java:global/jdbc/foo</res-ref-name> <res-type>javax.sql.DataSource</res-type> glassfish-web.xml : <resource-ref> <res-ref-name>java:global/jdbc/foo</res-ref-name> <jndi-name>foo</jndi-name> </resource-ref> Hope this helps.
        Hide
        Shalini added a comment -
        Show
        Shalini added a comment - Please refer https://blogs.oracle.com/JagadishPrasath/entry/applying_scope_for_jdbc_resources for more details.

          People

          • Assignee:
            sfelts
            Reporter:
            ljnelson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: