Source code XMLGreeting.java does NOT work

Hello!

My software is:
1) Tamino 3.1.1.1
2) Windows 2000 Professional with SP2
3) jdk 1.4.0
4) TaminoClient.jar, TaminoAPI4J.jar, jdom.jar


I have tried to compile source code by using command:

javac XMLGreeting.java,

Unfortunately I got the following message warning:

------------------------------------------------
Note: ProcessXMLGreeting.java uses or overrides a deprecated API.

Note: Recompile with -deprecation for details
------------------------------------------------

What does it mean?

However I got XMLGreeting.class so I have tried to execute this file by executing command:

java XMLGreeting

Unfortunately, I got the following error message exception:

-----------------------------------------------
Exception in thread “main” java.lang.NoClassDefFoundError: XMLGreeting (wrong name: com/softwareag/tamino/db/API/examples/greeting/XMLGreeting)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:509)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:246)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:306)
at sun.misc.Laucher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322)
-----------------------------------------------

What should I do to execute this sample code sucessfully?

Thanks in advance!

Regards,
Dariusz Baumann

PS.

Here is this sample code:

------------------------------------------------
/
|| Example for the Tamino API for Java
||
|| It is assumed that a Tamino database called “myDB” has
|| been created and is running.
|| For storing data the default collection ino:etc is used
|| which should only be used for examples/test code.
|| We do not recommend this for real applications.
||
|| The following tasks are performed:
||
|| - establish a connection to the Tamino database
|| - obtain an XML accessor
|| - insert a new XML document
|| - query the inserted document
|| - close the connection
/
package com.softwareag.tamino.db.API.examples.greeting;

import com.softwareag.tamino.db.API.accessor.;
import com.softwareag.tamino.db.API.common.
;
import com.softwareag.tamino.db.API.connection.;
import com.softwareag.tamino.db.API.objectModel.
;
import com.softwareag.tamino.db.API.objectModel.dom.;
import com.softwareag.tamino.db.API.response.
;
import org.jdom.;
import org.jdom.input.
;
import java.io.*;


public class XMLGreeting {

public static void main(String args) throws Exception {
// Put the XML content into a StringReader
StringReader stringReader = new StringReader( XML );
// Instantiate an empty TXMLObject instance using the DOM object model
TXMLObject xmlObject = TXMLObject.newInstance( TDOMObjectModel.getInstance() );
// Establish the DOM representation by reading the content from the
// character input stream
xmlObject.readFrom( stringReader );
// Establish the connection to Tamino
TConnection connection = TConnectionFactory.getInstance().newConnection( DATABASE_URI );
// Obtain a TXMLObjectAccessor with a DOM object model
TXMLObjectAccessor xmlObjectAccessor = connection.newXMLObjectAccessor(
TAccessLocation.newInstance( “ino:etc” ),
TDOMObjectModel.getInstance() );
try {
// Invoke the insert operation
xmlObjectAccessor.insert( xmlObject );
// Show the ino:id of the document just inserted
System.out.println( “Insert succeeded, ino:id=” + xmlObject.getId() );
}
catch (TInsertException insertException) {
// Inform about the reason for the failure
System.out.println( “Insert failed!” );
if ( insertException.hasAccessFailureMessage() )
System.out.println( “Insert rejected by Tamino. Reason:” +
insertException.getAccessFailureMessage() );
else
System.out.println( “Insert failed due to following reason:” +
insertException.getDeepestException().getMessage() );
}
// Prepare to read the instance
TQuery query = TQuery.newInstance( xmlObject.getDoctype() + “[@ino:id=” +
xmlObject.getId() + “]” );
try {
// Invoke the query operation
TResponse response = xmlObjectAccessor.query( query );
if ( response.hasFirstXMLObject() ) {
StringWriter stringWriter = new StringWriter();
response.getFirstXMLObject().writeTo( stringWriter );
System.out.println( “Retrieved following instance:” + stringWriter );
}
else
System.out.println( “No instance found!” );
}
catch (TQueryException queryException) {
// Inform about the reason for the failure
System.out.println( “Query failed!” );
if ( queryException.hasAccessFailureMessage() )
System.out.println( “Query rejected by Tamino. Reason:” +
queryException.getAccessFailureMessage() );
else
System.out.println( “Insert failed due to following reason:” +
queryException.getDeepestException().getMessage() );
}
// OK, everything is done, close the connection.
connection.close();
}

// URI of the Tamino database, please edit accordingly
public final static String DATABASE_URI = “http://localhost/tamino/myDB”;

// XML document to be written to the connected database
public final static String XML =
“Hello World”;

}
------------------------------------------------

Hi Dariusz,

the problem is that the Java class is actually called:
   com.softwareag.tamino.db.API.examples.greeting.XMLGreeting
not:
   XMLGreeting

So, you have two options:
1. Call java using the full classname:
   java com.softwareag.tamino.db.API.examples.greeting.XMLGreeting

2. Remove the package line from the source (so that the class is called XMLGreeting), recompile and execute:
   java XMLGreeting

If you would like to see the full details of the “deprecated” warning, compile like this:
   javac -deprecation XMLGreeting.java

Last thing: I would be careful about not having both TaminoClient.jar and TaminoAPI4J.jar in my classpath.
I don’t know of any problems with this, but I would still avoid it…

I hope that helps,
Trevor.