Invocation of request.getParts() in a Servlet 3.0 doPost Method Will Not Throw IllegalStateException

This one requires a bit of explaination.

When writing a Servlet that will enable users to upload files from a form you need to be able to limit both the size of the file(s) and the entire multipart/form-data request.  The Servlet 3.0 spec now includes a @MultipartConfig annotation (which can also be specified in web.xml, see other post in this blog).

Based on the Servlet 3.0 spec here is what is supposed to happen.

  1. The user submits a multi-part
Continue reading “Invocation of request.getParts() in a Servlet 3.0 doPost Method Will Not Throw IllegalStateException”

Touching a File in Java

The following is a tutorial on how to create a empty file on the filesystem:

// Destination directory
File destinationDir = new File(“/some/path”);

// The ‘touched’ file
File doneFile = new File(destinationDir, “some_file_name”);

// The JVM will only ‘touch’ the file if you instantiate a
// FileOutputStream instance for the file in question.
// You don’t actually write any data to the file through
// the FileOutputStream.  Just instantiate it and close it.
FileOutputStream doneFOS = null;
try {
    doneFOS → Continue reading “Touching a File in Java”

Fixing "Software installation has been disabled by your system administrator" Notice When Attempting to Install An Addon for Firefox

When I attempted to install the Web Developer Add-on in Firefox I was presented with the error in the title of this post.

After some searching it seems that the least intrusive way to go about fixing it is to update the Firefox configuration for your user profile.

If you are on WinXP look in C:\Documents and Settings\UID\Application Data\Mozilla\Firefox\Profiles\fxlme5ka.default.  On my install the following preference was in prefs.js

Change:

user_pref(“xpinstall.enabled”, false);

to:

user_pref(“xpinstall.enabled”, true);

Save the file and restart Firefox.→ Continue reading “Fixing "Software installation has been disabled by your system administrator" Notice When Attempting to Install An Addon for Firefox”

Configuring JBoss 6.x for HTTPS with a Self-Signed Cert

This tutorial makes the following assumptions:

  • That you are running JBoss under a ‘jboss’ user whose home directory is /home/jboss/

For the following examples the string “<server-name/ip>” should be replaced with the domain name, or ip address from which the site will be accessed via https.  Also the path to your installed JDK is likely different.

  • Create a new keystore using the jdk provided binary:

# /usr/lib/jvm/java-1.6.0-openjdk/bin/keytool -genkey -alias your_alias -keyalg RSA -keystore keystore.jks

Enter keystore password:
Re-enter new password:→ Continue reading “Configuring JBoss 6.x for HTTPS with a Self-Signed Cert”

Fixing JBoss Error installing to Start: name=IIOPInvoker state=Create: java.net.UnknownHostException:

If you ever see the following when attempting to start up an instance of JBoss 6.x:

15:41:15,740 ERROR [AbstractKernelController] Error installing to Start: name=IIOPInvoker state=Create: java.net.UnknownHostException: some_host_name: some_host_name
        at java.net.InetAddress.getLocalHost(InetAddress.java:1426)
        [:1.6.0_17] at org.jboss.invocation.iiop.IIOPInvoker.start(IIOPInvoker.java:233) [:6.0.0.Final]

It is because JBoss cannot resolve the host name of the machine on which it is running.  To fix:

 

  • Edit /etc/hosts and add the name of the box pointing to an ip address.
  • Set up a proper DNS entry for the host name of the machine.
Continue reading “Fixing JBoss Error installing to Start: name=IIOPInvoker state=Create: java.net.UnknownHostException:”

Installing Jboss 6.1.0-Final under RHEL or CentOS

The following is a howto for installing Jboss under Red Hat Enterprise Linux or CentOS.  The steps are most likely the same under any other Linux distro.

  • Unpack your jboss.zip (or .tar)
  • Jboss requires a ‘place’ to store data as it runs.  Out of the box it uses org.jboss.jdbc.HypersonicDatabase which is horribly inefficient and should never be used in a production system.  So we’ll set up MySQL such that jboss can write to it (installing and configuring MySQL is an
Continue reading “Installing Jboss 6.1.0-Final under RHEL or CentOS”

Configuring JBoss 6.x to Run as a Service Under RHEL and CentOS

In most cases you will want to run JBoss as a non-privileged user.  For this example we will set up a jboss user (adding the user is an excersize for the user).  This example covers jboss-6.1.0-Final.

  • Add $JAVA_HOME and $JBOSS_HOME environmental vars to .bash_profile for your jboss user.  $JAVA_HOME points to your install of the JDK and $JBOSS_HOME points to your jboss installation directory.

    JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk.x86_64
    export JAVA_HOME
    PATH=$JAVA_HOME/bin:$PATH
    export PATH

JBOSS_HOME=/opt/jboss/
export JBOSS_HOME

  • Once you have done the basic JBoss
Continue reading “Configuring JBoss 6.x to Run as a Service Under RHEL and CentOS”

Installing HP LaserJet 4050 Network Printer under Window 7 64bit

When attempting to install an HP LaserJet 4050 network printer under Win 7 64bit all you need to do is use the LaserJet 4200/4300 PCL6 naitive drivers that come with Windows.→ Continue reading “Installing HP LaserJet 4050 Network Printer under Window 7 64bit”

Fix For: Pango-WARNING **: failed to choose a font, expect ugly output and Other FireFox Errors

$ firefox &
[1] 1933

$
(firefox:1947): Pango-WARNING **: failed to choose a font, expect ugly output. engine-type=’PangoRenderFc’, script=’common’
GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details -? 1: Failed to get connection to session: /bin/dbus-launch terminated abnormally without any error message)

(firefox:1947): Pango-WARNING **: failed to choose a font, expect ugly → Continue reading “Fix For: Pango-WARNING **: failed to choose a font, expect ugly output and Other FireFox Errors”

Redirecting All Web Requests to the WWW. DNS Entry for Your Web Site

If you would like to redirect all non ‘www’ requests for pages on your site to the ‘www’ dns entry add the following to your .htaccess file in the document root of your site:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Continue reading “Redirecting All Web Requests to the WWW. DNS Entry for Your Web Site”