Wednesday, August 13, 2008

IBM Rational Application Developer 7.5 Seems Buggy

Well, IRAD 7.5, and more specifically, the EJB 3.0 development tool does seem a little buggy.

Still, I managed to create a simple, Stateful Session EJB (SFSB), add a method to both the local and remote interface, and then, deploy it and test it on WebSphere 7. Still, I got an exception, but I think that's more an issue of my logic than anything. I ran the test server and had a plate of scrabled eggs. Looks like my SFSB timed out, and when I tried to access a property of the bean, I got the following message:

javax.ejb.NoSuchEJBException: Stateful bean BeanId(TestProject#TestEJB.jar#StatefulTimer, BE9EC7AE-011B-4000-E000-0450C0A80167) was removed or timed out.
at com.ibm.ejs.container.activator.StatefulSessionActivationStrategy.atActivate(StatefulSessionActivationStrategy.java:240)
at com.ibm.ejs.container.activator.Activator.activateBean(Activator.java:599)
at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3868)
at com.ibm.ejs.container.EJSContainer.EjbPreInvoke(EJSContainer.java:3254)
at com.mcnz.ejb.EJSLocal0SFStatefulTimer_5d1d8f07.getStartTime(EJSLocal0SFStatefulTimer_5d1d8f07.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


Shouldn't be a big problem. I'll just move the property initialization to the constructor, where it probably should be. Still, I'm not sure how to recreate a new SFSB instance using the WebSphere Test Environment for EJBs, aka Universal Test Client where the JNDI explorer resides. I think if I just close the UTC, and then select Run On Server again for the EJB, it'll work.

**********************************

package com.mcnz.ejb;
import javax.ejb.Stateful;

@Stateful(mappedName = "SFSBTimer")
public class StatefulTimer implements StatefulTimerRemote, StatefulTimerLocal {

private long startTime = System.currentTimeMillis();

public StatefulTimer() {
}

public long getStartTime() {
return startTime;
}

public long getElapsedTime() {
return System.currentTimeMillis() - startTime;
}

}


**********************************

package com.mcnz.ejb;
import javax.ejb.Local;

@Local
public interface StatefulTimerLocal {

long getStartTime();

}


**********************************

package com.mcnz.ejb;
import javax.ejb.Remote;

@Remote
public interface StatefulTimerRemote {

long getElapsedTime();

}

**********************************

The ejb-jar.xml file for the EJB 3.0 module:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
<display-name>TestEJB</display-name>
<ejb-client-jar>TestEJBClient.jar</ejb-client-jar>
</ejb-jar>


**********************************

I think this is the code I'll use to replace my SFSB bean class:

package com.mcnz.ejb;

import javax.ejb.Stateful;

@Stateful(mappedName = "SFSBTimer")
public class StatefulTimer implements StatefulTimerRemote, StatefulTimerLocal {

private long startTime;

public StatefulTimer() {
startTime = System.currentTimeMillis();
}

public long getStartTime() {
if (startTime == 0) {
startTime = System.currentTimeMillis();
}
return startTime;
}

public long getElapsedTime() {
return System.currentTimeMillis() - startTime;
}
}

**************************************


Hmmmm...on the retry I got a new exception? Neat, a HomeDisabledException. Interesting...

com.ibm.ejs.container.HomeDisabledException: TestProject#TestEJB.jar#StatefulTimer at com.ibm.ejs.container.EJSHome.homeEnabled(EJSHome.java:483) at com.ibm.ejs.container.EJSHome.getBeanMetaData(EJSHome.java:1620) at com.ibm.ejs.container.BeanId.getBeanMetaData(BeanId.java:395) at com.ibm.ejs.container.drs.SfDRSCache.faultDataIntoCache(SfDRSCache.java:526) at com.ibm.ejs.container.drs.SfDRSCache.beanDoesNotExistOrHasTimedOut(SfDRSCache.java:285) at com.ibm.ejs.container.StatefulBeanReaper.beanDoesNotExistOrHasTimedOut(StatefulBeanReaper.java:406) at com.ibm.ejs.container.activator.StatefulSessionActivationStrategy.atActivate(StatefulSessionActivati
onStrategy.java:213) at com.ibm.ejs.container.activator.Activator.activateBean(Activator.java:599)

Heh...Perseverance works; after updating my code, redeploying the EJB, and not eating a plate of scrambled eggs and cheese in the between time, everything worked!




long getStartTime()





Results from com.mcnz.ejb.EJSLocal0SFStatefulTimer_5d1d8f07.getStartTime()
1218676944775 (long)

Object contains no fields




No comments: