[GLASSFISH-18865] getImplementationVersion() returns null for application classes within EJB container Created: 04/Jul/12  Updated: 08/May/13

Status: Open
Project: glassfish
Component/s: classloader
Affects Version/s: 3.1.1_b12
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: mkarg Assignee: Sanjeeb Sahoo
Resolution: Unresolved Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
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"!



 Comments   
Comment by marina vatkina [ 07/Jul/12 ]

Does it work in 3.1.2 or trunk?

Comment by mkarg [ 09/Jul/12 ]

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

Comment by mkarg [ 09/Jul/12 ]

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

Comment by mkarg [ 10/Jul/12 ]

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.

Comment by mkarg [ 06/May/13 ]

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

Comment by mkarg [ 08/May/13 ]

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!

Comment by mkarg [ 08/May/13 ]

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();
            }
        }
Generated at Fri Feb 27 05:04:10 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.