glassfish
  1. glassfish
  2. GLASSFISH-18865

getImplementationVersion() returns null for application classes within EJB container

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.1.1_b12
    • Fix Version/s: None
    • Component/s: classloader
    • Labels:
      None
    • Environment:

      Win7 Pro SP1 64 Bit JDK1.6.0_26

      Description

      My ejb-jar contains the following entry in the MANIFEST.MF (among others):

      Implementation-Version: 4.34.1-SNAPSHOT

      Inside of this jar is a SLSB (CallerNameSessionBean) which does the following code:

      public String getVersion()

      { return CallerNameSessionBean.class.getPackage().getImplementationVersion(); }

      When a client is calling this method, it always returns null.

      It seems this Java SE API is not working in GF3.1.1's EJB container?

      I am using the same solution pattern within GF3.1.1's ACC container, and there it is correctly returning "4.34.1-SNAPSHOT"!

        Activity

        Hide
        marina vatkina added a comment -

        Does it work in 3.1.2 or trunk?

        Show
        marina vatkina added a comment - Does it work in 3.1.2 or trunk?
        Hide
        mkarg added a comment -

        Cannot tell you whether it works on 3.1.2 due to this issue: http://java.net/jira/browse/GLASSFISH-18877

        Show
        mkarg added a comment - Cannot tell you whether it works on 3.1.2 due to this issue: http://java.net/jira/browse/GLASSFISH-18877
        Hide
        mkarg added a comment -

        Cannot tell you whether it works on trunk due to this test faults:

        ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test (default-test) on project common-util: There are test failures.

        Tests in error:
        com.sun.enterprise.universal.xml.MiniXmlParserTest

        Show
        mkarg added a comment - Cannot tell you whether it works on trunk due to this test faults: ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.4.3:test (default-test) on project common-util: There are test failures. Tests in error: com.sun.enterprise.universal.xml.MiniXmlParserTest
        Hide
        mkarg added a comment -

        Since http://java.net/jira/browse/GLASSFISH-18877 is fixed (thanks to Hong Zhang), I was able to reproduce the problem in GFv3.1.2. The result is the same as on GFv.3.1.1: Works in ACC, but fails (i. e. returns null) in EJB container.

        Show
        mkarg added a comment - Since http://java.net/jira/browse/GLASSFISH-18877 is fixed (thanks to Hong Zhang), I was able to reproduce the problem in GFv3.1.2. The result is the same as on GFv.3.1.1: Works in ACC, but fails (i. e. returns null) in EJB container.
        Hide
        mkarg added a comment -

        Sad to see that there is no further comment for over half a year.

        Show
        mkarg added a comment - Sad to see that there is no further comment for over half a year.
        Hide
        mkarg added a comment -

        I noticed the following, maybe it is of interest for fixing this bug:

        When doing CallerNameSessionBean.class.getResourceAsStream("/META-INF/MANIFEST.MF") and parsing it using Java.util.jar.Manifest class, it has a completely DIFFERENT set of attributes than the MANIFEST.MF file of the JAR. Hence, getResourceAsStream does not return the original file of the JAR!

        Show
        mkarg added a comment - I noticed the following, maybe it is of interest for fixing this bug: When doing CallerNameSessionBean.class.getResourceAsStream("/META-INF/MANIFEST.MF") and parsing it using Java.util.jar.Manifest class, it has a completely DIFFERENT set of attributes than the MANIFEST.MF file of the JAR. Hence, getResourceAsStream does not return the original file of the JAR!
        Hide
        mkarg added a comment -

        Identified a functional workaround (for those who suffer from the same pain):

                final InputStream pomPropertiesStream = CallerNameSessionBean.class
                        .getResourceAsStream("/META-INF/maven/de.quipsy.server/quipsy-ejb-module/pom.properties");
                try {
                    final Properties pomProperties = new Properties();
                    pomProperties.load(pomPropertiesStream);
                    return pomProperties.getProperty("version");
                } catch (final IOException ignored) {
                    LOGGER.fine(ignored.getMessage());
                    return null;
                } finally {
                    try {
                        pomPropertiesStream.close();
                    } catch (final IOException ignored) {
                        ignored.printStackTrace();
                    }
                }
        
        Show
        mkarg added a comment - Identified a functional workaround (for those who suffer from the same pain): final InputStream pomPropertiesStream = CallerNameSessionBean.class .getResourceAsStream( "/META-INF/maven/de.quipsy.server/quipsy-ejb-module/pom.properties" ); try { final Properties pomProperties = new Properties(); pomProperties.load(pomPropertiesStream); return pomProperties.getProperty( "version" ); } catch ( final IOException ignored) { LOGGER.fine(ignored.getMessage()); return null ; } finally { try { pomPropertiesStream.close(); } catch ( final IOException ignored) { ignored.printStackTrace(); } }

          People

          • Assignee:
            Sanjeeb Sahoo
            Reporter:
            mkarg
          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: