Introduction
Well, over the years I've had my share of problems to sort out in Java based projects. All of my problems (and solutions that I've found) are usually in the domain of web based applications.
Ya, ok, this should actually get turned in to a blog... Hmm, I've been needing a good project to really try out some faclets stuff.
ScrumWorks (on Linux)
Oct 25, 2006Hmm, I'll throw something in to try to maek this Linux specific :-) I'm experimenting with ScrumWorks, a task tracking tool by Danube which allows for the creation of Releases, Sprints and associated Tasks, with dependancies and really cool prioritization. It's both a thick and thin client tool - boy do I miss thick client - it's wonderful! Anyway, the server compotent is really a JBoss install. Like all JBosses, it dilligently tries to monopolize port 8080 (and others) with it's embeded Tomcat. Here's an overview of setting it up if you've already got a Tomcat or JBoss (or port 8080) app installed.
JBoss HTTP Listener Port Configuration
These instructions assume that you set your $JBOSS_HOME environment variable to the folder that ScrumWorks is installed in.
export $JBOSS_HOME=/opt/scrumworks-1.8.0for example.
Go to the folder $JBOSS_HOME/server/scrumworks/deploy/jbossweb-tomcat55.sar and backup the existing Tomcat
configuration file:
cd $JBOSS_HOME/server/scrumworks/deploy/jbossweb-tomcat55.sar cp server.xml server.xml.originalEdit the file and change the following sections so that the port nubmers are unique for your system:
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector port="18080" address="${jboss.bind.address}"
maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
emptySessionPath="true"
enableLookups="false" redirectPort="18443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"/>
<!-- A AJP 1.3 Connector on port 8009 -->
<Connector port="18009" address="${jboss.bind.address}"
emptySessionPath="true" enableLookups="false" redirectPort="18443"
protocol="AJP/1.3"/>
If you are going to actually use the redirectPort then you'll need to uncomment and
change the Connector to use the port number you specified above (18443 in my case).
Naming Server Port Configuration
If you are running another J2EE server on your system, you'll need to change the port number of JBoss's naming service. First back up the configuration file:
cd $JBOSS_HOME/server/scrumworks/deploy cp naming-service.xml naming-service.xml.originalThen edit the values in the file. For example:
<!-- The listening port for the bootstrap JNP service. Set this to -1
to run the NamingService without the JNP invoker listening port.
-->
<attribute name="Port">11099</attribute>
<!-- The port of the RMI naming service, 0 == anonymous -->
<attribute name="RmiPort">11098</attribute>
Now when the server starts, you should see your new ports numbers reported in the server output.
When you want to shut down, you'll have to specify the naming port (it'll default to 1099):
./shutdown.sh -s localhost:11099
JK2 Connector Configuration
I put Apache in front of my Tomcat and JBoss servers so that I don't have to open up wonky port numbers for people
to reach my applications. Using the JK2 connetor module with Apache lets you do this. I add the following
to my virtual host configuration in the httpd.conf file:
<Location "/scrumworks/*">
JkUriSet worker ajp13:localhost:18009
</Location>
and then I add the following to the workers2.properties file:
[channel.socket:localhost:18009] port=18009 host=127.0.0.1 # define the worker [ajp13:localhost:18009] channel=channel.socket2:localhost:18009 group=lb
NetBeans on Linux
May 25, 2006 Ok, this isn't specifically about Linux, but I'm experimenting with NetBeans (currently I use Eclipse/MyEclipse for J2EE development). My current technology stack is JSF, Facelets, Spring, Hibernate, Session Beans (for transaction demarcation/clustering/remoting) and JMS. I'm trying NetBeans because NetBeans 5.5 Beta looks really nice, has good support for servers (start/stop/restart/redeploy), has some great support for RAD (especially for Java EE 5) and it seems to be much faster than Eclipse (compile/deploy cycles). I am also growing very weary of MyEclipse only offering partial support for Linux/Mac. No, I do not work for Sun (I work for Virgin Mobile Canada), I'm just out to try something new.
It's very quick to get up and running with NetBeans, importing code and projects done under Eclipse. The IDE seems less cluttered with options and menus, yet I don't seem to be missing anything yet. I'm sure that won't last, though :-) I was really happy to see support for stand alone Java applications (it automatically manages your manifest.mf file for you including main class and classpath). Though I'm primarily doing J2EE development, my main project right now has a standalone server app which relays into a JMS queue. I had some problems getting my JSF/Facelets/Spring webapps running under GlassFish properly, but yanking the myfaces implementation out fixed that problem. It took a moment to figure out how to generate new getters/setters in my domain objects (drill down into Source Packages (in the Projects view) and expand the source file then the class and use Bean Patterns to add new properties (fields, getters and setters)). All in all it's been a good first night, setting up projects, running standalone apps and doing some minor coding. Next I'll be working on J2EE code - the Spring/Session Beans/Hibernate/JMS code.
Mustang on Ubuntu Dapper (Flight 7)
May 8, 2006 Another day, another distro :-) This month I've gone back to Ubuntu to experiment with Dapper (the next release, due out in June 2006). The wiki has instructions for installing J2SE 5 (Tiger) on Ubuntu but doesn't offer any suggestions for Java SE 6 (Mustang). The forums, however, explain how to hack the java-package script to support Mustang. Then all you have to do is follow the instructions on the wiki to make the deb, install the JDK and switch your default Java version. A few minutes work and you'll have all that Mustang goodness (like anti-aliased fonts) on your fav Linux distro.
Java Development on Fedora Core 5
April 5, 2006 Well, a day after it's released I seem to have Fedora Core 5 up and running. Thankfully, with the Test releases a lot of the extras are already out there. For instance, I found that gstreamer 10 ugly plugins are available for FC5 so I'm happily listening to mp3s using Rhythmbox as I type this. Rhythmbox also managed to find all the iTunes shared music folders from everyone on the corporate network so I have a much bigger selection of music to boot.
Mplayer installed just fine, though I couldn't find a mplayer-plugin RPM for FC5 so I built it from source and it plays various video files just fine (no sound yet, but I'll work on that).
FC5 ships with that crazy GNU version of Java that creates so much fun for everyone. That said, I accidently ran Eclipse before setting up a Sun JDK and it actually started! Ok, it's probably coming along, but it's still JDK1.4.2-- so it's not really suitable for the work that I do. I'll likely be lazy, rename the java executable and put Sun's JDK in the path. Wonder if that'll have an impact on OpenOffice?! Oh, and Evolution has crashed once since lunch (1/2 a day uptime). This seems better than the version that shipped with FC4 but still not good enough to use day to day. Maybe it's my 2600 email inbox or something...
Java Development Kits (JDK) and Ubuntu
I am quickly becoming quite enthusiastic about Ubuntu as a desktop O/S. I downloaded and installed "The Breezy Badger" on two machines and am about to reimage my laptop. So, would Ubuntu prove easier to get up and running than Fedora Core when it comes to Java development? It doesn't seem so.
On Fedora, I simply set my JAVA_HOME environment variable in /etc/profile along with adding the bin folder to the PATH and all was well. On Ubuntu, putting these settings in /etc/profile doesn't seem to work. I set in the ~/.bashrc but that only sets Java up to work in a shell - I can't launch eclipse from the Gnome menu this way.
A forum entry at Ubuntu's website said to put then entries in .gnomerc, but that doesn't seem 'correct' to me - what would I do for my server (which doesn't run Gnome)?? I'll post more when I find out more.
Update 2006-02-28 I wound up adding Java to my Ubuntu server and desktop using some instructions found on the Ubuntu forums: http://www.ubuntuforums.org/archive/index.php/t-76735.html. Of course I opted to install the JDK, not the JRE - it works just fine. I originally wanted to try installing Mustang (JDK1.6 which is currently in beta) but I haven't been daring enough to try.
I found that by putting JAVA_HOME in /etc/environment, it was available both during Ubuntu bootup (including init.d scripts) and to the shell as well. Yay!
One problem, however, is that using the 'start' option for catalina.sh runs tomcat in a new shell and JAVA_HOME doesn't get passed to the new environment. Grrrr...
Update 2006-03-09 after more struggling to get tomcat working in a server environment (ie, running it from init.d scripts), I ended up creating the file $CATALINA_HOME/bin/setenv.sh and setting the JAVA_HOME variable in it. This is an extension point in catalina.sh - if the file exists, it is run during tomcat startup and shutdown. Now everything works just fine. Since I'm lazy, I crafted the tomcat startup script to start under my own user so I can start and stop it. Root (who boots the machine) can also start and stop tomcat without any problems but other users would need to know the password of the user who started it (in multiuser environments you'd likely want to create a tomcat user and start tomcat as that user).
So, to make a long story short, my solution to getting Java working properly was to install Java using the instructions on the forum and to set up the JAVA_HOME (and other env variables like ANT_HOME) in both /etc/environment and $CATALINA_HOME/bin/setenv.sh.
The lines I added to /etc/environment are:
JAVA_HOME=/opt/java
The lines I added to $CATALINA_HOME/bin/setenv.sh are:
export JAVA_HOME=/usr/lib/j2sdk1.5-sun
My tomcat startup script which lives in /etc/init.d/tomcat and which starts tomcat with my own user account (dkittle) is:
#!/bin/sh
# Tomcat startup script
RUN_AS_USER=dkittle
START_TOMCAT="/opt/tomcat/bin/catalina.sh start"
STOP_TOMCAT="/opt/tomcat/bin/catalina.sh stop"
#. /etc/environment
chown ${RUN_AS_USER}. /opt/tomcat/logs/*
start() {
echo "Starting tomcat: "
if [ $USER != $RUN_AS_USER ]; then
su -p $RUN_AS_USER ${START_TOMCAT}
else
$START_TOMCAT
fi
echo "done."
}
stop() {
echo "Shutting down tomcat: "
if [ $USER != $RUN_AS_USER ]; then
su -p $RUN_AS_USER ${STOP_TOMCAT}
else
$STOP_TOMCAT
fi
echo "done."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 8
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
Java Development Kits and Fedora Core 3 and Fedora Core 4
(January 2005) Lately I've been wanting to put Linux on my Dell Inspiron laptop so when I bought an 80GB drive to replace by 'bursting at the seams' 40GB drive, I just had to give Fedora Core 4 a try.
Well, the distro annoys me in three ways so far, lack of shipped NTFS support when mounting your existing Windows partition, lack of mp3 support out of the box and broken Java support shipped with gcc.
The version of Java shipped with Fedora Core seems like it's far from 100% compliant with JDK 1.4.2. I have not played with it too much because I was in a rush to get Eclipse, Jude and DbVisualizer installed to get back to coding. I renamed java and javac in /usr/bin to include a .gcc extension and installed both JDK 1.4.2_6 and JDK1.5.0.
Eclipse seemed happy with either JDK, but Jude (the UML modelling tool I use) did not like JDK 1.4.2, complaining about:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/jdk1.4/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
Turns out, libXp is an xfree86 library, but Fedora is now including x.org's windowing system. I didn't want to try to install just this one shared library as I was concerned it might munge my X install so I tried running AWT apps which complained under JDK1.5. Turns out this resolved the issue. I'm sure running under 1.5 (or version 5) will haunt me in other ways, but at least I'm coding again!
(Feb, 2005) Jason Miller and Eric Newcomer emailed to let me know about installing xorg-x11-deprecated-libs. You'll find the RPM on disc 2, if you are installing from CD. This gives you good compatibility with older XFree86 APIs if you are running Xorg (which most distros seem to ship these days). Thanks a TON for your help!
In addition, if you are running Fedora Core 4, installing compat-libstdc seems to help with various GCC4.0 library problems.
Installing compat-libstdc for Fedora Core 5 also seems necessary (DB2-Express needs it, I'm sure other things do too).