Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "SMILA/Development Guidelines/Setup for JAXB code generation"

Line 4: Line 4:
  
 
<source lang="text">
 
<source lang="text">
java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: Provider com.w_wins.xml.xjcplugins.InterfacePlugin could not be instantiated: java.lang.ClassCastException
+
java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin:  
 +
Provider com.w_wins.xml.xjcplugins.InterfacePlugin could not be instantiated:  
 +
java.lang.ClassCastException
 
</source>
 
</source>
  

Revision as of 03:42, 25 May 2009

This page describes additional setup steps you need to do if you want to use JAXB to generate classes from XML schema descriptions for SMILA. This is also needed to be able to extend SMILA XML configuration file schemas, because we mostly use JAXB to parse them.

NOTE This setup works correctly only when using a JDK 1.5 to run ant. With JDK 1.6 you'll get a message like this:

java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: 
Provider com.w_wins.xml.xjcplugins.InterfacePlugin could not be instantiated: 
java.lang.ClassCastException

We are looking for version of this plugin that works with JDK 1.6, too. Any hints are welcome.

lib/
   ant-contrib/
      ant-contrib-1.0b1.jar
   xjc/
      jaxb-xjc.jar
      InterfacesXJCPlugin.jar
  • If you are developing with an integration environment:
    • From jaxb-ri-20071219/lib/ copy also these jars to lib/xjc:
lib/
   xjc/
      ...
      activation.jar
      jaxb-api.jar
      jaxb-impl.jar
      jsr173_1.0_api.jar
    • You need to checkout at least the bundle SMILA.builder from the SMILA subversion repository http://dev.eclipse.org/svnroot/rt/org.eclipse.smila/ into your workspace. Choose the version from the tag matching the SMILA version you want to develop for or use trunk.
    • In file SMILA.builder/xjc/build.xml remove these lines from the path definition xjc.classpath:
<fileset dir="../SMILA.extension/eclipse/plugins/" includes="javax.activation*.jar" />
<fileset dir="../javax.xml.bind" includes="*.jar" />
<fileset dir="../javax.xml.stream" includes="*.jar" />
<fileset dir="../com.sun.jaxb" includes="*.jar" />
  • If you want to generate JAXB classes for a new crawler configuration:
    • If you do not yet have a binary distribution of SMILA: Download or build one.
    • Copy org.eclipse.smila.connectivity.framework.schema_0.5.0.jar from the plugins directory of the SMILA distribution to lib/xjc. This is necessary because crawler configurations extend a base schema and therefore need to access classes in this bundle.
  • Put your bundle next to the SMILA.builder source bundle.
  • Create a schemas directory in your bundle and put the XSD and JXB file there (use the same basename and xsd and jxb as suffixes).
  • Create a build.xml in the bundle directory with this content, replace $SCHEMA_NAME with the basename of the XSD/JXB files:
<project name="sub-build" default="compile-schema-and-decorate" basedir=".">
  <property name="schema.name" value="$SCHEMA_NAME" />
  <import file="../SMILA.builder/xjc/build.xml" />
</project>
  • You can optionally add a file copyright.txt to the bundle (next to build.xml) containing a copyright header for the generated files (use valid Java comment syntax).
  • Add a code/gen folder to your bundle and add it as a source folder.

To generate the classes, you can now use:

ant -Dlib.dir=<SMILA-Build-Lib-Dir>

If you have created the folder with the build libs in the same directory where SMILA.builder is locaoted, you can just use:

ant

The JAXB classes should now be generated in the code/gen directory of your bundle.

Back to the top