aspose file tools*
The moose likes Tomcat and the fly likes invoke servlets from apache/htdocs/servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "invoke servlets from apache/htdocs/servlet " Watch "invoke servlets from apache/htdocs/servlet " New topic
Author

invoke servlets from apache/htdocs/servlet

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
hello all , im newbe to apache/tomcat , im trying to configure tomcat
to invoke servlets from witin apache htdocs/servlet dir
the apache/tomcat runing great and the htdocs/ is parsing jsp files
but not able to read java servlets what else do i miss here?
thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

In order for Tomcat to add a servlet to the class path it must be in one of the appropriate locations.
That means under WEB-INF/classes, or in a jar file in WEB-INF/lib or one of the common lib folders.

Put them anyplace else, and they won't get loaded.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
is there any trick or tip or work around ?
for runing servlets in else where?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Meir Yan:
is there any trick or tip or work around ?
for runing servlets in else where?


Look at the docBase attribute of the Context entry in this configuration guide.
You can run your app from any directory on the machine but you'll need to keep the structure of the context in tact.
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Also if you're using a connector to run Apache HTTPD with Tomcat, you may need to do some additional tweaking to let HTTPD know to pass certain requests to Tomcat.
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
thanks for the fast reply , yeah i do use the mod_jk
what exactly or what twiking do i need to do?
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
ׁׁhello all
well when you say web app do you mean where the jsp pages are runing ?
so if you do , i did changed the path in the server.xml and its looks like that :
<Context path="" docBase="/home/myplace/DevEnv/server/apache/htdocs" debug="0">
and the jsp pages are working just find and they do run from "apache/htdocs"
but ididn't manged to change the dir of the servlets , even so i changed in the apache httpd.conf to be as fallow :

jkMount /*.jsp ajp13
JkMount /servlet/* ajp13

can someone please give example how to configure tomcat to run servlets else where ?

thanks allot
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

For this application running under:
docBase="/home/myplace/DevEnv/server/apache/htdocs"
You will want to create a proper webapp directory structure.

That is..
Create a /home/myplace/DevEnv/server/apache/htdocs/WEB-INF directory with a classes sub directory.
Place your class files (with package directories) under the classes directory.

Again, you will probably also need to configure the connector so it knows when to pass servlet requests to Tomcat.
See your connector's documentations for this.
I believe the config file is worker.properties.
Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Hello and tnx for the fast reply
after diging the web i didnt found any thing about this , it all seams
they are runinh servlets from tomcat and not under apache
so i guess it can't be done? or im wrong this is my config and logs
please give me some hint can be done or not...
under apache/htdocs i have :
apache/htdocs/servlet.xml
apache/htdocs/servlet
apache/htdocs/servlet/WEB-INF
apache/htdocs/servlet/WEB-INF/classes
apache/htdocs/servlet/WEB-INF/classes/hello_servlet.java
apache/htdocs/servlet/WEB-INF/classes/hello_servlet.class
apache/htdocs/servlet/WEB-INF/web.xml

in server.xml :
<Context path="/servlet" docBase="servlet" debug="0"/>

in web.xml :
<!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>hello_servlet</servlet-name>
<servlet-class>hello_servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello_servlet</servlet-name>
<url-pattern>/servlet/hello_servlet</url-pattern>
</servlet-mapping>
</web-app>

in httpd.conf :
LoadModule jk_module modules/mod_jk.so
JkWorkersFile /home/blah/DevEnv/server/tomcat/conf/workers.properties
JkLogFile /home/blah/DevEnv/server/apache/logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

jkMount /*.jsp ajp13
JkMount /servlet/* ajp13

the tomcat log some of it.. :

2006-06-03 19:03:46 StandardWrapper[ rg.apache.catalina.INVOKER.hello_servlet]: Marking servlet org.apache.catalina.INVOKER.hello_servlet as unavailable
2006-06-03 19:03:46 invoker: Cannot allocate servlet instance for path /servlet/hello_servlet
javax.servlet.ServletException: Wrapper cannot find servlet class hello_servlet or a class it depends on

......................


can someone tell me what is wrong here ? do i need to config the tomcat server.xml also ?
thanks allot
 
 
subject: invoke servlets from apache/htdocs/servlet