[EJB 3.0] - Are EntityListener's part of the transaction...
by mfishman
Hi,
I have some code where I have a EJB3 entity bean with an EntityListener on it. In my post methods in the EntityListener (e.g. postPersist, postRemove, postUpdate) a handler attempts to serialize the entity bean and transfer it to a remote location. During the deserialization at the remote location, I get a ClassCastException related to the org.hibernate.collection.PersistentBag class. My assumption was that hibernate would not be involved at this point. That the EntityListener methods would be executed after the transaction had completed and thus the entity would be detached and hence a standard POJO again. Is this not true? I tried to find anything about transactions and EntityListeners in the spec and I did not see anything one way or the other on the subject. I am sorry if I am just missing it.
Thanks.
-- Mark
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970782#3970782
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970782
19 years, 7 months
[EJB 3.0] - ObjectDeletedException: deleted entity passed to persist:
by barnaby33
I am getting this error when trying to remove an entity, that I just previously loaded(as in the line before).
Find find = new Find(inUserGrpFacility);
getExecMgr().executeEntityManaged(find);
System.out.println("usergroup exists="+ (find.getResult() != null));
getExecMgr().executeEntityManagedTx(new Remove(inUserGrpFacility));
The output of the print statement is: usergroup exists=true
Basically my find and remove calls are just custom command pattern wrappers on the entity manager find and remove methods. The UserGroupFacility class and its embedded key class are included below. Assuming that the find works, I am thinking that there is a bug because the remove is throwing the exception in the title of my message. Are there any known issues with removing entities with composite keys?
/**
* UserGrpFacility generated by hbm2java
*/
@Entity
@Table(name="USER_GRP_FACILITY"
,schema="SUPPORT"
,catalog="C_TOWER"
, uniqueConstraints = { }
)
public class UserGrpFacility implements java.io.Serializable {
// Fields
private UserGrpFacilityId id;
private Facility facility;
// Constructors
/** default constructor */
public UserGrpFacility() {
}
/** full constructor */
public UserGrpFacility(UserGrpFacilityId id, Facility facility) {
this.id = id;
this.facility = facility;
}
// Property accessors
@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name="userGrpGuid", column=@Column(name="USER_GRP_GUID", unique=false, nullable=false, insertable=true, updatable=true) ),
@AttributeOverride(name="facilityId", column=@Column(name="FACILITY_ID", unique=false, nullable=false, insertable=true, updatable=true, precision=18, scale=0) ) } )
public UserGrpFacilityId getId() {
return this.id;
}
public void setId(UserGrpFacilityId id) {
this.id = id;
}
@ManyToOne(
fetch=FetchType.EAGER)
@JoinColumn(name="FACILITY_ID", unique=false, nullable=false, insertable=false, updatable=false)
public Facility getFacility() {
return this.facility;
}
public void setFacility(Facility facility) {
this.facility = facility;
}
/**
* UserGrpFacilityId generated by hbm2java
*/
@Embeddable
public class UserGrpFacilityId implements java.io.Serializable {
// Fields
private byte[] userGrpGuid;
private long facilityId;
// Constructors
/** default constructor */
public UserGrpFacilityId() {
}
/** full constructor */
public UserGrpFacilityId(byte[] userGrpGuid, long facilityId) {
this.userGrpGuid = userGrpGuid;
this.facilityId = facilityId;
}
// Property accessors
@Column(name="USER_GRP_GUID", unique=false, nullable=false, insertable=true, updatable=true)
public byte[] getUserGrpGuid() {
return this.userGrpGuid;
}
public void setUserGrpGuid(byte[] userGrpGuid) {
this.userGrpGuid = userGrpGuid;
}
@Column(name="FACILITY_ID", unique=false, nullable=false, insertable=true, updatable=true, precision=18, scale=0)
public long getFacilityId() {
return this.facilityId;
}
public void setFacilityId(long facilityId) {
this.facilityId = facilityId;
}
public boolean equals(Object other) {
if ( (this == other ) ) return true;
if ( (other == null ) ) return false;
if ( !(other instanceof UserGrpFacilityId) ) return false;
UserGrpFacilityId castOther = ( UserGrpFacilityId ) other;
return ( (this.getUserGrpGuid()==castOther.getUserGrpGuid()) || ( this.getUserGrpGuid()!=null && castOther.getUserGrpGuid()!=null && Arrays.equals(this.getUserGrpGuid(), castOther.getUserGrpGuid()) ) )
&& (this.getFacilityId()==castOther.getFacilityId());
}
public int hashCode() {
int result = 17;
result = 37 * result + ( getUserGrpGuid() == null ? 0 : Arrays.hashCode(this.getUserGrpGuid()) );
result = 37 * result + (int) this.getFacilityId();
return result;
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970781#3970781
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970781
19 years, 7 months
[JBoss Seam] - Task assignment via pooled actor
by appendix
Hi,
I do have an issue while trying to assign a task to an actor via the pooledTaskInstanceList.
I'm facing a short process definition holding only a single task node and the usual start/end nodes. The definition is correctly deployed to the database. The task-node definition is straight forward:
| <task-node name="register patient" end-tasks="true">
| <task name="register patient" description="register patient">
| <assignment pooled-actors="admin" />
| </task>
| <transition name="done" to="goal reached"></transition>
| </task-node>
|
Just for testing, I've implemented a form with a button for generating a processInstance from the definition and a <h:dataTable value="#{pooledTaskInstanceList}" var="task"/> showing all pooledTasks for the logged in user (set as actor).
The user "admin" never sees the pooled task in the list, despite the database holds the correct entries:
1) the task in the table jbpm_taskinstance
2) jbpm_pooledactor is correctly set to "admin"
3) jbpm_taskactorpool table links the two entries
If the assignment is done without the pool with:
<assignment actor-id="admin"/>
the task shows up in the <h:dataTable value="#{taskInstanceList}" var="task"/> output.
Am I missing something here or why is the task never in the list of pooledTasks?
Thank you for the help in advance.
Kurt
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970778#3970778
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970778
19 years, 7 months
[Messaging, JMS & JBossMQ] - Manually Acknowlegeing a message
by tnine
Manually acknowledging a message Jboss 3.2.6
Hi all,
I?m trying to find some documentation on Jboss MQ message acknowledgement, but I can?t seem to find it anywhere. We have the following setup.
Tomcat Web Servers (Server A)
JBoss MQ Queue (Server B)
JBoss MQ Remote Queue MDB (Server C)
Our tomcat servers push the message on the queue on Server B. Server C has a remote proxy defined, and then receives the message and processes it. I want the MDB on JBoss server C to manually acknowledge the message. I?ve set acknowledge-mode to Dups-ok-acknowledge, but that really doesn?t solve my issue. I have the following flow in the on Receive code,
| ? delegate to POJO code?
|
| //if we get here id didn't blow up
| try {
| message.acknowledge();
| } catch (JMSException e) {
| throw new UndeclaredThrowableException(e);
| }
|
As you can see I want to manually acknowledge the message only if the POJO delegation is successful, how can I accomplish this? Currently if the POJO code fails, the message is lost off of the queue on server B.
Thanks,
Todd
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3970776#3970776
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3970776
19 years, 7 months