Recent Notes

Displaying keyword search results 1 - 9
Created by nogeek on November 03, 2010 20:52:49    Last update: November 23, 2011 08:54:44
My problem is simple: in my XML data, a timestamp is provided as a long integer (number of milliseconds since the "the epoch"). When I do XSLT, I want to display it as a readable string, such as "Mon Nov 01 18:08:48 CDT 2010". After hours of struggle, I found: It's not so easy to get the job done with JDK 1.6 There are tons of garbage on the web in this space (suggestions, code snippets that simply don't work) Simple Xalan extension functions was the only resource that's somewhat informative. Even there some of the examples don't work. Below is a list of what worked and what didn't. This works: <xsl:stylesheet version="1.0" xmlns:xsl="h... This does not (providing long value to Date constructor): <xsl:stylesheet version="1.0" xmlns:xsl="h......
Created by Fang on October 22, 2011 19:51:05    Last update: October 22, 2011 20:31:48
I built a very basic JSF application and deployed to Tomcat 7.0.22, but it failed with this error: Caused by: java.lang.ClassFormatError: Absent Code... That looks weird and I wasn't able to find a sensible explanation! So I copied the jsf-api-2.1.jar , which was downloaded from the java.net Maven repository by Maven, into a temp folder. And tested it with this simple program: public class ClassFormatErrorTest { public ... I also copied servlet-api.jar from Tomcat's lib folder to the temp folder. Sure enough it failed with the same error: C:\tmp>java -cp .;jsf-api-2.1.jar;servlet-api.jar ... But when I replaced the javax.faces.webapp.FacesServlet class with one I compiled from source, the error disappears! Conclusions: The jar file jsf-api-2.1.jar from java.net Maven repository is good for compilation only (cannot be used...
Created by Dr. Xi on January 31, 2011 16:14:06    Last update: January 31, 2011 16:14:06
Sometimes ClassCastException happens when apprently a class is casted to the same class or a parent class. The exception looks like this: java.lang.ClassCastException: X cannot be cast to ... where Y may be the same as X , or a parent class of X . The cause of this error is that X and Y are loaded by different class loaders. You can use the FindClass utility to find all occurances of X and Y in the deployment tree. If there's no duplication of X and Y in the deployment tree, JNDI lookups may be the culprit. Suppose X is loaded by class loader LX and registered under name jndi/Resource . In the context of another loader LY , your code may be looking up...
Created by Dr. Xi on June 01, 2010 16:44:12    Last update: June 01, 2010 16:45:52
I installed JDK 1.6 under C:\jdk1.6.0_20 and unpacked Eclipse GALILEO in C:\local\eclipse . When I launched Eclipse with eclipse.exe , it simply displayed a splash page and shutdown. Running eclipsec.exe displayed some vague errors: C:\local\eclipse>eclipsec Error occurred during... Turning on debug: C:\local\eclipse>eclipsec -debug Start VM: -Dos... The Solution: add -vm option to eclipse.ini : -startup plugins/org.eclipse.equinox.launcher_1...
Created by Dr. Xi on March 22, 2010 01:50:49    Last update: March 22, 2010 01:50:49
The class org.apache.xerces.jaxp.SAXParserFactoryImpl extends javax.xml.parsers.SAXParserFactory , so casting the former to the latter should not be a problem. This error occurs when there are two copies of javax.xml.parsers.SAXParserFactory loaded by two different class loaders, and you are trying to cast one to the other. Normally, you'll be able to find xml-apis.jar under WEB-INF/lib of the WAR file. Deleting the jar will resolve the problem. java.lang.ClassCastException: org.apache.xerces.ja...
Created by Dr. Xi on February 13, 2010 22:52:18    Last update: February 13, 2010 22:52:18
This runtime error happens when the Sun EL implementation is not available. Look for the class com.sun.el.ExpressionFactoryImpl in your deployment package, you probably won't find it, or you'll find a version that can't be loaded in your deployment environment. If you are using Maven to build, you can add the following repository and dependency in pom.xml : <!-- Project dependencies --> <dependencies...
Created by Dr. Xi on December 12, 2007 20:30:01    Last update: December 12, 2007 20:32:23
This is a script to tail a log file through the web browser. It uses AJAX, apache web server, mod_python, UNIX utilities tail (requires the --lines switch) and wc . The log file may reside on the web server or any other host accessible from the web server through SSH. Although it's written in python, it should be easy to port to other languages such as Perl. Apache httpd.conf : LoadModule python_module modules/mod_python.so ... Python script: import time, os from os.path import basename ...
Created by Dr. Xi on August 15, 2007 18:08:34    Last update: November 08, 2007 22:00:01
I had this problem when deploying a J2EE application into Oracle app server. It worked fine with an OC4J container configured in the default group. But it failed to start with an OC4J container I created. Here's a sample stack trace of the initialization exception: 07/08/14 13:32:46.34 10.1.3.3.0 Started 07/08/1... The problem was, the struts ActionServlet loads commons logging LogFactory, the log factory somehow knows that it needs log4j, but it can't load log4j since it's loaded by a different class loader. The solution for Oracle is to omit commons logging from the list of inherited libraries. Add this to META-INF/orion-application.xml solves the problem: <imported-shared-libraries> <remove-inhe... Actually, this is a quite common problem with commons-logging. If you search the web, you'll find that people have...
Created by Dr. Xi on August 10, 2007 19:53:32    Last update: August 10, 2007 19:53:32
As a Java developer, I often need to find out which Jar file to include on my classpath in order to fix some compilation error (undefined package, class etc). This is a little Perl script I wrote to facilitate this task. #!/bin/perl # find jar containing specified...