Apache 2.0.52 + Tomcat 5.0.28 + mod_jk

Discussion in 'Java' started by Brent, Dec 15, 2004.

  1. Brent

    Brent Guest

    Hi,

    I'm trying to connect Apache 2.0.52 with Tomcat 5.0.28 using the mod_jk
    connector, to no avail.

    The documentation at
    http://jakarta.apache.org/tomcat/connectors-doc/index.html only really
    covers Tomcat 4.*.

    Has anyone been able to do this on a Windows or Linux platform? Are
    there any good resources out there that anyone knows of that I can look
    to?

    It seems like everything I find refers to mod_jk2, which I just found
    out is being discontinued and everything is moving to mod_jk, so I'd
    like to use something that will be around for a while.
    All help/information is greatly appreciated.

    Thanks,
    Brent
     
    Brent, Dec 15, 2004
    #1
    1. Advertising

  2. Brent

    Juha Laiho Guest

    "Brent" <> said:
    >I'm trying to connect Apache 2.0.52 with Tomcat 5.0.28 using the mod_jk
    >connector, to no avail.
    >
    >The documentation at
    >http://jakarta.apache.org/tomcat/connectors-doc/index.html only really
    >covers Tomcat 4.*.


    There shouldn't be any major changes after that regarding mod_jk set-up.

    >Has anyone been able to do this on a Windows or Linux platform? Are
    >there any good resources out there that anyone knows of that I can look
    >to?


    From top of my mind, it's three/four files you're looking for:
    - httpd.conf
    - module loading/initialization directives for mod_jk
    - either including mod_jk.conf to httpd.conf by a directive or
    having more or less copy of mod_jk.conf copied into httpd.conf
    - mod_jk.conf
    - JkMount directives for declaring HTTP resources that should be
    served by Tomcat; here the subtrees are assigned to named
    "worker"s
    - it's possible to get Tomcat to automatically generate pretty much
    correct mod_jk.conf -files on startup
    - server.xml
    - you need to set some listener for AJP13 protocol, at some given
    port (not the same as your actual WWW service port); additionally,
    I tend to limit this listener to localhost address only
    - workers.properties
    - port number in here must match the port number you set up in server.xml
    - worker name in here must match the worker name you use in httpd.conf

    That's pretty much it. Sorry for the lack of details, but I hope this
    provides at least a checklist.

    Are you seeing any error messages in any log, or are things just plain not
    working without any diagnostics anywhere?
    --
    Wolf a.k.a. Juha Laiho Espoo, Finland
    (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
    PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
    "...cancel my subscription to the resurrection!" (Jim Morrison)
     
    Juha Laiho, Dec 15, 2004
    #2
    1. Advertising

  3. Brent

    Brent Guest

    Juha,

    Thanks for the checklist. I did find most of the information you
    listed and I am now getting errors in my mod_jk.log file. Would you be
    willing to review my config files and error message to see if you
    happen to know what is wrong?

    workers.properties
    ----------------------------------------------------------
    worker.list=localtomcat

    worker.localtomcat.type=ajp13
    worker.localtomcat.host=localhost
    worker.localtomcat.port=8080
    worker.localtomcat.cachesize=50
    worker.localtomcat.cache_timeout=600
    worker.localtomcat.socket_keepalive=1
    worker.localtomcat.reclycle_timeout=300




    server.xml (snippets from Tomcat config file)
    ----------------------------------------------------------
    <Server port="8005" shutdown="SHUTDOWN" debug="0">

    <Listener
    className="org.apache.jk.config.ApacheConfig"
    modJk="D:/Apache2/modules/mod_jk.dll"
    workersConfig="D:/Apache2/conf/workers.properties"/>

    <Service name="Catalina">

    <Engine
    name="Standalone"
    defaultHost="localhost"
    debug="0"
    jvmRoute="localtomcat">

    <Host
    name="localhost"
    debug="0"
    appBase="webapps"
    unpackWARs="true"
    autoDeploy="true"
    xmlValidation="false"
    xmlNamespaceAware="false">

    <ApacheConfig
    forwardAll="false"
    noRoot="false"
    jkDebug="info"
    jkWorker="localtomcat"
    configHome="D:/Apache2/"
    jkLog="D:/Apache2/logs/mod_jk.log"
    modJk="D:/Apache2/modules/mod_jk.dll"
    jkConfig="D:/Apache2/conf/mod_jk.conf"
    workersConfig="D:/Apache2/conf/workers.properties"/>

    <Ajp13Connector port="8080"/>

    <Listener
    className="org.apache.jk.config.ApacheConfig"
    append="true"
    forwardAll="false"
    modJk="D:/Apache2/modules/mod_jk.dll"/>

    </Host>
    </Engine>
    </Service>
    </Server>



    mod_jk.config (I copied and pasted this into my Apache httpd.conf file)
    ----------------------------------------------------------
    ########## Auto generated on Wed Dec 15 14:14:20 CST 2004##########

    <IfModule !mod_jk.c>
    LoadModule jk_module "D:/Apache2/modules/mod_jk.dll"
    </IfModule>

    JkWorkersFile "D:/Apache2/conf/workers.properties"
    JkLogFile "D:/Apache2/logs/mod_jk.log"

    JkLogLevel debug

    <VirtualHost localhost>
    ServerName localhost

    #################### localhost:/corpapps ####################

    # Static files
    Alias /corpapps "D:/tomcat5/webapps/corpapps"

    <Directory "D:/tomcat5/webapps/corpapps">
    Options Indexes FollowSymLinks
    DirectoryIndex index.jsp index.html index.htm
    </Directory>


    # Deny direct access to WEB-INF and META-INF
    #
    <Location "/corpapps/WEB-INF/*">
    AllowOverride None
    deny from all
    </Location>

    <Location "/corpapps/META-INF/*">
    AllowOverride None
    deny from all
    </Location>
    #
    # Use Directory too. On Windows, Location doesn't work unless case
    matches
    #
    <Directory "D:/tomcat5/webapps/corpapps/WEB-INF/">
    AllowOverride None
    deny from all
    </Directory>

    <Directory "D:/tomcat5/webapps/corpapps/META-INF/">
    AllowOverride None
    deny from all
    </Directory>

    JkMount /corpapps/UploadFeedServlet localtomcat
    JkMount /corpapps/SetupServlet localtomcat
    JkMount /corpapps/LoginServlet localtomcat
    JkMount /corpapps/*.jspx localtomcat
    JkMount /corpapps/PlacementPerformanceServlet localtomcat
    JkMount /corpapps/*.jsp localtomcat
    JkMount /corpapps/ReconcileServlet localtomcat
    </VirtualHost>



    Errror Messages in mod_jk.log file
    ----------------------------------------------------------
    [Wed Dec 15 14:25:04 2004] [jk_uri_worker_map.c (445)]: Into
    jk_uri_worker_map_t::map_uri_to_worker
    [Wed Dec 15 14:25:04 2004] [jk_uri_worker_map.c (459)]: Attempting to
    map URI '/corpapps/main.jsp'
    [Wed Dec 15 14:25:04 2004] [jk_uri_worker_map.c (539)]:
    jk_uri_worker_map_t::map_uri_to_worker, Found a suffix match
    localtomcat -> *.jsp
    [Wed Dec 15 14:25:04 2004] [mod_jk.c (1689)]: Into handler
    r->proxyreq=0 r->handler=jakarta-servlet r->notes=4983192
    worker=localtomcat
    [Wed Dec 15 14:25:04 2004] [jk_worker.c (90)]: Into
    wc_get_worker_for_name localtomcat
    [Wed Dec 15 14:25:04 2004] [jk_worker.c (94)]: wc_get_worker_for_name,
    done found a worker
    [Wed Dec 15 14:25:04 2004] [mod_jk.c (472)]: agsp=80 agsn=localhost
    hostn=localhost shostn=localhost cbsport=0 sport=0
    [Wed Dec 15 14:25:04 2004] [jk_ajp_common.c (1741)]: Into
    jk_worker_t::get_endpoint
    [Wed Dec 15 14:25:04 2004] [jk_ajp_common.c (1367)]: Into
    jk_endpoint_t::service
    [Wed Dec 15 14:25:04 2004] [jk_ajp_common.c (257)]: Into
    ajp_marshal_into_msgb
    [Wed Dec 15 14:25:04 2004] [jk_ajp_common.c (425)]:
    ajp_marshal_into_msgb - Done
    [Wed Dec 15 14:25:04 2004] [jk_connect.c (136)]: Into jk_open_socket
    [Wed Dec 15 14:25:04 2004] [jk_connect.c (143)]: jk_open_socket, try
    to connect socket = 1392 to 127.0.0.1:8080
    [Wed Dec 15 14:25:05 2004] [jk_connect.c (159)]: jk_open_socket, after
    connect ret = -1
    [Wed Dec 15 14:25:05 2004] [jk_connect.c (188)]: jk_open_socket,
    connect() failed errno = 61
    [Wed Dec 15 14:25:05 2004] [jk_ajp_common.c (720)]: Error connecting
    to tomcat. Tomcat is probably not started or is listening on the wrong
    host/port (127.0.0.1:8080). Failed errno = 61
     
    Brent, Dec 15, 2004
    #3
  4. Brent

    RC Guest

    Brent wrote:
    > Hi,
    >
    > I'm trying to connect Apache 2.0.52 with Tomcat 5.0.28 using the mod_jk
    > connector, to no avail.
    >
    > The documentation at
    > http://jakarta.apache.org/tomcat/connectors-doc/index.html only really
    > covers Tomcat 4.*.
    >
    > Has anyone been able to do this on a Windows or Linux platform? Are
    > there any good resources out there that anyone knows of that I can look
    > to?


    Very easy, I made them work on my Redhat Linux OS 7.2

    1. appended a line to bottom of $APACHE2/conf/httpd.conf

    LoadModule jk2_module modules/mod_jk2.so

    cp the workers2.properties into $APACHE2/conf/

    2. # For your *.jsp files
    mkdir -p $TOMCAT5.28/webapps/your_project/jsp
    # For your servlet *.class files
    mkdir -p $TOMCAT5.28/webapps/your_project/WEB-INF/classes

    create a web.xml file under $TOMCAT5.28/webapps/your_project/WEB-INF
    see it from examples

    3. start apache2 and tomcat 5
    $APACHE2bin/apachectl start
    $TOMCAT5.28/bin/catalina.sh start

    Good luck!
     
    RC, Dec 15, 2004
    #4
  5. Brent

    Brent Guest

    Status - success!

    Thanks for everyone's help. (Now the next step is clustering...ugh..I
    think the trick is matching the jvmRoute Engine attribute to the load
    balancing worker defined in workers.properties...or something along
    those lines??)

    Couple of things I'd like to mention in case anyone else needs the
    information (or I forget!):

    server.xml (Should look more like this)
    ---------------------------------------------------------------
    <Server port="8005" shutdown="SHUTDOWN" debug="0">

    <!--
    Note I had to change the class from
    org.apache.ajp.tomcat4.config.ApacheConfig to
    org.apache.jk.config.ApacheConfig because the install of Tomcat I have
    does not include a jar file that contains the ApacheConfig class in
    that package
    -->
    <Listener
    className="org.apache.jk.config.ApacheConfig"
    forwardAll="false"
    noRoot="false"
    jkDebug="info"
    jkWorker="localtomcat"
    configHome="D:/Apache2/"
    jkLog="D:/Apache2/logs/mod_jk.log"
    modJk="D:/Apache2/modules/mod_jk.dll"
    jkConfig="D:/Apache2/conf/mod_jk.conf"
    workersConfig="D:/Apache2/conf/workers.properties"/>

    <Service name="Catalina">

    <!-- CONNECTOR FOR JK / AJP1.3 -->
    <Connector port="8080"
    enableLookups="false"
    redirectPort="8443"
    debug="0"
    protocol="AJP/1.3"/>

    <Engine
    name="Standalone"
    defaultHost="localhost"
    debug="0"
    jvmRoute="localtomcat">

    <Host
    name="localhost"
    debug="0"
    appBase="webapps"
    unpackWARs="true"
    autoDeploy="true"
    xmlValidation="false"
    xmlNamespaceAware="false">

    <!--
    Note I had to change the class from
    org.apache.ajp.tomcat4.config.ApacheConfig to
    org.apache.jk.config.ApacheConfig because the install of Tomcat I have
    does not include a jar file that contains the ApacheConfig class in
    that package
    -->
    <Listener
    className="org.apache.jk.config.ApacheConfig"
    forwardAll="false"
    noRoot="false"
    jkDebug="info"
    jkWorker="localtomcat"
    configHome="D:/Apache2/"
    jkLog="D:/Apache2/logs/mod_jk.log"
    modJk="D:/Apache2/modules/mod_jk.dll"
    jkConfig="D:/Apache2/conf/mod_jk.conf"
    workersConfig="D:/Apache2/conf/workers.properties"/>

    </Host>
    </Engine>
    </Service>
    </Server>




    workers.properties (stayed the same)
    ---------------------------------------------------------------
    worker.list=localtomcat
    worker.localtomcat.type=ajp13
    worker.localtomcat.host=localhost
    worker.localtomcat.port=8080
    worker.localtomcat.cachesize=50
    worker.localtomcat.cache_timeout=600
    worker.localtomcat.socket_keepalive=1
    worker.localtomcat.reclycle_timeout=300




    httpd.conf (copied from auto-generated mod_jk.conf file from Tomcat)
    to generate from Tomcat use:
    ..\startup.bat -jkconfg
    ---------------------------------------------------------------
    <IfModule !mod_jk.c>
    LoadModule jk_module "D:/Apache2/modules/mod_jk.dll"
    </IfModule>

    JkWorkersFile "D:/Apache2/conf/workers.properties"
    JkLogFile "D:/Apache2/logs/mod_jk.log"

    JkLogLevel debug

    <VirtualHost localhost>
    ServerName localhost

    # localhost:/corpapps

    ######
    # Static files
    ######
    Alias /corpapps "D:/tomcat5/webapps/corpapps"

    <Directory "D:/tomcat5/webapps/corpapps">
    Options Indexes FollowSymLinks
    DirectoryIndex index.jsp index.html index.htm
    </Directory>


    ######
    # Deny direct access to WEB-INF and META-INF
    ######
    <Location "/corpapps/WEB-INF/*">
    AllowOverride None
    deny from all
    </Location>

    <Location "/corpapps/META-INF/*">
    AllowOverride None
    deny from all
    </Location>

    ######
    # Use Directory too. On Windows, Location doesn't work unless case
    matches
    ######
    <Directory "D:/tomcat5/webapps/corpapps/WEB-INF/">
    AllowOverride None
    deny from all
    </Directory>

    <Directory "D:/tomcat5/webapps/corpapps/META-INF/">
    AllowOverride None
    deny from all
    </Directory>

    JkMount /corpapps/UploadFeedServlet localtomcat
    JkMount /corpapps/SetupServlet localtomcat
    JkMount /corpapps/LoginServlet localtomcat
    JkMount /corpapps/*.jspx localtomcat
    JkMount /corpapps/PlacementPerformanceServlet localtomcat
    JkMount /corpapps/*.jsp localtomcat
    JkMount /corpapps/ReconcileServlet localtomcat
    </VirtualHost>
     
    Brent, Dec 15, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Golem
    Replies:
    0
    Views:
    845
    Golem
    Nov 27, 2003
  2. Stian Kaasa

    Apache + Tomcat + mod_jk configuring

    Stian Kaasa, Jan 18, 2004, in forum: Java
    Replies:
    1
    Views:
    2,401
    Sudsy
    Jan 18, 2004
  3. i5513
    Replies:
    2
    Views:
    2,421
    Axel Seinsche
    May 24, 2004
  4. Lalit Mehta

    Apache 2, Tomcat 5 and mod_jk

    Lalit Mehta, Sep 16, 2004, in forum: Java
    Replies:
    1
    Views:
    485
    code learner
    Dec 24, 2010
  5. Matrix
    Replies:
    0
    Views:
    878
    Matrix
    Jan 18, 2005
Loading...

Share This Page