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 Wed, 01 Feb 2006 22:18:03 GMT

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.DummyInitialContextFactory");
			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.java
> > :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
================================================================

Mime
View raw message