[ 
https://issues.apache.org/jira/browse/XMLBEANS-602?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

PJ Fanning resolved XMLBEANS-602.
---------------------------------
    Resolution: Information Provided

> Upgrade to xmlbeans to 5.x.x cannot use Factory
> -----------------------------------------------
>
>                 Key: XMLBEANS-602
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-602
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: Tools
>    Affects Versions: Version 5.0.3
>         Environment: Windows 10
>            Reporter: mikael petterson
>            Priority: Major
>
> 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:
>  
> {code:java}
> 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{code}
>  
> 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:
>  
> {code:java}
> [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
>  
> {code}
> Could it be that I use different jdk for generating files and compiling?
> //mike



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to