Dear whom it may concern,
I have following set up…
1)Tamino Database called “myDB” is created and running
2)jdom.jar, log4j.jar, TaminoAPI4J.jar, TaminoJCA.jar, JavaTaminoAPIExamples.jar, xercesImpl.jar, xmlParserAPIs.jar, are included
3)Tamino 4.1.4.1
4)j2sdk1.4.1_03
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
------------------------------------------------
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)
-----------------------------------------------
Then I commented out the “package” line in the sample code and recompiled, but still got the same error messages…
Could you help me what I should do?
Thank you very much in advance,
/****Sample Code/
/
|| Example for the Tamino API for Java.
||
|| Assumes that there is a Tamino database called “myDB”.
|| The example simply uses the default collection ino:etc.
|| This collection should only be used for examples/test code.
|| It shouldn’t generally be used for real applications.
||
|| The example does the following:
||
|| establishes a connection to the Tamino database
|| obtains an XML accessor
|| inserts a new document of … into ino:etc
|| queries for the inserted document
|| closes 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 related to 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 Tamino connection.
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 newly inserted document.
System.out.println(“Insert succeeded, ino:id=” + xmlObject.getId());
} catch (TInsertException insertException) {
// Tell 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) {
// Tell 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. Let’s close the connection.
connection.close();
}
// Constant for the database URI. Please edit to use your uri of interest.
public final static String DATABASE_URI = “http://localhost/tamino/myDB”;
// Constant for the applications XML message that shall be written to the
// connected database.
public final static String XML =
“Hello World”;
}
Hello,
are you trying this in the context of Tamino X-Application?
If you are using the Tamino Java API, could you post this to the Java API Forum?
Anyway: did you set your classpath settings right?
Regards, Harald
Regards, Harald
Topic will be moved to Assistance Forum
Hello,
this topic will be moved to the Assistance Forum in the next days.
The assistance forum is intended to be used for technical questions and answers.
Thank you for your understanding.
Regards,
Christian.