Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-648

Cannot resolve type for handle _XY_Q=lang|R=lang@http://www.w3.org/XML/1998/namespace when running on java 9+

    XMLWordPrintableJSON

Details

    Description

      When XsbReader loads internal resources (i.e.: org/apache/xmlbeans/metadata/attribute/http_3A_2F_2Fwww_2Ew3_2Eorg_2FXML_2F1998_2Fnamespace/lang.xsb) it ends up calling SchemaTypeLoaderImpl#typeSystemForComponent. There, _resourceLoader is null, and using the classloader it cannot find resources in packages not exported (declared in module-info.java).

      An alternative would be to have a _resourceLoader that attempts to load the resource with the anchorClass rather than with the classLoader, that way internal resources are visible from within the module.

      The stack of the error that is thrown is:

      Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: Cannot resolve type for handle _XY_Q=lang|R=lang@http://www.w3.org/XML/1998/namespace (org.apache.xmlbeans.metadata.system.sXMLSCHEMA.schemad77felemtype) - code 13at org.apache.xmlbeans/org.apache.xmlbeans.impl.schema.XsbReader.readHandle(XsbReader.java:483)at org.apache.xmlbeans/org.apache.xmlbeans.impl.schema.XsbReader.readTypeRef(XsbReader.java:548)at org.apache.xmlbeans/org.apache.xmlbeans.impl.schema.XsbReader.loadAttribute(XsbReader.java:1282)at org.apache.xmlbeans/org.apache.xmlbeans.impl.schema.XsbReader.readAttributeData(XsbReader.java:1275)at org.apache.xmlbeans/org.apache.xmlbeans.impl.schema.XsbReader.finishLoadingType(XsbReader.java:902)at org.apache.xmlbeans/org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.resolveHandle(SchemaTypeSystemImpl.java:940)at org.apache.xmlbeans/org.apache.xmlbeans.SchemaComponent$Ref.getComponent(SchemaComponent.java:111)at org.apache.xmlbeans/org.apache.xmlbeans.SchemaType$Ref.get(SchemaType.java:1072)at org.apache.xmlbeans/org.apache.xmlbeans.impl.schema.SchemaPropertyImpl.getType(SchemaPropertyImpl.java:85)at org.apache.xmlbeans/org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createElementType(SchemaTypeImpl.java:991)at org.apache.xmlbeans/org.apache.xmlbeans.impl.values.XmlObjectBase.create_element_user(XmlObjectBase.java:879)at org.apache.xmlbeans/org.apache.xmlbeans.impl.store.Xobj.getUser(Xobj.java:1597)at org.apache.xmlbeans/org.apache.xmlbeans.impl.store.Xobj.find_element_user(Xobj.java:1968)at org.apache.xmlbeans/org.apache.xmlbeans.impl.xb.xsdschema.impl.SchemaDocumentImpl.getSchema(SchemaDocumentImpl.java:38)at org.apache.xmlbeans/org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compile(SchemaTypeSystemCompiler.java:163)...

       

      This works fine on java 8 because module access rules are not enforced by java in that version (jpms was introduced in java 9).

      Attachments

        1. Test678.java
          4 kB
          Rodrigo Merino

        Issue Links

          Activity

            People

              Unassigned Unassigned
              elrodro83 Rodrigo Merino
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m