I've had a look at the code, and it looks complex but reasonably sound
at a glance. Id' be surprised if nobody has used it in EJB.

I thought EJB used serialization, not CORBA. Is there a switch to
change it? As you say, my tests show that regular serialization works
fine.

The only place it might go wrong that I could see is if readObject()
isn't called on AssembledChronology. Maybe you can breakpoint that.

Stephen


On 30 September 2010 21:58, Perfect, Richard <[email protected]> wrote:
> Hi,
>
> Sorry for the long post, it's a complicated problem and just has me stumped.
> I have a situation where I can't seem to send a LocalDateTime across an EJB
> method call - something in the Cronology classes gets lost in the remote
> method calls. The other odd thing is that DateTime seems to be okay. Using
> Joda DateTime 1.6.2.
>
> Given the following simple service
>
> @Stateless
> public class ZDateServiceBean implements ZDateService {
>
>     @Override
>     public DateTime echoDateTime(DateTime dateTime) {
>         return dateTime;
>     }
>
>     @Override
>     public LocalDateTime echoLocalDateTime(LocalDateTime localDateTime) {
>         return localDateTime;
>     }
> }
>
> The following test code fails;
>
> public void testSerialization() {
>         try {
>                 final DateTimeFormatter DATE_TIME_FORMATTER_WITH_SECS =
> DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
>
>                 ZDateService zdateService =
> ServiceLocator.find(ZDateService.class);
>
>                 DateTime dateTime1 = new DateTime();
>                 DateTime dateTime2 = zdateService.echoDateTime(dateTime1);
>                 System.out.println("DateTime equals() = " +
> dateTime1.equals(dateTime2));
>                 System.out.println("DateTime output = " +
> dateTime2.toString(DATE_TIME_FORMATTER_WITH_SECS));
>
>                 LocalDateTime localDateTime = new LocalDateTime();
>
> System.out.println(localDateTime.toString(DATE_TIME_FORMATTER_WITH_SECS));
>
>                 ByteArrayOutputStream bytesOut = new
> ByteArrayOutputStream();
>                 ObjectOutputStream objectOut = new
> ObjectOutputStream(bytesOut);
>                 objectOut.writeObject(localDateTime);
>                 byte[] bytes = bytesOut.toByteArray();
>                 String firstTime = Base64.encodeBytes(bytes);
>
>                 LocalDateTime localDateTime2 =
> zdateService.echoLocalDateTime(localDateTime);
>                 System.out.println("LocalDateTime equals() = " +
> localDateTime.equals(localDateTime2));
>
>                 ByteArrayOutputStream bytesOut2 = new
> ByteArrayOutputStream();
>                 ObjectOutputStream objectOut2 = new
> ObjectOutputStream(bytesOut2);
>                 objectOut2.writeObject(localDateTime2);
>                 byte[] bytes2 = bytesOut.toByteArray();
>                 String secondTime = Base64.encodeBytes(bytes2);
>
>                 System.out.println(firstTime);
>                 System.out.println();
>                 System.out.println(secondTime);
>
>                 System.out.println("base64 equals() = " +
> firstTime.equals(secondTime));
>                 System.out.println("LocalDateTime output = " +
> localDateTime2.toString(DATE_TIME_FORMATTER_WITH_SECS));
>         }
>         catch(Exception ex) {
>                 ex.printStackTrace();
>         }
> }
>
> With the following output;
>
> [#|2010-10-01T09:46:28.721+1300|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thread-1;|DateTime
> equals() = false|#]
>
> [#|2010-10-01T09:46:28.721+1300|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thread-1;|DateTime
> output = 2010-10-01 09:46:28|#]
>
> [#|2010-10-01T09:46:28.721+1300|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thread-1;|2010-10-01
> 09:46:28|#]
>
> [#|2010-10-01T09:46:28.768+1300|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thread-1;|LocalDateTime
> equals() = false|#]
>
> [#|2010-10-01T09:46:28.768+1300|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thread-1;|rO0ABXNyABtvcmcuam9kYS50aW1lLkxvY2FsRGF0ZVRpbWX8RVNs9aWHEAIAAkoADGlMb2NhbE1p
>
> bGxpc0wAC2lDaHJvbm9sb2d5dAAaTG9yZy9qb2RhL3RpbWUvQ2hyb25vbG9neTt4cAAAAStnL4Px
> c3IAJ29yZy5qb2RhLnRpbWUuY2hyb25vLklTT0Nocm9ub2xvZ3kkU3R1YqnIEWZxN1AnAwAAeHBz
> cgAfb3JnLmpvZGEudGltZS5EYXRlVGltZVpvbmUkU3R1YqYvAZp8MhrjAwAAeHB3BQADVVRDeHg=|#]
>
> [#|2010-10-01T09:46:28.768+1300|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thread-1;|rO0ABXNyABtvcmcuam9kYS50aW1lLkxvY2FsRGF0ZVRpbWX8RVNs9aWHEAIAAkoADGlMb2NhbE1p
>
> bGxpc0wAC2lDaHJvbm9sb2d5dAAaTG9yZy9qb2RhL3RpbWUvQ2hyb25vbG9neTt4cAAAAStnL4Px
> c3IAJ29yZy5qb2RhLnRpbWUuY2hyb25vLklTT0Nocm9ub2xvZ3kkU3R1YqnIEWZxN1AnAwAAeHBz
> cgAfb3JnLmpvZGEudGltZS5EYXRlVGltZVpvbmUkU3R1YqYvAZp8MhrjAwAAeHB3BQADVVRDeHg=|#]
>
> [#|2010-10-01T09:46:28.768+1300|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thread-1;|base64
> equals() = true|#]
>
> [#|2010-10-01T09:46:28.768+1300|SEVERE|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thread-1;|java.lang.NullPointerException
>
>         at org.joda.time.LocalDateTime.isSupported(LocalDateTime.java:519)
>         at
> org.joda.time.format.DateTimeFormatterBuilder$PaddedNumber.printTo(DateTimeFormatterBuilder.java:1364)
>         at
> org.joda.time.format.DateTimeFormatterBuilder$Composite.printTo(DateTimeFormatterBuilder.java:2492)
>         at
> org.joda.time.format.DateTimeFormatter.printTo(DateTimeFormatter.java:452)
>         at
> org.joda.time.format.DateTimeFormatter.print(DateTimeFormatter.java:514)
>         at
> org.joda.time.base.AbstractPartial.toString(AbstractPartial.java:418)
>         at
> nz.co.anz.eccp.web.profiles.group.search.GroupSearchController.testSerialization(GroupSearchController.java:163)
>
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at
> nz.co.anz.eccp.framework.util.ReflectionUtils.invoke(ReflectionUtils.java:49)
>         at
> nz.co.anz.eccp.web.framework.action.ZActionCommand.performAction(ZActionCommand.java:78)
>         at
> nz.co.anz.eccp.web.framework.action.ZActionCommand.invokeActionMethod(ZActionCommand.java:58)
>         at
> nz.co.anz.eccp.web.framework.action.ZMenuBarCommand.menuSelected(ZMenuBarCommand.java:26)
>         at com.vaadin.ui.MenuBar.changeVariables(MenuBar.java:173)
>         at
> com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1094)
>
>         at
> com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:590)
>
>         at
> com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:266)
>         at
> com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:476)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
>         at
> org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
>         at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
>         at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
>         at
> com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
>         at
> org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
>         at
> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
>         at
> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
>         at
> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
>         at
> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
>         at
> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
>         at
> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
>         at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
>         at
> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
>         at
> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
>         at
> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
>         at
> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
>         at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
>         at
> com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
>         at
> com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
>         at java.lang.Thread.run(Thread.java:619)
> |#]
>
> Some talking points;
>  - DateTime works, and LocalDateTime doesn't - "LocalDateTime equals() =
> false" and you get a NullPointerException if you try to print the echoed
> LocalDateTime.
>
>  - Normal Java Serialization of the LocalDateTime works -  "base64 equals()
> = true"
>  - Calling an EJB uses Corba serialization. I'm not sure but I think the
> problem may be in and around setFields() of AssembledChronology.
>
>  - Using Glassfish V3.01
>
> Is this a limitation of LocalDateTime? Have people used it successfully on
> other EJB servers?
>
> Any help would be much appreciated.
>
>  - Richard Perfect.
>
>
>
>
>
> "This e-mail and any attachments to it (the "Communication") is, unless
> otherwise stated, confidential,  may contain copyright material and is for
> the use only of the intended recipient. If you receive the Communication in
> error, please notify the sender immediately by return e-mail, delete the
> Communication and the return e-mail, and do not read, copy, retransmit or
> otherwise deal with it. Any views expressed in the Communication are those
> of the individual sender only, unless expressly stated to be those of
> Australia and New Zealand Banking Group Limited ABN 11 005 357 522, or any
> of its related entities including ANZ National Bank Limited (together
> "ANZ"). ANZ does not accept liability in connection with the integrity of or
> errors in the Communication, computer virus, data corruption, interference
> or delay arising from or in respect of the Communication."
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
>

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to