Friday, 22 July 2011

I hate HP QC (Quality Centre).

Holy f*. HP QC (Quality Centre) is such a piece of shit. One of our QA
teams is on QC 9.2, so I don't know if this has been fixed in more
recent versions.

So I wanted to update a bug today and had to go through this.

1. Wait for IE to re-download CAB files and got error message about
not being able to download and "Close all connections to server and
try again"

2. Restart IE.

3. Log into QC and open bug.

4. Update Status to "Ready to Test" and reassign to the tester. Tried
to type in Comment area after clicking "Add Comment" but I can't seem
to type in it!

5. Close dialog box, reopen bug and try again. Still not displaying what I type.

6. Looks like the text box for comments in the dialog box doesn't
work. But if you just view the listing of all bugs, and select the bug
you want, you can click on "Add a Comment" on the lower right box and
it accepts text input.

Our company has started using JIRA, but it looks like all the testers
will remain on QC. And there doesn't seem to be a way for QC and JIRA
to communicate both ways. QC can probably create a corresponding bug
in JIRA, but JIRA isn't able to go and update the same test in QC.

Ah, enterprise-y crap.

Friday, 3 June 2011

Hey Google: No love for Opera?

"As of August 1st, we will discontinue support for the following
browsers and their predecessors: Firefox 3.5, Internet Explorer 7, and
Safari 3."

http://gmailblog.blogspot.com/2011/06/our-plans-to-support-modern-browsers.html

"So if it's been a a while since your last update, we encourage you to
get the latest version of your favorite browser. There are many to
choose from:
• Chrome
• Firefox
• Internet Explorer
• Safari
"

I felt a teeny tiny disturbance in the Force... as if all 50 Opera
users suddenly cried out in terror at their favourite browser once
again being ignored and they can't shut up about it.

Randoms adding you on LinkedIn

You gotta wonder - "Bosnia and Herzegovina -
Transportation/Trucking/Railroad" - why would you even think of adding
me as a Friend?

How to export iPhone geolocation data

How to export iphone geolocation data so you can play around with the
data. I tried using some python scripts but they didn't work. Once I
exported the data, tried to use sqlite but the Firefox plugin is
really the best way to deal with sqlite.

* Get iPhone backup extractor from http://supercrazyawesome.com/

* Run backup and export your iOS Files - I had 2 backups and the older
backup was the one with all the geolocation data.

* Using Firefox, install the SQLite Manager plugin. Using this
plugin, open the file /iOS
Files/Library/Caches/locationd/consolidated.db

* Export the data - you can export as CSV, SQL, or XML


Now do an update of iphone to iOS 4.3.3 so it doesn't keep your retain
data anymore! (not too long anyway. they might keep it for a week,
apparently)

Wednesday, 18 May 2011

JSTL not working? Check that you have the correct servlet version in web.xml!!!

This is a pretty silly gotcha, but this normally wouldn't have
happened since most of the time I'm working on updates to existing
deployed webapps running on Tomcat 6.

Anyway, this sucked up about 1 hour of my life, trying to find out why
my JSP 2.0 style tags weren't working. Even things as basic as c:out
weren't working either.

Finally stumbled upon a forum post that pointed to this.

http://www.coderanch.com/how-to/java/ServletsWebXml

Aha!! The webapp I'd created using the Maven archetype
maven-archetype-webapp has Servlet 2.3 declared in it's web.xml. A
version that is pretty bloody old, considering the ref implementation
for that is Tomcat 4! Seriously, an upgrade for the built-in web.xml
wouldn't be that hard to do, Maven plugin people!

Anyway, all's well.

For now.

Wednesday, 23 March 2011

Coding WTF: Throw an exception to trace callers of a method

I found an interesting bit of code at work:


try { // This will allow us to debug future cache reloads
throw new Exception("Issuer Security Cache was Reloaded");
} // Stack Trace gives context to see where it was initiated from
catch(Exception e) {
log.debug(e, e);
}

It was a bit of a WTF, and it probably still is from a performance
point of view, but I can see why they did this.

I guess this was written before they had IDEs that could find out the
callers for a particular method. But couldn't they have just done
that anyway by grepping through the code base? Oh, right, inheritance
4 levels deep can leave you unable to find out which actual class
you're looking at.

Tuesday, 22 February 2011

Gravity

Gravity 
Translator

In your life there's someone waiting,
lost on streets that no one travels
In my dream I see this meeting,
we're a knot that fate unravels

But beyond our shameless sorrow,
catch me if I'm with the wind
We may be the sky tomorrow,
we're a branch that will not bend

The world is spinning through my head
Your gravity won't let me go,
You're holding me together,
No one ever has to know

I'm a dream and you're fading away, 
I'm a dream and you're fading away 

In your face there's someone sleeping,
lost in years that no one's counting
The only way to hear the weeping,
suffering is like a fountain

Everything is far away now,
held beyond our nameless sorrow
Shifting streets that no one wanders,
lose the days, we only borrow



Thursday, 13 January 2011

Coding WTF of the Week

I think I'll start a new segment for this blog, ala - DailyWTF.. hey,
I should submit this...

Task: Get a list of all securities that have prices.

Instead of doing a join between two tables (SECURITY, SECURITY_PRICE),
the developer did this

1. Get all securities.
2. Get all security prices.
3. Loop through all the securities.
4. Inside that loop, loop through all the prices.
5. Where price.securityId = security.id, put them into the container class

Not too big a deal on dev database, but problematic on UAT database
which had 7000 securities and 1000 security prices.

Removing this code and replacing it with code that used a join,
brought down a method call from 50 seconds to 2 seconds.

Friday, 17 December 2010

JBoss stops with "Listening for transport dt_socket at address: 8787" message - change your debug startup settings

Hopefully someone out there finds this helpful.
I was trying to start Jboss in debug mode, so I went into
{JBOSS]/bin/run.bat and uncommented this:
rem JPDA options. Uncomment and modify as appropriate to enable remote
debugging.
set JAVA_OPTS=%JAVA_OPTS% -Xdebug
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y

I then started up JBoss manually and on the screen it seemed to hang
at this message:
Listening for transport dt_socket at address: 8787

I had a look at the debug settings that IntelliJ recommends to use in
"Run -> Edit Configurations" and noticed that it was slightly
different:
-Xdebug -Xrunjdwp:transport=dt_socket,address=3599,suspend=n,server=y
notice the difference, aside from the port?? "suspend" has a value of
"n" instead of "y".
Turns out that "suspend=y" means it will not run until a debugger
attaches itself to the process. In most cases, you will probably want
to use "suspend=n" instead. I think "suspend=y" is mainly useful if
you're trying to track down things that occur on startup of the
webapp. If the part you're interested in will only happen after a user
action, it's best to use "suspend=n".

Useful reference:
http://download.oracle.com/javase/1.5.0/docs/guide/jpda/conninv.html

Thursday, 16 December 2010

Maven: "mvn archetype:generate" gives you 358 archetypes to choose from - too much of a good thing??

Just typed

maven archetype:generate

and I get a long long long list that goes up to...


349: remote -> nexus-plugin-archetype (-)
350: remote -> spring-osgi-bundle-archetype (Spring OSGi Maven2 Archetype)
351: remote -> spring-ws-archetype (Spring Web Services Maven2 Archetype.)
352: remote -> trails-archetype (-)
353: remote -> trails-secure-archetype (-)
354: remote -> tynamo-archetype (-)
355: remote -> wicket-scala-archetype (Basic setup for a project that
combines Scala and Wicket,
depending on the Wicket-Scala project. Includes an example Specs
test.)
356: remote -> wikbook.archetype (-)
357: remote -> circumflex-archetype (-)
358: remote -> javg-minimal-archetype (-)
Choose a number: 97:


358 archetypes??? At least it means a lot of projects have adopted
maven. But how usable is this?

Shouldn't we have something like a menu instead?

Thursday, 21 October 2010

GTKPod troubles in Fedora 11

NOTE: this happened a while ago, but I never solved this problem. I
ended up using another program, I think.

=======================

Just when I thought Fedora was good enough for normal use, (Fedora 11)
here comes a use case to stop me in my tracks.

Plugged in the iPod. Got mounted as a HD.

Ran GTKPod. No iPod recognised. Hmm... how to make it recognise the
iPod. See Help..

"...if the iPod cannot be mounted then gtkpod is NOT going to do it
for you! Thus, before firing up gtkpod make sure you can see the
filesystem of your iPod at its desginated mount point, eg. /mnt/ipod."

Ruh roh. Warning Warning.

"The result of this is that the ipod will be located on a device node
and this can be mounted manually using the command (performed as
root):

mount /dev/sdc2 /mnt/ipod"

Tried running it:

sudo mount /dev/sdc2 /mnt/ipod
mount: mount point /mnt/ipod does not exist

FEK.

FARK.

FUUUUUCK.

What the hell do I do now?

Google it, google it.

Create the mount manually using:

sudo mkdir /mnt/ipod

Okay! Seems to have mounted it.

ls -l /mnt/ipod/
total 2295312
(SNIP)

Back to GTKPod. Seems to have found my model #
xA003 - 60Gb, Video, 1st Gen

Ruh roh.

"Warning: Extended info will not be used"

Seems to be doing something. Hashing all my tracks. WTF? Do you need
to do this now?? I just want you to list them all.

Hmm.. "Duplicate detection. The following 3 duplicate tracks have been
removed."

What? "'Malcolm Gladwell Outliers 02': identical to 'Malcom Gladwell
Outliers 01'"

Okay, seems to have finished.

Now I want to get all the tracks by "2 Many DJs" onto my computer.
Should be easy right? In Sharepod, I just type in the search term, it
finds them, I select all of them then export.

But here, it has 3 panes, 2 of them for sorting and sub-sorting. I
select Artist "2 Many DJs", then "All" in 2nd tab. Then I get a dialog
box:

"Export selected entry of which sort tab"

And a select box has "1 and 2". Is it so hard to recognise which tabs
are selected and present the names in the select box instead of just 1
and 2?

Click OK.

"Filename format" field is just waay too confusing. A bit of polish
and simpler tooltips here would be good. I wonder if this thing will
work.

Click OK.

WTF is going on?? "Overwriting external media" - how come the
filenames are all ending in "..mp3"?? What the hell??

Fucking bullshit, now its hanging. No display update. No nothing. I
don't know WTF is going on!

SHIT. Linux FAIL yet again. Okay, Linux APP FAIL, to be accurate.

SHIT SHIT SHIT.

I hope killing the GTKPod process doesnt fuck up my iPod.

Okay, tried again. It didn't like having %o as the first format when
it said it didn't have Extended info

%a/%A/%T - %a - %t.m4a;%a/%A/%T - %a - %t.mp3;%a/%A/%T - %t.wav

works now.

Or so i thought.

Still nothing on the HD!

SHIT.

Monday, 9 August 2010

Unable to run Vignette Portal on JDK6 - error: " java.lang.NoSuchMethodError: javax.xml.bind.annotation.XmlAccessorType.value()Ljavax/xml/bind/annotation/AccessType;"

PROBLEM:

I was running Vignette Portal Application Server on tomcat 6, using
JDK5u21, and decided to start using JDK6u20. The Portal wouldn't start
and was getting this error:


Jul 14, 2010 10:57:01 AM org.apache.catalina.core.ApplicationContext log
SEVERE: com.vignette.portal.website.internal.StartupProtectionFilter:
system startup failure detected, unable to process request.
javax.naming.NamingException: Could not initialize instance of
com.vignette.portal.portlet.management.internal.PortletManagementSystem
as an error occured during invocation. [Root exception is java.
lang.NoSuchMethodError:
javax.xml.bind.annotation.XmlAccessorType.value()Ljavax/xml/bind/annotation/AccessType;]
at com.vignette.portal.naming.internal.portal.LocalLookup.create(LocalLookup.java:130)
at com.vignette.portal.naming.internal.portal.SingletonLocalLookup.<init>(SingletonLocalLookup.java:31)
at com.vignette.portal.naming.internal.portal.ServiceLifecycleManager.loadService(ServiceLifecycleManager.java:220)
at com.vignette.portal.naming.internal.portal.ServiceLifecycleManager.initializeServiceSet(ServiceLifecycleManager.java:168)
at com.vignette.portal.naming.internal.portal.ServiceLifecycleManager.lookup(ServiceLifecycleManager.java:142)
at com.vignette.portal.naming.internal.portal.PortalInitialContextSPIImpl.lookup(PortalInitialContextSPIImpl.java:44)
at com.vignette.portal.naming.PortalInitialContext.lookup(PortalInitialContext.java:86)
at com.epicentric.system.SystemManager$StartupThread.run(SystemManager.java:240)
Caused by: java.lang.NoSuchMethodError:
javax.xml.bind.annotation.XmlAccessorType.value()Ljavax/xml/bind/annotation/AccessType;
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getAccessType(ClassInfoImpl.java:339)
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getProperties(ClassInfoImpl.java:228)
at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.getProperties(RuntimeClassInfoImpl.java:87)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:127)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:49)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:41)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:189)
at com.sun.xml.bind.v2.model.impl.RegistryInfoImpl.<init>(RegistryInfoImpl.java:51)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.addRegistry(ModelBuilder.java:232)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:201)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:327)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:198)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:128)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:277)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)
at com.vignette.portal.portlet.jsrcontainer.internal.standardcontainer.management.PortletApplicationFactory.buildPortletApplication(PortletApplicationFactory.java:153)
at com.vignette.portal.portlet.jsrcontainer.internal.standardcontainer.management.PortletApplicationManager.addApplication(PortletApplicationManager.java:154)
at com.vignette.portal.portlet.jsrcontainer.internal.standardcontainer.management.PortletApplicationManager.access$000(PortletApplicationManager.java:46)
at com.vignette.portal.portlet.jsrcontainer.internal.standardcontainer.management.PortletApplicationManager$PortalAgentImpl.portletApplicationStarted(PortletApplicationManager.java:315)
at com.vignette.portal.portlet.jsrcontainer.internal.registry.PortletApplicationRegistry.registerPortal(PortletApplicationRegistry.java:118)
at com.vignette.portal.portlet.jsrcontainer.internal.standardcontainer.management.PortletApplicationManager.init(PortletApplicationManager.java:77)
at com.vignette.portal.portlet.jsrcontainer.internal.standardcontainer.PortletContainerImpl.init(PortletContainerImpl.java:44)
at com.vignette.portal.portlet.management.internal.implementation.provider.jsr.deployment.JsrPortletApplicationDeployer.<init>(JsrPortletApplicationDeployer.java:37)
at com.vignette.portal.portlet.management.internal.implementation.provider.jsr.deployment.JsrPortletApplicationDeployer.getInstance(JsrPortletApplicationDeployer.java:31)
at com.vignette.portal.portlet.management.internal.implementation.provider.jsr.JsrPortletApplicationManagerSpiImpl.initialize(JsrPortletApplicationManagerSpiImpl.java:88)
at com.vignette.portal.portlet.management.internal.PortletManagementSystem.init(PortletManagementSystem.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)


Googling around, I found this:

http://forums.sun.com/thread.jspa?threadID=5320481

"The actual problem is that jaxb classes like AccessType etc were
renamed to XmlAccessType in the latest jaxb-release. SunOne happens to
use these classes and consequently fails because those classes will
not be available. For the issue to be resolved, place old jaxb related
jars in SunInstallDir\AppServer\lib\endorsed and restart."

"I was facing similar problems with Tomcat.....when I was trying to
install VAP 7.4 on tomcat. What I have done to solve the problem is
copied jaxb-api.jar from
Tomcat-install-directory/webapps/portal/WEB-INF/lib to
Tomcat/common/endorsed.........restart and you are done."


Aargh. Too difficult. Back to JDK 5. :(

Tuesday, 13 July 2010

Rejuvenating rechargable batteries using MH-C204W charger

I bought a Maha MH-C204W charger and one of its big selling points for me is the ability to rejuvenate rechargable batteries that haven't been used in a while. A common problem with rechargeable batteries is that they don't seem to hold enough of a charge if they don't get used frequently. If you Google on "Maha MH-C204W", you'll see it has quite a good reputation with getting these batteries to be quite useable again.

However, when I first started using the charger I was getting behaviour that was not really as described in the 1-page 'manual' for the unit. I put in these 6-yr old Sanyo 2300 Ni-MH batteries to see if they could be made usable again. What follows are my emails to Maha, and the quite helpful responses I got. Hopefully this will be of use to someone experiencing the same issues.

I've reversed the contents of the email thread, so we can start at the beginnning. =)

=========================================

> -----Original Message-----
> Sent 7/5/2010 5:30:45 AM
> To: xxxxxxxxxxxxx@mahaenergy.com
> Subject: Maha/PowerEx Tech Support Request
>
> I have a MH-C204W charger, and just inserted 4 AA batteries to recharge.
> On the lower end there are 2 lights, and after charging for 2 hours, only
> the right one is green. The indicator on the left is not lit at all. The
> manual states "Note the two indicators may not turn green at the same time
> due to minor difference in battery status in each bank." What is the
> expected behaviour of the unit? Is each light supposed to be lit as you
> put the batteries into each half of the unit? (red at first, then green
> after charging)
>
>

=========================================

On Tue, Jul 6, 2010 at 3:50 AM, XXXXXXXXXX (MAHA ENERGY COI)
wrote:
> Hi XXXXXXXXXX,
>
>
> Thank you for contacting Maha. Here is a brief explanation to what each of
> the four LED lights mean:
>
> 1.Solid red (Charging)
> 2.Green (Charging complete)
> 3.Flashing red (Battery fault)
> 4.No light (Battery or charger fault)
>
> To determine whether the charger or the batteries are defective, please
> insert a pair of known "good" battery inside the slot in question. The LED
> should light up as solid red if the slot is working properly. If it gives
> you no signal/light, please provide me with your shipping address so I can
> have this defective unit replaced for you. Thank you and I look forward to
> hearing from you.
>
>
> Regards,
>
>
> xxxxxxxxxx

=========================================

-----Original Message-----

Sent: Friday, July 09, 2010 3:39 AM
To: xxxxxxxxx(MAHA ENERGY COI)
Subject: Re: Maha/PowerEx Tech Support Request

Hi XXXX,

It looks like some of my old batteries are at fault. I've inserted 2
sets of recent NiMh batteries and they are charging as expected with
the lights first showing as red for both pairs, and then green.

However, I'm trying to rejuvenate them so following the instructions,
I've charged them til both lights were green, then took them out to
cool down, then put them back and pressed the button between the
lights.

The instructions say the lights should then flash yellow. Now in some
cases what I'm seeing is that only one of the lights will flash yellow
and the other one remains green. What does this mean?

thanks,

xxxxxxxxxxx

=========================================

From MAHA:

Thank you for the follow-up. To condition both set of batteries, first place two batteries in the middle while leaving the two outer slots empty. After both of the batteries has been firmly secured, place the other two batteries in the two outer slots. Press and hold the conditioning button until you see both LED lights flashes yellow.


Regards,

xxxxxxxxxxx

=========================================

Monday, 12 July 2010

Fun with portlets - Vignette Error: "The provided content type, application/octet-stream, is not a valid response content type." (FIXED)

PROBLEM:

I had a portlet (written using Spring MVC) where I had to download a
CSV file, so in the code, I was making this call

response.setContentType("application/vnd.ms-excel");

But I kept getting the error below from Vignette.

===============================

General Error

The provided content type, application/octet-stream, is not a valid
response content type. Please check the valid response content types
by invoking PortletRequest.getResponseContentTypes().

Please contact your System Administrator for assistance.

class java.lang.IllegalArgumentException

================================

I tried using "text/csv" and "application/octet-stream" and same response.

SOLUTION:

This was caused by a missing config in portlet.xml

The portlet I was working on had this config:

<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>

and to fix the above error, I had to add this:

<supports>
<mime-type>application/vnd.ms-excel</mime-type>
<portlet-mode>view</portlet-mode>
</supports>

Friday, 18 June 2010

"java.lang.IllegalArgumentException: unknown format type at" when using 'format' in displaytag ()

I spent about an hour stuck on this problem, so hopefully this it
helps someone avoid that. =)

We've started using the displaytag library on our JSP pages, and I was
moving a table to use this, and it makes the page much more concise
and readable, but I was getting an error when I started using the
format attribute in <display:column>

MY ORIGINAL CODE WAS:

<display:column property="expiryDate" title="Expiry Date"
format="{0,expiryDate,dd/MM/yyyy}" group="2" sortable="true"
headerClass="sortable" />
<display:column property="endDate" title="End Date"
format="{0,endDate,dd/MM/yyyy}" group="3" sortable="true"
headerClass="sortable" />

GETTING ERROR:

Caused by: java.lang.IllegalArgumentException: unknown format type at
at java.text.MessageFormat.makeFormat(MessageFormat.java:1433)
at java.text.MessageFormat.applyPattern(MessageFormat.java:450)
at java.text.MessageFormat.<init>(MessageFormat.java:368)
at org.displaytag.decorator.MessageFormatColumnDecorator.<init>(MessageFormatColumnDecorator.java:52)
at org.displaytag.tags.ColumnTag.addHeaderToTable(ColumnTag.java:722)
at org.displaytag.tags.ColumnTag.doEndTag(ColumnTag.java:622)

At first I thought it was something related to the Locale that I had,
that maybe the JDK was defaulting to US Locale and maybe I should be
setting it to Australia. But I realised this wasn't the case because
the example war file with example-format.jsp had exactly this date
format and it didn't set the locale at all and was displaying fine on
my Tomcat instance.

Started playing around with the date itself then changed it to "date"
instead of the name of the property and it worked!!

SHOULD BE:

<display:column property="expiryDate" title="Expiry Date"
format="{0,date,dd/MM/yyyy}" group="2" sortable="true"
headerClass="sortable" />
<display:column property="endDate" title="End Date"
format="{0,date,dd/MM/yyyy}" group="3" sortable="true"
headerClass="sortable" />

THE LESSON:

When using "format" atribute in <display:column> of displaytag,
remember: "date" should *always* be used, since in the format
attribute it is a hardcoded value, not something to match to the
property name.

NOTE: Googling the above error message reveals it's actually a JDK
bug, as the error message should be reporting the POSITION of the
unknown format type, but at the moment MessageFormat class just has
this:

default:
maxOffset = oldMaxOffset;
throw new IllegalArgumentException("unknown format type at ");

See: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6481179

Saturday, 8 May 2010

Spring error message - "can't parse argument number"

PROBLEM:
The story:
I want to display an error message that contains two dates which are derived from the exception returned by a remote web service that I'm calling from the webapp.

I'm almost there, since this error seems to relate to the display of the message, and the log also shows lines where it is going wrong in the JSP (the one with "form:errors")

2010-05-08 15:28:21,237 DEBUG
[org.springframework.context.support.ResourceBundleMessageSource] -
<Creating MessageFormat for pattern [New bulletin cannot be created
until conflicting bulletins from {} to {} are recalled.] and locale 'en'>
2010-05-08 15:28:21,362 ERROR
[org.springframework.web.servlet.tags.form.ErrorsTag] - <can't parse
argument number >
java.lang.IllegalArgumentException: can't parse argument number
       at java.text.MessageFormat.makeFormat(MessageFormat.java:1330)
       at java.text.MessageFormat.applyPattern(MessageFormat.java:450)
       at java.text.MessageFormat.<init>(MessageFormat.java:368)
       at org.springframework.context.support.MessageSourceSupport.createMessageFormat(MessageSourceSupport.java:118)
       at org.springframework.context.support.ResourceBundleMessageSource.getMessageFormat(ResourceBundleMessageSource.java:277)
       at org.springframework.context.support.ResourceBundleMessageSource.resolveCode(ResourceBundleMessageSource.java:184)
       at org.springframework.context.support.AbstractMessageSource.getMessageInternal(AbstractMessageSource.java:205)

SOLUTION:
The error is occurring because the error message I'm using from messages.properties is:
admin.bulletin.previousBulletin.notRecalled = New bulletin cannot be created until conflicting bulletins from {} to {} are recalled.

when it should be:
admin.bulletin.previousBulletin.notRecalled = New bulletin cannot be created until conflicting bulletins from {0} to {1} are recalled.

Error in webapp - javax/xml/soap/Detail violates loader constraints

added this to my pom.xml

<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3</version>
</dependency>

because i could not get the SOAPFaultException.Detail value

and got this when exception was being handled

2010-05-08 16:22:41,039 ERROR
[org.springframework.web.portlet.DispatcherPortlet] - <Could not
complete request>
javax.portlet.PortletException: Error occured during request
processing: Class javax/xml/soap/Detail violates loader constraints
at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:715)
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:480)
at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:462)
at com.vignette.portal.portlet.jsrcontainer.internal.standardcontainer.management.FilterChainImpl.doFilter(FilterChainImpl.java:204)
at com.vignette.portal.portlet.jsrcontainer.internal.standardcontainer.management.FilterManagerImpl.processFilter(FilterManagerImpl.java:67)
at com.vignette.portal.portlet.jsrcontainer.internal.standardcontainer.invocation.ProcessActionCommand.execute(ProcessActionCommand.java:62)
at com.vignette.portal.portlet.jsrcontainer.PortletCommandServlet.service(PortletCommandServlet.java:170)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


because I should have set dependency scope to "provided"

<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3</version>
<scope>provided</scope>
</dependency>

Friday, 7 May 2010

Exotic error message of the week (Spring transactions) - "Application exception overridden by commit exception"

The @Transactional annotation in Spring makes it easy to make things
uh, transactional, right? So why did I get this stackTrace when I
threw an expected exception?

The web service I was testing returned this response:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault xmlns:fault="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>fault:CO10001</faultcode>
<faultstring>An unknown error occurred</faultstring>
<faultactor>AdminService</faultactor>
<detail>
<java:string xmlns:java="java.io">Transaction rolled back
because it has been marked as rollback-only</java:string>
</detail>
</env:Fault>
</env:Body>
</env:Envelope>


And the log file contained this:


ERROR [Fri May 7 18:29:46 EST 2010:] [[ACTIVE] ExecuteThread: '0' for
queue: 'weblogic.kernel.Default (self-tuning)'] [string] [367]
org.springframework.transaction.interceptor.TransactionInterceptor :
Application exception overridden by commit exception
mycompany.exception.Exception: Bulletin cannot be created because
of active bulletins that were created between 28/04/2010 and
06/05/2010
at mycompany.domain.service.spring.SpringAdminDomainService.checkForExistingBulletins(SpringAdminDomainService.java:441)
at mycompany.domain.service.spring.SpringAdminDomainService.createBulletin(SpringAdminDomainService.java:384)
at mycompany.domain.service.spring.SpringAdminDomainService.manageBulletin(SpringAdminDomainService.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy391.manageBulletin(Unknown Source)
at mycompany.application.facade.spring.SpringAdminFacade.manageBulletin(SpringAdminFacade.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy392.manageBulletin(Unknown Source)
at mycompany.package.service.ws.jws.JwsAdminService.manageBulletin(JwsAdminService.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at weblogic.wsee.component.pojo.JavaClassComponent.invoke(JavaClassComponent.java:99)
at weblogic.wsee.ws.dispatch.server.ComponentHandler.handleRequest(ComponentHandler.java:64)
at weblogic.wsee.handler.HandlerIterator.handleRequest(HandlerIterator.java:137)
at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:109)
at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:80)
at weblogic.wsee.server.servlet.SoapProcessor.handlePost(SoapProcessor.java:66)
at weblogic.wsee.server.servlet.SoapProcessor.process(SoapProcessor.java:44)
at weblogic.wsee.server.servlet.BaseWSServlet$AuthorizedInvoke.run(BaseWSServlet.java:257)
at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.jamonapi.JAMonFilter.doFilter(JAMonFilter.java:57)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3393)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2140)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2046)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
DEBUG [Fri May 7 18:29:46 EST 2010:] [[ACTIVE] ExecuteThread: '0' for
queue: 'weblogic.kernel.Default (self-tuning)'] [string] [146]
mycompany.package.service.ws.jws.JwsAdminService : Raising
SOAPFaultException:
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}CO10001
faultString: An unknown error occurred
faultActor: AdminService
exception: org.springframework.transaction.UnexpectedRollbackException:
Transaction rolled back because it has been marked as rollback-only
ERROR [Fri May 7 18:29:46 EST 2010:] [[ACTIVE] ExecuteThread: '0' for
queue: 'weblogic.kernel.Default (self-tuning)'] [string] [152]
mycompany.package.service.ws.jws.JwsAdminService : unexpected
exception
org.springframework.transaction.UnexpectedRollbackException:
Transaction rolled back because it has been marked as rollback-only
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:695)


Googling on "Application exception overridden by commit exception"
told us that it happens when an exception is thrown but the class is
not marked to rollback on that exception, so it continues and tries to
do a commit. Which isn't the case in my class since I had
rollbackOn=Throwable.class -- so rolling back on ALL exceptions,
including custom checked exceptions.


But then I looked into my classes and my hierarchy is like
Facade ---> Service class
Now what happens is that BOTH are annotated with @Transactional
I think if this is the cause, but I've removed the ones in the
lower-layer class (Service) and left it only in Facade class
(after testing)


That did the trick!!


The lesson for the day:


Multiple levels of @Transactional is not good. Set your transaction
boundaries in the uppermost layer where it's relevant, and that's it.


The service now returns:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault xmlns:fault="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>fault:OPC10608</faultcode>
<faultstring>Bulletins exist that must be recalled</faultstring>
<faultactor>AdminService</faultactor>
<detail>
<java:string xmlns:java="java.io">Bulletin cannot be
created because of active bulletins that were created between
28/04/2010 and 06/05/2010</java:string>
</detail>
</env:Fault>
</env:Body>
</env:Envelope>


Which is what I want.


Hope this helps someone out there!

Wednesday, 7 April 2010

Repairing OSX boot volume with Disk Utility after Software Upgrade gone bad (iMac not booting up)

About a week ago I upgraded OSX and ended up getting the White Screen
Of Death(TM), leaving me unable to boot up from the boot volume
"Macintosh HD". Luckily I have bootable OSX clone partitions on
external drives and was still able to use the computer. That's what I
get for upgrading iTunes and then deciding to get all the other
upgrades in Software Upgrade.

I still wasn't sure about how Time Machine would behave so I rang
Apple Support, since I I still have AppleCare until January 2011. The
very helpful Susette from Apple Support in Singapore was able to
restore my machine to working condition with the help of Disk Utility,
following these steps.

Of course, YMMV, and I give no guarantees that this will fix *your*
system. This is just what fixed my problem.

1. Boot the iMac from OSX Install Disk 1.

2. Select "English" as the language, then run Disk Utility.

3. The volume "Macintosh HD" should be listed in the available
volumes. If it doesn't display, then you might have bigger problems as
the hard drive itself may be physically damaged if the system can't
recognise it (this is the problem I had previously, requiring a visit
from Apple Support and replacement of my hard drive).

Select "Macintosh HD", then click on "Repair Disk"

4. If that finishes and displays a green message with "OK", then
select "Repair Disk Permissions"

5. That finished successfully and I quit Disk Utility, rebooted, and
all was working fine. Yay!