wood burning stoves*
The moose likes Servlets and the fly likes Servlet running on Local host but throwing Exception on public server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet running on Local host but throwing Exception on public server" Watch "Servlet running on Local host but throwing Exception on public server" New topic
Author

Servlet running on Local host but throwing Exception on public server

Poonam Gulve
Greenhorn

Joined: Aug 13, 2007
Posts: 16
Hi,
I am new to servlets. and facing a problem ..
I hv written a servlet which just displays a html file like this..

RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/index.html");
rd.forward(request, response);


when i upload it on my local host, it runs fine. but when i upload it on the public server, it throws an exception :

exception

javax.servlet.ServletException: Error allocating a servlet instance
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
java.lang.Thread.run(Thread.java:534)



I want to know where is the problem .. is there any setting that i hv missed?? on my local host i m using jdk 1.5 and on server its 1.6 .. is it bcoz of that??


Thanks and Regards,
Poonam


Regards,<br />Poonam Gulve
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Are the both running the same server and the same version of the server?
Poonam Gulve
Greenhorn

Joined: Aug 13, 2007
Posts: 16
no the 2 servers are different.. one is my local host tomcat ie local IP and other is server with public IP..

Public servers tomcat version is 5.0.25
and my local host's tomcat version is also 5.0.25
[ October 05, 2007: Message edited by: Poonam Gulve ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Since it's small, can you post the code to the servlet, your web.xml file, and the exact URL that you're using when trying to access this servlet?
Also, can you tell us exactly where you've placed the servlet's class file?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Poonam Gulve
Greenhorn

Joined: Aug 13, 2007
Posts: 16
My Servlet is this:

facebook.java



My web.xml is:



and my html is simply displaying a title nothing else..



=========

when i run on my local host i go to http://localhost:8080/facebook/facebook
and i can see a blank page with title "tween_start"

and after uploading and running to public server http://203.115.112.151:8080/facebook/facebook,
i get the exception


Servlet Class file is kept in C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\facebook\WEB-INF\classes

[ October 05, 2007: Message edited by: Poonam Gulve ]
[ October 05, 2007: Message edited by: Poonam Gulve ]
Mladen Grabowsky
Greenhorn

Joined: Sep 19, 2007
Posts: 29
When i go to the url you posted, i get following error:

ava.lang.UnsupportedClassVersionError: facebook (Unsupported major.minor version 49.0)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:539)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1634)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:860)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1307)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
java.lang.Thread.run(Thread.java:534)



You're probably using a higher Java version on you dev machine than on your prod machine.
Ayanik Sil
Greenhorn

Joined: Sep 23, 2007
Posts: 27
Here might be one solution...
although i am also new to servlets.
in the request dispatcher code,u gave the name of html file as
index.fbml,not index.html Please check.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"maki",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

ava.lang.UnsupportedClassVersionError: facebook (Unsupported major.minor version 49.0)


This is probably it.

This error occurs when you compile one of your classes with a newer version of javac than the version of the JVM you are using at run time.
Either recompile with the same version as the one on your public server or use the -source switch in javac to specify that this class is to be compatible with the version of the JVM on your server.
Poonam Gulve
Greenhorn

Joined: Aug 13, 2007
Posts: 16
ok sir i'll check it.. right now my server is not getting connected..
But i compiled my java file in jdk 1.5 version and on server its jdk 1.6 .. so i think that shudnt give any problem.. but still i'll check it ..
Poonam Gulve
Greenhorn

Joined: Aug 13, 2007
Posts: 16
Hello sir,
its working now.. thanks a lot .. i recompiled the java file on server..

but i dont understand one thing that my colleague has written his own servlet, compiled in 1.5 jdk, uploaded it onthe same server with jdk 1.6 and running it just fine .. he didnt requir any recompiling of the files .. what might be the reason ??

anyways thanks a lot again ..
Mladen Grabowsky
Greenhorn

Joined: Sep 19, 2007
Posts: 29
Originally posted by David O'Meara:
"maki",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave

Hi Dave,

i changed my nick to my real name, sorry about that.

Regards,

Mladen
Akshay Kiran
Ranch Hand

Joined: Aug 18, 2005
Posts: 220
Originally posted by Poonam Gulve:
Hello sir,
its working now.. thanks a lot .. i recompiled the java file on server..

but i dont understand one thing that my colleague has written his own servlet, compiled in 1.5 jdk, uploaded it onthe same server with jdk 1.6 and running it just fine .. he didnt requir any recompiling of the files .. what might be the reason ??

anyways thanks a lot again ..


I think you got it wrong. The target runtime (on the server) is a lower version than that of the compiler. You say it is 1.5 in dev and 1.6 in prod, but this cannot be possible as generated classfiles are always forward compatible. You must be missing something...
As for the other question- assume you're working on jdk 1.5, but want to run it on a 1.4 jvm, all you need to do is

Note that this will essentially disallow you to use any features that are not available to the target runtime.

Originally posted by Ben Souther:


This is probably it.

This error occurs when you compile one of your classes with a newer version of javac than the version of the JVM you are using at run time.
Either recompile with the same version as the one on your public server or use the -source switch in javac to specify that this class is to be compatible with the version of the JVM on your server.


Ben, I think the correct flag would be "-target" and not "-source"

regards,
Akshay


"It's not enough that we do our best; sometimes we have to do<br />what's required."<br /> <br />-- Sir Winston Churchill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet running on Local host but throwing Exception on public server