Darren Hall

Greenhorn
+ Follow
since Jan 22, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Darren Hall

And, I found the cause of the problem.

Essentially, my build.xml file was not including my compiled classes in the jar file, so the jar was essentially empty and the resulting war file I was deploying contained an empty jar.

Thus the class loader was unable to find my servlet.

I've repaired my build.xml and fixed the issue.

Thanks.
15 years ago
Ok, I have an application (named 'abc' application) deployed in Tomcat 5.5 on Solaris using the war deploy feature in the manager.

The application (lets call it 'foo') shows up in the manager as '/foo', so I know that it deploys. When I look in catalina.log, I see a ClassNotFound exception, alerting me that the ClassLoader wasn't able to find my ControllerServlet class. Here is the error from Catalina.log:

2006-07-24 09:38:46,987 DEBUG org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/foo] - Sending application start events
2006-07-24 09:38:46,987 DEBUG org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/foo] - Starting filters
2006-07-24 09:38:47,002 INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/foo] - Marking servlet controller as unavailable
2006-07-24 09:38:47,002 ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/foo] - Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@1c92535
com.abc.framework.controller.ControlServlet
java.lang.ClassNotFoundException: com.abc.framework.controller.ControlServlet

My ControlServlet class is located in this jar file webapps/foo/WEB-INF/lib/abc.jar in the package com.abc.framework.controller;.

I wanted to confirm that jar files in the WEB-INF/lib directory were included in the classpath for my application. In reading through the online documentation for Tomcat I found the following:

"WebappX - A class loader is created for each web application that is deployed in a single Tomcat 5 instance. All unpacked classes and resources in the /WEB-INF/classes directory of your web application archive, plus classes and resources in JAR files under the /WEB-INF/lib directory of your web application archive, are made visible to the containing web application, but to no others."

I am doing exactly this. My jar file (foo.jar) is in the webapps/abc/WEB-INF/lib directory for my 'abc' application. However, in the Catalina log file, when Tomcat starts, I get the above "ClassNotFound - com.abc.framework.ControlServlet" error. Why can my servlet not be found if it resides in abc.jar under the WEB-INF/lib directory???

Thanks,

Darren
[ July 24, 2006: Message edited by: Darren Hall ]
15 years ago
I've resolved the issue.

Essentially the war file was named 'foo.war' and was deploying to the webapps/foo/ directory, yet I was looking for the abc/ url mapping for my servlet.

By renaming my war to abc.war and having it deploy in the webapps/abc/ directory the mapping worked correctly and the servlet could be reached.

I'm not sure if this is the "correct" answer, but it does work, so I'll take it for now.
[ July 24, 2006: Message edited by: Darren Hall ]
15 years ago
Thanks for the reply Ben.

No, I didn't install the app as the default Tomcat app (at least I didn't mean to). This instance of Tomcat will eventually host 3 web apps for me, and I wanted each to be wholy and completely seperate. The ROOT app in Tomcat still exists, and when I point a browser to http://localhost:8080/ it displays the default Tomcat page (with links to the manager, examples, etc. in the left-hand menu).

I had wanted to manage things by URL so that if the URL pattern '/abc' came in, it would map to the web app I am trying to deploy.

Is this not correct? In the past I seem to remember having been able to do this, and I was able to get things configured properly. Unfortunately this was a few years ago, and I no longer remember how I did it.

Thanks,

Darren

[ July 19, 2006: Message edited by: Darren Hall ]
[ July 19, 2006: Message edited by: Darren Hall ]
15 years ago
One more thing I tried -

When I point my browser at http://localhost:8080/abc, I get the same Tomcat error "The requested resource (/abc) is not available.", so the Apache configuration is irrelevant.

Something is wrong with the way I have things set up in Tomcat.

Any ideas?

Thanks,

Darren
15 years ago
Simple problem (hopefully) and I've been here before, but for some reason I can't find my way through this error.

Here's the scenario:

I've written a servlet which I'm deploying in Tomcat 5.5 using Apache 2.2 as the web server. The servlet is a controller for one domain I have on my server (lets call it the 'abc' domain.) The servlet is bundled into a war file and deploys into Tomcat with no errors. The servlet-mapping in the web.xml file defines the following:

<!-- Controller Servlet Configuration -->
<servlet>
<servlet-name>controller</servlet-name>
<servlet-class>com.abc.framework.controller.ControlServlet</servlet-class>
</servlet>

<!-- Controller Servlet Mapping -->
<servlet-mapping>
<servlet-name>controller</servlet-name>
<url-pattern>/abc</url-pattern>
</servlet-mapping>

I've configured my httpd-vhosts.conf file to do a proxy pass through as follows:

<VirtualHost www.abc.com>
DocumentRoot /work/abc/abc-app/deploy/var/www/htdocs/abc
ServerName www.abc.com
ServerPath /abc
ErrorLog logs/abc/www.abc.com-error_log
CustomLog logs/abc/www.abc.org-access_log common

ProxyRequests Off
ProxyPass / http://localhost:8080/abc
ProxyPassreverse / http://localhost:8080/abc
</VirtualHost>

When I point my browser at http://www.abc.com/, I get a Tomcat error "The requested resource (/abc) is not available."

This indicates to me that the proxy pass through is working properly in Apache, but that Tomcat is not handing off the request to my serlvet.

What have I done wrong?

Thanks for the help.

Darren Hall
[ July 18, 2006: Message edited by: Bear Bibeault ]
15 years ago
well, I have done more with this issue...

I added the "HelloWorldExample" servlet to my webapps/servlet/WEB-INF/classes folder and I modified the web.xml for that application to include a servlet mapping for the HelloWorldExample servlet as such -

<servlet>
<servlet-name>HelloWorldExample</servlet-name>
<servlet-class>HelloWorldExample</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>HelloWorldExample</servlet-name>
<url-pattern>/HelloWorldExample</url-pattern>
</servlet-mapping>

Upon reloading tomcat and pointing my borwser to "http://<localhost>/servlet/HelloWorldExample" I got an error telling me the ResourceBundles could not be located.

(For anyone who does not have the servlet example that come with Tomcat, the 'HelloWorldExample' servlet uses a resource bundle so that the output strings it writes are based on the curent locale. Here is the code -

...
ResourceBundle rb =
ResourceBundle.getBundle("LocalStrings",request.getLocale());

response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<html>");
out.println("<head>");

String title = rb.getString("helloworld.title");

out.println("<title>" + title + "</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">");
...

I commented out the ResourceBundle line and made the reference to the variable 'title' static text, and the servlet ran fine.

So, this tells me I *can* run a servlet with no package specified and map it through my web.xml file - however, the code only executed after the ResourceBundle code was removed.

Now the code runs properly in its default /servlets-examples context fine, even with the ResourceBundle in place, and only failed when I moved it to my /servlet context. Does this tell me its a classpath issue, or...?

(I'm getting confused...)
16 years ago
I've also heard that the current Servlet Spec does require that servlet classes be in a package. Is this correct, and could this be causing my issues?
16 years ago
William -

> All classes used in servlets in any way should be in a package. Under some
> circumstances you can apparently get away without a package but you end up
> with hard to debug errors.
> Bill

I've heard this mentioned in many forums. Here's the deal - The person who originally wrote the code for this website made some (what I would consider) big mistakes. Not only did they not use packages in *any* of the java classes, but they also implemented 90% of the site as servlets. These servlets have an inheritance heirarchy (at most 3 levels deep), and only the base level servlets (of which there are 2 for some reason) interact with the few java classes (beans) the site uses (simple beans - not EJB). The few beans the application does use are not in packages, and have a smattering of behaviors - one stores query results, one is a standard 'app user' object, another is used to connect to the database and manage (and by 'manage' I mean open and close) that database connection, and the last one is read from text files.

The servlet that I'm trying to load instantialtes two other "base level" servlets, one of which instantiates the database connection manager (bean) and creates a database connection, and the other which instantiates a file reader (bean) and reads from a local config file (text file). All class files used by the application, whether servlet or bean, exist in the ${catalina.home}/webapps/servlet/WEB-INF/classes folder. There is no file structure at all under the classes directory - just all the class files in that one directory.

I'm not sure if any of this information is helpful, though, for solving the ClassDefNotFound issue (which appears to refer to the original servlet I was trying to load).
16 years ago
Satou -

> I'd like to confirm two things :
> 1. Is your class in a package ?

No. The person who originally programmed these servlets had something against packages (I guess). None of the java code running here specifies a package.

> 2. Is the class name correct ?

The class name is correct. In order to make sure of this (to avoid any typos I might have made), I actually copied and pasted it out of the windows explorer window and into my web.xml file.
16 years ago
To make things simpler (potentially), I get the same exact log entries and behavior when I take Apache out of the mix and hit the servlet directly through Tomcat.
16 years ago
Hello.

I've seen topics similar to this one posted in this group, but I wasn't able to find a solution that worked for me, so I'l post my situation and hope someone here can help me.

I'm running Tomcat 5.0 and Apache 2 on Windows XP Pro. I'm using mod_jk to create the Apache-Tomcat connection.

I'm dealing with existing HTML and java servlets, and in our existing environment, all servlets were invoked using Tomcats invoker servlet. Moving forward, this will not be possible, however, in the short term, I want to get the existing site working using its current configuration but without using the invoker servlet. To start off, I've decided to try and get one servlet working properly, before I map all of the rest of them.

I successfully connected Tomcat and Apache together using mod_jk, and then mapped the example servlets as a test. After that success, I created a new directory under webapps called 'servlet', and added the following entry to my httpd.conf -

# Send servlet for context /servlet to 'flcworker'
<Location /servlet/*>
JkMount flcworker
</Location>

I then created a webapps/servlet/WEB-INF/web.xml file that looks like this -

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<servlet>
<servlet-name>FLCUpEvDisplayServlet</servlet-name>
<servlet-class>FLCUpEvDisplayServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FLCUpEvDisplayServlet</servlet-name>
<url-pattern>/FLCUpEvDisplayServlet</url-pattern>
</servlet-mapping>
</web-app>

Upon restarting Tomcat and Apache, I tried to point to the URL http://<localhost>/servlet/FLCUpEvDisplayServlet and received the following error -

exception
javax.servlet.ServletException: Wrapper cannot find servlet class FLCUpEvDisplayServlet or a class it depends on

root cause
java.lang.ClassNotFoundException: FLCUpEvDisplayServlet

In my log files I see the following (I'm not going to print the entire stack trace here, only what I think is relevant) -

2006-01-22 20:32:50 StandardContext[/servlet]Marking servlet FLCUpEvDisplayServlet as unavailable
2006-01-22 20:32:50 StandardContext[/servlet]Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/

2006-01-22 20:32:50 StandardWrapperValve[FLCUpEvDisplayServlet]: Allocate exception for servlet FLCUpEvDisplayServlet
javax.servlet.ServletException: Wrapper cannot find servlet class FLCUpEvDisplayServlet or a class it depends on

So, is this a simple classpath error? It looks like the classloader was unable to find my servlet, but since the class lives in the webapps/servlet/WEB-INF/classes directory, I thought it was included in the classpath of the app server by default, correct?

Can anyone explain what the cause of my problem is here?

Thanks.
[ January 22, 2006: Message edited by: Darren Hall ]
16 years ago