Monday, August 20, 2012

Debugging an SLF4J error, mvn dependency:tree to the rescue

As a Java developer, I frequently add additional dependencies to maven as new features are being built.  Sometimes you don't know what will break your build, but here's my "stack trace", as I worked through solving an error from:

 peterdietz:dspace-3.0-SNAPSHOT-build peterdietz$ /dspace/bin/dspace dsrun  
 Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V  
      at org.dspace.servicemanager.spring.SpringServiceManager.startup(  
      at org.dspace.servicemanager.DSpaceServiceManager.startup(  
      at org.dspace.servicemanager.DSpaceKernelImpl.start(  

Basically the error above means that you've got two different (incompatible versions of slf4j present 1.6 and 1.5). If your build output has a lib/ directory, check that for jars that have slf4j in their name. If you've got two different versions, thats your problem. Your quick fix would be to delete one of the versions (most likely 1.6).

However, to actually fix your problem, you've got to stop Maven from including two different versions of SLF4J. You can "Find in Path" from your IDE to see if you are manually including two different versions of SLF4J, but thats likely not the case, you'll need to look at Maven's dependency tree to see what has snuck both versions into your build.

mvn dependency:tree

Maven Dependency Tree will process all of your imports, all dependency entries in your pom.xml files, and recursively give you a tree output that will show which parent project includes which sub-project, which includes some feature, which includes which JAR. In my case, I was hunting down jcl-over-slf4j-1.6.1.jar. And looking through the output of mvn dependency:tree, I found it.

[INFO] +- org.dspace:dspace-stats:jar:3.0-SNAPSHOT:compile
[INFO] |  +- org.apache.solr:solr-solrj:jar:3.5.0:compile
[INFO] |  |  +- org.codehaus.woodstox:wstx-asl:jar:3.2.7:runtime
[INFO] |  |  \- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile

To solve it, I found my pom.xml for the dspace-stats project. And specifically, the import for solr-solrj


This will include solr-solrj, and all of its neccessary dependencies, and according to the dependency:tree, this is where slf4j has snuck through. So, we need to exclude slf4j from coming through, luckily maven lets us do exactly that. So, add the <exclusions> block below to this <dependency>, and you should be able to rebuild, and be all set. 

Good Luck!

Friday, July 20, 2012

How to Easily Delete EVERYTHING in iCal

I've had some issues with OSX iCal, where the sync with work's Exchange server got interrupted when I changed my password, I then added some events to iCal, noticed syncing wasn't working, created the event again directly in Exchange using Outlook, and then realized that I had to edit iCal's settings to change the exchange password to resume syncing. This caused mysterious sync problems with iCal, and it would run into issues of event conflicts, and would take turns going online, offline, and then sending email notifications to co-workers that I'd accepted or declined their event. After about the third time it went online, offline, online and resend email notifications, I've decided thats enough, and would like to start fresh with iCal. However, Apple has "The Apple Way" of deleting all events, and all everything from iCal, and it makes no sense to me. Thus, I have to create a posting on:

How to Easily Delete EVERYTHING in iCal

So you can perhaps re-enable sync with your server.

Step 1 - Remove Server Sync Accounts

You don't want to delete any events that are safely stored on the server. So go to iCal -- Preferences -- Accounts, and then delete your server account (Exchange in my case).

Step 2 - Realize that there's no Delete All button in the iCal preferences or anywhere, and start Googling for advice, and hopefully arrive here at this blog post.

Go to:

Step 3 - Go to the Calendars button, create a new Calendar, and delete your existing Calendar.

After your server account is deleted, the Calendars button should have a default Calendar called "No Category". You can't delete that if thats the only calendar that exists, so create a new calendar, by Right Clicking, and adding a new calendar.

After the new calendar is created (I called it Temporary), you can delete the old calendar that has the offline / synced events that you wish to delete. To delete your old / cached information, right click on "No Category" and select Delete.

And accept the confirmation to actually delete everything. 

Warning: If that was your Calendar that had all your information, it will delete it. Please ensure that you've followed the above advice before clicking Delete (for reals), that you've removed your sync connection to any of your server based calendar systems (such as Exchange), so that you don't actually delete your Calendar events that you perhaps share with your colleagues.

Wednesday, March 07, 2012

On The Desktop, Changing from Linux to OSX

I wanted to make an immediate, I switched to OSX blog post, but I didn't want the takeaway to be too temporal.

After using OSX full-time for atleast the past month as my primary desktop, I've gotten to know what I like and don't like about the switch. Hopefully some desktop developer stumbles upon this an implements the improvements, otherwise kudos to those who've built the good parts.

What I immediately and still desperately miss after having left Linux (primary distribution is Ubuntu), is that OSX does not have a tier one blessed software repository. I can't explain how nice it is to be able to install all of your software through something like: apt-get install package-name. I don't want to install git by going to their website, downloading a disk-image, and launching an installer. I believe that a package manager is mandatory for an OS. I guess the App Store attempts to approximate this, but its so far from impressive. When you launch the App Store, then search bar isn't selected by default, and the App Store should work from the terminal as well. How about:

sudo app-store install photoshop

Now, what I really really like about OSX, is how stable it is. Apps don't crash, and if they do, I'm very surprised. So much so, that you almost feel compelled to complain about it to the developer (which as an ecosystem, probably helps to fix bugs). On Ubuntu (especially the post-10.10 era), apps and core services crashing is so common that I disabled feedback reporting because even that too would crash, and cause more popup windows to report bugs.

I also like how easy most of the system is to manage. Top left-corner Apple Icon with all the bells, knobs, and whistles are easy to click and change most things. Very excellent. Command Space to launch Spotlight so I can easily search to find apps, and all the results show up nicely grouped, with the one I'm most likely to click on being the top hit, and hitting Enter then launches that, ohh yes!!

I don't know if there are patents protecting those works-really-well parts, but its just behavior. If I were Desktop Linux, I would copy that verbatim, and frame a picture of the designer at Apple who created it. I might even buy him a beer, a Trappist Ale, or perhaps even a Framboise.

Another big win in OSX, is how well the gestures work. All Apps should allow for back-button support with a simple swipe. Also, the hardware is nice. I really like the keyboard (I have the wider keyboard with  Home / End and delete buttons, which is great since I hit those buttons all day long)

That said, theres still plenty of unexpected, un-intuition in OSX.
How does one always show hidden files and folders in Finder?
- (Edit a system variable in terminal, or get An-app-for-that).

How does one browse their filesystem, when all Finder is doing is showing me a coverflow of all of my images?
- (Hit Command UP, until you get to your /Users/myusername directory)
I would prefer having a location bar at the top, so I can atleast type in the directory path that I'd like to be at. I kind of see how "The End User" would like meta-displays the abstract folders, and just show them their music, pictures, and documents, but I'd like to opt-out of that.

How does one open an application that updated itself when it shut-down?
- (You can't use the Spotlight quick find, because it now has the translucent crossed-out circle around its launcher. So you have to open the Application's list, and click it and allow the "From the Internet" app to run yet again. Even if the update caused this app to be "From the Internet", it still should have showed up in Spotlight. You can keep the crossed-out-circle icon to show its currently disabled, but Spotlight needs to always work.)

How do I get my Home key to go to the first character on a line, and End to the last character on a line, as opposed to first character on page, and last character on page?
- (There an app for that. There built-in configuration doesn't allow remapping...)

How does one see all the messages in a email thread in from the sender and all others in the thread, and my response inline as well? You know, I'd like to see all my responses to a client within the email thread...
- (Command click to select Inbox, and Sent ?? really?!?. I guess that would follow the Apple design guide, but I would say that Gmail has quickly claimed the title for best email interface, especially with its immensely fantastic threading. In that case, the Gmail way trumps Apple standards, and awesome-threading should be the default view.)

In the end, I'm happy on OSX, its a very solid Desktop Interface that "just works", so I can be productive. I suppose some of this rant is just someone coming in from outside-of-Mac, and they're "used to the old way", but its a case where I'm convinced that certain conventions are just better.  I'm not sure you could measure it up precisely to say that this action that I do 47 times a day is 0.32 seconds faster on OSX thus gaining me x hours a year in productivity to justify the higher cost. But its very much like a nice car, nice bicycle, or even a nice wheelbarrow, and it does what you'd expect it to very well. So much so that its now my preferred tool.