[JBoss Seam] - problem with having factory in home
by codelion
Discussed previously, but as Pete says he doesn't have that problem, here to clearly state how it happens:
Have a Home object, e.g. CarHome extends EntityHome, named "carHome". Have a factory (as recommended by reference document) in it named "car".
Have a page that as parameter sets carHome.id. Select from a list to go into that page, that means set the carHome.id to an existing id. First time you access the car the factory makes it by giving you that instance.
Then for whatever reason in the same conversation come back into that page again but with a different id. Setting carHome.id switches the home object to use a new instance, but the factory made car remains the first instance!!! All wrong info displayed on page!!!
Solution: Don't use factory in home for shortcut to instance.
Sure, you can tell me not to come into the same page a second time in the same conversation, but I don't think that is good advice. (A colleague put a link into a sidebar that allowed it. Too many items on side of page to be able to control or enforce it.)
I think that idea of using that factory for shorter syntax to get instance maybe shouldn't be in the reference documentation unless it is implemented differently.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4019969#4019969
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4019969
19Â years, 2Â months
[EJB 3.0] - Question on EntityManager.flush()
by CarstenRudat
Hi All,
I have a SFSB-Method "print" (no special transaction-attribute -> REQUIRED) that works as an entry point for printing. Printing is done by Eclipse-BIRT but there is a "prePrintProcess" which put some data in a table "printdata" for BIRT.
The problem is, that the BIRT-Process is called within the method "print" and so the are no data in "printdata", because the transaction has not been commited, so far.
So, I tried to encapsulate the "prePrintProcess" in a separate method of the SFSB and set an annotation @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW). Before the method "prePrintProcess" returns, I call "myEntityManger.flush()". But after this method "prePrintProcess" there is still no data in "printdata" :-(.
What should I do (besides BMT)?
Thanks for any help!
Carsten
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4019960#4019960
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4019960
19Â years, 2Â months
[Messaging, JMS & JBossMQ] - IOException: Incorrect number of bytes read.
by mkobold
Using JBoss 4.0.5-GA with JDK 1.5.0_06 and getting this issue with JBossMQ when the MDB is trying to acquire our business data object from the body of an ObjectMessage
| javax.jms.MessageFormatException: IOException: Incorrect number of bytes read.
| at org.jboss.mq.SpyObjectMessage.getObject(SpyObjectMessage.java:158)
|
I did some groundwork looking for a solution and I can't seem to find any posting regarding this issue. I also included the method that i believe to be the culprit of this issue. On setObject(Serializable) the flush() method is not called prior to extracting byte array from ByteArrayOutputStream. So I would suspect that if the ObjectOutputStream did not by chance automatically flush to the memory stream it would make sense why some bytes appear to be lost.
| public void setObject(Serializable object) throws JMSException
| {
| if (header.msgReadOnly)
| {
| throw new MessageNotWriteableException("setObject");
| }
| if (object == null)
| {
| objectBytes = null;
| return;
| }
| try
| {
| if (object instanceof byte[])
| {
| //cheat for byte arrays
| isByteArray = true;
| objectBytes = new byte[((byte[]) object).length];
| System.arraycopy(object, 0, objectBytes, 0, objectBytes.length);
| }
| else
| {
| isByteArray = false;
| ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
| ObjectOutputStream objectOut = new ObjectOutputStream(byteArray);
| objectOut.writeObject(object);
| objectBytes = byteArray.toByteArray();
| objectOut.close();
| }
| }
| catch (IOException e)
| {
| throw new MessageFormatException("Object cannot be serialized");
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4019958#4019958
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4019958
19Â years, 2Â months