• 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

Servlet running on Local host but throwing Exception on public server

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are the both running the same server and the same version of the server?
 
Poonam Gulve
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
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
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?
 
Poonam Gulve
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
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

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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic