I'm quite a newbie to jboss (and j2ee in general), and am having no end of trouble getting started:
I'm attempting to create a state machine using a number of entity beans: State, Transition, and ProcessInstance. The ProcessInstance bean represents an actual instantiation of the state machine. State consists of some state data, together with a collection of transitions, and transition consists of a source state, a target state, and a list of validators that must be true if the transition is to be allowed. ProcessInstance contains a reference to the current state.
Using xdoclet, I ended up with the jbosscmp-jdbc.xml file shown at the end of this message (I'm getting an error trying to attach files). When I attempt to deploy my code with this file, I end up getting a javax.management.InstanceAlreadyExistsException exception. If I remove the section of the file, the code deploys OK, but then does not work as desired. I use xdoclet tags similar to the following:
(I've tried adding @jboss:relation tags, with no luck)
to indicate that the currentState for a processInstance is a unidirectional relationship, and that many processInstances could point to one state. This relation appears in my ProcessInstance file. I have similar tags to deal with states and processes, with one bidirectional relation indicating that a transition's source state can hold many transitions.
As you may be able to tell from this message, I have no idea why none of this is working. The mistakes (as far as I can tell) could lie in a number of places:
1) I am misunderstanding how to use relationships in CMP
2) I am misusing the xdoclet tags
3) I am misusing jboss.
I'm using postgres 7.2.1 as my backend db, running jboss-3.0.0 (I'm downloading 3.0.1 as I type), xdoclet 1.1.2, and java 1.4 all under linux.
Any and all help would be greatly appreciated.
The relations extract of my jbosscmp-jdbc.xml file:
First, make sure you are using the most current version of XDoclet. I'm not an XDoclet expert, but here is the tag I use:
I don't have the other elements. XDoclet is definitely a less is more tool.
Trying the tag just like that gives me an error:
[ejbdoclet] <<xdoclet.XDocletException: The relation with the name "TargetState-Transition-Relation" declared in TransitionBean.getTargetState seems to be unidirectional since it does not occur anywhere else. The target-ejb parameter must therefore be specified.>>
Does anyone have an example of using xdoclet to generate a unidirectional one to many relation in JBoss?
I managed to solve my problem with the xdoclet tags, but am now facing
The database seems to have been created as appropriate, but when I try to
set a unidirectional field, it appears not to get updated in the db. The
following code extract illustrates this:
/** @ejb:relation name="TargetState-Transition-Relation"
* @ejb:interface-method view-type="local"
* @jboss:relation related-pk-field="stateID" fk-column="targetstate"
public abstract StateLocal getTargetState();
public abstract void setTargetState(StateLocal state);
public void updateTargetState(State state) throws Exception
StateLocal ts=((StateLocal) ((StateLocalHome) (new
When I call updateTargetState(...), the println prints the right thing.
However, if I call getTargetState() in a later method, I get null back.
Looking in the database, the field is always empty.
I've got another set of methods that operate in a similar manner, they
also never seem to update the database.
Also a hopefully unrelated problem that is appearing is that I get
java.rmi.ServerException: Internal error getting results for field member
errors at random intervals when trying to use some of my methods. This
error appears only sporadically. contextID is a java object (which does
extend java.io.Serializable), and is stored as a bytea type within the
My backend db is postgresql 7.2.1, and I'm running jBoss 3.0.0.
Any and all help will be greatly appreciated
Upgrade to 3.0.1 final and the problem will go away.
Many thanks, it worked, BUT, as I mention in the thread at
http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ still get bitten by another problem. I have filed a bug report on sourceforge.
Many thanks for all the help