aspose file tools*
The moose likes Servlets and the fly likes Facing the problem when loading the servlet but not when compiling. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Facing the problem when loading the servlet but not when compiling." Watch "Facing the problem when loading the servlet but not when compiling." New topic
Author

Facing the problem when loading the servlet but not when compiling.

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Hi,
Am facing a strange Problem when working with the servlets, Please help me. ( When trying to execute the example from "CORE SERVLETS AND JAVA SERVER PAGES, Chapter 7)
I am having a servlet, "ShadowedText.java", which will invoke a method from "MessageImage.java". These two files are in the same directory.
"MessageImage.java", is importing a class "Acme.JPM.Enoceds.GifEncoder". I have imported the whole pacakge of "Acme" from the net and copied to my system.
From one of the methods of "MessageImage.java", i am calling a method of the class "GifEncoder.java"
When compiling the source files, every thing is going fine and all the class files are available.
But when loading the servlet through IE, am getting the below error -- At "MessageImage.java" when calling the method from the class "GifEncoder.java".
Error:
=============================================
Sun Sep 07 11:26:22 GMT 2003:<E> <ServletContext-General> Servlet failed with Exception
java.lang.NoClassDefFoundError: Acme/JPM/Encoders/GifEncoder
at coreservlets.MessageImage.sendAsGIF(MessageImage.java:69)
at coreservlets.ShadowedText.doGet(ShadowedText.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.ServletServlet.service(ServletServlet.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:941)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:905)
at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:391)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:273)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
========================================================
My doubt is, Why am i getting the error, when loading the servlet but not when compiling the source files.
Link to the source files ("ShadowedText.java", "MessageImage.java")
http://archive.coreservlets.com/Chapter7.html
Link to -- "Acme.JPM.Enoceds.GifEncoder"
http://www.acme.com/java/software/Acme.JPM.Encoders.GifEncoder.html
By the way, I am using Bee Weblogic Server Version 5.1.0.
[ September 07, 2003: Message edited by: narasimha rao bandlamudi ]

Narasimha
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
You are getting the error from the servlet because the latest Tomcat ignores the system CLASSPATH. Read the Class Loader How-To section of the Tomcat documentation installed by tomcat as web pages - look at /tomcat-docs/index.html - the how-to link is on the left side.
Bill
Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Hi William,
I am not using Tomcat webserver. I am using Bee Weblogic server version 5.1.0

Regards,
Narasimha.
[ September 07, 2003: Message edited by: narasimha rao bandlamudi ]
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
check the classpath setting of your server.


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Hi Ravish,
Before starting the server from the command window, i have appended to the classpath "d:\java\acme". And in the "MessageImage.java" file i am having the import statement, "import Acme.JPM.Encoders.GifEncoder;" . So server can found the "GifEncoder.java" file, at "d:\java\acme\Acme\JPM\Encoders\GifEncoder".
But still i am getting the same error.
Idly Vada
Ranch Hand

Joined: Sep 02, 2003
Posts: 135
Why don't u make a jar file of the entire Acme package and put it in the lib directory of the app server(in ur case BEA Weblogic).
Then directly use the package in ur application
Ashok Mash
Ranch Hand

Joined: Oct 13, 2000
Posts: 1936
Also, instead of adding the path to '..acme..', try including the ACME jar (if its thirdparty api, its normally a jar, is it not?) into your classpath


[ flickr ]
Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Hi,

I have made the entire Acme package as a jar file and put the jar file in the lib directory of the server and added the path of the jar file to my classpath, still i am getting the same error.
In IE window below error is throwing,
-----------------------------------
Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.
-------------------------------------------------
[ September 08, 2003: Message edited by: narasimha rao bandlamudi ]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Some dumb questions
1.How did you jar it? Did you mean that directory hierarchy when the file was jared?
2. Did you put the jar file in the SERVER CLASSPATH.


Groovy
Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Hi Pradeep,
I have jarred using the command "jar cf Acme.jar *". After that i unjarred every thing is fine, when i look at that one.
Sorry i didn't get the meaning of the SERVER CLASSPATH. Is it the the classpath?. If it is the CLASSPATH, i have added the jar file into the classpath and java files are compiling using the jar file and classfiles are generated properly.
Please clarify my doubt, Why am i not getting the error when compiling?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

http://www.weblogic.com/docs51/admindocs/classpath.html#cpwls
Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Hi,
Finally it is working by updating the classpath variable value(weblogic.httpd.servlet.classpath=<<path of the jar file or path of the directory where the class files are located>> ) in weblogic.properties file.
Thnaks a ton to all.
[ September 09, 2003: Message edited by: narasimha rao bandlamudi ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Facing the problem when loading the servlet but not when compiling.