Search code examples
javaspringapachetomcatmod-jk

Spring and mod_jk jsp source in the response


I have spring contoller, also apache + mod_jk + tomcat. So after making an requesto to my controller in the response I am getting jsp source code

mod_jk config:

<VirtualHost <some ip>:8000>
        ServerName <host>
        ServerAlias <alias> 
        DocumentRoot <path>
        JkMountCopy On
</VirtualHost>
JkWorkersFile <path>/workers.properties
JkMount /app* worker1

workers.properties

worker.list=worker1
worker.worker1.port=18001
worker.worker1.secret=some_secret
worker.worker1.host=localhost

How I understand apache sucessefully receives request => mod_jk redirects it to spring controller. Question is what happens next? Does spring converts response body to the jsp page, and forward it to apache? How can i fix this issue?


Solution

  • Here is a working configuration, maybe you can find anyting thats missing in yours:

    1. httpd.conf (Mod_jk module must be activated in httpd.conf):

      LoadModule jk_module modules/mod_jk.so
      
      #### JK CONFIG
      
      JkWorkersFile   D:\Server\jk\workers.properties
      JkLogFile       D:\Server\jk\mod_jk.log
      JkShmFile       D:\Server\jk\jk-runtime-status
      JkLogLevel      warning
      
      JkMount /modjkstatus    stats
      
    2. workers.properties:

      worker.list=stats,node1
      
      worker.node1.type=ajp13
      worker.node1.host=localhost
      worker.node1.port=8009
      
      #status information (optional)
      worker.stats.type=status
      
    3. Virtual Host Config

      JkMount /myapp                node1
      JkMount /myapp/*              node1
      
    4. Restart Apache and check error.log and mod_jk.log

    5. Check that the ajp port, from workers.properties, matches the apj connector port in server.xml.
    6. Start Tomcat.
    7. Access /modjkstatus. If modjk is working you should see an info page.
    8. Access /myapp.