Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Information Provided
-
Version 5.0.3
-
None
-
None
-
Windows 10
Description
Hi,
I used xmlbeans-4.0.0 before. I just updated dependency to 5.0.3 in maven pom.xml.
I got the following error:
HelloDocument helloDocument = HelloDocument.Factory.newInstance();
Error message in Eclipse:
Type mismatch: cannot convert from XmlObject to HelloDocument
The HelloDocument is an XmlObject
public abstract interface x0.ietfParamsXmlNsNetconfBase1.HelloDocument extends org.apache.xmlbeans.XmlObject {
}
Then from forum I got recommendation to regenerate classes. So I use java 11 and regenerate my classes using the following command:
java -mx512m -cp /c/Users/eraonel/tmp/xmlbeans-5.0.3/lib/xmlbeans-5.0.3.jar:/c/Users/eraonel/tmp/xmlbeans-5.0.3/lib/log4j-api-2.17.1.jar:/c/Users/eraonel/tmp/xmlbeans-5.0.3/lib/log4j-core-2.17.1.jar org.apache.xmlbeans.impl.tool.SchemaCompiler -out /c/Users/eraonel/tmp/xmlbeans-5.0.3/tutorial/rfc4741/output/NetconfSchema-1.0.11.jar /c/Users/eraonel/tmp/xmlbeans-5.0.3/tutorial/rfc4741/action.xsd /c/Users/eraonel/tmp/xmlbeans-5.0.3/tutorial/rfc4741/notification.xsd /c/Users/eraonel/tmp/xmlbeans-5.0.3/tutorial/rfc4741/notificationManagement.xsd /c/Users/eraonel/tmp/xmlbeans-5.0.3/tutorial/rfc4741/netconf.xsd /c/Users/eraonel/tmp/xmlbeans-5.0.3/tutorial/rfc4741/netconf.xsdconfig Time to build schema type system: 1.42 seconds Time to generate code: 1.872 seconds Time to compile code: 5.581 seconds Compiled types to: C:\Users\eraonel\tmp\xmlbeans-5.0.3\tutorial\rfc4741\output\NetconfSchema-1.0.11.jar
I checked the content of the jar file and I found that there is a difference in classes ( inner classes).
- version 4
HelloDocument$Factory.class
HelloDocument$Hello$Capabilities$Factory.class
HelloDocument$Hello$Capabilities.class
HelloDocument$Hello$Capabilities.class
HelloDocument$Hello$Factory.class
HelloDocument.class
- version 5
HelloDocument$Hello$Capabilities.class
HelloDocument$Hello.class
HelloDocument.class
So I see 3 more innerclasses called factory.
Then add the jar into my local .m2 repository and try to compile with java 8:
[ERROR] C:\Users\eraonel\git\managed-objects-bundle\netconf\jcat_commonlibrary_netconf\src\main\java\com\ericsson\commonlibrary\netconf\transport\HelloHandler.java:[32,59] error: cannot access DocumentFactory class file for org.apache.xmlbeans.impl.schema.DocumentFactory not found
Could it be that I use different jdk for generating files and compiling?
//mike