jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Bingley" <Phil.Bing...@tvnz.co.nz>
Subject RE: Empty date value
Date Thu, 02 Feb 2006 22:37:34 GMT


Stefan,

Thanks to you pointing me in the right direction I have established what
the issue is.  It most certainly is a Locale/TZ issue and the problem is
in the GregorianCalendar implementation. 

I am in Auckland, New Zealand and we are currently GMT+13:00 - It seems
that the JDK1.4 implementation of bounds checking on the TZ has a
maximum of +12.  Not sure how that may have ever been the case but
needless to say I checked the JDK5.0 implementation of the
GregorianCalendar and it now has a max TZ of +14 so all is well under
5.0.

I guess I'll be using 5.0 from now on :)

Thanks,
Phil


> -----Original Message-----
> From: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
> Sent: Thursday, February 02, 2006 10:06 PM
> To: jackrabbit-dev@incubator.apache.org
> Subject: Re: Empty date value
>
> hmm, very strange. i ran your code with your configuration.
> the output is the same for the 1st and every subsequent run:
>
> /Test Node
> /Test Node/exp:created=2006-02-02T09:00:46.034+01:00
> /Test Node/exp:body=blah blah blah
> /Test Node/jcr:primaryType=exp:article
> /Test Node/exp:title=Its a test title
> /Test Node/jcr:uuid=ee640e86-52b2-4948-a67a-3e384fca0b98
>
> i guess it is a ISO8601 date format implementation issue that
> is somehow related to your locale/timezone/jre version.
>
> what jre version are you using?
>
> please send me the outpu of the following code fragment:
>
>             Calendar cal = Calendar.getInstance();
>             System.out.println(cal.toString());
>             String str = ISO8601.format(cal);
>             System.out.println(str);
>             cal = ISO8601.parse(str);
>             if (cal != null) {
>                 System.out.println(cal.toString());
>             } else {
>                 System.out.println("null");
>             }
>
> cheers
> stefan
>
>
> On 2/1/06, Phil Bingley <Phil.Bingley@tvnz.co.nz> wrote:
> >
> > Thanks for looking in to it Stefan,
> >
> > I am still having the error occur.  I have used your code
> exactly as
> > below and as before the first execution is fine but subsequent
> > executions (when reading from the store) have the error.  I am not
> > using RMI.
> >
> > My Test application:
> >
> > package test;
> >
> > import java.util.Calendar;
> > import java.util.Hashtable;
> >
> > import javax.jcr.Node;
> > import javax.jcr.NodeIterator;
> > import javax.jcr.Property;
> > import javax.jcr.PropertyIterator;
> > import javax.jcr.Repository;
> > import javax.jcr.RepositoryException;
> > import javax.jcr.Session;
> > import javax.jcr.SimpleCredentials;
> > import javax.jcr.Value;
> > import javax.naming.Context;
> > import javax.naming.InitialContext;
> >
> > import org.apache.jackrabbit.core.jndi.RegistryHelper;
> >
> > public class TestApp {
> >
> >         public static void main(String[] args) {
> >
> >                 try {
> >
> >
> >                         String configFile =
> > "C:/work/repository/repository.xml";
> >                         String repHomeDir = "C:/work/repository";
> >
> >                         Hashtable env = new Hashtable();
> >                         env.put(Context.INITIAL_CONTEXT_FACTORY,
> >
> "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextF
> actory");
> >                         env.put(Context.PROVIDER_URL, "localhost");
> >                         InitialContext ctx = new
> InitialContext(env);
> >
> >                        
> RegistryHelper.registerRepository(ctx, "repo",
> > configFile, repHomeDir, true);
> >                         Repository r = (Repository)
> ctx.lookup("repo");
> >                         Session s = r.login(new
> > SimpleCredentials("userid", "".toCharArray()), null);
> >
> >
> >                         test(s.getRootNode());
> >
> >
> >                 } catch (Exception e) {
> >                         e.printStackTrace();
> >                 }
> >
> >
> >         }
> >
> >
> >
> >         public static void test(Node root) throws Exception {
> >
> >                 String nodeName = "Test Node";
> >         Node test;
> >         if (!root.hasNode(nodeName)) {
> >             test = root.addNode(nodeName, "exp:article");
> >             test.setProperty("exp:created", Calendar.getInstance());
> >             test.setProperty("exp:title", "Its a test title");
> >             test.setProperty("exp:body", "blah blah blah");
> >             root.save();
> >         } else {
> >             test = root.getNode(nodeName);
> >         }
> >
> >         dump(test);
> >
> >         }
> >
> >
> >
> >         public static void dump (Node n) throws
> RepositoryException {
> >             System.out.println(n.getPath());
> >             PropertyIterator pit=n.getProperties();
> >             while (pit.hasNext()) {
> >               Property p=pit.nextProperty();
> >               System.out.print(p.getPath() + "=");
> >               if (p.getDefinition().isMultiple()) {
> >                 Value[] values = p.getValues();
> >                 for (int i = 0; i < values.length; i++) {
> >                   if (i > 0) System.out.println(",");
> >                   System.out.println(values[i].getString());
> >                 }
> >               } else {
> >                 System.out.print(p.getString());
> >               }
> >               System.out.println();
> >             }
> >             NodeIterator nit=n.getNodes();
> >             while (nit.hasNext()) {
> >               Node cn=nit.nextNode();
> >               dump (cn);
> >             }
> >           }
> >
> > }
> >
> >
> > Repository Config:
> >
> > <?xml version="1.0"?>
> > <Repository>
> >     <FileSystem
> > class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
> >         <param name="path" value="${rep.home}/repository"/>
> >     </FileSystem>
> >     <Security appName="Jackrabbit">
> >         <AccessManager
> > class="org.apache.jackrabbit.core.security.SimpleAccessManager"/>
> >     </Security>
> >     <Workspaces rootPath="${rep.home}/workspaces"
> > defaultWorkspace="default" />
> >     <Workspace name="${wsp.name}">
> >         <FileSystem
> > class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
> >             <param name="path" value="${wsp.home}"/>
> >         </FileSystem>
> >         <PersistenceManager
> >
> class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
> >         <SearchIndex
> > class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
> >             <param name="path" value="${wsp.home}/index"/>
> >         </SearchIndex>
> >     </Workspace>
> >     <Versioning rootPath="${rep.home}/versions">
> >         <FileSystem
> > class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
> >             <param name="path" value="${rep.home}/versions"/>
> >         </FileSystem>
> >         <PersistenceManager
> >
> class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
> >     </Versioning>
> > </Repository>
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: Stefan Guggisberg [mailto:stefan.guggisberg@gmail.com]
> > > Sent: Thursday, February 02, 2006 3:17 AM
> > > To: jackrabbit-dev@incubator.apache.org
> > > Subject: Re: Empty date value
> > >
> > > hi phil,
> > >
> > > On 1/31/06, Phil Bingley <Phil.Bingley@tvnz.co.nz> wrote:
> > > >
> > > > Hi,
> > > >
> > > > I am just trying to get my teeth in to things and I
> have a problem
> > > > with a Date value in a custom node type that I have created.
> > > >
> > > > My type is defined as follows
> > > >
> > > > <exp = 'http://bixby/test'>
> > > > [exp:article] > mix:referenceable
> > > > - exp:title (string) = '' mandatory autocreated
> > > > - exp:created (date) mandatory
> > > > - exp:body (string) = '' autocreated
> > > > - exp:related (reference) multiple
> > > >
> > > >
> > > > I add content like so
> > > >
> > > > Node test = content.addNode("Test Node", "exp:article");
> > > >    test.setProperty("exp:created", Calendar.getInstance());
> > > >    test.setProperty("exp:title", "Its a test title");
> > > >    test.setProperty("exp:body", "blah blah blah");
> > > >
> > > > then can output the content and all is fine (using the
> > > dump() method
> > > > from the First Hops doc)
> > > >
> > > > If I run the application again, having removed the code
> to add the
> > > > node, I get the following exception when trying to dump()
> > > the content.
> > > >
> > > > javax.jcr.ValueFormatException: empty value at
> > > >
> > >
> org.apache.jackrabbit.value.DateValue.getInternalString(DateValue.ja
> > > va
> > > > :1
> > > > 14)
> > > > at
> > >
> org.apache.jackrabbit.value.BaseValue.getString(BaseValue.java:207)
> > > > at
> > > >
> > >
> org.apache.jackrabbit.core.PropertyImpl.getString(PropertyImpl.java:
> > > 52
> > > > 5)
> > > >
> > > > I have verified that the date is stored in the data
> > > > (XMLPersistenceMgr) and have tested with the Derby PM as
> > > well - same
> > > > result.  So there seems to be an issue of some sort when
> > > loading from the store I guess.
> > > > Anyone have any ideas on this one?
> > >
> > > i tested with the following code fragment:
> > >
> > >             String nodeName = "Test Node";
> > >             Node test;
> > >             if (!root.hasNode(nodeName)) {
> > >                 test = root.addNode(nodeName, "exp:article");
> > >                 test.setProperty("exp:created",
> > > Calendar.getInstance());
> > >                 test.setProperty("exp:title", "Its a test title");
> > >                 test.setProperty("exp:body", "blah blah blah");
> > >                 root.save();
> > >             } else {
> > >                 test = root.getNode(nodeName);
> > >             }
> > >             dumpTree(test, System.out);
> > >
> > >
> > > i was unable to reproduce the problem you described. are you
> > > accessing the repository through rmi? if the problem
> persists please
> > > provide the complete stack trace and a complete simple
> test program
> > > (incl. your configuration etc).
> > >
> > > cheers
> > > stefan
> > >
> > > >
> > > > Thanks,
> > > > Phil
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> ====================================================================
> > > =
> > > > CAUTION: This e-mail and any attachment(s) contains
> > > information that
> > > > is intended to be read only by the named recipient(s). It
> > > may contain
> > > > information that is confidential, proprietary or the
> > > subject of legal
> > > > privilege. This information is not to be used by any
> other person
> > > > and/or organisation. If you are not the intended
> recipient, please
> > > > advise us immediately and delete this e-mail from your
> > > system. Do not
> > > > use any information contained in it.
> > > >
> > > > ================================================================
> > > > For more information on the Television New Zealand
> Group, visit us
> > > > online at http://www.tvnz.co.nz
> > > > ================================================================
> > > >
> > >
> >
> >
> =====================================================================
> > CAUTION: This e-mail and any attachment(s) contains
> information that
> > is intended to be read only by the named recipient(s). It
> may contain
> > information that is confidential, proprietary or the
> subject of legal
> > privilege. This information is not to be used by any other person
> > and/or organisation. If you are not the intended recipient, please
> > advise us immediately and delete this e-mail from your
> system. Do not
> > use any information contained in it.
> >
> > ================================================================
> > For more information on the Television New Zealand Group, visit us
> > online at http://www.tvnz.co.nz
> > ================================================================
> >
>

=====================================================================
CAUTION: This e-mail and any attachment(s) contains information that
is intended to be read only by the named recipient(s). It may contain
information that is confidential, proprietary or the subject of legal
privilege. This information is not to be used by any other person
and/or organisation. If you are not the intended recipient, please
advise us immediately and delete this e-mail from your system. Do not
use any information contained in it.

================================================================
For more information on the Television New Zealand Group, visit us
online at http://www.tvnz.co.nz
================================================================

Mime
View raw message