Friday, June 15, 2012

WAS 8 has SSL turned on for RMI by default

As it appears WAS 8 comes with SSL turned on for RMI/IIOP connections. That subtle configuration difference can give you a lot of headache. Especially if you, as one of our clients, are trying to connect as JMS thin client. Client side exception you may encounter will be similar to this one
javax.naming.ServiceUnavailableException: A communication failure occurred while attempting to obtain an initial context with the provider URL: "iiop://localhost:2812".  Make sure that any bootstrap address information in the URL is correct and that the target name server is running.  A bootstrap address with no port specification defaults to port 2809.  Possible causes other than an incorrect bootstrap address or unavailable name server include the network environment and workstation network configuration. [Root exception is org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible:
Forwarded IOR failed with: java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine:host=mresetar-t510,port=0
.
.
.
Caused by: java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine
 at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:391)
 at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:252)
As stack trace has nothing to point you in right direction you may wander around and try to change version of JMS client and who-knows-what. If you want to change JMS client (you're on Java 6) and really want to use SSL then you could follow notes found here to enable security and here to setup JMS client.
You can test this by sending JMS message to server by putting com.ibm.ws.ejb.thinclient_8.0.0.jar & com.ibm.ws.sib.client.thin.jms_8.0.0.jar in classpath and running class with following VM arguments:
-Dcom.ibm.CORBA.Debug=true 
-Dcom.ibm.CORBA.CommTrace=true
-Dcom.ibm.CORBA.Debug.Output=client.log
-Dcom.ibm.SSL.ConfigURL=file:/d:/IBM/WebSphere/Was8Nd/profiles/AppSrv01/properties/ssl.client.props
-Dcom.ibm.CORBA.ConfigURL=file:/d:/IBM/WebSphere/Was8Nd/profiles/AppSrv01/properties/sas.client.props 
-Dcom.ibm.CORBA.loginUserid=admin 
-Dcom.ibm.CORBA.loginPassword=admin 
-Dcom.ibm.CORBA.loginSource=properties
Java class to test JNDI connection and to send JMS message is available here.
On other side if you just want to behave WAS as it did in version 6.1 or 7.0 you can disable RMI SSL. This can be done via admin console by exercising "CSIv2 inbound&outbound communications" options found in Global security menu. Change Transport property from "SSL-required" to "SSL-supported" after restart you should be good to go and send JMS messages without SSL.

Sunday, January 29, 2012

Using Groovy to receive and send mail

In ongoing integration project we had to add e-mail notification (by Zawinski's law). For development, we are using well known Apache James Server. Setting it up was piece of cake but for initial testing it is good to test send and receive functionality. That can be done in numerous ways, one is to use Groovy. Because we use Java to send e-mail, using Groovy for testing, makes perfectly sense. To send e-mail one can make use of ant task for sending mail from Groovy. Script is straight forward and inspired by this ONJava article. There is one caveat though, one must load javax.mail library via systemClassLoader. Putting it all together it looks like self explanatory script below: To read e-mail, Groovy can also be handy, but script is not one-liner as one above. It is actually rewrite of some Java class found on internet. Use both scripts as you like.

Monday, January 16, 2012

How to speed up 802.11n wireless

This is first my first not development related post but it may help you develop faster :-)
If you recently bought new router, compliant with 802.11n standard, you may have been disappointed by getting only 54 Mbit throughput. That is, router appears to work in 802.11g mode. If you use your router for DLNA or HTPC, speed may be of great importance. To get this speed, your computer (laptop) must be also 802.11n compatible but that is something well known. There are others things that may obstruct you. My router was configured to support TKIP or AES (TKIP+AES) encryption and my windows machine used TKIP. According to Intel TKIP is not supported for 802.11n. They say:
If you use these encryption methods (for example, WEP, WPA-TKIP), your data rate will drop to 54 Mbps.

For me it has worked. I have just changed my security setting from WEP-Personal TKIP -> AES and speed was up to 72 Mbps.  If this didn't help you there is some other stuff that you can check out also.

Update 29.1.2012:
Recently I have found out that my wireless adapter driver was set up to use 20MHz bandwidth only. I have changed this and immediately get a connection with full (theoretical)  150 Mbps. That should make synchronization between notebook and home pc even faster.  Changed driver setting is like one on the image below:


While I was on it I have changed my router and adapter power level. After little experimenting I have found out that I need only 25% percent of router power to have good signal. I have also changed adapter power level to Medium (Transmit Power -> 3. Medium). Updated router setting via Advanced Wireless Settings screen is as shown on image below:

I suggest to everyone to change power level at least at their laptops. Why pollute environment with high level radiation? In most cases wireless router is in the same (or next) room, power level should reflect router proximity (low distance -> low power).