Skip to main content

Glassfish and mod_jk not working / 404 error

8 replies [Last post]
leontabak
Offline
Joined: 2010-01-12
Points: 0

I need help making mod_jk work with Glassfish.

I am running CentOS 6 on a GoDaddy virtual dedicated server. GoDaddy included the Parallels Plesk Panel to manage the server. I have installed the Glassfish 3.1.2.2 server and the Joomla 3.0.2 content management system. I am running Apache/2.2.15.

I have deployed Java applications on Glassfish and can access them with URI's that include
the server's port number:

http://www.eonsahead.com:8080/dynamic/landscape
http://www.eonsahead.com:8080/cellularautomata

I would like to be able to access them with URI's that look like this:

http://www.eonsahead.com/landscape
http://www.eonsahead.com/dynamic/cellularautomata

To do this, I followed instructions that I found in Amy Roh's posting on java.net.

I downloaded and compiled mod_jk and moved mod_jk.so to /etc/httpd/modules.

I edited /etc/httpd/conf/workers.properties so that it looks like this:

worker.list=worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
#worker.list=ajp13
#worker.ajp13.port=9008
#worker.ajp13.host=localhost
#worker.ajp13.type=ajp13

I created /etc/httpd/conf.d/glassfish.conf. It looks like this:

# where to find workers.properties
#JkWorkersFile /etc/httpd/conf/workers.properties
# where to put jk logs
JkLogFile /var/log/httpd/mod_jk.log
# set the jk log level [debug/error/info]
JkLogLevel info
# select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# jkRequestLogFormat set the request format
jkRequestLogFormat "%w %V %T"
# send everything for context /dynamic to worker named worker1 (ajp13)
jkMount /dynamic/* worker1
jkMount /landscape worker1

I have commented out the JkWorkersFile directive here because Apache
allows this directive only once and I found it already contained in:

/usr/local/psa/admin/conf/generated/13439510590.54764400_server.include

That file contains this:

<IfModule mod_jk.c>
   JkWorkersFile "/etc/httpd/conf/workers.properties"
   JkLogFile /var/log/httpd/mod_jk.log
   JkLogLevel info

It points to my workers.properties file.

I created a jk-enabled network listener like this:

asadmin create-network-listener --protocol http-listener-1 --listenerport 8009 --jkenabled true jk-connector

I restarted Apache and Glassfish.

I can see the jk-connector network listener listed on the Glassfish administrator's console.

I also can see it this way:

$ netstat -a | grep 8009 
tcp        0      0 *:8009                      *:*                         LISTEN 

When I try to access my Java applications, I see a "404 Category not found" error
on Joomla.

I "sudo tail /var/log/httpd/error_log" and see this:

[Tue Dec 11 09:14:30 2012] [notice] mod_python: using mutex_directory /tmp 
[Tue Dec 11 09:14:30 2012] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Dec 11 09:14:30 2012] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Dec 11 09:14:30 2012] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Dec 11 09:14:30 2012] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Dec 11 09:14:30 2012] [notice] Apache/2.2.15 (Unix) DAV/2 mod_fcgid/2.3.6 mod_jk/1.2.37 mod_python/3.3.1 Python/2.6.6 mod_ssl/2.2.15 OpenSSL/1.0.0-fips mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
[Tue Dec 11 09:14:30 2012] [error] avahi_entry_group_add_service_strlst("lists") failed: Invalid host name
[Tue Dec 11 09:14:30 2012] [error] avahi_entry_group_add_service_strlst("lists") failed: Invalid host name
[Tue Dec 11 09:14:30 2012] [error] avahi_entry_group_add_service_strlst("default-184_168_117_170") failed: Invalid host name
[Tue Dec 11 09:14:30 2012] [error] avahi_entry_group_add_service_strlst("default") failed: Invalid host name

The time and date correspond to the time at which I restarted httpd.

I type "sudo tail /var/log/httpd/mod_jk.log" and see this:

[Tue Dec 11 09:14:30 2012] [15762:47150044530336] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
[Tue Dec 11 09:14:30 2012] [15763:47150044530336] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized

Any ideas on how I can make this work?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
leontabak
Offline
Joined: 2010-01-12
Points: 0

I have (mostly) fixed the problem. I used Apache's mod_proxy_ajp module (part of Apache 2.2, so no need to download, compile, or install) in place of the mod_jk module. I created a jk-enabled network listener in Glassfish in the same way that I described in my original post. I edited /etc/httpd/conf.d/glassfish.conf (the configuration file that I created) so that it now looks like this:

ProxyRequests off

<Proxy *>
Order deny,allow
Allow from localhost
</Proxy>

<Location /dynamic >
ProxyPass ajp://localhost:8009/dynamic
</Location>

I was then able to able to access my Web site's home page by typing www.eonsahead.com in my browser's address window and access Java Web applications by typing www.eonsahead.com/dynamic/landscape and www.eonsahead.com/cellularautomata.

(I am still working on the site and may change the location of these applications, so the links that I am including in this post might not work for you.)

At first, I saw many 404 and 503 errors from Apache. If I repeatedly hit the "reload page" button in my browser, I sometimes got my Java application and sometimes a "page not found" or "internal error message." Also, some of my applications that put Servlet-generated images in pages gave me pages without the images. Forms on applications did not work.

It looks like I have fixed those problems by logging onto the Glassfish administrator's console and adjusting the parameters of the thread pool that my jk-connector network listener is using.
I found minimum = 2, maximum = 5, and idle = 900. I changed those numbers to minimum = 4, maximum = 12, and idle = 4096. (I guessed at those numbers.)

Now I am working on finding the right mapping that will get Apache serving static pages and PHP applications while Glassfish serves my Java applications.

I found many postings about how to use mod_jk to make Apache and Glassfish (or Tomcat) work together (including instructions in the Oracle Glassfish 3.1 Administration Guide) but also found some suggestions on the Web that we should now prefer mod_proxy_ajp. I'd like to hear from you if you know more about this.

Thanks to those read my posting!

Roel_D

I can't further help you at this point, but i would suggest you take a look at liferay.

Since i asume you have joomla for writting blogs an maybe a forum, i think liferay suits you best.
It:
- is 100% java,
- Has all you want from joomla
- has an installer complete with glassfish
- allows you to install every java /jsp app as a portlet
- is less prune to hackers

Kind regards,

The out-side

Op 14 dec. 2012 om 17:30 heeft forums@java.net het volgende geschreven:

> I have (mostly) fixed the problem. I used Apache's mod_proxy_ajp module (part
> of Apache 2.2, so no need to download, compile, or install) in place of the
> mod_jk module. I created a jk-enabled network listener in Glassfish in the
> same way that I described in my original post. I edited
> /etc/httpd/conf.d/glassfish.conf (the configuration file that I created) so
> that it now looks like this: ProxyRequests off Order deny,allow Allow from
> localhost ProxyPass ajp://localhost:8009/dynamic I was then able to able to
> access my Web site's home page by typing www.eonsahead.com [1] in my
> browser's address window and access Java Web applications by typing
> www.eonsahead.com/dynamic/landscape [2] and
> www.eonsahead.com/cellularautomata [3]. (I am still working on the site and
> may change the location of these applications, so the links that I am
> including in this post might not work for you.) At first, I saw many 404 and
> 503 errors from Apache. If I repeatedly hit the "reload page" button in my
> browser, I sometimes got my Java application and sometimes a "page not found"
> or "internal error message." Also, some of my applications that put
> Servlet-generated images in pages gave me pages without the images. Forms on
> applications did not work. It looks like I have fixed those problems by
> logging onto the Glassfish administrator's console and adjusting the
> parameters of the thread pool that my jk-connector network listener is using.
> I found minimum = 2, maximum = 5, and idle = 900. I changed those numbers to
> minimum = 4, maximum = 12, and idle = 4096. (I guessed at those numbers.) Now
> I am working on finding the right mapping that will get Apache serving static
> pages and PHP applications while Glassfish serves my Java applications. I
> found many postings about how to use mod_jk to make Apache and Glassfish (or
> Tomcat) work together (including instructions in the Oracle Glassfish 3.1
> Administration Guide) but also found some suggestions on the Web that we
> should now prefer mod_proxy_ajp. I'd like to hear from you if you know more
> about this. Thanks to those read my posting!
>
> [1] http://www.eonsahead.com
> [2] http://www.eonsahead.com/dynamic/landscape
> [3] http://www.eonsahead.com/dynamic/cellularautomata
>
> --
>
> [Message sent by forum member 'leontabak']
>
> View Post: http://forums.java.net/node/893134
>
>

oleksiys
Offline
Joined: 2006-01-25
Points: 0

If you're running Glassfish 3.1.2.2, pls. apply this ajp related patch
http://java.net/jira/browse/GRIZZLY-1340

rlubke
Offline
Joined: 2003-08-21
Points: 0

To rule out an AJP configuration issue, have you tried setting the JK mapping to /* and trying to access the default welcome page? If this works, then we can rule out a GlassFish/ModJK issue.

Also, the "404 Category Not Found", after a quick search, seems to be a Joomla specific message. It could be, assuming a proper basic configuration working (as per above), that there are additional confirmation requirements in order for this to work. If we rule out the above, it may be best to seek help from the Joomla community.

Roel_D

If you want the URL's to be shortened then for joomla you need to use the .htaccess file. But for stuff running on glassfish this doesn't work so easy.

But why not download quercus (read online help) and drop the JAR's in the domain/lib directory? You can run both joomla and your java code on a single glassfish instance.

Glassfish has plesk-like hostname-to-content-rules so you're easy up and running.

And quercus offers 5x more PHP speed ;-) and less vulnerabities

Kind regards,

The out-side

Op 11 dec. 2012 om 21:47 heeft forums@java.net het volgende geschreven:

> To rule out an AJP configuration issue, have you tried setting the JK mapping
> to /* and trying to access the default welcome page? If this works, then we
> can rule out a GlassFish/ModJK issue. Also, the "404 Category Not Found",
> after a quick search, seems to be a Joomla specific message. It could be,
> assuming a proper basic configuration working (as per above), that there are
> additional confirmation requirements in order for this to work. If we rule
> out the above, it may be best to seek help from the Joomla community.
>
> --
>
> [Message sent by forum member 'rlubke']
>
> View Post: http://forums.java.net/node/893134
>
>

leontabak
Offline
Joined: 2010-01-12
Points: 0

I am still stuck.

I tried replacing the "JkMount" directives with "JkMount /* worker1" in /etc/httpd/conf.d/glassfish.conf. I moved Joomla out of the way by renaming index.php in the root directory of my Web site. I also moved .htaccess out of the way by renaming that file just in case that was causing some URL rewriting that I was not seeing. I added read permissions for the world to /etc/httpd/conf/workers.properties and /etc/httpd/conf.d/glassfish.conf just in case restricted access to the configuration files was the problem.

Now I type http://www.eonsahead.com in my browser and I see the trivial home page that I put in place of Joomla. I type http://www.eonsahead.com:8080 and I see the Glassfish "Your server is running" page. I type http://www.eonsahead.com:8080/cellularautomata and I see my Java application served up by Glassfish. I type http://www.eonsahead.com/cellularautomata and I see "404 not found/The requested document was not found on this server."

Thank you for taking a look at my problem and thank you for your suggestions.

Roel_D

Just to be sure: you do know that joomla runs standard on apache which runs at port 80 and glassfish is normaly running on 8080?
You can't have both webservers running on the same port 80, that's why glasssfish runs on 8080.

So you must modify modproxy to serve /translate the glassfish pages from 8080 at apache's port 80.

Kind regards,

The out-side

Op 11 dec. 2012 om 23:26 heeft forums@java.net het volgende geschreven:

> I am still stuck. I tried replacing the "JkMount" directives with "JkMount /*
> worker1" in /etc/httpd/conf.d/glassfish.conf. I moved Joomla out of the way
> by renaming index.php in the root directory of my Web site. I also moved
> .htaccess out of the way by renaming that file just in case that was causing
> some URL rewriting that I was not seeing. I added read permissions for the
> world to /etc/httpd/conf/workers.properties and
> /etc/httpd/conf.d/glassfish.conf just in case restricted access to the
> configuration files was the problem. Now I type http://www.eonsahead.com in
> my browser and I see the trivial home page that I put in place of Joomla. I
> type http://www.eonsahead.com:8080 and I see the Glassfish "Your server is
> running" page. I type http://www.eonsahead.com:8080/cellularautomata and I
> see my Java application served up by Glassfish. I type
> http://www.eonsahead.com/cellularautomata and I see "404 not found/The
> requested document was not found on this server." Thank you for taking a look
> at my problem and thank you for your suggestions.
>
> --
>
> [Message sent by forum member 'leontabak']
>
> View Post: http://forums.java.net/node/893134
>
>

leontabak
Offline
Joined: 2010-01-12
Points: 0

I am new to this but I think that mod_proxy is an alternative to mod_jk. The postings that I have found tell me that the mod_jk module for Apache is the simplest and most common way of accomplishing what I want to do.

If I understand this correctly, when I have everything working visitors to my Web site will send HTTP requests to Apache on port 80. The mod_jk module in Apache will forward some requests to Glassfish, on which I have created a network listener on port 8009. Glassfish then fetches or generates the requested HTML page (or jpg image or whatever is the correct response to the request), passes it to Apache, which then sends the HTTP response back to the visitor in the usual way. I specify which requests Apache will forward to Glassfish in my configuration file by saying, for example, that all requests with URLs that begin with "/dynamic" shall be forwarded to Glassfish.

Some schools have firewalls that prevent students from accessing services (like Glassfish) that run on port 8080. I would like to make my Java Web applications accessible to those students through the (unblocked) port 80. Even where there is no firewall, I would like to relieve visitors to my Web site from the need to include a port number in what they enter in their browser's address window because few members of my potential audience are likely to be familiar with port numbers.

Roel_D

For some reason my iphone strips the subject of every mail i send to this list :-(
But on topic: if you are only wanting to serve java (generated) content to your visitors then stop apache ( so port 80 is free for use) and alter your domain.xml. Somewhere there is line that says glassfish will run on port 8080. Http-listener section. Change it to port 80.
Maybe you need to make sure user apache runs glassfish since on linux port 80 is a privileged port, if so don't forget to chown -R the whole glassfish installation directory to user apache.

Kind regards,

The out-side

Op 12 dec. 2012 om 20:45 heeft forums@java.net het volgende geschreven:

> I am new to this but I think that mod_proxy is an alternative to mod_jk. The
> postings that I have found tell me that the mod_jk module for Apache is the
> simplest and most common way of accomplishing what I want to do. If I
> understand this correctly, when I have everything working visitors to my Web
> site will send HTTP requests to Apache on port 80. The mod_jk module in
> Apache will forward some requests to Glassfish, on which I have created a
> network listener on port 8009. Glassfish then fetches or generates the
> requested HTML page (or jpg image or whatever is the correct response to the
> request), passes it to Apache, which then sends the HTTP response back to the
> visitor in the usual way. I specify which requests Apache will forward to
> Glassfish in my configuration file by saying, for example, that all requests
> with URLs that begin with "/dynamic" shall be forwarded to Glassfish. Some
> schools have firewalls that prevent students from accessing services (like
> Glassfish) that run on port 8080. I would like to make my Java Web
> applications accessible to those students through the (unblocked) port 80.
> Even where there is no firewall, I would like to relieve visitors to my Web
> site from the need to include a port number in what they enter in their
> browser's address window because few members of my potential audience are
> likely to be familiar with port numbers.
>
> --
>
> [Message sent by forum member 'leontabak']
>
> View Post: http://forums.java.net/node/893134
>
>