Friday, December 28, 2012

WD MyBook Essential in Linux

After some searches on Google, I found the best solution to mount the WD MyBook Essential to my Ubuntu 12.04. First, I'm using the drive over my Network. The drive is connected to my router via USB and accessible to all connecting computers. I'm not using a password to login to the drive.

Procedure:
1) Open a terminal
2) sudo mkdir /media/directory-you-want-to-mount-to
3) sudo gedit /etc/fstab
4) When the gedit window opens, add the following:
//router-ip-address/USB_Storage/directory-you-want-to-mount-from /media/directory-you-want-to-mount-to cifs guest,_netdev 0 0
5) Save
6) sudo mount -a
7) If successful, you should see the drive mounted on you desktop. If not successful, I'm guessing that you'll get a message from 'mount' command. I'd recommend that 'mount -a' works before restarting, you might have issues with logging in if you don't.

Notes:
- I read that '_netdev' is used to wait until the network connection is available to finalize the command.
- If you need a secured login, see http://opensuse.swerdna.org/susesambacifs.html#permsec
- I've recently had to include 'sec=ntlm' before 'guest' above in order to make the connection.  Without it, I was getting an input/output error.

Saturday, December 1, 2012

WAS 8.5

WAS 8.5 for Developers is 2.4 GIGABYTES installed on Ubuntu Linux. That's crazy! Tomcat is, what?, 50 MB.

Sunday, July 8, 2012

WebSphere and Logging

I've recently had some experience configuring WebSphere to use logging other than Jakarta Commons Logging (JCL) that is natively included in WAS.  I found a lot of blogs, forum posts, and tech write ups from IBM on the subject.  None were very satisfactory to me.  Therefore, I set out to find out how it worked.  I created an EAR with three different WARs in it.  Each WAR contained different types of logging that you might use in your application.

Environment
WAS 7.0.0.0 (it's actually WAS for Developers although that shouldn't matter)
Windows 7 64bit
Eclipse Java EE Indigo
Maven 2
Spring 3.0.0

Project Setup
was-logger
-> was-logger-ear
-> was-logger-jcl-war
-> was-logger-log4j-war
-> was-logger-slf4j-war (with log4j as the implementing logger)

I used the Maven project/module model to help build my resulting EAR file and dependency management.

was-logger-jcl-war
This WAR contains only the applicationContext.xml, web.xml, and Spring JARs.
I created a class called LogEvent.  The class is loaded by Spring as a bean and performs a simple loop to display 10 messages.  The point of the loop was to easily find those messages amongst others.


package org.foo.bar.jcl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LogEvent {

private static final Log log = LogFactory.getLog(LogEvent.class);

public void initialize() {

for (int i = 0; i < 10; i++) {
log.info("Testing commons logging #" + i);
}
}

}


The resulting log records will appear in the SystemOut.log file.  Like this:

[7/8/12 8:12:14:701 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #0
[7/8/12 8:12:14:701 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #1
[7/8/12 8:12:14:716 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #2
[7/8/12 8:12:14:716 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #3
[7/8/12 8:12:14:716 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #4
[7/8/12 8:12:14:716 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #5
[7/8/12 8:12:14:732 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #6
[7/8/12 8:12:14:732 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #7
[7/8/12 8:12:14:732 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #8
[7/8/12 8:12:14:732 CDT] 0000000a LogEvent      I org.foo.bar.jcl.LogEvent initialize Testing commons logging #9


If you have one application in the environment this might be ok. If you want to customize or use different and better loggers, then you'll want to read further.

was-logger-log4j-war
This WAR contains the log4j.xml, commons-logging.properties, applicationContext.xml, web.xml, log4j JAR, and Spring JARs.  I basically created this WAR with the same class, LogEvent, but backed it up with log4j Logger instead of the commons-logging Log class.


commons-logging.properties file contains some information to route commons logging over to log4j.  In other words, Spring uses JCL and the point of the properties file in my WAR is get Spring to use log4j instead.  However, it didn't work from a Spring perspective.  The messages from LogEvent were routed to the file specified in my appender.


2012-07-07 22:04:13,712 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #0
2012-07-07 22:04:13,715 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #1
2012-07-07 22:04:13,715 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #2
2012-07-07 22:04:13,715 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #3
2012-07-07 22:04:13,715 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #4
2012-07-07 22:04:13,715 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #5
2012-07-07 22:04:13,715 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #6
2012-07-07 22:04:13,715 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #7
2012-07-07 22:04:13,715 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #8
2012-07-07 22:04:13,715 [WebContainer : 3] INFO  (LogEvent)  - Testing log4j logging #9


So why didn't it work?  I'm not sure. I think one thing that happens is that Spring attaches to the JCL logger before it gets a chance to hook up with log4j.  There is a part of the ContextLoaderListener to load log4j.  There is also a defined listener to load you log4j configuration.  I haven't played with that, but I fear that it is only really going to apply to Spring.  What about other frameworks (like CXF) that use JCL as well?  Read on.

was-logger-slf4j-war
This WAR contains the log4j.xml, commons-logging.properties, applicationContext.xml, web.xml, log4j JAR, slf4j JARs and Spring JARs.  There is also another JAR that seems to be key, jcl-over-slf4j-1.6.6.jar.


When the slf4j logging facade is used on top of log4j, Spring and my application information are routed to the file defined in my log4j.xml file.

2012-07-07 22:04:14,143 [WebContainer : 3] INFO  (ContextLoader)  - Root WebApplicationContext: initialization started
2012-07-07 22:04:14,291 [WebContainer : 3] INFO  (XmlWebApplicationContext)  - Refreshing Root WebApplicationContext: startup date [Sat Jul 07 22:04:14 CDT 2012]; root of context hierarchy
2012-07-07 22:04:14,486 [WebContainer : 3] INFO  (XmlBeanDefinitionReader)  - Loading XML bean definitions from class path resource [applicationContext.xml]
2012-07-07 22:04:14,778 [WebContainer : 3] INFO  (DefaultListableBeanFactory)  - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@56c556c5: defining beans [logEvent]; root of factory hierarchy
2012-07-07 22:04:14,863 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #0
2012-07-07 22:04:14,863 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #1
2012-07-07 22:04:14,863 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #2
2012-07-07 22:04:14,864 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #3
2012-07-07 22:04:14,864 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #4
2012-07-07 22:04:14,864 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #5
2012-07-07 22:04:14,864 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #6
2012-07-07 22:04:14,864 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #7
2012-07-07 22:04:14,864 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #8
2012-07-07 22:04:14,864 [WebContainer : 3] INFO  (LogEvent)  - Testing slf4j logging #9
2012-07-07 22:04:14,886 [WebContainer : 3] INFO  (ContextLoader)  - Root WebApplicationContext: initialization completed in 740 ms


Conclusions
I like my logging configurable outside of the WAS Admin Console.  In most production environments, you're not going to have any kind of permissions to change items in the Admin Console.  Then you would have to engage someone in a support area who does have access and they might not be as up to date on your application and what your request is.  Log4j and slf4j give you greater flexibility in defining your logging solution.  I like the slf4js ability to route any framework over to the log4j configuration.

Appendix - Class Loading
This discussion wouldn't be complete with some mention of class loading.  A lot of posts I saw mentioned that setting the class loader to PARENT_LAST,  I have done that for another application for the purposes of CXF, but for this test application, I did not.  Therefore, you can get different logging without changing the classloading order.

I've posted the code at the following link. was-logger

Wednesday, July 4, 2012

DSL

I've been an AT&T DSL customer since 2001. At that time it was with SBC in the Kansas City area. I have a @swbell.net email address to this day. When it was initially rolled out it was $49.95 1 year contact for 1.5 Mbps down. Over time that price went down. I think it took 3 years to get a price break.

Now, it's $43 for existing customers on 6 Mbps no contract. They've raised the price the past couple of year's a dollar here and two dollars there. The reason they give is the same. Something to do with keeping up with market conditions.

To be fair they do include WI-FI at Starbucks, McDonald's, etc for when you use a laptop. For me though that doesn't happen often enough to pay for it included in the $43. Further, you can't separate the two  features.  I suppose that's because most people would separate the two and no one would pay for it.  Then they'd have to drop the feature.

I'm leaving you, AT&T, for Comcast.  I can't ignore the short term deals and the chance to compete for my business with deal negotiation.  I found a two-year contract @ $39.99 for the first 12 months and $56.99 for the second 12 months for phone and internet.  In the end, with taxes, I'll still end up paying less for faster internet (max 20 Mbps!) and the same phone features.  Install is on 7/10.  My wife has put me in charge of this task to switch over.  Which means that not only do I have to monitor the install and make sure everything works just as it does currently, I'll also be the complaint department when it doesn't work right.

Monday, July 2, 2012

iPhone and Gmail

I use my iPhone to manage personal appointments much as one would use their corporate mail server to manage meetings.

My wife and I have Gmail accounts. Our phones are both set to use gmail as an Outlook Exchange server. What that extra distinction allows for is the ability to send and receive calendar entries and accept or deny them as you would within an outlook client on your computer.

When my wife has an appointment she invites me to it and it appears in my calendar after I accept it, for example.

The limitations are that 1) your mail server (e.g. Hotmail, Yahoo, etc) has to support Microsoft Exchange and 2) the scheduler has to know that ahead of time. It's works really well with my wife and I though.

Log4j dynamic log level changes

Recently, I've been working with a colleague on implementing a solution to use Spring JMS to pass messages to other JVMs in a clustered environment for the purpose of setting log4j logging levels to something else.  For example, by configuration file, I've got 'org.foo.bar' logger set to level INFO.  I've found that during some production issue I need to set 'org.foo.bar' to level DEBUG.  Without redeploying the application, I want to set that level for every JVM in my cluster.  I don't want to have to go to each JVM and set that level I want to go to one and let the application handle the rest.

We're using WebSphere 7.0 for z/OS and taking advantage of the included SIBUS. SIBUS is an all java implementation of MQ. I don't believe it is as robust as MQ, but for this purpose it is good enough.

This solution was chosen over others because it can all be implemented within our application except for the SIBUS configuration. We discussed using JMX, but found that we would have potential security limitations. Further we could switch out SIBUS for MQ if need be without application changes.

The solution includes a JSP page to display and set the different log levels for each logger defined. The page reads the loggers that are defined at runtime and code time. The server processes requests from the JSP and builds the message to be processed. A listener processes the message in each JVM to update the logger.

A challenge we ran across was that in WAS z/OS the messaging bus runs as a parallel task (adjunct) to the application  server (servant).  Those tasks start in parallel when a bounce of the server is performed.  We discussed with IBM the possibility of existing implementation to serialize those start ups such that the adjunct starts before the servant.  They didn't have that as a current implementation and suggested that we open an enhancement request.  The challenge is that Spring JMS is looking for the messaging bus to be active during startup.  If the messaging bus is not active, Spring JMS will try to refresh the connection at intervals that you set.  The key to all of this is that Spring JMS run in a separate thread than the thread that is used to start the application context.  If they run in the same thread and the messaging bus is not found on a bounce, the application will fail to start.  IBM recommended some code that is part of their documentation to search for the messaging bus and delay further processing until it is found.  The logic is WebSphere specific and we wanted to remain platform agnostic.

Follow the information in this developerWorks article to a tee and you should have no issues.

http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html

Credit to Srini Ivaturi for this solution. It was his design. I helped with the implementation.

Sunday, April 29, 2012

Server

So I recently converted my tower desktop from a multi-boot desktop to a server.  I found that with the numerous laptops in the house I never had want to sit in front of the stationary desktop.  First, it's in my unfinished basement.  It gets cold down there in the winter and it isn't well lit either.  Second,  I found that my laptops could do everything that the desktop could do.

I chose the Ubuntu Server 11.10 for my installation. I was familiar with Ubuntu desktop at home and I had used the server edition at work as well.  I've found that I couldn't have made a better choice.

I installed a few things to make the server interesting.

  • DNS.  I'm able to use www.halverson.net on my local network.  
  • MySQL.  I have a test Java app that I like to play with every now and again and the app is backed by MySQL.
  • SSH.  Remote management is the greatest.  I still don't have to sit down there and work with the computer.
  • Apache HTTP and Tomcat.  For running the aforementioned app.
  • World Community Grid.  The server runs 24x7 so I'm making good use of the CPU for a good cause.
The major challenge I had was setting up the DNS.  I think the directions on the Ubuntu server guide were clear, but only after I had it working.  Further, I found that I couldn't get my router to recognize a primary and secondary DNS without the secondary finding the www.halverson.net outside of the network.  I'm not sure why that is.

It seems if I've made use of a computer that is near end of life.  I'm glad I did too.

Thursday, April 12, 2012

LDAP

Today I dug into the world of LDAP.  It is a pretty interesting repository.  I played with a straight Java implementation first where the LDAP is fronting another security database, ACF2.  Yep, the mainframe.  Once I got that working and got a frame of reference on the workings of interface, I moved onto Spring LDAP.  Tomorrow, I'll be completing that coding.

Friday, March 30, 2012

Laptop, Geek Squad and Fun

So I got a new laptop. Well, new to me at least. The story is that my mother-in-law had bought this computer (really, the one I'm typing on now) a few years ago, 2009 I think, and by fall 2011 it wasn't working at all. So they took it to the Geek Squad and they said 'nothing we can do, needs a new hard drive'. Two months ago, she gave it to me for 'spare parts.' I didn't really know what happened to it so I fired it up. When it got to the Windows 7 'Starting Wnidows' screen, I knew it wasn't the hard drive. However, I did get a, dum dum dum duh, Blue Screen of Death. I haven't seen one yet on Windows 7, so I was shocked to see one now. The message was UNMOUNTABLE_BOOT_VOLUME. Fine, simple, reload the software. I actually found on the HP website the Recovery Disk for $15. Then the battery was shot so I order a new battery. Then something happened to the original charger and it was replaced with a generic Rocketfish adapter. Got a new adapter too. All told I spent $50.

So then I'm playing with the laptop and realized, damn, this is hot! Damn hot! Did some searches and found that since the fan intake is on the bottom of the laptop, and since folks tend to put a laptop on their lap (novel idea!) that the fan sucks in lint and what not from your clothes. So found some directions and disassembled the whole thing. I found that the fan had packed in some lint, hair, etc on the exhaust side of the fan. It was so thick it reminds me of dryer lint. Ya know how dense that is, right? Exactly. So I cleaned that out and now it's cool as a cucumber. I also upgraded the BIOS to current and flipped a switch in the BIOS to run the fan as needed rather than all the time. I deduced that the fan running all the time and the excessive heat probably killed the battery prematurely.

Anyway, when I got the disk from HP. I reloaded the software. Now I'm an Ubuntu fan, but I know full well that when you need to run some Windows program it's much better to have Windows installed than use Wine or equivalent. Unfortunately, HP does not have it in mind to make those Recovery Disks user configurable. So the disk I get re-imaged the hard drive back to factory. Then of course I get all of the junk programs with trials and useless software. In the end, deleted the junk software, and installed Ubuntu 11.10 alongside Windows.

Works like a charm, my computer does. And it was a lot of fun to work with.

Tuesday, March 27, 2012

The Floppy

I was thinking about the floppy this morning. At one time it was the only way to carry data from place to place. And now it is no longer useful. Sure you might be able to store one Word doc on it. With the megapixels were into now with pictures and the lossless quality music files, the floppy just doesn't cut it.

I recall my first floppy drives. Back in the day, I had a Tandy 1000 with two floppy drives. Both were of the 5.25" variety. I remember, also, that those floppy drives were the only way to get use of the computer. No hard drive!

Then we got the 3.5" floppy. 200 more KB and even more portable. I still have a 3.5" floppy in my desktop. I'm not thinking that I'll ever really be able to use it. I'm just too lazy to take it out.

Monday, March 26, 2012

Tech at my house

Currently I have the following tech:

3 HP laptops (2 in use)
1 home built desktop
iPad
2 iPhones
Wii
Play station 3
1 TB network drive

I'll comment on them all in future posts.

Sunday, March 25, 2012

Windows XP

It's dead at my house. How about yours?

I would say that XP helped more people get connected than any other OS at its time. I recall buying the full version in 2002 and installing on my first home built computer. At the time, of course, the OS was much faster than its predecessors and better looking as well. I will say that I won't miss BSOD though.

Bye XP.

First blog

Well never had a blog before so I thought I'd give one a whirl.