5 Replies Latest reply on Nov 3, 2009 11:11 AM by adrian.brock

    Change in manifest parser breaks symbolic name

    thomas.diesler

      https://jira.jboss.org/jira/browse/JBOSGI-137

      When you remove the fallback hack, you should see the SimpleBundleTestCase fail

      DEPLOYMENTS IN ERROR:
       Deployment "vfszip:/home/tdiesler/svn/jboss-osgi/projects/runtime/microcontainer/trunk/target/test-libs/simple-bundle.jar/" is in error due to the following reason(s): java.lang.IllegalStateException: Cannot obtain Bundle-SymbolicName
      


      I guess that many BND generated bundles might fail.

      The fallback hack does not handle potential parameters.

        • 1. Re: Change in manifest parser breaks symbolic name
          thomas.diesler

           

          2009-08-26 09:37:42,614 ERROR [org.jboss.osgi.plugins.metadata.QNameAttributeListValueCreator] Exception parsing parameters.
          org.jboss.osgi.plugins.metadata.ParseException: Encountered "jboss-osgi-common" at line 1, column 1.
          Was expecting:
           <QNAME> ...
          
           at org.jboss.osgi.plugins.metadata.HeaderValue.generateParseException(HeaderValue.java:962)
           at org.jboss.osgi.plugins.metadata.HeaderValue.jj_consume_token(HeaderValue.java:842)
           at org.jboss.osgi.plugins.metadata.HeaderValue.parameterInfo(HeaderValue.java:214)
           at org.jboss.osgi.plugins.metadata.HeaderValue.parseParameters(HeaderValue.java:122)
           at org.jboss.osgi.plugins.metadata.HeaderValue.parseParameters(HeaderValue.java:65)
           at org.jboss.osgi.plugins.metadata.HeaderValue.parseParameters(HeaderValue.java:87)
           at org.jboss.osgi.plugins.metadata.QNameAttributeListValueCreator.parseAttribute(QNameAttributeListValueCreator.java:39)
           at org.jboss.osgi.plugins.metadata.ParameterizedAttributeListValueCreator.useString(ParameterizedAttributeListValueCreator.java:39)
           at org.jboss.osgi.plugins.metadata.ParameterizedAttributeListValueCreator.useString(ParameterizedAttributeListValueCreator.java:1)
           at org.jboss.osgi.plugins.metadata.AbstractValueCreator.createValue(AbstractValueCreator.java:53)
           at org.jboss.osgi.plugins.metadata.AbstractOSGiMetaData.get(AbstractOSGiMetaData.java:272)
           at org.jboss.osgi.plugins.metadata.AbstractOSGiMetaData.get(AbstractOSGiMetaData.java:260)
           at org.jboss.osgi.plugins.metadata.AbstractOSGiMetaData.parseSymbolicName(AbstractOSGiMetaData.java:250)
           at org.jboss.osgi.plugins.metadata.AbstractOSGiMetaData.getBundleSymbolicName(AbstractOSGiMetaData.java:176)
           at org.jboss.osgi.plugins.facade.bundle.OSGiBundleState.getSymbolicName(OSGiBundleState.java:184)
          


          • 2. Re: Change in manifest parser breaks symbolic name

            The parsing of ParameterAttribute(s) and its decendent classes was already broken. The issue is in the javacc generated code.

            The change I made was to parse the BundleSymbolicName as a ParameterAttribute
            instead of a plain string because it has directives and attributes, e.g.
            Bundle-Symbolic-Name=foo.bar;singleton=true

            The reason is that the grammer is ambigous so sometimes it thinks it is parsing a PATH
            when it should be parsing a QNAME.
            The "tokenizer" part of the code is generating a wrong token and then it fails to match
            in the parsing.

            There's a commented out test with a TODO in the package import testing because of this.

            Fixing this parsing problem is on my list of things to fix.

            P.S. This is an "anti-pattern"

             public String getBundleSymbolicName()
             {
            
            <snip/>
            
             if (symbolicName == null)
             throw new IllegalStateException("Cannot obtain " + Constants.BUNDLE_SYMBOLICNAME);
            
             return symbolicName;
             }
            


            You shouldn't put validation logic in the metadata model.
            This validation of the model should be done when we are asked to install the bundle
            so that others can augment/vary the model.

            e.g. you could imagine a custom deployer that does for example
            OSGiMetaData md = ...;
            if (md.getBundleSymbolicName() == null)
             // generate one
            


            Instead your validation in the getter would mean it has to catch the exception which is counter intuitive.

            • 3. Re: Change in manifest parser breaks symbolic name
              thomas.diesler

               


              This validation of the model should be done when we are asked to install the bundle
              so that others can augment/vary the model.


              ok

              • 4. Re: Change in manifest parser breaks symbolic name
                thomas.diesler

                Folks (Adrian), do we have an update on this? It is scheduled for Beta5 01-Dec-2009

                • 5. Re: Change in manifest parser breaks symbolic name

                  This has been done, but I've still got https://jira.jboss.org/jira/browse/JBOSGI-200 TODO