0

I have a Java program that I'm trying to access through my Apache 2.4.7 webserver locally. At first I had it set up as a reverse proxy using mod_proxy_fcgi whereby I would have to start the webserver with the configuration (1), start the java program manually from the command line each time before I requested the webpage (2), then I navigated to the correct link with a query string (3). This worked for my testing and would return the JSON from the Java program.

//(1) The configuration for the proxy that works
<IfModule proxy_fcgi_module> 
    ProxyPass /doTheThings/ fcgi://localhost:4000/
</IfModule>
<Proxy fcgi://localhost:4000/>
    ProxySet retry=0
</Proxy>

//(2) Command I entered into command line
java -DFCGI_PORT=4000 matdbquery/MatDbQuery  each time

//(3) The URL I would use
localhost/doTheThings/?noUpdate=false&whichData=layoutData 


Now I am looking to make it so I don't have to start the Java program manually each time. Apache would end my Java process when it used mod_proxy_fcgi so it would no longer accept new requests, which sounds like that's the way mod_proxy_fcgi is supposed to work so I decided to start using mod_fcgid. The Java program was already using the FCGI package from fastcgi.com so no changes made there. I'm now stuck on what I need to put in the Apache configuration file. It's only made harder because I cannot debug the problem as I have no view of what errors java.exe might be giving or what command Apache is actually running even with LogLevel debug.

(1) Where does FCGI_PORT factor into this setup with mod_fcgid?
(2) When calling java.exe, you never include the .class in the name. I don't see how I can control the actual filename Apache passes to the FcgidWrapper, which directive to use (<Files>, <Directory>, <Location>) to say which files need the AddHandler and FcgidWrapper, or how I would even state AddHandler without using the file extension .class

//Sample of a configuration that I tried so you can see my mindset?
<Files ~ "\.class$">
    Options ExecCGI
    AddHandler fcgid-script .class
    FcgidWrapper "\"C:/Program Files/Java/jre7/bin/java.exe\" -DFCGI_PORT=4000" virtual
</Files>

If it seems I'm completely missing some sort of process on how FastCGI or Apache works, an explanation would be nice.

  • Well, it's been a while and I came up with a makeshift solution. I run a Perl program in a while(1) loop that will call the java command every time the program itself finishes or is killed so I can continually access the webpage. This is only temporary and am still looking for a permanent and stable solution if anyone has any input. – Coburn Feb 7 '14 at 14:58
  • Hitting some walls now that multiple people are trying to use the program and the poor Perl program cannot keep up. If anyone has input that'd be nice – Coburn Mar 3 '14 at 16:25
  • Project deadline is tomorrow. Any more help x:? – Coburn Mar 25 '14 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.