Get a respose from the database vol. 2

Hello again,
sorry to put on this topic again. But I was interrupted by other tasks, and this is still a problem. I get no vailid response from the Database.

This is my servlet:

try {
	TConnection connection = TConnectionFactory.getInstance().newConnection( "http://localhost/tamino/chris" );
	TXMLObjectAccessor xmlObjectAccessor = connection.newXMLObjectAccessor(
            TAccessLocation.newInstance( "test1" ),
            TJDOMObjectModel.getInstance() );
	        myret = xmlObjectAccessor.insert( tobj );
	out.println(" Create now a XML-Objekt of that data ");
	out.println("The return is:" + myret.getReturnValue() + "</p>");
	connection.close();
	} catch ( TConnectionException te ) { te.getCause(); }  
	  catch ( TInsertException ie ) { ie.toString(); };
	
	
	out.println("The Database answers:" + myret.getReturnValue() + "</p>");
	out.println("</BODY></HTML>");
	out.close();

But this works, and even if the database doesn’t run. And there is a problem. I need a response, at least when the database is not working! This is very importend for me.

Can anybody help. Hope I have enough time to finish this problem now :?

Thank you.

Gruss Christian

Check the Tamino API for Java Documentation
and the Interface TSystemAccessor
and the method isServerAlive

That will provide you with the servers status.
It checks whether the Tamino database is running by trying to establish a connection. It returns true if this succeeds, false otherwise

But allow me the stupid question, this is an interface, I have to implemtent this myself. I dontn’t know if I lose the sight of something?

Gruss Christian

Hi Christian ,

There is an example in the following topic:
[url]http://forums.tamino.com/viewtopic.php?t=4948&highlight=isServerAlive&sid=909e9e8d476f3c611f88dfe723efc8fd[/url].

Follow that link and check the example in the 6th entry.

Best of luck,
Rob

Hello,
I took your code to change my servlet in this form:

try {
	connection = TConnectionFactory.getInstance().newConnection( "http://localhost/tamino/chris" );
	 if ( !checkServerAndPrintSystemInformation( connection, "http://localhost/tamino/chris" ) )
	 {
		 out.println(" Database doesn't run! ");
         return;
	 }
		 
	connection.close();
	} catch ( TConnectionException te ) { te.getCause(); }  
	  catch ( TInsertException ie ) { ie.toString(); }
      catch ( TAccessorException ti) { ti.toString(); };

And I used your “checkServerAndPrintSystemInformation”-Method ( with your permission ? :wink:

protected static boolean checkServerAndPrintSystemInformation(TConnection connection, String DATABASE_URL ) throws TAccessorException 
  {
//	 Obtain the TSystemAccesor
	TSystemAccessor systemaccessor = connection.newSystemAccessor();


	if (!systemaccessor.isServerAlive()) 
	{
	  return false;
	} 
	else 
	{
	  System.out.println( "------------------------------\nServer is alive" );
	  System.out.println( "The Tamino server hosting " + DATABASE_URL +
	  " is version " + systemaccessor.getServerVersion() );
	  return true;
	}
 } 

But the result is the same. If I started the database or not, doesn’t matter to the servelt. I get no negative response nor a positive.

This is really weird!

Gruss Christian

Have you tried the same URL from a browser?

I.e. what do you get if you try the following from a browser:

http://localhost/tamino/chris?_diagnose=version

Ok, if I try your URL (without starting the database), I got this response:


<?xml version='1.0'?>
<ino:response xmlns:ino='http://namespaces.softwareag.com/tamino/response2'>
<ino:message ino:returnvalue='8201'>
<ino:messagetext ino:code='INOXHE8201'>Can't connect to server on host localhost at port 3201, TCP error code 10061.</ino:messagetext>
</ino:message>
</ino:response>

And if I start the “chris” database before this:

<?xml version="1.0" encoding="ISO-8859-1" ?><ino:response xmlns:ino="http://namespaces.softwareag.com/tamino/response2" xmlns:xql="http://metalab.unc.edu/xql/">  <ino:request>
    <ino:diagnose ino:request-type="version"/>
  </ino:request>
  <ino:message>
    <ino:messageline ino:subject="Version">4.2.1.2</ino:messageline>
  </ino:message>
</ino:response>

Gruss Christian

So now try the create object code from a command line Java application.

If that works then that would indicate that the problem lies somewhere in the servlet environment (or accessing Tamino from it).

So, now I got time to solve this problem.

I made this application:

import com.softwareag.tamino.db.api.accessor.TAccessLocation;
import com.softwareag.tamino.db.api.accessor.TAccessorException;
import com.softwareag.tamino.db.api.accessor.TSystemAccessor;
import com.softwareag.tamino.db.api.common.TException;
import com.softwareag.tamino.db.api.connection.TConnection;
import com.softwareag.tamino.db.api.connection.TConnectionFactory;
import com.softwareag.tamino.db.api.common.TAccessFailureMessage;
import com.softwareag.tamino.db.api.connection.TConnectionException;
import java.io.*;
import java.lang.*;
import java.util.*;


public class TaminoApp {

	protected static boolean checkServerAndPrintSystemInformation(TConnection connection, String DATABASE_URL ) throws TAccessorException 
	{
//	 Obtain the TSystemAccesor
	TSystemAccessor systemaccessor = connection.newSystemAccessor();


	 if ( !systemaccessor.isServerAlive() ) 
	 {
	    return false;
	 } 
	 else 
	 {
	    System.out.println( "------------------------------\nServer is alive" );
	    System.out.println( "The Tamino server hosting " + DATABASE_URL +
	    " is version " + systemaccessor.getServerVersion() );
	    return true;
	 }
    }
	
	 private static String[] parseArgs( String[] args)
	 {
		 if (args.length >= 1)
		 return args;

		 else 
		 {
		    System.out.println("\nUsage: java TaminoApp database-url\n" +
		    " e.g. java TaminoApp http://pcmypc/tamino/mydb\n" );
		    System.exit(0);
		    return null;
		 } // end else
	 } // end parseArgs() 
	 
	 
	 public static void main (String[] args) throws Exception 
	 {

		 parseArgs(args);
		 String sargs[]= parseArgs(args);

//		  URL of the Tamino database
		 String DATABASE_URL = new String( sargs[0]);

//		  Establish the connection to Tamino
		 TConnection connection = TConnectionFactory.getInstance().newConnection( DATABASE_URL );

//		  Check if the connection is available and print out some system information
		 if ( !checkServerAndPrintSystemInformation( connection, DATABASE_URL ) )
		   return ;


	 } // end main

} // end CheckDBstatus

Which is getting compiled.
But if I call this app with

I got this dumped:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Layout
        at com.softwareag.common.instrumentation.logging.LoggerFactory.getLogger
(Unknown Source)
        at com.softwareag.common.instrumentation.contract.Contract.<clinit>(Unkn
own Source)
        at com.softwareag.common.instrumentation.contract.Precondition.isEnabled
(Unknown Source)
        at com.softwareag.tamino.db.api.objectModel.TXMLObjectFactory.<clinit>(U
nknown Source)
        at com.softwareag.tamino.db.api.objectModel.TXMLObject.<clinit>(Unknown
Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.softwareag.tamino.db.api.objectModel.dom.TDOMObjectModel.class$(U
nknown Source)
        at com.softwareag.tamino.db.api.objectModel.dom.TDOMObjectModel.<init>(U
nknown Source)
        at com.softwareag.tamino.db.api.objectModel.dom.TDOMObjectModel.getInsta
nce(Unknown Source)
        at com.softwareag.tamino.db.api.common.TPreference.<init>(Unknown Source
)
        at com.softwareag.tamino.db.api.common.TPreference.getInstance(Unknown S
ource)
        at com.softwareag.tamino.db.api.connection.TConnectionFactory.<init>(Unk
nown Source)
        at com.softwareag.tamino.db.api.connection.TConnectionFactory.<clinit>(U
nknown Source)
        at TaminoApp.main(taminoapp.java:60)

Hi

You need to add “log4j.jar” in your classpath to resolve this problem.

Thanks,
Srinu

Ah okay, I added it plus JDOM too.
My classpath looks like this

.;%SAG_COMMON%\xts.jar;C:\Programme\Gemeinsame Dateien\Software AG\sagxds.jar;%SAG_COMMON%\saglic.jar;%SAG_COMMON%\sagxds.jar;C:\Programme\Java\classes\TaminoAPI4J.jar;
C:\Programme\Java\classes\TaminoJCA.jar;C:\Programme\Java\classes\log4j.jar;C:\Programme\Java\classes\jdom.jar

And the dump is this:

Exception in thread "main" Nested Exception ( com.softwareag.tamino.db.api.invoc
ation.TCommunicationException, tag: JavaTaminoAPI_4_1_4_42_1_1, java: 1.5.0_06,
os: Windows XP 5.1 ) stacktrace:

Nested Exception ( com.softwareag.tamino.db.api.invocation.TInvocationRetryHandl
erException, tag: JavaTaminoAPI_4_1_4_42_1_1, java: 1.5.0_06, os: Windows XP 5.1
 ) stacktrace:

Nested Exception ( com.softwareag.tamino.db.api.invocation.http.THTTPCommunicati
onException, tag: JavaTaminoAPI_4_1_4_42_1_1, java: 1.5.0_06, os: Windows XP 5.1
 ) stacktrace:

Nested Exception ( com.softwareag.tamino.db.api.common.TAccessFailureException,
tag: JavaTaminoAPI_4_1_4_42_1_1, java: 1.5.0_06, os: Windows XP 5.1 ) stacktrace
:

Tamino access failure.
        at com.softwareag.tamino.db.api.invocation.http.THTTPInvocation.getInput
Stream(Unknown Source)
        at com.softwareag.tamino.db.api.invocation.http.THTTPInvocation.doGetInv
oke(Unknown Source)
        at com.softwareag.tamino.db.api.invocation.http.THTTPInvocation.doInvoke
(Unknown Source)
        at com.softwareag.tamino.db.api.invocation.TAbstractInvocation.doTemplat
eInvoke(Unknown Source)
        at com.softwareag.tamino.db.api.invocation.TAbstractInvocation.invoke(Un
known Source)
        at com.softwareag.tamino.db.api.invocation.TAbstractInvocation.checkServ
erAvailabilityAndVersion(Unknown Source)
        at com.softwareag.tamino.db.api.connection.TConnectionImpl.<init>(Unknow
n Source)
        at com.softwareag.tamino.db.api.connection.TConnectionFactory.newConnect
ion(Unknown Source)
        at TaminoApp.main(taminoapp.java:60)

Gruss Christian

Hi

The exception says “Tamino access failure.”. Please check whether the status of the tamino database you mentioned as URI is proper and is started or not ?

Thanks, Srinu

Hello Srinu, thank you for your help.

As you can see above, this URL works with e.g. Firefox-Browser and give me the version-number of my tamino-server.

I made this app just to test if there is problem between eclipse and tamino. But it seems to be that eclipse is not the only problem, maybe it isn’t a problem at all. I just startet the “chris”-Database with the “System managemant hub” and got the same output (exceptions) as I got right before I started this database-instance.

And this app is also created to make a test-connection to the database, if this fails it should return with a failure. But without an exception?

I have absolutely to clue, where the problem is.

What is the name of the Tamino-Server-Process, to find it in the Task-Manager-schedule?

Gruss Christian

Hi Christian,

I guess the problem you are facing is because of the wrong parameter you are sending to the application. As a database URI, you are sending the argument
http://localhost/tamino/chris?_diagnose=version” which is not valid. The argument must be “http://localhost/tamino/chris”.

I have executed the same application on my machine and it works fine.
Following is the output -


Server is alive
The Tamino server hosting http://localhost/tamino/mydb is version 4.4.1.4

Hope this helps.

Thanks.

Yea,

C:\Dokumente und Einstellungen\chris\Eigene Dateien>java TaminoApp http://localhost/tamino/chris
------------------------------
Server is alive
The Tamino server hosting http://localhost/tamino/chris is version 4.2.1.2

But this really means, that there is something wrong with Eclipse and its Sysdeo-Plugin for Tomcat?!?

There it is much more complicated to find a problem :roll:

But thank you anyway, you bring me one step further.

Gruss Christian

Hi

Nice to hear that you are a step further.

But i didnt understand the following line in your previous post

As far as my knowledge is concerned, there is no problem with Eclipse because i ran your above program from my eclipse and it works fine. The only thing you need to do when running the program in eclipse is to set the program arguments from Run → Run → Arguments tab.

Thanks. Srinu

This is not a problem concerning the arguments, but getting a real connection to the server. Take a look at the last post of Mark Kuschnir. He was the one who leads me to the idea to create a application without servlets and without eclipse. I use the Eclipse-Tomcat plugin by Sysdeo [url]http://www.sysdeo.com/eclipse/tomcatplugin[/url] and this is perhaps the reason for the problem of “getting tomcat and tamino together” ?

By the way, I didn’t get the application to run in eclipse. Althought I put the argument in the “run-dialog”

I got this dumped:


Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.softwareag.tamino.db.api.common.TAccessFailureException.retrieveAccessFailureDetails(Unknown Source)
	at com.softwareag.tamino.db.api.common.TAccessFailureException.<init>(Unknown Source)
	at com.softwareag.tamino.db.api.invocation.http.THTTPInvocation.getInputStream(Unknown Source)
	at com.softwareag.tamino.db.api.invocation.http.THTTPInvocation.doGetInvoke(Unknown Source)
	at com.softwareag.tamino.db.api.invocation.http.THTTPInvocation.doInvoke(Unknown Source)
	at com.softwareag.tamino.db.api.invocation.TAbstractInvocation.doTemplateInvoke(Unknown Source)
	at com.softwareag.tamino.db.api.invocation.TAbstractInvocation.invoke(Unknown Source)
	at com.softwareag.tamino.db.api.invocation.TAbstractInvocation.checkServerAvailabilityAndVersion(Unknown Source)
	at com.softwareag.tamino.db.api.connection.TConnectionImpl.<init>(Unknown Source)
	at com.softwareag.tamino.db.api.connection.TConnectionFactory.newConnection(Unknown Source)
	at TaminoApp.main(TaminoApp.java:62)
Caused by: java.lang.NullPointerException
	at com.softwareag.common.resourceutilities.ResourceLocator.getAllResourceLocations(Unknown Source)
	at com.softwareag.common.resourceutilities.AbstractXMLBasedResourceBundle.getBundle(Unknown Source)
	at com.softwareag.common.resourceutilities.message.XMLMessageResourceBundle.getBundle(Unknown Source)
	at com.softwareag.common.resourceutilities.message.XMLMessageResourceBundle.getBundle(Unknown Source)
	at com.softwareag.tamino.db.api.message.TResourceId.<init>(Unknown Source)
	at com.softwareag.tamino.db.api.common.TCommonMessages.<clinit>(Unknown Source)
	... 11 more

Gruss Christian

Ok sorry, these exceptions were thrown because I didn’t start the database! :oops: :oops: :oops: