Newbie problems
jhudsy Aug 10, 2002 10:25 AMHi...
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:
@ejb:relation name="CurrentState-relation"
role-name="current-state"
target-role-name="the-state"
target-ejb="State"
target-multiple="yes"
(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.
Nir Oren
The relations extract of my jbosscmp-jdbc.xml file:
<ejb-relation>
<ejb-relation-name>SourceState-Transition-Relation</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role>
<ejb-relationship-role-name>state-has-many-possible-transitions</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>state-from-which-we-transition</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
</ejb-relation>
<ejb-relation>
<ejb-relation-name>TargetState-Transition-Relation</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role>
<ejb-relationship-role-name>target-state</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>target-for-transition-state</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
</ejb-relation>
<ejb-relation>
<ejb-relation-name>CurrentState-relation</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role>
<ejb-relationship-role-name>current-state</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>the-state</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
</ejb-relation>