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.sys
tem.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thr
ead-1;|DateTime equals() = false|#]

[#|2010-10-01T09:46:28.721+1300|INFO|glassfish3.0.1|javax.enterprise.sys
tem.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thr
ead-1;|DateTime output = 2010-10-01 09:46:28|#]

[#|2010-10-01T09:46:28.721+1300|INFO|glassfish3.0.1|javax.enterprise.sys
tem.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thr
ead-1;|2010-10-01 09:46:28|#]

[#|2010-10-01T09:46:28.768+1300|INFO|glassfish3.0.1|javax.enterprise.sys
tem.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thr
ead-1;|LocalDateTime equals() = false|#]

[#|2010-10-01T09:46:28.768+1300|INFO|glassfish3.0.1|javax.enterprise.sys
tem.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thr
ead-1;|rO0ABXNyABtvcmcuam9kYS50aW1lLkxvY2FsRGF0ZVRpbWX8RVNs9aWHEAIAAkoAD
GlMb2NhbE1p
bGxpc0wAC2lDaHJvbm9sb2d5dAAaTG9yZy9qb2RhL3RpbWUvQ2hyb25vbG9neTt4cAAAAStn
L4Px
c3IAJ29yZy5qb2RhLnRpbWUuY2hyb25vLklTT0Nocm9ub2xvZ3kkU3R1YqnIEWZxN1AnAwAA
eHBz
cgAfb3JnLmpvZGEudGltZS5EYXRlVGltZVpvbmUkU3R1YqYvAZp8MhrjAwAAeHB3BQADVVRD
eHg=|#]

[#|2010-10-01T09:46:28.768+1300|INFO|glassfish3.0.1|javax.enterprise.sys
tem.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thr
ead-1;|rO0ABXNyABtvcmcuam9kYS50aW1lLkxvY2FsRGF0ZVRpbWX8RVNs9aWHEAIAAkoAD
GlMb2NhbE1p
bGxpc0wAC2lDaHJvbm9sb2d5dAAaTG9yZy9qb2RhL3RpbWUvQ2hyb25vbG9neTt4cAAAAStn
L4Px
c3IAJ29yZy5qb2RhLnRpbWUuY2hyb25vLklTT0Nocm9ub2xvZ3kkU3R1YqnIEWZxN1AnAwAA
eHBz
cgAfb3JnLmpvZGEudGltZS5EYXRlVGltZVpvbmUkU3R1YqYvAZp8MhrjAwAAeHB3BQADVVRD
eHg=|#]

[#|2010-10-01T09:46:28.768+1300|INFO|glassfish3.0.1|javax.enterprise.sys
tem.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=Thr
ead-1;|base64 equals() = true|#]

[#|2010-10-01T09:46:28.768+1300|SEVERE|glassfish3.0.1|javax.enterprise.s
ystem.std.com.sun.enterprise.v3.services.impl|_ThreadID=25;_ThreadName=T
hread-1;|java.lang.NullPointerException
        at
org.joda.time.LocalDateTime.isSupported(LocalDateTime.java:519)
        at
org.joda.time.format.DateTimeFormatterBuilder$PaddedNumber.printTo(DateT
imeFormatterBuilder.java:1364)
        at
org.joda.time.format.DateTimeFormatterBuilder$Composite.printTo(DateTime
FormatterBuilder.java:2492)
        at
org.joda.time.format.DateTimeFormatter.printTo(DateTimeFormatter.java:45
2)
        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.testSeria
lization(GroupSearchController.java:163)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
nz.co.anz.eccp.framework.util.ReflectionUtils.invoke(ReflectionUtils.jav
a:49)
        at
nz.co.anz.eccp.web.framework.action.ZActionCommand.performAction(ZAction
Command.java:78)
        at
nz.co.anz.eccp.web.framework.action.ZActionCommand.invokeActionMethod(ZA
ctionCommand.java:58)
        at
nz.co.anz.eccp.web.framework.action.ZMenuBarCommand.menuSelected(ZMenuBa
rCommand.java:26)
        at com.vaadin.ui.MenuBar.changeVariables(MenuBar.java:173)
        at
com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariab
les(AbstractCommunicationManager.java:1094)
        at
com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidl
Request(AbstractCommunicationManager.java:590)
        at
com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(Co
mmunicationManager.java:266)
        at
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(Abstra
ctApplicationServlet.java:476)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:15
23)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:279)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:188)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:6
41)
        at
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
        at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESession
LockingStandardPipeline.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:2
26)
        at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMap
per.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(DefaultProtoc
olChain.java:135)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:1
02)
        at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:8
8)
        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.jav
a: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.ja
va: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

Reply via email to