Jethro,

What Jacob was referring to were "JDK" versions not XmlBeans versions.
But I think a common point is that (just as Java .class files) Schemas
compiled with a version of XmlBeans (say 2.2) will work with later
versions of XmlBeans (say 2.3), but not the other way around, in
general.

So putting the newer version of XmlBeans that you used to compile the
Schemas on your classpath was the right thing.

Radu

On Tue, 2007-07-31 at 09:02 +0200, Jethro Borsje wrote:
> Hi there,
> 
> Your comment about different versions got me thinking. I am working on a 
> big project with multiple developers. The point was that I compiled my 
> XSD with a newer version of XMLBeans than the one on my classpath. I 
> just placed this newer version on my classpath and now I do not get the 
> error anymore. I have some other unexpected behavior which I will start 
> debugging now.
> 
> -- 
> Best regards,
> Jethro Borsje
> 
> http://www.jborsje.nl
> 
> Jacob Danner wrote:
> > I have seen this when using different JDK versions with compiled types.
> > Specifically, if I compiled an XSD using JDK 1.6 and then try to run
> > my code using that XSD with say JDK 1.4.
> > Can you let us know if this is the problem you are having?
> > Thanks,
> > -Jacob Danner
> > 
> > On 7/30/07, Jethro Borsje <[EMAIL PROTECTED]> wrote:
> >> Hi everybody,
> >>
> >> I have used XMLBeans 2.3.0 to compile an .xsl file to a .jar which I
> >> want to use to create XML files. However, I keep getting the following
> >> exceptions:
> >> [exceptions]
> >> java.lang.ExceptionInInitializerError
> >>         at sun.misc.Unsafe.ensureClassInitialized(Native Method)
> >>         at
> >> sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
> >>         at
> >> sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
> >>         at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
> >>         at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
> >>         at java.lang.reflect.Field.get(Field.java:358)
> >>         at 
> >> org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(XmlBeans.java:770)
> >>         at nl.semlab.event.EventsDocument.<clinit>(Unknown Source)
> >>         at nl.semlab.event.EventsDocument$Factory.newInstance(Unknown 
> >> Source)
> >>         at
> >> nl.semlab.viewerpro.client.eventeditor.commands.ExportEventsCommand.exportToXML(ExportEventsCommand.java:69)
> >>         at
> >> nl.semlab.viewerpro.client.eventeditor.commands.ExportEventsCommand.execute(ExportEventsCommand.java:53)
> >>         at
> >> nl.semlab.viewerpro.client.eventeditor.EventEditor.deliverEvent(EventEditor.java:108)
> >>         at
> >> nl.semlab.viewerpro.client.eventeditor.EventEditor.<init>(EventEditor.java:81)
> >>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> >> Method)
> >>         at
> >> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> >>         at
> >> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> >>         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> >>         at java.lang.Class.newInstance0(Class.java:355)
> >>         at java.lang.Class.newInstance(Class.java:308)
> >>         at
> >> nl.semlab.viewerpro.client.editableheadlinesviewer.HeadlinesViewer.startPluginExtensions(HeadlinesViewer.java:93)
> >>         at
> >> nl.semlab.viewerpro.client.editableheadlinesviewer.HeadlinesViewer.initViewMain(HeadlinesViewer.java:69)
> >>         at
> >> nl.semlab.commons.swing.commands.ViewActivate.execute(ViewActivate.java:91)
> >>         at
> >> nl.semlab.commons.swing.listeners.DockingWindowAdapterImpl.activateView(DockingWindowAdapterImpl.java:60)
> >>         at
> >> nl.semlab.commons.swing.docking.DockingWindows.activateSelectedViews(DockingWindows.java:121)
> >>         at
> >> nl.semlab.commons.swing.docking.DockingWindows.<init>(DockingWindows.java:100)
> >>         at nl.semlab.commons.swing.Workbench.doStart(Workbench.java:168)
> >>         at org.java.plugin.Plugin.start(Unknown Source)
> >>         at org.java.plugin.PluginManager.startPlugin(Unknown Source)
> >>         at
> >> org.java.plugin.standard.StandardPluginManager.activatePlugin(Unknown
> >> Source)
> >>         at
> >> org.java.plugin.standard.StandardPluginManager.activatePlugin(Unknown
> >> Source)
> >>         at
> >> nl.semlab.viewerpro.client.ViewerProClient.startVisualisationPlugin(ViewerProClient.java:326)
> >>         at
> >> nl.semlab.viewerpro.client.ViewerProClient.access$1(ViewerProClient.java:314)
> >>         at
> >> nl.semlab.viewerpro.client.ViewerProClient$2.run(ViewerProClient.java:260)
> >>         at 
> >> java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
> >>         at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
> >>         at
> >> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
> >>         at
> >> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
> >>         at
> >> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
> >>         at 
> >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
> >>         at 
> >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
> >>         at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
> >> Caused by: java.lang.RuntimeException: Could not instantiate
> >> SchemaTypeSystemImpl (java.lang.reflect.InvocationTargetException): is
> >> the version of xbean.jar correct?
> >>         at
> >> schemaorg_apache_xmlbeans.system.s152C24368131DC098995DB87B4792116.TypeSystemHolder.loadTypeSystem(Unknown
> >> Source)
> >>         at
> >> schemaorg_apache_xmlbeans.system.s152C24368131DC098995DB87B4792116.TypeSystemHolder.<clinit>(Unknown
> >> Source)
> >>         ... 41 more
> >> Caused by: java.lang.reflect.InvocationTargetException
> >>         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> >> Method)
> >>         at
> >> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> >>         at
> >> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> >>         at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> >>         ... 43 more
> >> Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS
> >> compiled schema: Incompatible minor version - expecting up to 23, got 24
> >> (schemaorg_apache_xmlbeans.system.s152C24368131DC098995DB87B4792116.index)
> >> - code 3
> >>         at
> >> org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.<init>(SchemaTypeSystemImpl.java:1522)
> >>         at
> >> org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.initFromHeader(SchemaTypeSystemImpl.java:260)
> >>         at
> >> org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(SchemaTypeSystemImpl.java:183)
> >>         ... 47 more
> >> [/exceptions]
> >>
> >> This is what my code looks like:
> >> [code]
> >> // Create a new XML document.
> >> EventsDocument newEventsDoc = EventsDocument.Factory.newInstance();
> >>
> >> // Create the root element (<events>).
> >> Events events = newEventsDoc.addNewEvents();
> >>
> >> // Loop through all the events in the manager.
> >> Event[] eventsArray = m_eventManager.getEvents();
> >> for (Event event : eventsArray)
> >> {
> >>         // Create an <event> element with the id of the event as attribute.
> >>         EventType eventType = events.addNewEvent();
> >>         eventType.setId(event.getId());
> >>
> >>         // Create a <name> element.
> >>         eventType.setName(event.getName());
> >>
> >>         // Create a <description> element.
> >>         eventType.setDescription(event.getDescription());
> >>
> >>         // TODO: use real action implementation here.
> >>         // Create an <impact> element.
> >>         EventAction[] actions = (EventAction[]) 
> >> event.getEventActions().toArray();
> >>         eventType.setImpact(Integer.parseInt(actions[0].getValue()));
> >>
> >>         // Create an element for the instances of this event <instances>.
> >>         Instances eventInstances = eventType.addNewInstances();
> >>         Set<EventInstance> instances = event.getEventInstances();
> >>         for (EventInstance instance : instances)
> >>         {
> >>                 // Create an <instance> element with the id of the event 
> >> instance as
> >> attribute.
> >>                 InstanceType instanceType = 
> >> eventInstances.addNewInstance();
> >>                 instanceType.setId(instance.getId());
> >>
> >>                 // Create a <selectedText> element.
> >>                 
> >> instanceType.setSelectedText(instance.getAnnotatedSelectedText());
> >>
> >>                 // Create a <newsItemId> element.
> >>                 instanceType.setNewsItemId(instance.getNewsItem().getId());
> >>         }
> >> }
> >>
> >> String xmlText = newEventsDoc.xmlText();
> >> try
> >> {
> >>         FileWriter writer = new FileWriter("events.xml");
> >>         BufferedWriter buffWriter = new BufferedWriter(writer);
> >>         buffWriter.write(xmlText);
> >>         buffWriter.close();
> >>         writer.close();
> >> }
> >> catch (IOException ex)
> >> {
> >>         Logger.getLogger(DefaultEventManager.class).error("Error creating 
> >> XML
> >> export for events", ex);
> >> }
> >> Logger.getLogger(ExportEventsCommand.class).info("XML EXPORT DONE");
> >> [/code]
> >>
> >> Everything goes wrong on this line: "EventsDocument newEventsDoc =
> >> EventsDocument.Factory.newInstance();". I have xbean.jar on my classpath.
> >>
> >> Does anybody know what is going wrong?
> >>
> >> --
> >> Best regards,
> >> Jethro Borsje
> >>
> >> http://www.jborsje.nl
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Notice:  This email message, together with any attachments, may contain 
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated 
entities,  that may be confidential,  proprietary,  copyrighted  and/or legally 
privileged, and is intended solely for the use of the individual or entity 
named in this message. If you are not the intended recipient, and have received 
this message in error, please immediately return this by email and then delete 
it.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to