glassfish
  1. glassfish
  2. GLASSFISH-19654

Unable to specify a DataSource in an embedded EJB container

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.1
    • Fix Version/s: None
    • Component/s: ejb_container
    • Labels:
      None

      Description

      There is no way to programmatically specify the datasource for an EJB container. If a module is written to make use of a JTA datasource (by declaring the following in the module's persistence.xml):

      <jta-data-source>jdbc/myDS</jta-data-source>

      Then it seems impossible to load this module into an embedded EJB container, because the container cannot be configured to set up a datasource, and so the module cannot find one and deployment fails.

      Being able to specify datasource details in an embedded EJB container is critical for testing, where we want to use a different datasource but be sure we are testing the same artifact/jar/war file that will eventually be released.

      Other embedded EJB containers use properties to achieve this:

      However, the only relevant property for glassfish is
      org.glassfish.ejb.embedded.glassfish.configuration.file
      which could in theory be used to specify a domain.xml file with a pre-configured test datasource. Unfortunately, this property is ignored unless the following property is set
      org.glassfish.ejb.embedded.glassfish.installation.root
      and to set this second property requires an existing glassfish installtion - thus ruining the project portability I was trying to achieve by using embedded glassfish in the first place.

      See here for the forum post I made which describes other awkward and limited workarounds:
      http://stackoverflow.com/questions/14748280/how-to-define-a-test-datasource-for-an-embedded-ejb-container

        Activity

        Hide
        marina vatkina added a comment -

        Embeddable EJB container is designed to work either with pre-installed GlassFish, where any resource can be added using CLI or UI, or by specifying the config file with the pre-defined resources.

        Changing to RFE

        Show
        marina vatkina added a comment - Embeddable EJB container is designed to work either with pre-installed GlassFish, where any resource can be added using CLI or UI, or by specifying the config file with the pre-defined resources. Changing to RFE
        Hide
        skwirking added a comment -

        I agree that the feature to configure a datasource via EJB Container properties should be a feature request.

        However, specifying the config file (domain.xml) only works if the installation root is also specified. If the installation root is not specified, the config file option is ignored.

        Thus, it appears to be impossible to set up a datasource inside an EJB Container without having an existing installation of GlassFish - and for this reason I respectfully request that the issue still be marked as a 'bug'.

        Show
        skwirking added a comment - I agree that the feature to configure a datasource via EJB Container properties should be a feature request. However, specifying the config file (domain.xml) only works if the installation root is also specified. If the installation root is not specified, the config file option is ignored. Thus, it appears to be impossible to set up a datasource inside an EJB Container without having an existing installation of GlassFish - and for this reason I respectfully request that the issue still be marked as a 'bug'.

          People

          • Assignee:
            marina vatkina
            Reporter:
            skwirking
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: