0

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?

Sergey
  • 933
  • 2
  • 19
  • 48

1 Answers1

1

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.
Stefan
  • 12,108
  • 5
  • 47
  • 66
  • there are no results, i've debuged mod_jk and see that in logs tomcat returns the jsp source. The question is what is wrong with tomcat on the server (locally it working), cause i have tomcat configured by our it department not me. And is it possible, in generall, to dissalow jsp execution on apache + tomcat? – Sergey Jun 04 '14 at 18:48
  • 1
    Yes if the JSP servlet is disabled or badly mapped. See [tomcat-folder]/conf/web.xml, should be line 225 and 360, or search for 'org.apache.jasper'. – Stefan Jun 05 '14 at 06:36
  • You was right thank you! The reason was that jsp compiler was disabled see org.apache.jasper.servlet.JspServlet, in the tomcat\conf\web.xml. It-team says that it is recommend option for production) – Sergey Jun 06 '14 at 12:35