2008年5月30日金曜日

[Firefox]blank page is displayed, not able to access to the localhost(127.0.0.1) when using Firefox browser.

Description
When I use the firefox browser in Windows Vista environment and access to my localhost environment to test my web page, I can't access to my localhost web page. blank page is found and firefox doesn't display my test page, and System has no response. However, Internet Explorer works fine in the same environment.

Resolution
  1. Start the firefox browser
  2. Type "about:config" in URL field, the configuration page is displayed.
  3. Type "ipv6" in Filter field located at the top of the config page.
  4. Check "network.dns.disableIPv6", the default value of this configuration is FALSE, change the value of this configuration to TRUE(doubleclick this field and system will change the value to TRUE.)

2008年5月26日月曜日

[Java>JavaMail] java.lang.SecurityException: "Access to default session denied" occures.

Description
This problem occures in my web application environment using tomcat server. When using the javamail library to send email from my application, sometimes the java.lang.SecurityException: "Access to default session denied" error occures and I can not send email from my application. After rebooting my application server(tomcat), javamail works fine for a while.

Error Details
Error message outputted by the javamail is java.lang.SecurityException: "Access to default session denied". After occuring this error, system always fails to send email, but system works fine after rebooting the tomcat server.

Cause
This error is raised in the getDefaultInstance method in javax.mail.Session.java. According to this source code, this error occures when the default session object is already initialized, but authenticator instance is renewed or changed, or the class loader of the default session object is different from the argument authentificator's. Maybe the java source code using the default session instance of the java mail is recompiled and reloaded, or duplicate javamail class libraries are included into the Classpath of the environment.
javax.mail.Session.java file
public static synchronized Session getDefaultInstance(Properties props,
Authenticator authenticator) {
if (defaultSession == null)
defaultSession = new Session(props, authenticator);
else {
// have to check whether caller is allowed to see default session
if (defaultSession.authenticator == authenticator)
; // either same object or both null, either way OK
else if (defaultSession.authenticator != null &&
authenticator != null &&
defaultSession.authenticator.getClass().getClassLoader() ==
authenticator.getClass().getClassLoader())
; // both objects came from the same class loader, OK
else
// anything else is not allowed
throw new SecurityException("Access to default session denied");
}

return defaultSession;
}

Resolution
  1. Recompile and restart application server to reload the new class file.
    After restarting the application server, does your system work fine?
    Do you use auto-deploy functionality? If yes, restart application server and use it without modifying and recompiling your java files.
  2. If the duplicate class files are included.
    Please check the class path directories and some jar files including the javamail class file is included. For example, please check common/lib directory and WEB-INF/lib in your application if you are using tomcat application server. If the duplicate class files are found, please remove the jar file.

2008年5月9日金曜日

[Groovy>Grails] IncompatibleClassChangeError error when starting jetty server in grails development environment

Description
I useally use the Java environment based on Sun's JDK when using grails and groovy, but sometimes I change the JDK from Sun's to IBM's to check the behavior and performance. After changing the IBM's JDK, following error occures when starting up the jetty application server on grails environment.

Error Detail
Failed startup of context org.mortbay.jetty.webapp.WebAppContext@3c003c{/test,/home/admin/test/web-app}
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.IncompatibleClassChangeError: the number of constructors during runtime and compile time for java.lang.Thread do not match. Expected 8 but got 9.

Solution
This error occures because the runtime of java version or provider(Sun, IBM or others) is different from the version of compiled jdk environment. In my case, I compile the grails source code based on Sun's jdk(Ver.1.5), and then I change the JDK from Sun to IBM(Ver.1.5) without recompiling my java source codes. Maybe the IBM internal classes using in the JDK is different from the Sun's. In this case, the error is resolved after clearing all old compiled class files and recompile all classes by using new java compiler.