Thursday, July 22, 2010
Eclipse 3.6 Helios had problem after upgrading to JDK 6u21 (1.6.0_21)
I found this link http://www.infoq.com/news/2010/07/eclipse-java-6u21 which explains well why they have this problem.
The native code launcher uses the "COMPANY_NAME=Sun Microsystems, Inc", which then changed to "COMPANY_NAME=Oracle Corporation" by Oracle. Not just Eclipse, all RCP based applications are affected.
Saturday, June 12, 2010
Attending Singapore Google Technology Group Meetup
Today I attended this Singapore Google Technology User Group Meeting. It's my first time to attend such a Google meetings. Some of previous meet ups had always fallen on the wrong days -- on the day that I have something else to do. Today I am glad to be able to make it, attended the meeting, and Wesley Chun, was the speaker. He presented 2 sessions, one about Python and the other one about Google App Engine.
This guy's a hardcore Python guy, wrote the Core Python series of book, and was a presenter in the PyCon Asia Pacific 2010, Singapore -- an event that has been held last 3 days. Awesome in depth knowledge, vast industrial experiences, and keep the talk flows fluent.
The rest about the meeting can be found here: http://www.sg-gtug.org/2010/05/sg-gtug-special-tutorial-session-june.html
Wednesday, May 26, 2010
NTLM authentication is no longer supported by Spring Security 3.0.x
I am exploring the way to automatically authenticated on Windows platforms on Spring Security. The older way of doing this is by using the NTLM_FILTER which works with Spring Security 2.0.x.
I just realised that the NTLM filter is no longer supported in Spring Security 3.0.x. The preferred way to do authentication is using the Kerberos.
http://blog.springsource.com/2009/09/28/spring-security-kerberos/
I have stumbled upon this Kerberos authentication has since my freshmen year at university back in 1995. It should then be I remember when using the yellow page tools on SunOS in SPARCstation boxes; the ypbind, yppasswd, etc (renamed NIS) are Kerberos based. It's been around for years, yet I haven't had much experience in setting the configuration on the server from scratch.
Now that I have to explore this, it's time to go in depth with this Kerberos stuffs.
The Windows NT which formerly has its own authentication system, that time, began to adopting standards such as LDAP, Kerberos, etc. NTLM -- which stands for NT LAN Manager, hum, sounds very very oldies kind of stuff -- has been superseded by Kerberos based authentication. Windows 2000 started providing Kerberos authentication as an alternative. Of course since the introduction of Kerberos based system, the transition has been slow, suggesting the new user to use Kerberos by default, and only supporting NTLM when they need backward compatibility with old systems (such as Windows 98). Nevertheless there are some people is still using the NTLM on their legacy systems.
The Spring Security team has deprecated the NTLM integration and move to Kerberos based authentication (for Windows systems) instead.
Monday, March 29, 2010
Hudson Shows "No buffer space available (maximum connections reached?): JVM_Bind"
Here is the capture in my browser:
I purposely put the same message as in the captured image so that search engine will be able to find when people search using the error message.
java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind at java.net.PlainSocketImpl.socketBind(Native method) at java.net.PlainSocketImpl.bind(Unknown Source) at java.net.ServerSocket.(Unknown Source) at hudson.TcpSlaveAgentListener.(TcpSlaveAgentListener.java:91) at hudson.model.Hudson.(Hudson.java:598) at hudson.WebAppMain$2.run(WebAppMain.java:224)
I initially tried to find any solutions to this issue using Google search without much luck. There are few reference on this kind of error but it happened long time ago and seemed to be unrelated to the problem we encountered.
Initially I was thinking of the user limits on Windows, something like ulimit in UNIX/Linux systems.
After 2 cups of coffee, there come the enlightenment.
It's hard to believe that this problem was caused by this (http://support.microsoft.com/kb/196271). The Hudson CI application is currently running on Windows Server 2003 box. This version of Windows Server has something called "maximum ephemeral port number".
Quoting from this Wikipedia entry:
"Ephemeral port is a transport protocol port for Internet Protocol (IP) communications allocated automatically from a predefined range by the TCP/IP Stack Software. It is typically used by the TCP, UDP or SCTP as port for the client end of a client-server communication when the application doesn't bind the socket to a specific port number, or by a server application to free up service's well known listening port and establish a service connection to the client host. The allocations are temporary and only valid for the duration of the connection. After completion of the communication session the ports become available for reuse, although most implementations simply increment the last used port number until the ephemeral port range is exhausted."
According to the Microsoft support website:
Windows Vista and Windows Server 2008 use the IANA suggested ephemeral ports range while the Windows Server 2003 is still using port range of 1250 to 5000.
Ephemeral ports are short-lived port, chosen ad-hoc to serve. In most implementations, they usually only add the port numbers by one until get exhausted on port numbers.
May be this is just my silly thought of me, but it seems like they implemented like this pseudo-code:
[sourcecode lang="python"]
next_port_num = 1250
def get_next_ephemeral_port_num():
result = next_port_num
next_port_num = next_port_num + 1
if next_port_num > 5000:
raise ValueError('no buffer space available')
return result
[/sourcecode]
I wasn't really sure that it is the cause of the problem, but I guess no kangaroo being harmed in the making of the game, so I tried it anyway.
The remedy was simply, run the Registry Editor in the Administrator privilege, open the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters and create new DWORD entry, "MaxUserPort", fill with 65534.
The result, after 2 days monitoring, Hudson is still running well.
NOTE:
- It seems that the problem happens to this specific version of Windows (Windows Server 2003)
- I haven't been able to reproduce this problem on another platforms
Monday, March 1, 2010
Apache Beehive Moved into Apache Attic
Our long time friend, Apache Beehive framework, which was from BEA WebLogic Workshop Framework donated to Apache Software Foundation has reached its end of life. Personally I have encountered this framework a few times when dealing with production application developed using BEA WebLogic Workshop Framework 8.1.x (the BEA's proprietary IDE), and also the development that we did using BEA WebLogic Workshop Framework 9.2 (the Eclipse based IDE).
The framework consisted of NetUI, Control and Web Service Metadata.
The Beehive NetUI is a framework built on top of Struts 1.x (I think it was 1.1, but not from 1.3.x for sure). I remembered when using the BEA WebLogic Workshop IDE, we can configure the page flow using diagrams. It was quite a mess after a while, when you have a lot of page flows though.
The Beehive Controls framework was a superb innovation that time. It simplifies a lot of things (taking into account that at those time it took a lot of extra jobs when you want to configure EJB 2.1 invocation yourself). I believe was based on EJBGen, and predates the Java annotations. The major setbacks with Controls frameworks were that it make it difficult for developers to decouple the application from the BEA WebLogic Workshop Framework, and even more difficult to decouple with the WebLogic Workshop IDE! The IDE did a lot of magic behind the scene (at least for WebLogic 8.1.x), such as generating Ant build files that uses weblogic.jar classes.
Most of the contribution from BEA Systems Inc had been absorbed into the Java Annotations. Well, I think the Beehive Control framework served its duty at its time, yet now it became less and less compelling to use for the reason that it's been obsolete. With almost every comparable framework providing the similar ease of use without having to couple with some jars; who wants to use this "maintenance mode" framework for new developments.
The Beehive WSM (web service metadata), has also served its duty during its time, as new web service standards and frameworks have rolled out one by one. It's been obsolete just as many other web service frameworks. it's cousin, the XMLBeans framework (http://xmlbeans.apache.org) seems to survive much longer. It has just released version 2.5.0 last December 14th, 2009. I personally enjoy using this component framework, generating Java classes and XML mapping. Though we have some other frameworks like Jibx, I personally feel that this XMLBeans is more sophisticated.
Commiters of the project eventually voted to close the Apache Beehive project (http://beehive.apache.org) due to lack of activity. It is moved to Apache Attic (http://attic.apache.org) - such an affectionate name :D
The project was lacking activities, and I agree that it should be shelved into the attic. I believe legacy applications that uses this component should not have any problems because the component is still there, the source code is still there, and more or less it is stable enough.
Recommendations for replacement components are shown in the page, Spring Web Flow/Struts 2 to replace Beehive NetUI, Spring Framework Core to replace Beehive Controls, and Axis2 to replace Beehive WSM.
Good bye, old friend!
Thursday, July 9, 2009
Python's Lazy Evaluation on Exception Handling
[sourcecode lang="python"]
try:
while True:
print('yipee')
except KeyboardInterrupt:
print('w00t')
[/sourcecode]
It runs successfully on command line interface, and keeps printing "yipee" until the user press Ctrl-C. After that I did a typo, which turns out to mistype the "KeyboardInterrupt" as "KeybaordInterrupt".
[sourcecode lang="python"]
try:
while True:
print('yipee')
except KeybaordInterrupt:
print('w00t')
[/sourcecode]
To my surprise, it still runs well, it keeps printing "yipee" to the screen. It's just that
when I press Ctrl-C, Python threw this error:
[sourcecode lang="shell"]
Traceback (most recent call last):
File '<stdin>', line 3, in <module>
KeyboardInterrupt
[/sourcecode]
During handling of the above exception, another exception occurred:
[sourcecode lang="shell"]
Traceback (most recent call last):
File '<stdin>', line 4, in <module>
NameError: name 'KeybaordInterrupt' is not defined
[/sourcecode]
I looked at the documentation of Python 3.1 which says:
The try statement works as follows.
First, the try clause (the statement(s) between the try and except keywords) is executed.
- If no exception occurs, the except clause is skipped and execution of the try statement is finished.
- If an exception occurs during execution of the try clause, the rest of the clause is skipped. Then if its type matches the exception named after the except keyword, the except clause is executed, and then execution continues after the try statement.
- If an exception occurs which does not match the exception named in the except clause, it is passed on to outer try statements; if no handler is found, it is an unhandled exception and execution stops with a message as shown above.
The exception handling in Python works in a lazy manner, they will only validate the except clauses just before processing the exception!
Wednesday, July 1, 2009
Adding Embedded ActiveMQ to Spring Container (on Maven 2 Project)
First I add the dependency for the latest version of ActiveMQ (version 5.2.0):
[sourcecode lang="xml"]
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.2.0</version>
<optional>false</optional>
</dependency>
[/sourcecode]
Now it's time to add something into the Spring application context configuration file.
As suggested by the documentation, I added new namespace amq in my XML. It points to "http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd" schema location.
[sourcecode lang="xml"]
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
[/sourcecode]
I tried to run a JUnit test just to make sure that the new change in the configuration works well. There were some 2 errors. It turns to be a stale schema location. I figured it out from opening the URL http://activemq.apache.org/schema/core and see what's in there. So now need to modify a bit, change "http://activemq.apache.org/schema/core/activemq-core.xsd" to "http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd".
So here goes the correct version that works (syntactically correct XML):
[sourcecode lang="xml"]
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd">
[/sourcecode]
Now the next beast coming in, when I tried to use the new namespace by adding this inside the <beans/> tag.
[sourcecode lang="xml"]
<amq:broker useJmx="false" persistent="false">
<amq:transportConnectors>
<amq:transportConnector uri="tcp://localhost:0" />
</amq:transportConnectors>
</amq:broker>
[/sourcecode]
It produced this error:
[sourcecode lang="shell"]
java.lang.ExceptionInInitializerError
at com.triquesta.tcm.core.services.MessagingServiceTest.init(MessagingServiceTest.java:17)
[...deleted...]
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [tcm_configs.xml]; nested exception is org.springframework.beans.FatalBeanException: NamespaceHandler class [org.apache.xbean.spring.context.v2.XBeanNamespaceHandler] for namespace [http://activemq.apache.org/schema/core] not found; nested exception is java.lang.ClassNotFoundException: org.apache.xbean.spring.context.v2.XBeanNamespaceHandler
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
[...deleted...]
Caused by: org.springframework.beans.FatalBeanException: NamespaceHandler class [org.apache.xbean.spring.context.v2.XBeanNamespaceHandler] for namespace [http://activemq.apache.org/schema/core] not found; nested exception is java.lang.ClassNotFoundException: org.apache.xbean.spring.context.v2.XBeanNamespaceHandler
at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:134)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1292)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
[...deleted...]
Caused by: java.lang.ClassNotFoundException: org.apache.xbean.spring.context.v2.XBeanNamespaceHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:123)
... 37 more
[/sourcecode]