Tuesday, May 18, 2010

Inside Arrays.asList(T… a)

A small article explaining why we cannot add elements to the List returned by Arrays.asList(T... a) method - Inside Java: Arrays.asList(T… a)

Thursday, September 24, 2009

What do you deserve?

"The minute you settle for less than you deserve, you get even less than you settled for."

-- Maureen Dowd

Thursday, September 10, 2009

Weblogic 9.2 and Java 6 runtime

When we try to execute and Weblogic J2EE code in Java 6 Runtime using weblogic 9.2 libraries in a small sample code, we get the following exception :

 
[Root exception is java.rmi.UnmarshalException: failed to unmarshal class weblogic.security.acl.internal.AuthenticatedUser; nested exception is: 
 java.io.StreamCorruptedException: invalid type code: 31]
 at weblogic.management.Helper.getMBeanHomeForName(Helper.java:105)
 at weblogic.management.Helper.getAdminMBeanHome(Helper.java:38)
 at WeblogicMBean.main(WeblogicMBean.java:23)


After some search on google, I found the following link which exactly explains the problem :
Serialization error when client app on JDK1.6 access WebLogic on JDK1.5

I tried the suggested solution by starting JVM with the arguments -> -Dsun.lang.ClassLoader.allowArraySyntax=true
and it worked perfectly fine.

Thursday, January 29, 2009

Tact

Tact is the ability to tell your boss that he is open-minded when you know he has a hole in his head.

Tuesday, December 23, 2008

Xalan, Java, XSLTC

What is difference in xalan XSLT processor and and SUN XSLTC compiler ?
They are completely different products. They are both XSLT processors, but they do the same job in very different ways: Xalan (like nearly all other XSLT processors) is in effect a stylesheet interpreter while XSLTC is a stylesheet compiler: it generates Java bytecodes which can be executed directly by the Java VM.

IBM's JDK includes XSLT4J which is based on Xalan. IBM JDK 1.5 it is based on Xalan Java 2.6.0. So there should be no issue moving from Xalan to the IBM JDK.

SUN's JDK 1.5 contains only XSLTC which does not have all of the features of the Xalan interpretive processor. The main differences are in extension support. XSLTC does not support the following extensions:
  • Dynamic EXSLT extensions
  • NodeInfo extension functions
  • SQL library extension
  • PipeDocument extension
  • Evaluate extension
  • Tokenize extension
  • JavaScript extensions
In addition to the above :
  • It does not support all of the XSLT type to Java type conversions that the interpreter supports. You may be able to work around this by adding an explicit cast (e.g. call to the boolean(), number(), etc. function).
  • It does not work well if you return a Boolean object instead of a boolean from a Java extension, or a Double object instead of a double, etc. You can work around this by returning the primitive types instead of objects.
  • It does not provide a default object when the method being called is not static and no object is provided in the extension call. You can work around this by providing the object in the extension call.
It only supports the abbreviated syntax for Java extension calls (see Using the abbreviated syntax for extensions implemented in Java)

So, when you use SUN's JDK 1.5 or later for Transformation on an XSL like this






You will get the following error:

ERROR: 'The first argument to the non-static Java function 'completeTaskOnExit' is not a valid object reference.'
FATAL ERROR: 'Could not compile stylesheet'
Exception in thread "main" javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source)
at Transform.main(Transform.java:29)


If you want to continue to use the Xalan interpreter with SUN's JDK you can use the endorsed standards override mechanism - Create the "endorsed" directory in "...\jre\lib\endorsed" and copy the Xalan 2.7 files into it.

If you are using Xalan 2.8, then extracting "xalan.jar" from 'Xerces-J-tools.2.8.1.zip' and copying it into the 'endorsed' directory solves the problem of not finding 'org.apache.xalan.processor.TransformerFactoryImpl'.

OR you can also force the SUN JDK to use Xalan by setting the System property :

System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");

References:
Ad xslt-sample (not working on Java 1.5 & 1.6) ...
what is difference in xalan XSLT processor and and SUN XSLTC compiler
jdk1.5 and Xalan.jar differences?