Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Tomcat8 NoClassDefFoundError: javax/servlet/http/HttpServlet
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
lostinspace2011
Apprentice
Apprentice


Joined: 09 Sep 2005
Posts: 200

PostPosted: Fri Oct 30, 2015 1:17 am    Post subject: Tomcat8 NoClassDefFoundError: javax/servlet/http/HttpServlet Reply with quote

Since upgrading to the latest tomcat the service failed to start successfully. The catalina log reported a NoClassDefFoundError for javax/servlet/http/HttpServletRequest. This class is provided by the tomcat-servlet-api package.

To restore my tomcat I added this dependency manually to the /etc/conf.d/tomcat-8-production configuration under the TOMCAT_EXTRA_JARS section

Quote:

..
TOMCAT_EXTRA_JARS="sun-jai-bin,jdbc-postgresql,log4j,javamail,tomcat-servlet-api-3.1"
..


I am not sure why this is no longer included automatically.
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 4849
Location: The Peanut Gallery

PostPosted: Fri Oct 30, 2015 9:54 am    Post subject: Re: Tomcat8 NoClassDefFoundError: javax/servlet/http/HttpSer Reply with quote

lostinspace2011 wrote:
I am not sure why this is no longer included automatically.

File a bug; you've done all the work so all they need to do is patch it in Gentoo, and submit upstream for you (if it's not distro config), so that the next version (hopefully) won't need a patch.

And good job. :-)
Back to top
View user's profile Send private message
Chewi
Developer
Developer


Joined: 01 Sep 2003
Posts: 858
Location: Edinburgh, Scotland

PostPosted: Fri Oct 30, 2015 1:19 pm    Post subject: Reply with quote

Please don't file a bug actually. It's bug #559576. It isn't a bug per se and all you need to do is this:

Code:
cp /usr/share/tomcat-8/gentoo/tomcat.init /etc/init.d/tomcat-8-production
cp /usr/share/tomcat-8/conf/catalina.properties /var/lib/tomcat-8-production/conf/catalina.properties


Obviously be wary of any customisations you may have made to these files. We really should have done a news item about this. The problem isn't new as these files have always required manual updates but this is probably the first time we have introduced a significant breaking change. I believe this could be handled by dispatch-conf but someone needs to add the functionality to tomcat-instance-manager.bash. Java team is totally swamped (as usual).
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 4849
Location: The Peanut Gallery

PostPosted: Fri Oct 30, 2015 9:51 pm    Post subject: Reply with quote

Chewi wrote:
Please don't file a bug actually. It's bug #559576.

OK, if it's already filed, np; but the first part of filing a bug is about searching to make sure it hasn't been reported already.

The init.d script should not be customised in the general case: that's what /etc/conf.d is for. Both are however in the CONFIG_PROTECT default (under /etc.)

Why on earth does tomcat-8 config live under /var?

If you cannot change that insanity (why not? that's what a distribution is about), consider adding /var/lib/tomcat-8-production/conf to the default set, if possible, or ewarn on install.

IDK what you mean about "tomcat-instance-manager.bash"; if you want help with something like that, it's conventional to provide a link to the file, preferably the HEAD link from a repo.
Back to top
View user's profile Send private message
Chewi
Developer
Developer


Joined: 01 Sep 2003
Posts: 858
Location: Edinburgh, Scotland

PostPosted: Sat Oct 31, 2015 11:14 am    Post subject: Reply with quote

Don't blame me for this "insanity" as this is how we have packaged Tomcat for years. If you actually used this package, you would see tomcat-instance-manager.bash (with a full path) mentioned in pkg_postinst and this is what lostinspace2011 used to set up his "production" instance. The files are not updated by Portage because they are created by the instance manager outside of the normal merge process. While it is unlikely that you would want to customise the init.d script, people running Tomcat tend to have weird and wonderful requirements. It is much more likely that you would need to customise catalina.properties. This is not a conf.d file and Tomcat expects to find it alongside the rest of the instance under /var.

In order to make this work better, tomcat-instance-manager.bash would need to create ._cfg files for dispatch-conf to consume just like webapp-config does. I hope that the PMS will allow us to run it for each instance during pkg_postinst so that users will not have to trigger these updates manually.
Back to top
View user's profile Send private message
fistfullast33l
n00b
n00b


Joined: 26 May 2004
Posts: 28

PostPosted: Sun Nov 01, 2015 4:15 pm    Post subject: Reply with quote

Chewi wrote:
We really should have done a news item about this.


A news item is helpful, but updating the Tomcat wiki with a warning would be a big help too. My first inclination was to check there when my instances stopped working (fortunately I upgraded my dev environment first). Only after mucking around for an hour after the wiki had no details did I think to check whether there were bug reports/forum posts.

Also, I should note that this solution isn't very systemd friendly. Once you noted the classpath was being set in the init script, I decided to hack the setenv.sh file to set the classpath to match what GCLASSPATH is doing in the init script, and then noted that catalina.sh has this java-config line that wipes out the CLASSPATH variable entirely:

Code:
CLASSPATH=`java-config --classpath tomcat-8`


Modifying it to this allowed me to get this working with setenv.sh:

Code:
CLASSPATH=`java-config --classpath tomcat-8`:$CLASSPATH


Should I file a bug report for this since anyone setting the CLASSPATH in setenv.sh (as recommended by Apache) would be in for a surprise?

I understand packages change, and obviously my setup is a bit custom, but publicizing a change like this feels like something important since it essentially breaks the server if you don't update your enviornment.
Back to top
View user's profile Send private message
Chewi
Developer
Developer


Joined: 01 Sep 2003
Posts: 858
Location: Edinburgh, Scotland

PostPosted: Sun Nov 01, 2015 5:00 pm    Post subject: Reply with quote

News items and wiki updates are nice but I'd rather spend the time on making it work through dispatch-conf so that these updates can be delivered in the usual fashion without any special action required.

The issue with catalina.sh has been noted here. It was an oversight on my part as I am not very familiar with Tomcat.

To put this in perspective, the two most active Gentoo Java developers have barely written any real Java for years (I'm a Ruby developer by trade) and we don't have any production systems running Gentoo either. My company uses CentOS and Debian, though that's not my choice. It's not ideal but if it weren't for us, nobody would be updating Tomcat or even the JDKs at all.

Now I'm not denying that things need to be fixed here but I also have to bump the vulnerable icedtea and then fix every version of antlr so that I can remove all traces of Java 6, which should have gone years ago. I class these as more important and that's just the stuff I'm looking at right now.
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 4849
Location: The Peanut Gallery

PostPosted: Sun Nov 01, 2015 7:52 pm    Post subject: Reply with quote

Not ignoring this; just not dealing with it til I'm back in work-mode. Posting solely to say that:

No-one's blaming you for anything Chewi, and we appreciate the work you put in.
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 4849
Location: The Peanut Gallery

PostPosted: Wed Nov 25, 2015 2:53 pm    Post subject: Reply with quote

Chewi wrote:
Don't blame me for this "insanity" as this is how we have packaged Tomcat for years. If you actually used this package, you would see tomcat-instance-manager.bash (with a full path) mentioned in pkg_postinst and this is what lostinspace2011 used to set up his "production" instance. The files are not updated by Portage because they are created by the instance manager outside of the normal merge process.

OK.
Quote:
While it is unlikely that you would want to customise the init.d script, people running Tomcat tend to have weird and wonderful requirements. It is much more likely that you would need to customise catalina.properties. This is not a conf.d file and Tomcat expects to find it alongside the rest of the instance under /var.

Well, the script does what I was getting at, already: makes a symlink from the upstream-expected /var to /etc, though as you said, not to conf.d (for initscript options), but to /etc/tomcat8-production (in this example):
Code:
instance_name="tomcat-@SLOT@"
.. # possible: instance_name+="-$suffix"
tomcat_home="/@GENTOO_PORTAGE_EPREFIX@usr/share/tomcat-@SLOT@"
instance_base="/@GENTOO_PORTAGE_EPREFIX@var/lib/$instance_name"
instance_conf="/@GENTOO_PORTAGE_EPREFIX@etc/$instance_name"
..
cp -r "$tomcat_home/conf/"* "$instance_conf/" || die
..
ln -s "$instance_conf" "$instance_base/conf" || die
ln -s "$instance_temp" "$instance_base/temp" || die
So now I see what you mean by this part:
Quote:
In order to make this work better, tomcat-instance-manager.bash would need to create ._cfg files for dispatch-conf to consume just like webapp-config does. I hope that the PMS will allow us to run it for each instance during pkg_postinst so that users will not have to trigger these updates manually.
So the files are tracked already, as they're under /etc.
As an aside, so the above advice could be written
Code:
cp /usr/share/tomcat-8/gentoo/tomcat.init /etc/init.d/tomcat-8-production
cp /usr/share/tomcat-8/conf/catalina.properties /etc/tomcat-8-production

Creating ._cfg files is certainly feasible, though. The question is whether you want that added or not, because you're going to do this via the mangler.
I'd opt for the latter; like you said, it's more convenient. The "vanilla" directory, under /etc would just be "tomcat-$SLOT", which I think would need to be part of src_install, to initialise the tracking process (unless "$tomcat_home/conf" is under CONFIG_PROTECT; still a user is going to start with the /etc directory to tweak.)

Sounds like you might need to add the .cfg files in pkg_postinst in any case? They're not part of the built pkg, so portage isn't going to be tracking them.

/ramble
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum