Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 18353

Summary: Tomcat: build of connectors (mod_jk2, etc)
Product: Gentoo Linux Reporter: Dylan Carlson (RETIRED) <absinthe>
Component: New packagesAssignee: Java team <java>
Status: RESOLVED FIXED    
Severity: enhancement CC: apache-bugs, dave, dr, hlobil, jgonzalez.openinput, lars, m.debruijne, mholzer, mkennedy, mwolfe, paulpach, per, zyl
Priority: High Keywords: EBUILD
Version: unspecified   
Hardware: All   
OS: Linux   
URL: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jk2/index.html
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 18352    
Bug Blocks:    
Attachments: VERY basic ebuild file to build ONLY mod_jk2
Apache directives to load mod_jk2 if -D JK2 is defined
Basic workers2.properties. Adjust to meet your needs.
Patch to help the buildfile find Apache's build/libtool on Gentoo without Apache2 src
New ebuild - now also compiles jkjni.so module
New ebuild - now also compiles jkjni.so module
New ebuild - now also compiles jkjni.so module
Changed the "sh configure" statement to add jni support.
working version of ebuild - applied changes from comments #13 and #16
cleaned up code and packaged
Added libpcre dep and modified postinst message
mod_jk2-2.0.4 ebuild
mod_jk2 ebuild

Description Dylan Carlson (RETIRED) gentoo-dev 2003-03-28 03:16:48 UTC
This will be a separate ebuild (jakarta-tomcat-connectors).  My tentative plan is to set USE switches inside the ebuild ('apache2') which will:

1. depend on the jakarta-tomcat-connectors package.
2. only be applicable for Tomcat 4.1+, and Apache 2.0.43+.  

It's too dodgy to attempt getting the connectors to build for earlier Tomcat and Apache releases.  My intent is to focus on Tomcat 4.1 and Apache 2.0 since that's where everything is headed anyway.
Comment 1 Tim Shadel 2003-04-24 11:55:05 UTC
Created attachment 11074 [details]
VERY basic ebuild file to build ONLY mod_jk2

I needed an ebuild for mod_jk2, so I put together a VERY simple one.  It ONLY
builds mod_jk2, and it includes 2 BASIC config files.  I used this as a
starting point, and expect that any real attempt at a connectors ebuild will go
far beyond what I've done here.  

But for what it's worth, here are the files:

mod_jk2-2.0.2.ebuild
workers2.properties
105_mod_jk2.conf
mod_jk2-server-apache2-Makefile.in.patch

I put them in my /usr/local/portage directory like this:

/usr/local/portage/net-www/mod_jk2/mod_jk2-2.0.2.ebuild
/usr/local/portage/net-www/mod_jk2/files/workers2.properties
/usr/local/portage/net-www/mod_jk2/files/105_mod_jk2.conf
/usr/local/portage/net-www/mod_jk2/files/mod_jk2-server-apache2-Makefile.in.patch


I look forward to a better ebuild of the connectors.  In the meantime, this
works for me and I hope this could help a few others as well.
Comment 2 Tim Shadel 2003-04-24 11:56:16 UTC
Created attachment 11075 [details]
Apache directives to load mod_jk2 if -D JK2 is defined
Comment 3 Tim Shadel 2003-04-24 11:57:21 UTC
Created attachment 11076 [details]
Basic workers2.properties.  Adjust to meet your needs.
Comment 4 Tim Shadel 2003-04-24 11:58:57 UTC
Created attachment 11077 [details]
Patch to help the buildfile find Apache's build/libtool on Gentoo without Apache2 src
Comment 5 Bryan Duff 2003-07-16 07:54:25 UTC
Created attachment 14543 [details]
New ebuild - now also compiles jkjni.so module

This adds jni support to the mod_jk2 module, the only change is an edit to one
line, the configure line.  I've tested them on two computers, one with the old
version and one with no previous version.  Both work fine.  

Here is what I added to tomcat's conf/server.xml file:

<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
	port="8009" minProcessors="5" maxProcessors="75"
	enableLookups="true" redirectPort="8443"
	acceptCount="10" debug="0" connectionTimeout="20000"
	protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
/>

(note: that block was added just before </Server>

Hope this was helpful.

-Duff
Comment 6 Bryan Duff 2003-07-16 07:57:47 UTC
Created attachment 14544 [details]
New ebuild - now also compiles jkjni.so module

This adds jni support (and a java_home path, and tomcat_path, which btw, is
hardcoded so make sure to change it under "src_compile()", in the "sh
configure" line) to the mod_jk2 module, the only change is an edit to one line,
the configure line.  I've tested them on two computers, one with the old
version and one with no previous version.  Both work fine.  

Here is what I added to tomcat's conf/server.xml file:

<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
	port="8009" minProcessors="5" maxProcessors="75"
	enableLookups="true" redirectPort="8443"
	acceptCount="10" debug="0" connectionTimeout="20000"
	protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
/>

(note: that block was added just before </Server>

Hope this was helpful.

-Duff
Comment 7 Bryan Duff 2003-07-16 07:58:39 UTC
Created attachment 14545 [details]
New ebuild - now also compiles jkjni.so module

This adds jni support (and a java_home path, and tomcat_path, which btw, is
hardcoded so make sure to change it under "src_compile()", in the "sh
configure" line) to the mod_jk2 module, the only change is an edit to one line,
the configure line.  I've tested them on two computers, one with the old
version and one with no previous version.  Both work fine.  

Here is what I added to tomcat's conf/server.xml file:

<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
	port="8009" minProcessors="5" maxProcessors="75"
	enableLookups="true" redirectPort="8443"
	acceptCount="10" debug="0" connectionTimeout="20000"
	protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
/>

(note: that block was added just before </Server>

Hope this was helpful.

-Duff
Comment 8 Bryan Duff 2003-07-16 08:18:22 UTC
Created attachment 14546 [details]
Changed the "sh configure" statement to add jni support.

This adds jni support and a java_home path, and tomcat_path, which btw,
is hardcoded so make sure to change it under "src_compile()", in the "sh
configure" line) to the mod_jk2 module from
--with-tomcat41=$CATALINA_HOME to --with-tomcat[version you have
installed]=$CATALINA_HOME, I realize I haven't tested that, so I am
uncertain what would happen with the wrong version of tomcat put in
there.	It might not be an issue.  I've tested this ebuild on two
computers, one with the old version and one with no previous version.
Both work fine.

Here is what I added to tomcat's conf/server.xml file:

<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
	port="8009" minProcessors="5" maxProcessors="75"
	enableLookups="true" redirectPort="8443"
	acceptCount="10" debug="0" connectionTimeout="20000"
	protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
/>

(note: that block was added just before </Server>

Hope this was helpful.

-Duff
Comment 9 Brett Simpson 2003-08-15 12:21:29 UTC
Just tested this on a server and it works great with apache 2, tomcat 4.1, and Sun-jdk 1.4.2.
Comment 10 Thiago dos Santos Alves 2003-08-15 15:28:49 UTC
I've get this error when I try to emerge this:
------------------------------------------------------------------------------
Calculating dependencies ...done!
>>> emerge (1 of 1) net-www/mod_jk2-2.0.2 to /
>>> md5 src_uri ;-) jakarta-tomcat-connectors-jk2-2.0.2-src.tar.gz
>>> Unpacking source...
>>> Unpacking jakarta-tomcat-connectors-jk2-2.0.2-src.tar.gz to /var/tmp/portage/mod_jk2-2.0.2/work
 * Applying mod_jk2-server-apache2-Makefile.in.patch...

 * Failed Patch: mod_jk2-server-apache2-Makefile.in.patch!
 *
 * Include in your bugreport the contents of:
 *
 *   /var/tmp/portage/mod_jk2-2.0.2/temp/mod_jk2-server-apache2-Makefile.in.patch-18382.out


!!! ERROR: net-www/mod_jk2-2.0.2 failed.
!!! Function epatch, Line 354, Exitcode 0
!!! Failed Patch: mod_jk2-server-apache2-Makefile.in.patch!

------------------------------------------------------------------------------
The content of /var/tmp/portage/mod_jk2-2.0.2/temp/mod_jk2-server-apache2-Makefile.in.patch-18382.out is this:

------------------------------------------------------------------------------
***** mod_jk2-server-apache2-Makefile.in.patch *****

====================================================

PATCH COMMAND:  patch  -p0 < /usr/local/portage/net-www/mod_jk2/files/mod_jk2-server-apache2-Makefile.in.patch

====================================================
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -Naur jakarta-tomcat-connectors-jk2-2.0.2-src.orig/jk/native2/server/apache2/Makefile.in jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2/server/apache2/Makefile.in
|--- jakarta-tomcat-connectors-jk2-2.0.2-src.orig/jk/native2/server/apache2/Makefile.in 2002-10-25 16:00:00.000000000 -0600
|+++ jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native2/server/apache2/Makefile.in      2003-04-24 10:47:46.000000000 -0600
--------------------------
No file to patch.  Skipping patch.
patch: **** malformed patch at line 12: INCLUDES= -I${JK_DIR}/include \
Comment 11 Per Cederberg 2003-10-16 11:34:07 UTC
The SRC_URI in the latest ebuild seems to have gone 404. The following one
should work, though:
http://www.apache.org/dist/jakarta/tomcat-connectors/jk2/source/jakarta-tomcat-connectors-jk2-2.0.2-src.tar.gz
Comment 12 Per Cederberg 2003-10-16 13:12:19 UTC
I found two more problems in the last ebuild provided, before I was able
to make everything compile and install properly:

1. There seems to be additional spaces after \ on a couple of lines. This
break the build with various error messages:

	sh configure --with-apxs2=`which apxs2` \ 
		--with-tomcat41=$CATALINA_HOME \ 
		--with-java-home=$JAVA_HOME \ 
		--with-jni --with-pcre || die

2. The "userpriv" feature breaks the build, as /opt/tomcat is not readable
by normal users. It must be turned off.

Apart from this, everything worked perfectly. Even the configuration was
much easier than expected (although I spent several hours reading docs just
to find that I already had it working...)  Thanks to everyone involved!
Comment 13 Cedric Veilleux 2003-11-15 09:16:37 UTC
I have tested this ebuild and it works fine.

I would propose to remove the dependency on tomcat. mod_jk2 builds perfectly without tomcat installed and tomcat does not need to be installed on the same machine for mod_jk2 to work afaik.
Comment 14 Mike Morris 2003-11-17 22:41:25 UTC
To add to comment#13 above:  Tomcat is definitely /not/ going to be on the same machine as httpd/mod-jk2 in my setup, so the dependency is bogus.
Comment 15 Per Cederberg 2003-11-24 06:07:38 UTC
Installing on another machine today I had the ebuild failing while attempting 
to link with libpcre (Perl-compatible RE:s). Seems like metalog includes that
dependency on my normal machine, but not on this one. Adding dev-libs/libpcre
to the DEPENDS in the ebuild solved this, however:

DEPEND=">=virtual/jdk-1.4
        >=net-www/tomcat-4.1
        >=net-www/apache-2.0.45
        dev-libs/libpcre"
Comment 16 James Lee 2004-01-20 22:26:02 UTC
This is a very nice ebuild.  I just had to change the patch to:

-LIBTOOL=${APACHE2_HOME}/build/libtool 
+LIBTOOL=${APACHE2_LIBEXEC}/../build/libtool

instead of:

-LIBTOOL=${APACHE2_HOME}/build/libtool 
+LIBTOOL=${APACHE2_LIBEXEC}/build/libtool

I also had to download the source manually cause the URL in the ebuild is a little out-of-date.  Other than that this worked right out of the box with Tomcat 5.0.16 :-D

Gentoo-Java team: please get your act together and get Tomcat 5 and mod_jk2 into Portage!
Comment 17 Martin Hajduch 2004-01-29 09:31:55 UTC
Created attachment 24596 [details]
working version of ebuild - applied changes from comments #13 and #16

i'd like to see this in portage as well; so i'm doing the only thing i can -
posting a version of ebuild with fixes from comments #13 and #16 (and removed
tomcat dependency)

i have tested it on a freshly installed machine and it seems to work well
Comment 18 Pavel 2004-02-12 21:01:25 UTC
Created attachment 25514 [details]
cleaned up code and packaged

Packaged files so it could be put into the portage tree.

ebuild cleanup and changes
1) use ${PV} instead of 2.0.2
2) moved einfo contents to pkg_postinst()
3) emake instead of make
4) applied comment #16 to mod_jk2-server-apache2-Makefile.in.patch
5) indentation
Comment 19 Olle Mulmo 2004-02-13 15:59:10 UTC
I just ran into the libpcre dependency as well... latest tar file (dated 2004-02-12) is missing comment #15.
Comment 20 Jason Calabrese 2004-02-19 13:38:47 UTC
I had to reverse the patch in #16 to get mod_jk2 to build
Comment 21 James Lee 2004-03-09 16:00:51 UTC
Created attachment 27124 [details]
Added libpcre dep and modified postinst message

I ran into the same libpcre linking error as in <a
href="http://bugs.gentoo.org/show_bug.cgi?id=18353#c15">Comment #15</a>.  I
modified the DEPEND variable.

I also modified the postinst message.  Being that
/etc/apache2/conf/workers2.properties isn't part of a default install of
mod_jk2, I saw that it might be a security hazard in not letting the user know
about it.  A user might have loaded the module with the *jsp forwarded by
default which could give access to some pretty nice pages for hackers :D.
Comment 22 Chetan Sarva 2004-03-29 21:25:41 UTC
Created attachment 28339 [details]
mod_jk2-2.0.4 ebuild 

New ebuild for 2.0.4 plus various other fixes:
* apache version checking
* tomcat 4 version checking
Comment 23 Pavel 2004-04-12 18:27:48 UTC
1)

line >>>

apache2? ( >=net-www/apache-2 ) : ( =net-www/apache-1.* )

should be >>>

apache2? ( >=net-www/apache-2 ) : ( net-www/apache-1* )


from ERROR

emerge: there are no masked or unmasked ebuilds to satisfy "=net-www/apache-1.*".

2) IUSE should have apache2
Comment 24 Philip H. Smith 2004-05-06 01:04:51 UTC
Can we expect to see this taken into portage anytime soon?  I mean, the ebuild looks like it's already built;  it just needs to go through the testing spin cycles a few times I imagine.  I don't think I'm in a minority as I wait for this ebuild...
Comment 25 James Doherty 2004-06-02 03:42:10 UTC
It would be a big help to have the /tomcat-docs directory set up and working automagically with this ebuild. 
Comment 26 Jens Hilligsøe 2004-06-15 10:14:58 UTC
The IUSE part sounds reasonable. Maybe even a INEED :)

It apparently does all the checking and compiling for either version 1 or 2 of Apache, but it only seems to be installing it into a Apache2 directory.

On the other hand, it seems to work like a charm for Apache2.
Comment 27 unlord 2004-07-22 07:53:43 UTC
Right now the ebuild for mod_jk2 depends on >=net-www/tomcat-4.1  This needs to be changed because jboss comes bundled with Tomcat.  In addition, different application servers come with their own servlet container that can use mod_jk2 as a connector to apache.  This ebuild should instead depend on something like virtual/servlet-container and the jboss, tomcat, resin, etc. ebuilds be updated to provide this virtual package.
Comment 28 Dylan Carlson (RETIRED) gentoo-dev 2004-07-25 19:43:06 UTC
Re-assigning to java.
Comment 29 Per Cederberg 2004-07-26 00:38:30 UTC
I agree with comment #24. This ebuild has been over a year in the making and it seems to be working without problems for normal setups. There have been no error reports for months. Sure, it could use some improvements, but so could many ebuilds already in the portage tree.

So pretty please, with sugar on top, could someone include mod_jk2 2.0.4 in portage?
Comment 30 Kevin J. Menard, Jr. 2004-08-03 13:41:39 UTC
Agreed as well.  I think it's high time this goes into portage.  Without it, gentoo is losing out on its usefulness as a server.
Comment 31 Dave Brondsema 2004-08-03 13:52:18 UTC
I just used it and it works flawlessly.  Let's go!
Comment 32 Dan Check 2004-08-04 08:28:44 UTC
I've been using this ebuild for 6 months to serve a mission critical application without any problems.  To add to the chorus, I'd love to see this in portage.
Comment 33 Dan Check 2004-08-04 11:49:48 UTC
The changes suggested in comment #23 should be encorporated.  Also, if you want to make tomcat optional, depend should be like so:

DEPEND="
    >=virtual/jdk-1.4
    tomcat? >=net-www/tomcat-4.1
    apache2? ( >=net-www/apache-2 ) : ( net-www/apache-1* )
    dev-libs/libpcre"

and IUSE should be like this:

IUSE="apache2 tomcat"

And then finally, in the main part of the ebuild, wrap the has_version tomcat stuff in a `use tomcat`:

    if [ "`use tomcat`" ]; then
        has_version '=net-www/tomcat-4.0*' && TOMCAT4="--with-tomcat40=/opt/tomcat"
        has_version '=net-www/tomcat-4.1*' && TOMCAT4="--with-tomcat41=/opt/tomcat"
    fi

... and that takes care of comment #27 AFAIK.
Comment 34 Jonathan Pappworth 2004-08-29 10:58:29 UTC
Need to change depend net-www/tomcat to www-servers/tomcat
Comment 35 Robert Krimen 2004-08-31 12:32:15 UTC
I was having problems until I manually editing the ebuild to depend on 'www-servers'.
Comment 36 Darren Spruell 2004-10-11 14:55:17 UTC
Does this ebuild force the user to have Tomcat installed, or is it left as optional? For one of the applications I am working on, we want ONLY the Apache2 server and mod_jk2 and we will be connecting to a JBoss/Tomcat server installed remotely. It would be inconvenient (and introduce unneeded bloat) if we need Tomcat installed on the web server as well.
Comment 37 veurits 2004-10-13 05:51:41 UTC
The ebuild worked fine for me.


Rgds Veurits.
Comment 38 Mark Wolfe 2004-10-15 15:06:09 UTC
Created attachment 41924 [details]
mod_jk2 ebuild

This ebuild only works with apache2 and is tested with sockets and SSL
- apache 2.0.51
- tomcat 5.0.28

Tomcat is not required to be installed on the system.
Comment 39 Segedunum 2004-10-30 08:10:09 UTC
Is this ebuild going into Portage any time soon?
Comment 40 Jason Komar 2004-11-17 15:43:28 UTC
Can the ~amd64 keyword be added to this ebuild? I have been testing the 2004-10-15 ebuild on amd64 and it seems to build and work without errors.

Thanks,
Jason
Comment 41 Graham King 2004-11-21 10:07:40 UTC
 I have also used the ebuild from Comment #38 by adding the ~amd64 command and it works fine.
Comment 42 Karl Trygve Kalleberg (RETIRED) gentoo-dev 2004-12-10 17:20:46 UTC
Fixed. Available for testing on x86 and amd64 as www-apache/mod_jk2-2.0.4