• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlets exception thrown

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I try to run my servlet coding deployed in tomcat5 I get the display of the HTML page...but when I click a button and the servlet gets called I get the following message.
This is my first servlet program .please do help.Thanks in advance.


exception

javax.servlet.ServletException: Error allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(catalina-5.5.26.jar.so)
org.apache.catalina.connector.CoyoteAdapter.service(catalina-5.5.26.jar.so)
org.apache.coyote.http11.Http11Processor.process(tomcat-http-5.5.26.jar.so)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(tomcat-http-5.5.26.jar.so)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(tomcat-util-5.5.26.jar.so)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(tomcat-util-5.5.26.jar.so)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(tomcat-util-5.5.26.jar.so)
java.lang.Thread.run(libgcj.so.8rh)

root cause

java.lang.ClassFormatError: com.example.web.BeerSelect (unrecognized class file version)
java.lang.VMClassLoader.defineClass(libgcj.so.8rh)
java.lang.ClassLoader.defineClass(libgcj.so.8rh)
java.security.SecureClassLoader.defineClass(libgcj.so.8rh)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(catalina-5.5.26.jar.so)
org.apache.catalina.loader.WebappClassLoader.findClass(catalina-5.5.26.jar.so)
org.apache.catalina.loader.WebappClassLoader.loadClass(catalina-5.5.26.jar.so)
org.apache.catalina.loader.WebappClassLoader.loadClass(catalina-5.5.26.jar.so)
org.apache.catalina.valves.ErrorReportValve.invoke(catalina-5.5.26.jar.so)
org.apache.catalina.connector.CoyoteAdapter.service(catalina-5.5.26.jar.so)
org.apache.coyote.http11.Http11Processor.process(tomcat-http-5.5.26.jar.so)
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(tomcat-http-5.5.26.jar.so)
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(tomcat-util-5.5.26.jar.so)
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(tomcat-util-5.5.26.jar.so)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(tomcat-util-5.5.26.jar.so)
java.lang.Thread.run(libgcj.so.8rh)
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using the GNU version of Java that shipped with your Linux distribution? If so, download a version from Sun and set your JAVA_HOME environment variable to use that.
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I restart tomcat and run it in my browser, it displays a blank page (when its supposed to display a line of text) and when I run it subsequently I get the error message.
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I downloaded it from sun and java is working good already..Please help
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, you've downloaded a Sun JVM.
Are you sure that Tomcat is using it?
To check, go to:
http://localhost:8080/manager/html and click on the Server Status link.

That page will show you exactly what JVM Tomcat is using.
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah...I guess thats the problem.To my knowledge I installed a jdk1.6.0_04 and that page displays a 1.5 JVM.I checked my JAVA_HOME variable and here is the result

[root@localhost beerV1]# echo $JAVA_HOME
/usr/java/jdk1.6.0_04

How can I make tomcat "see" my 1.6 JDK...Much of thanks for guiding me so far...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to move this to our Tomcat forum since this doesn't appear to be a servlet problem. We can pick it up there.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you starting Tocmat?
Are you doing manually from your user?
Or
Are is there a daemon script installed by someone else responsible for starting it?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[root@localhost beerV1]# echo $JAVA_HOME



By the way:
Running Tomcat (or any other container for that matter) as root is a real bad idea. Once you get past this issue, you should look into reworking your permissions so that it can run as a lesser user.
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I become the root user and run the "service tomcat5 start" command...When I make some changes to the code I restart tomcat using "service tomcat5 restart"
I am still working my way around file permissions etc in linux as I am just 2 weeks old to linux.Thanks...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like your service scripts are setting the JAVA_HOME environment variable.

For now try starting it with the startup.sh script in tomcat/bin

If that doesn't work, then I'm guessing that JAVA_HOME was set in catalina.sh but don't worry about that now. Just try starting Tomcat from startup.sh and check the JVM version in the manager.
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope you mean this...but it says command not found

[root@localhost bin]# startup.sh
-bash: startup.sh: command not found

Thanks for your patience...
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just looked around and found a file called tomcat.conf and I am copy-pasting a part of its contents

# System-wide configuration file for tomcat5 services


# This will be sourced by tomcat5 and any secondary service
# Values will be overridden by service-specific configuration
# files in /etc/sysconfig
# Use this one to change default values for all services
# Change the service specific ones to affect only one service
# (see, for instance, /etc/sysconfig/tomcat5)
#
# tomcat5 service configuration file

# you could also override JAVA_HOME here
# Where your java installation lives
JAVA_HOME="/usr/java/jdk1.6.0_04"

I also tried restarting my system a couple of times.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did that work for you?
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No..it did not...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, did you dowload and install Tomcat from the Apache site or are you using a version that shipped with your OS?

Personally, I like to use the versions from the site.
The versions that ship with the Linux distros are usually heavily configured and spread out all over the machine. This might make sense from a Unix standpoint but when learning Tomcat or trying to stay on top of Tomcat upgrades, I find it easier to have the whole thing in one, self contained directory.
[ February 19, 2008: Message edited by: Ben Souther ]
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am running fedora 8 so I used "yum"

"yum install tomcat5 tomcat5-webapps tomcat5-admin-webapps"
Thanks for your tips...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's the same as the one that would ship with Redhat.

My advice:
Remove that version of Tomcat and go get one from Tomcat's site.
Installing and running is as easy as unpacking a zipped tarball, setting your JAVA_HOME environment variable, and executing the startup.sh script.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hope you find this useful.

For Cent OS pre-packaged tomcat5 there�s an issue in JAVA_HOME variable.

I don't know exactly why but it's always pointed to /usr/lib/jvm/java

So I resolved this issue removing that directory and creating a symbolic link instead, pointing to my Sun�s java installation.

Here is a ll comand of this:

[root@itce-prepro jvm]# ll java
lrwxrwxrwx 1 root root 22 Jul 17 16:06 java -> /usr/java/jdk1.6.0_07/
[root@itce-prepro jvm]#

Regards!
[ July 17, 2008: Message edited by: Ricardo Martinez ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I had the exact same problem. It was a little frustrating that the first example in the book Head First Servlets & Jsp didn't work right out of the box (not the book's fault, but my system).

I am running Fedora 5, and changing the link
/etc/alternatives/java_sdk to point to the same version reported by javac -version made tomcat5 much happier.

What I did was:

ls -l /usr/lib/jvm/java:
java -> /etc/alternatives/java_sdk
ls -l /etc/alternatives/java_sdk:
/usr/lib/jvm/java-1.4.2-gcj
rm /etc/alternatives/java_sdk
ln -s /usr/java/jdk1.6.0_05 /etc/alternatives/java_sdk

And then restarted tomcat.

Hope this is of any help for other users.

By the way, I am deploying, starting, reloading, stopping and undeploying applicaions from the tomcat web interface. In that way I don't need to restart tomcat at all.

Kind regards
J

[ August 10, 2008: Message edited by: J Langberg ]
[ August 10, 2008: Message edited by: J Langberg ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Devs, I also get the same error, but the stack trace doesn't explicitly show the root cause.

Am using ant to generate the war file I deployed in tomcat. Thats the tomcat that Yawl comes with.



Here the stack trace from the log files


What am I missing?
Regards,
Simon.
 
reply
    Bookmark Topic Watch Topic
  • New Topic