Running servlet in Tomcat with Tamino

I compiled and run examples of Tamino API (e.g. XMLGreeting), all of them are ok.
Now I modify XMLGreeting.java to servlet version XMLGreetingServlet.java, there are always errors occurred when I attempt to run it!

I traced XMLGreetingServlet.java, found that error ocuurred when reaching this line
“TXMLObject xmlObject = TXMLObject.newInstance( TDOMObjectModel.getInstance() );” in the source.

I attach the source file, hope anyone can help solving! Thanks

PS:
1. Tomcat is running on Port:8080
2. Apache + Tamino 3.1.1.4 is running on Port:80
test.java (3.62 KB)

Hi,

I compiled your servlet and tried to run it, but I got a http error because the servlet had no get() method (I tried to invoke it by direct URL in a browser: http://localhost:8080/testapp/servlet/test)

So I added a simple get method (that just invokes the post method with the same arguments) and it works (modified code attached).

I also added some writes to “out” so you can see in your browser response where the problem happens in future.

If this doesn’t help, please give us more information on what error you get, and what jar files you have in your servlet’s classpath (tomcat_home/webapps/appname/web-inf/lib).
test.java (3.93 KB)

Thanks for help! But unfortunately there are still errors.

Because I call this servlet in html through “POST” method,
I did not write doGet() function.

Browser shows 500 error as attached file.

My %CLASSPATH% looks like this:
.;
C:\Software AG\xts.jar;
C:\Software AG\saglic.jar;
C:\Software AG\sagxds.jar;
D:\Tomcat\common\lib\servlet.jar;
D:\Tamino\lib\jdom.jar;
D:\Tamino\lib\log4j-core.jar;
D:\Tamino\lib\TaminoAPI4J.jar;
D:\Tamino\lib\xerces.jar


no this directory “tomcat_home/webapps/appname/web-inf/lib”
only “tomcat_home/webapps/appname/web-inf/classes”
and only test.class in this directory
error500.htm (6.48 KB)

The root cause of your 500 error is “NoClassDefFoundError: com/softwareag/tamino/db/API/objectModel/dom/TDOMObjectModel”

As I understand it, your system classpath, %CLASSPATH%, is not relevant to Tomcat. He has his own classpath. This is set by setclasspath.bat if you’re running Tomcat normally, or in wrapper.properties if you’re using jk_nt_service to start Tomcat as a service.

Each application also has a separate classpath which is built at run time from the contents of tomcat_home/webapps/appname/web-inf/lib (for jar files)
and
tomcat_home/webapps/appname/web-inf/classes for class hierarchies.

The easiest answer: If you don’t have a tomcat_home/webapps/appname/web-inf/lib directory, just create one and put the TaminoAPI4J jar files into it.