skip to Main Content

I have a new Debian 10 server with Apache 2 + Tomcat 9. I can’t run the JSF page due to an internal server error. I think the error is in the Apache Tomcat connector (libapache2-mod-jk) ..

I use OpenJDK v. 11, I also use the Apache Tomcat Native library [1.2.23] using the APR version [1.7.0].
Tomcat runs regularly and also Apache.

This is my workers.properties file :

        # workers.properties -
    #
    # This file is a simplified version of the workers.properties supplied
    # with the upstream sources. The jni inprocess worker (not build in the
    # debian package) section and the ajp12 (deprecated) section are removed.
    #
    # As a general note, the characters $( and ) are used internally to define
    # macros. Do not use them in your own configuration!!!
    #
    # Whenever you see a set of lines such as:
    # x=value
    # y=$(x)something
    #
    # the final value for y will be valuesomething
    #
    # Normaly all you will need to do is un-comment and modify the first three
    # properties, i.e. workers.tomcat_home, workers.java_home and ps.
    # Most of the configuration is derived from these.
    #
    # When you are done updating workers.tomcat_home, workers.java_home and ps
    # you should have 3 workers configured:
    #
    # - An ajp13 worker that connects to localhost:8009
    # - A load balancer worker
    #
    #

    # OPTIONS ( very important for jni mode )

    #
    # workers.tomcat_home should point to the location where you
    # installed tomcat. This is where you have your conf, webapps and lib
    # directories.
    #
    workers.tomcat_home=/usr/share/tomcat9

    #
    # workers.java_home should point to your Java installation. Normally
    # you should have a bin and lib directories beneath it.
    #

    workers.java_home=/usr/lib/jvm/java-11-openjdk-amd64

    #
    # You should configure your environment slash... ps= on NT and / on UNIX
    # and maybe something different elsewhere.
    #
    ps=/

    #
    #------ ADVANCED MODE ------------------------------------------------
    #---------------------------------------------------------------------
    #

    #
    #------ worker list ------------------------------------------
    #---------------------------------------------------------------------
    #
    #
    # The workers that your plugins should create and work with
    #
    worker.list=ajp13_worker

    #
    #------ ajp13_worker WORKER DEFINITION ------------------------------
    #---------------------------------------------------------------------
    #

    #
    # Defining a worker named ajp13_worker and of type ajp13
    # Note that the name and the type do not have to match.
    #
    worker.ajp13_worker.port=8009
    worker.ajp13_worker.host=localhost
    worker.ajp13_worker.type=ajp13
    #
    # Specifies the load balance factor when used with
    # a load balancing worker.
    # Note:
    #  ----> lbfactor must be > 0
    #  ----> Low lbfactor means less work done by the worker.
    worker.ajp13_worker.lbfactor=1

    #
    # Specify the size of the open connection cache.
    #worker.ajp13_worker.cachesize

    #
    #------ DEFAULT LOAD BALANCER WORKER DEFINITION ----------------------
    #---------------------------------------------------------------------
    #

    #
    # The loadbalancer (type lb) workers perform wighted round-robin
    # load balancing with sticky sessions.
    # Note:
    #  ----> If a worker dies, the load balancer will check its state
    #        once in a while. Until then all work is redirected to peer
    #        workers.
    worker.loadbalancer.type=lb
    worker.loadbalancer.balance_workers=ajp13_worker

and this is my httpd-jk.conf file :

        # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements.  See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License.  You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.

    # Configuration Example for mod_jk
    # used in combination with Apache 2.2.x

    <IfModule jk_module>

        # We need a workers file exactly once
        # and in the global server
        JkWorkersFile /etc/libapache2-mod-jk/workers.properties

        # Our JK error log
        # You can (and should) use rotatelogs here
        JkLogFile /var/log/apache2/mod_jk.log

        # Our JK log level (trace,debug,info,warn,error)
        JkLogLevel debug

        # Our JK shared memory file
        JkShmFile /var/log/apache2/jk-runtime-status

        # Define a new log format you can use in any CustomLog in order
        # to add mod_jk specific information to your access log.
        # LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" "%{Cookie}i" "%{Set-Cookie}o" %{pid}P %{tid}P %{JK_LB_FIRST_NAME}n %{JK_LB_LAST_NAME}n ACC %{JK_LB_LAST_ACCESSED}n ERR %{JK_LB_LAST_ERRORS}n BSY %{JK_LB_LAST_BUSY}n %{JK_LB_LAST_STATE}n %D" extended_jk

        # This option will reject all requests, which contain an
        # encoded percent sign (%25) or backslash (%5C) in the URL
        # If you are sure, that your webapp doesn't use such
        # URLs, enable the option to prevent double encoding attacks.
        # Since: 1.2.24
        # JkOptions +RejectUnsafeURI

        # After setting JkStripSession to "On", mod_jk will
        # strip all ";jsessionid=..." from request URLs it
        # does *not* forward to a backend.
        # This is useful, if all links in a webapp use
        # URLencoded session IDs and parts of the static
        # content should be delivered directly by Apache.
        # Of course you can also do it with mod_rewrite.
        # Since: 1.2.21
        # JkStripSession On

        # Start a separate thread for internal tasks like
        # idle connection probing, connection pool resizing
        # and load value decay.
        # Run these tasks every JkWatchdogInterval seconds.
        # Since: 1.2.27
        JkWatchdogInterval 60

        # Configure access to jk-status and jk-manager
        # If you want to make this available in a virtual host,
        # either move this block into the virtual host
        # or copy it logically there by including "JkMountCopy On"
        # in the virtual host.
        # Add an appropriate authentication method here!
        <Location /jk-status>
            # Inside Location we can omit the URL in JkMount
            JkMount jk-status
            Require ip 127.0.0.1
        </Location>
        <Location /jk-manager>
            # Inside Location we can omit the URL in JkMount
            JkMount jk-manager
            Require ip 127.0.0.1
        </Location>

        # If you want to put all mounts into an external file
        # that gets reloaded automatically after changes
        # (with a default latency of 1 minute),
        # you can define the name of the file here.
        # JkMountFile conf/extra/uriworkermap.properties

        # Example for Mounting a context to the worker "balancer"
        # The URL syntax "a|b" instantiates two mounts at once,
        # the first one is "a", the second one is "ab".
        # JkMount /myapp|/* balancer

        # Example for UnMounting requests for all workers
        # using a simple URL pattern
        # Since: 1.2.26
        # JkUnMount /myapp/static/* *

        # Example for UnMounting requests for a named worker
        # JkUnMount /myapp/images/* balancer

        # Example for UnMounting requests using regexps
        # SetEnvIf REQUEST_URI ".(htm|html|css|gif|jpg|js)$" no-jk

        # Example for setting a reply timeout depending on the request URL
        # Since: 1.2.27
        # SetEnvIf Request_URI "/transactions/" JK_REPLY_TIMEOUT=600000

        # Example for disabling reply timeouts for certain request URLs
        # Since: 1.2.27
        # SetEnvIf Request_URI "/reports/" JK_REPLY_TIMEOUT=0

        # IMPORTANT: Mounts and virtual hosts
        # If you are using VirtualHost elements, you
        # - can put mounts only used in some virtual host into its VirtualHost element 
        # - can copy all global mounts to it using "JkMountCopy On" inside the VirtualHost
        # - can copy all global mounts to all virtual hosts by putting
        #   "JkMountCopy All" into the global server
        # Since: 1.2.26

    </IfModule>

This is my mod_jk.log log file (I replaced my real domain with www.mydomain.com)

    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] jk_set_time_fmt::jk_util.c (487): Pre-processed log time stamp format is '[%a %b %d %H:%M:%S.000 %Y] '
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] dump_options::mod_jk.c (678): JkOption 'ForwardURIProxy' set in server 'www.mydomain.com [*:80]' (default)
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] dump_options::mod_jk.c (698): JkOption 'ForwardKeySize' set in server 'www.mydomain.com [*:80]' (default)
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_open::jk_uri_worker_map.c (898): rule map size is 1
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_add::jk_uri_worker_map.c (848): wildchar rule '/*=ajp13_worker' source 'JkMount' was added
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (178): uri map dump after map open: id=0, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 0: size=0 nosize=0 capacity=0
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 1: size=1 nosize=0 capacity=4
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (197): NEXT (1) map #0: uri=/* worker=ajp13_worker context=/* source=JkMount type=Wildchar len=2
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [info] init_jk::mod_jk.c (3591): mod_jk/1.2.46 initialized
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] wc_get_worker_for_name::jk_worker.c (120): did not find a worker ajp13_worker
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [error] extension_fix::jk_uri_worker_map.c (580): Could not find worker with name 'ajp13_worker' in uri map post processing.
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (178): uri map dump after extension stripping: id=2, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 0: size=0 nosize=0 capacity=0
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 1: size=1 nosize=0 capacity=4
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (197): NEXT (1) map #0: uri=/* worker=ajp13_worker context=/* source=JkMount type=Wildchar len=2
    [Mon Nov 25 16:40:11.684 2019] [1914:140619718063232] [debug] uri_worker_map_switch::jk_uri_worker_map.c (602): Switching uri worker map from index 0 to index 1
    [Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] jk_set_time_fmt::jk_util.c (487): Pre-processed log time stamp format is '[%a %b %d %H:%M:%S.000 %Y] '
    [Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] dump_options::mod_jk.c (678): JkOption 'ForwardURIProxy' set in server 'www.mydomain.com [*:80]' (default)
    [Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] dump_options::mod_jk.c (698): JkOption 'ForwardKeySize' set in server 'www.mydomain.com [*:80]' (default)
    [Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_open::jk_uri_worker_map.c (898): rule map size is 1
    [Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_add::jk_uri_worker_map.c (848): wildchar rule '/*=ajp13_worker' source 'JkMount' was added
    [Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (178): uri map dump after map open: id=0, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
    [Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 0: size=0 nosize=0 capacity=0
    [Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 1: size=1 nosize=0 capacity=4
    [Mon Nov 25 16:40:11.690 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (197): NEXT (1) map #0: uri=/* worker=ajp13_worker context=/* source=JkMount type=Wildchar len=2
    [Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [info] init_jk::mod_jk.c (3591): mod_jk/1.2.46 initialized
    [Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] wc_get_worker_for_name::jk_worker.c (120): did not find a worker ajp13_worker
    [Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [error] extension_fix::jk_uri_worker_map.c (580): Could not find worker with name 'ajp13_worker' in uri map post processing.
    [Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (178): uri map dump after extension stripping: id=2, index=0 file='(null)' reject_unsafe=0 reload=60 modified=0 checked=0
    [Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 0: size=0 nosize=0 capacity=0
    [Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (184): generation 1: size=1 nosize=0 capacity=4
    [Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_dump::jk_uri_worker_map.c (197): NEXT (1) map #0: uri=/* worker=ajp13_worker context=/* source=JkMount type=Wildchar len=2
    [Mon Nov 25 16:40:11.691 2019] [1915:140619718063232] [debug] uri_worker_map_switch::jk_uri_worker_map.c (602): Switching uri worker map from index 0 to index 1

my Apache is :

        <VirtualHost *:80>
    DocumentRoot "/var/www/vhosts/www.mydomain.com/ROOT"
    ServerName www.mydomain.com
    ServerAdmin [email protected]

    JkMount /* ajp13_worker
    JkLogLevel debug


    <Directory "/var/www/vhosts/www.mydomain.com/ROOT">
    allow from all
    Options None
    Require all granted
    </Directory>
    </VirtualHost>

It seems that Apache cannot find “ajp13_worker” worker..

Why?

Thanks.

3

Answers


  1. You have to define the JK options in your apache file, before the virtualhost, not in. for example:

    JkWorkersFile /etc/libapache2-mod-jk/workers.properties
    JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
    JkLogFile ${APACHE_LOG_DIR}/mod_jk.log
    JkLogLevel info                
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    

    The JKWorkersFile is the necessary, the others are optional.

    Login or Signup to reply.
  2. You have to rename the JK configuration file from httpd-jk.conf to jk.conf.
    This worked for me :

    $ sudo a2dismod jk
    $ sudo mv /etc/apache2/mods-available/httpd-jk.conf /etc/apache2/mods-available/jk.conf
    $ cd /etc/libapache2-mod-jk/
    $ sudo ln -f -s ../apache2/mods-available/jk.conf httpd-jk.conf
    $ sudo a2enmod jk
    $ sudo apache2ctl configtest
    $ sudo systemctl restart apache2
    
    Login or Signup to reply.
  3. I met this issue. By analyzing the Apache logs (error.log), I noticed that the file /etc/apache2/mods-available/httpd-jk.conf (symbolic link from /etc/libapache2-mod-jk/httpd-jk.conf) was not loaded because Apache fixed the default name of the log file (JkLogFile directive).
    Then just copy the httpd-jk.conf file under /etc/apache2/conf-available and then make a symbolic link of this copy to the target /etc/apache2/conf-enabled and everything works.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search