Apache Tuscany > Home > SDO Overview > SDO Java > Tuscany SDO Java - FAQ User List | Dev List | Issue Tracker  

Build and Development Questions

How can I debug into EMF in Eclipse?

Download an SDK archive of the appropriate version of eclipse EMF containing EMF and XSD (and Eclipse's SDO 1.0 impl which can be ignored) from http://www.eclipse.org/modeling/emf/downloads/#archives (currently 2.2.3 and likely to remain that way until SDO is not constrained to work with Java 1.4.2). The archive contains source code for each jar in zip files. Extract this archive onto your file system somewhere. You can associate a jar with a source zip in two ways. Either ...

  1. wait until you debug into an EMF class file that doesn't have a source association and then click the "Attach Source ..." button, or ...
  2. in the package explorer pane, open up the "Referenced Libraries" part of a projects source hierarchy and right click on one of the referenced libraries. Select Properties, and click on the Java Source Attachment tab.

Now you have the opportunity to define a variable for eclipse to provide an starting root location in the file system which can be extended in order to locate the source code (this allows for easy transport of eclipse projects between environments, since only the small set of environment variables need to be updated in order to make the project build again in the new environment.) Define a "New..." variable (mine is EMF_SRC) and make it point to a location above all the source file zips. The variable's value will be something like C:/Dev/downloads/emf-sdo-xsd-SDK-2.2.3/eclipse/plugins/. Now create an extension to that variable by clicking on "Extension...". Select your new variable, and open up the hierarchy to find the source zip file. For example


Be sure to select the zip file, and not a folder above the file. Close all the dialogs. Now your source file attachment is made and you will be able to debug through any file in that jar. You'll need to make more associations for the other jars by extending the existing EMF_SRC variable for those jars.

What is the connection between static XSDHelper calls when definition and load could be using different XSDHelpers for the same instance in the same VM?

For example:

XSDHelper.INSTANCE.define(is, null);

and then in another static method xml is loaded

XMLDocument xmlDoc = XMLHelper.INSTANCE.load(is);

Answer: The methods you point out are not static methods, but are executed in the context of the singleton helpers, and the
metadata generated by the XSDHelper.INSTANCE singleton is stored in the TypeHelper.INSTANCE and accessed from there by the
XMLHelper.INSTANCEsingleton. Together these singletons form a default set of helpers centred
around a default scope for types. The recently introduced HelperContext SDO 2.1 API allows you to create new collections of helpers that together define alternative scopes.

Is there support for extending generated SDO implementation classes?

Here is my understanding:
1) I cannot have my own superclass of a generated SDO class since this is already occupied
2) I cannot (yet) simply subclass a generated SDO class, this may be addressed in TUSCANY-513
As a consequence I would have to modify the generated SDO implementation class in order to offer custom formatter and validation logic!? Is there eventually a way to inject code using annotations? Or is it possible to re-generate and prevent override of custom code (merge)?*

Answer: The Tuscany SDO generator is currently reusing the code generator
framework from Eclipse EMF project. If you look at the EMF generator, you'll see that it's very powerful and customizable. In Tuscany all we've
done is create a simple command line invocation of the EMF generator, using our own templates, and a few basic options.

One thing we don't support is regen/merge because the EMF merger prereqs the Eclipse JDT, which we didn't want to drag into Tuscany as a
dependency. If someone is willing to write a standalone merger for Tuscany, we could support regen.
Other things like generating a different base class or adding methods, are supported in EMF but we don't have a way do it in with the Tuscany
generator yet. If you'd be willing to help get some of this function into Tuscany, I'm sure a lot of people would be interested in it.

The bottom line is that real sophisticated tooling is outside of the scope of the Tuscany project. Another possible direction for this is for some
Eclipse project to provide a fancy GUI-generator (and possibly other tools) for developing Tuscany SDO applications. It would be nice to see something like that get started.

How do I work with javajet files to modify the SDO generator code?

Answer: You can learn how to set up your Eclipse environment to have javajet function built in using this tutorial.
Note that if you install the JET plugin via the Help => Software Updates => Find and Install .. menu of the eclipse IDE then you may see that selecting the "Java Emitter Templates SDK" causes the somewhat cryptic error message that you need the EMF codegen plugin, but there is no such plugin listed as an additional item to select. To clear this error and proceed you will need to select the "EMF Extender SDK" option.

Once you have the right eclipse environment you must add a javajet nature to the sdo-tools project, and modify the javajet configuration to match the shape of the sdo-tools project.

  File => New => Other
  Select "Java Emitter Templates"
  Select "Convert Projects to Jet Projects"
  Select "tuscany-sdo-tools"
  Click "Finish"

Then in the Package Explorer pane of the Java perspective of Eclipse, right click on the tuscany-sdo-tools project

  Select "Properties"
  Select "Jet Settings"
  Change the Source Container to "src/main/java"

Following this, when you change the code in templates/models/SDOClass.javajet, or templates/models/SDOFactoryClass.javajet, then the corresponding java class will be updated each time that you save the javajet file.

How to make the SDO-Tuscany library work in an eclipse plugin?

Answer: Please refer to the following email thread for answer:

How to use SDO in tuscany SCA?

Answer:- It's possible to use Static SDO or Dynamic SDO

  • For the dynamic SDO, you can use DataObject as parameter type.
  • You are required to put something like this in the SCDL (*.composite) file:
        <composite ...
        <dbsdo:import.sdo location="wsdl/helloworld.wsdl"/>-

    [Note: It's possible to have multiple <import.sdo> elements]

I am having issues with Sun JDK 1.4.2 while trying to do SDO build.

Answer: This is a known issue of SUN JDK. The Crimson DOM implementation in (some versions of) the Sun JDK 1.4 has a bug in the implementation of hasAttributeNS.
This bug can be seen as either a null pointer exception or as an error message "Specify a valid XML Schema and try loading again" while loading or importing a model from XML Schema.
To avoid this, use the following to control the JAXP implementaion:
<eclipse-install-dir>eclipse.exe -vmargs -Djava.endorsed.dirs=<path-to-your-xerces-jars-folder>

Is there a way to restrict the version of maven used?

Answer: According to the POM model, you can use the <prerequisites> element to specify the minimum version of Maven required to build the project.
for example:


How can I define multiple XSD files with same namespace in same XSDHelper.INSTANCE?

Answer: You need to create a HelperContext that has the extensible namespaces set to true. So, instead of using XMLHelper.INSTANCE you must do the following:

HelperContext scope = SDOUtil.createHelperContext(true);
   then use the XSDHelper from
XSDHelper xsdHelper = scope.getXSDHelper()

if you use this instance of XSDHelper you will be able to add types to your namespace.

Is it possible to generatie a DataObject from XML with XML Schema types?

*Answer:*Currently, Tuscany doesn't automatically load metadata (schemas) on the fly. It is required to register the types before the instances are loaded.
It's required to execute something like this before calling XMLHelper.load():

URL url = SdoDroolsTest.class.getResource("/XYZ.xsd");
getScope().getXSDHelper().define(url.openStream(), url.toString());

How to add Property to an XSDHelper-defined Type‎?

Answer: If you create your HelperContext using SDOUtil.createHelperContext(true); XSDHelper.define() method will then let you add new types to an existing namespace
and also to replace an existing type with a new version (Note: This is a "use at your own risk" feature).
So, you could add a new property by calling XSDHelper.define() again passing in a new version of the XSD type that includes the new element/attribute.

Why does the DataObject with contained DataGraph causes NullPointerException in ChangePackage$Literals?

Answer: Please refer to the following email thread for answer:

How can I use SDO for my Eclipse RCP application?

Answer: Please refer to the following email thread for answer:

Is there a mechanism or workaround to pause and resume the recording in the ChangeSummary?

Answer: There's no standard "spec-defined" way, but I believe in Tuscany you can
call endLogging() to suspend and then call
ChangeSummaryImpl.resumeLogging() instead of beginLogging() to restart.
Note that you'll need to cast your ChangeSummary to ChangeSummaryImpl to
call resumeLogging().

website stats