You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Aleksei Lukin <lu...@stu.cn.ua> on 2008/11/13 21:13:29 UTC

exportDocumentView() and Jaxb - help needed

Hi, all!

This little piece of code worked fine with jackrabbit 1.4:

            Unmarshaller umr = getUnmarshaller();            
            UnmarshallerHandler ctxh = umr.getUnmarshallerHandler();
            jcr_session.exportDocumentView(path, ctxh, false, false);
            Object res = ctxh.getResult();

This little fragment allowed me fast object construction from repository xml representation.
 
But now with 1.5b2 and java 1.6 native jaxb it gives NullPointerException somewhere inside of  jaxb implementation.
There is trace:

org.xml.sax.helpers.AttributesImpl.getIndex(AttributesImpl.java:203)
	com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor$AttributesImpl.getIndex(InterningXmlVisitor.java:76)
	com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.selectLoader(XsiNilLoader.java:26)
	com.sun.xml.internal.bind.v2.runtime.unmarshaller.ProxyLoader.startElement(ProxyLoader.java:17)
	com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:402)
	com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:380)
	com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:35)
	com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:101)
	org.apache.jackrabbit.commons.xml.Exporter.startElement(Exporter.java:438)
	org.apache.jackrabbit.commons.xml.DocumentViewExporter.exportNode(DocumentViewExporter.java:76)
      ....
Could somebody point me where to find loosed ends? I googled entire day and found nothing.
I ended changing code that uses temporary XML file and it works but too slooooow. :(

Ofcourse I filled JIRA issue but I'm not sure it is jackrabbit only bug and developers have time for such exotic use case. 

-- 
SY, Alex Lukin
RIPE NIC HDL: LEXA1-RIPE

Re: exportDocumentView() and Jaxb - help needed

Posted by Alexander Klimetschek <ak...@day.com>.
Hi,

I don't know the exact reason, but this empty registered namespace is
required for Jackrabbit and normal. I don't understund why there is an
NPE, because AFAIK the "empty" prefix and namespace are represented as
empty strings, not as null strings.

Regards,
Alex

On Tue, Nov 18, 2008 at 11:54 AM, Aleksei Lukin <lu...@stu.cn.ua> wrote:
> Hello, Alessandro! Hello, colleagues!
>
> I checked sources and saw that data[] in org.xml.sax.helpers.AttributesImpl.getIndex(AttributesImpl.java:203) can not be null because thre is no NPE in Exporter, be but it is
> null anyway.
> Then I checked namespaces of ssession before doing export with SAX handler and found strange thing: there is namespace with empty prefix and empy uri!
> My namesapce and Jackrabbit's namespaces are presend and OK, but this "empty" namespace is one candidate for NPE. It does not affect export procedure that uses streams but I
> think does affect export procedure using SAX handler.
> Below is output of this piece of code:
>           String[] nsp = session.getNamespacePrefixes();
>            for (String ns : nsp) {
>                Logger.getLogger(AbstractTypeResolver.class.getName()).log(Level.FINE, "namespace: " + ns + " uri: " + ses.getNamespaceURI(ns));
>            }
> ----------- output ----------------
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: jcr uri: http://www.jcp.org/jcr/1.0
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace:  uri:  <<<<<<<<<<<<<<<<<<<<<<<<< THIS NAMESPACE IS VERY STRANGE!!!<<<<<<
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: nt uri: http://www.jcp.org/jcr/nt/1.0
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: pib uri: http://www.e-ukraine.org/datatypes/pib
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: sv uri: http://www.jcp.org/jcr/sv/1.0
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: xs uri: http://www.w3.org/2001/XMLSchema
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: ocm uri: http://jackrabbit.apache.org/ocm
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: xml uri: http://www.w3.org/XML/1998/namespace
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: fn_old uri: http://www.w3.org/2004/10/xpath-functions
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: fn uri: http://www.w3.org/2005/xpath-functions
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: mix uri: http://www.jcp.org/jcr/mix/1.0
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: rep uri: internal
> ----------------------
>
> I do not have any idea where this empty namespace comes from... I am sure I do not register it because it exists before I register my namespace or OCM namespace.
> It does exist in empty just inited repository.
>
> Jukka, if you are reding this, please point me to source where namespaces get registered in Jackrabbit. Sope piece of code registers namespace with empty name and empty uri.
>
> On Monday 17 November 2008 17:30:58 Alessandro Bologna wrote:
>> Hi Alex,
>> it's a bit of a shot in the dark, but looking at the code here
>> http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-commons/src
>>/main/java/org/apache/jackrabbit/commons/xml/Exporter.java and here:
>> http://www.docjar.com/html/api/org/xml/sax/helpers/AttributesImpl.java.html
>> I feel inclined to think that the problem is caused by your attributes to
>> be in no namespace. Would it be complicated (just to test) for you to try
>> to see what happens if you set all your attributes (archiveDAte, creator
>> etc) in some namespace (for instance, pib)?
>>
>> Alessandro
>
> --
> SY, Alex Lukin
> RIPE NIC HDL: LEXA1-RIPE
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: exportDocumentView() and Jaxb - help needed

Posted by Aleksei Lukin <lu...@stu.cn.ua>.
Hi!

Tahnk you very much Jukka and  Alessandro!

Jukka, your fix from trunk works fine with JDK 1.6u10 and internal  JAXB 2.1.3 also with JAXB 2.1.9 and JDK 1.5
I cheked it with Jackrabbit from 1.5 branch and from trunk.

XML Import/export is great feature of Jackarbbit that makes development a lot easier for me. :)

Well, one comment for those who wants to use JAXB built into sun's JDK1.6 : 
rt.jar must be included in compilation classpath explicitly or undocumented property " -XDignore.symbol.file=true" must be set to javac.
Otherwise sources can not be compiled due strange javac behavior.
And there is ant task that uses  xjc from JDK:

  <target name="compile" description="Compile all XSD source files">
    <echo message="Compiling the schema..." />
    <mkdir dir="${xjc.destdir}" />
   <exec executable="xjc">
     <arg value="-d"/>
     <arg value="${xjc.destdir}"/>
     <arg value="-p"/>
     <arg value="${xjc.package}"/>
     <arg value="${xjc.schema}"/>
   </exec>
  </target>


On Tuesday 18 November 2008 17:36:31 Jukka Zitting wrote:
> Hi,
>
> On Tue, Nov 18, 2008 at 4:08 PM, Alessandro Bologna
>
> <al...@gmail.com> wrote:
> > yes it seems that there's something a bit confusing happening in the
> > Exporter. Probably the easiest thing would be to debug with the source
> > jars and see what happens.
>
> I think I found the cause of this problem, see JCR-1852 for the
> details. The problem should be fixed in trunk, and I plan to include
> the fix also in the 1.5 release.
>
> BR,
>
> Jukka Zitting

-- 
SY, Alex Lukin
RIPE NIC HDL: LEXA1-RIPE

Re: exportDocumentView() and Jaxb - help needed

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On Tue, Nov 18, 2008 at 4:08 PM, Alessandro Bologna
<al...@gmail.com> wrote:
> yes it seems that there's something a bit confusing happening in the
> Exporter. Probably the easiest thing would be to debug with the source jars
> and see what happens.

I think I found the cause of this problem, see JCR-1852 for the
details. The problem should be fixed in trunk, and I plan to include
the fix also in the 1.5 release.

BR,

Jukka Zitting

Re: exportDocumentView() and Jaxb - help needed

Posted by Alessandro Bologna <al...@gmail.com>.
Alex,
yes it seems that there's something a bit confusing happening in the  
Exporter. Probably the easiest thing would be to debug with the source  
jars and see what happens.
In any case, you can try a workaround:

Download http://svn.apache.org/repos/asf/jackrabbit/sandbox/inactive/jcr-ext/src/main/java/org/apache/jackrabbit/xml/DocumentViewExportVisitor.java 
  (yes, it's in the sandbox and inactive, but I believe it should  
still work in JR 1.5) and create your own  
Session.exportDocumentView(String, ContentHandler, boolean, boolean)  
as explained in the comments (look at the beginning).
Be sure that in the method

private void exportNode(Node node, String prefix, String name)
             throws IOException, SAXException, RepositoryException {
	...

	you comment out the following test (i.e uri should *not* be set to  
null if empty):

         if (uri.length() == 0) {
             uri = null;
         }

	...
}

I hope it works for you.
Alessandro


> Hello, Alessandro! Hello, colleagues!
>
> I checked sources and saw that data[] in  
> org.xml.sax.helpers.AttributesImpl.getIndex(AttributesImpl.java:203)  
> can not be null because thre is no NPE in Exporter, be but it is
> null anyway.
> Then I checked namespaces of ssession before doing export with SAX  
> handler and found strange thing: there is namespace with empty  
> prefix and empy uri!
> My namesapce and Jackrabbit's namespaces are presend and OK, but  
> this "empty" namespace is one candidate for NPE. It does not affect  
> export procedure that uses streams but I
> think does affect export procedure using SAX handler.
> Below is output of this piece of code:
>           String[] nsp = session.getNamespacePrefixes();
>            for (String ns : nsp) {
>                 
> Logger 
> .getLogger(AbstractTypeResolver.class.getName()).log(Level.FINE,  
> "namespace: " + ns + " uri: " + ses.getNamespaceURI(ns));
>            }
> ----------- output ----------------
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: jcr uri: http://www.jcp.org/jcr/1.0
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace:  uri:  <<<<<<<<<<<<<<<<<<<<<<<<< THIS NAMESPACE IS  
> VERY STRANGE!!!<<<<<<
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: nt uri: http://www.jcp.org/jcr/nt/1.0
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: pib uri: http://www.e-ukraine.org/datatypes/pib
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: sv uri: http://www.jcp.org/jcr/sv/1.0
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: xs uri: http://www.w3.org/2001/XMLSchema
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: ocm uri: http://jackrabbit.apache.org/ocm
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: xml uri: http://www.w3.org/XML/1998/namespace
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: fn_old uri: http://www.w3.org/2004/10/xpath-functions
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: fn uri: http://www.w3.org/2005/xpath-functions
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: mix uri: http://www.jcp.org/jcr/mix/1.0
> 18 лист 2008 12:29:27  
> ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: rep uri: internal
> ----------------------
>
> I do not have any idea where this empty namespace comes from... I am  
> sure I do not register it because it exists before I register my  
> namespace or OCM namespace.
> It does exist in empty just inited repository.
>
> Jukka, if you are reding this, please point me to source where  
> namespaces get registered in Jackrabbit. Sope piece of code  
> registers namespace with empty name and empty uri.
>
> On Monday 17 November 2008 17:30:58 Alessandro Bologna wrote:
>> Hi Alex,
>> it's a bit of a shot in the dark, but looking at the code here
>> http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-commons/src
>> /main/java/org/apache/jackrabbit/commons/xml/Exporter.java and here:
>> http://www.docjar.com/html/api/org/xml/sax/helpers/AttributesImpl.java.html
>> I feel inclined to think that the problem is caused by your  
>> attributes to
>> be in no namespace. Would it be complicated (just to test) for you  
>> to try
>> to see what happens if you set all your attributes (archiveDAte,  
>> creator
>> etc) in some namespace (for instance, pib)?
>>
>> Alessandro
>
> -- 
> SY, Alex Lukin
> RIPE NIC HDL: LEXA1-RIPE


Re: exportDocumentView() and Jaxb - help needed

Posted by Stefan Guggisberg <st...@day.com>.
On Tue, Nov 18, 2008 at 11:54 AM, Aleksei Lukin <lu...@stu.cn.ua> wrote:
> Hello, Alessandro! Hello, colleagues!
>
> I checked sources and saw that data[] in org.xml.sax.helpers.AttributesImpl.getIndex(AttributesImpl.java:203) can not be null because thre is no NPE in Exporter, be but it is
> null anyway.
> Then I checked namespaces of ssession before doing export with SAX handler and found strange thing: there is namespace with empty prefix and empy uri!
> My namesapce and Jackrabbit's namespaces are presend and OK, but this "empty" namespace is one candidate for NPE. It does not affect export procedure that uses streams but I
> think does affect export procedure using SAX handler.
> Below is output of this piece of code:
>           String[] nsp = session.getNamespacePrefixes();
>            for (String ns : nsp) {
>                Logger.getLogger(AbstractTypeResolver.class.getName()).log(Level.FINE, "namespace: " + ns + " uri: " + ses.getNamespaceURI(ns));
>            }
> ----------- output ----------------
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: jcr uri: http://www.jcp.org/jcr/1.0
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace:  uri:  <<<<<<<<<<<<<<<<<<<<<<<<< THIS NAMESPACE IS VERY STRANGE!!!<<<<<<
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: nt uri: http://www.jcp.org/jcr/nt/1.0
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: pib uri: http://www.e-ukraine.org/datatypes/pib
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: sv uri: http://www.jcp.org/jcr/sv/1.0
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: xs uri: http://www.w3.org/2001/XMLSchema
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: ocm uri: http://jackrabbit.apache.org/ocm
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: xml uri: http://www.w3.org/XML/1998/namespace
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: fn_old uri: http://www.w3.org/2004/10/xpath-functions
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: fn uri: http://www.w3.org/2005/xpath-functions
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: mix uri: http://www.jcp.org/jcr/mix/1.0
> 18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
> FINE: namespace: rep uri: internal
> ----------------------
>
> I do not have any idea where this empty namespace comes from... I am sure I do not register it because it exists before I register my namespace or OCM namespace.
> It does exist in empty just inited repository.

the empty namespace URI is a built-in JCR namespace. it is always
mapped to the empty prefix.
for more information, see "6.3.1 Namespace Registry" in the JSR 170
specification.

cheers
stefan

>
> Jukka, if you are reding this, please point me to source where namespaces get registered in Jackrabbit. Sope piece of code registers namespace with empty name and empty uri.
>
> On Monday 17 November 2008 17:30:58 Alessandro Bologna wrote:
>> Hi Alex,
>> it's a bit of a shot in the dark, but looking at the code here
>> http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-commons/src
>>/main/java/org/apache/jackrabbit/commons/xml/Exporter.java and here:
>> http://www.docjar.com/html/api/org/xml/sax/helpers/AttributesImpl.java.html
>> I feel inclined to think that the problem is caused by your attributes to
>> be in no namespace. Would it be complicated (just to test) for you to try
>> to see what happens if you set all your attributes (archiveDAte, creator
>> etc) in some namespace (for instance, pib)?
>>
>> Alessandro
>
> --
> SY, Alex Lukin
> RIPE NIC HDL: LEXA1-RIPE
>

Re: exportDocumentView() and Jaxb - help needed

Posted by Aleksei Lukin <lu...@stu.cn.ua>.
Hello, Alessandro! Hello, colleagues!

I checked sources and saw that data[] in org.xml.sax.helpers.AttributesImpl.getIndex(AttributesImpl.java:203) can not be null because thre is no NPE in Exporter, be but it is 
null anyway.
Then I checked namespaces of ssession before doing export with SAX handler and found strange thing: there is namespace with empty prefix and empy uri!
My namesapce and Jackrabbit's namespaces are presend and OK, but this "empty" namespace is one candidate for NPE. It does not affect export procedure that uses streams but I 
think does affect export procedure using SAX handler.
Below is output of this piece of code: 
           String[] nsp = session.getNamespacePrefixes();
            for (String ns : nsp) {
                Logger.getLogger(AbstractTypeResolver.class.getName()).log(Level.FINE, "namespace: " + ns + " uri: " + ses.getNamespaceURI(ns));
            }
----------- output ----------------
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: jcr uri: http://www.jcp.org/jcr/1.0
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace:  uri:  <<<<<<<<<<<<<<<<<<<<<<<<< THIS NAMESPACE IS VERY STRANGE!!!<<<<<<
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: nt uri: http://www.jcp.org/jcr/nt/1.0
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: pib uri: http://www.e-ukraine.org/datatypes/pib
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: sv uri: http://www.jcp.org/jcr/sv/1.0
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: xs uri: http://www.w3.org/2001/XMLSchema
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: ocm uri: http://jackrabbit.apache.org/ocm
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: xml uri: http://www.w3.org/XML/1998/namespace
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: fn_old uri: http://www.w3.org/2004/10/xpath-functions
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: fn uri: http://www.w3.org/2005/xpath-functions
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: mix uri: http://www.jcp.org/jcr/mix/1.0
18 лист 2008 12:29:27 ua.org.dg.semaril.helpers.AbstractTypeResolver logNamespaces
FINE: namespace: rep uri: internal
----------------------

I do not have any idea where this empty namespace comes from... I am sure I do not register it because it exists before I register my namespace or OCM namespace.
It does exist in empty just inited repository.

Jukka, if you are reding this, please point me to source where namespaces get registered in Jackrabbit. Sope piece of code registers namespace with empty name and empty uri.

On Monday 17 November 2008 17:30:58 Alessandro Bologna wrote:
> Hi Alex,
> it's a bit of a shot in the dark, but looking at the code here
> http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-commons/src
>/main/java/org/apache/jackrabbit/commons/xml/Exporter.java and here:
> http://www.docjar.com/html/api/org/xml/sax/helpers/AttributesImpl.java.html
> I feel inclined to think that the problem is caused by your attributes to
> be in no namespace. Would it be complicated (just to test) for you to try
> to see what happens if you set all your attributes (archiveDAte, creator
> etc) in some namespace (for instance, pib)?
>
> Alessandro

-- 
SY, Alex Lukin
RIPE NIC HDL: LEXA1-RIPE

Re: Re: exportDocumentView() and Jaxb - help needed

Posted by Alessandro Bologna <al...@gmail.com>.
Hi Alex,
it's a bit of a shot in the dark, but looking at the code here
http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/xml/Exporter.java
and here:
http://www.docjar.com/html/api/org/xml/sax/helpers/AttributesImpl.java.html
I feel inclined to think that the problem is caused by your attributes to be
in no namespace. Would it be complicated (just to test) for you to try to
see what happens if you set all your attributes (archiveDAte, creator
etc) in some namespace (for instance, pib)?

Alessandro

On Fri, Nov 14, 2008 at 4:23 AM, Aleksei Lukin <lu...@stu.cn.ua> wrote:

> Hi there!
>
> Thank you for response, I attached xml that
>  jcr_session.exportDocumentView() puts to file.
> Jackrabbit adds a lot of its own namespacxes but my namespace is registerd
> and present as
> xmlns:pib="http://www.e-ukraine.org/datatypes/pib"
>
> May be other namespaces are causing JAXB exception becuase JAXB does not
> know how to operate with?
> But I really do not want to put all those XSDs into my app...
>
> On Friday 14 November 2008 00:39:18 Alessandro Bologna wrote:
> > Could you possibly just post the (whole) XML that comes out from
> > jcr_session.exportDocumentView(path, output, false, false)?
> > It would help a lot too see what could be your issue. It could have to do
> > with how namespace are registered in your repository, I had once a maybe
> > similar issue.
> >
> > Alessandro
> >
> > On Thu, Nov 13, 2008 at 3:13 PM, Aleksei Lukin <lu...@stu.cn.ua> wrote:
> > > Hi, all!
> > >
> > > This little piece of code worked fine with jackrabbit 1.4:
> > >
> > >            Unmarshaller umr = getUnmarshaller();
> > >            UnmarshallerHandler ctxh = umr.getUnmarshallerHandler();
> > >            jcr_session.exportDocumentView(path, ctxh, false, false);
> > >            Object res = ctxh.getResult();
> > >
> > > This little fragment allowed me fast object construction from
> repository
> > > xml representation.
> > >
> > > But now with 1.5b2 and java 1.6 native jaxb it gives
> NullPointerException
> > > somewhere inside of  jaxb implementation.
> > > There is trace:
> > >
> > > org.xml.sax.helpers.AttributesImpl.getIndex(AttributesImpl.java:203)
> > >
> > >
> > >
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor$Att
> > >ributesImpl.getIndex(InterningXmlVisitor.java:76)
> > >
> > >
> > >
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.selectLoad
> > >er(XsiNilLoader.java:26)
> > >
> > >
> > >
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.ProxyLoader.startElemen
> > >t(ProxyLoader.java:17)
> > >
> > >
> > >
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._s
> > >tartElement(UnmarshallingContext.java:402)
> > >
> > >
> > >
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.st<http://com.sun.xml.internal.bind.v2.runtime.unmarshaller.unmarshallingcontext.st/>
> > >artElement(UnmarshallingContext.java:380)
> > >
> > >
> > >
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.sta
> > >rtElement(InterningXmlVisitor.java:35)
> > >
> > >
> > >
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startEleme
> > >nt(SAXConnector.java:101)
> > >
> > >
> > >
> org.apache.jackrabbit.commons.xml.Exporter.startElement(Exporter.java:438
> > >)
> > >
> > >
> > >
> org.apache.jackrabbit.commons.xml.DocumentViewExporter.exportNode(Documen
> > >tViewExporter.java:76) ....
> > > Could somebody point me where to find loosed ends? I googled entire day
> > > and found nothing.
> > > I ended changing code that uses temporary XML file and it works but too
> > > slooooow. :(
> > >
> > > Ofcourse I filled JIRA issue but I'm not sure it is jackrabbit only bug
> > > and developers have time for such exotic use case.
> > >
> > > --
> > > SY, Alex Lukin
> > > RIPE NIC HDL: LEXA1-RIPE
>
> --
>  SY, Alex Lukin
> RIPE NIC HDL: LEXA1-RIPE
>

Re: Re: exportDocumentView() and Jaxb - help needed

Posted by Aleksei Lukin <lu...@stu.cn.ua>.
Hi there!

Thank you for response, I attached xml that  jcr_session.exportDocumentView() puts to file.
Jackrabbit adds a lot of its own namespacxes but my namespace is registerd and present as 
xmlns:pib="http://www.e-ukraine.org/datatypes/pib"

May be other namespaces are causing JAXB exception becuase JAXB does not know how to operate with?
But I really do not want to put all those XSDs into my app... 

On Friday 14 November 2008 00:39:18 Alessandro Bologna wrote:
> Could you possibly just post the (whole) XML that comes out from
> jcr_session.exportDocumentView(path, output, false, false)?
> It would help a lot too see what could be your issue. It could have to do
> with how namespace are registered in your repository, I had once a maybe
> similar issue.
>
> Alessandro
>
> On Thu, Nov 13, 2008 at 3:13 PM, Aleksei Lukin <lu...@stu.cn.ua> wrote:
> > Hi, all!
> >
> > This little piece of code worked fine with jackrabbit 1.4:
> >
> >            Unmarshaller umr = getUnmarshaller();
> >            UnmarshallerHandler ctxh = umr.getUnmarshallerHandler();
> >            jcr_session.exportDocumentView(path, ctxh, false, false);
> >            Object res = ctxh.getResult();
> >
> > This little fragment allowed me fast object construction from repository
> > xml representation.
> >
> > But now with 1.5b2 and java 1.6 native jaxb it gives NullPointerException
> > somewhere inside of  jaxb implementation.
> > There is trace:
> >
> > org.xml.sax.helpers.AttributesImpl.getIndex(AttributesImpl.java:203)
> >
> > 
> > com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor$Att
> >ributesImpl.getIndex(InterningXmlVisitor.java:76)
> >
> > 
> > com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.selectLoad
> >er(XsiNilLoader.java:26)
> >
> > 
> > com.sun.xml.internal.bind.v2.runtime.unmarshaller.ProxyLoader.startElemen
> >t(ProxyLoader.java:17)
> >
> > 
> > com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._s
> >tartElement(UnmarshallingContext.java:402)
> >
> > 
> > com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.st
> >artElement(UnmarshallingContext.java:380)
> >
> > 
> > com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.sta
> >rtElement(InterningXmlVisitor.java:35)
> >
> > 
> > com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startEleme
> >nt(SAXConnector.java:101)
> >
> > 
> > org.apache.jackrabbit.commons.xml.Exporter.startElement(Exporter.java:438
> >)
> >
> > 
> > org.apache.jackrabbit.commons.xml.DocumentViewExporter.exportNode(Documen
> >tViewExporter.java:76) ....
> > Could somebody point me where to find loosed ends? I googled entire day
> > and found nothing.
> > I ended changing code that uses temporary XML file and it works but too
> > slooooow. :(
> >
> > Ofcourse I filled JIRA issue but I'm not sure it is jackrabbit only bug
> > and developers have time for such exotic use case.
> >
> > --
> > SY, Alex Lukin
> > RIPE NIC HDL: LEXA1-RIPE

-- 
SY, Alex Lukin
RIPE NIC HDL: LEXA1-RIPE

Re: exportDocumentView() and Jaxb - help needed

Posted by Alessandro Bologna <al...@gmail.com>.
Could you possibly just post the (whole) XML that comes out from
jcr_session.exportDocumentView(path, output, false, false)?
It would help a lot too see what could be your issue. It could have to do
with how namespace are registered in your repository, I had once a maybe
similar issue.

Alessandro






On Thu, Nov 13, 2008 at 3:13 PM, Aleksei Lukin <lu...@stu.cn.ua> wrote:

> Hi, all!
>
> This little piece of code worked fine with jackrabbit 1.4:
>
>            Unmarshaller umr = getUnmarshaller();
>            UnmarshallerHandler ctxh = umr.getUnmarshallerHandler();
>            jcr_session.exportDocumentView(path, ctxh, false, false);
>            Object res = ctxh.getResult();
>
> This little fragment allowed me fast object construction from repository
> xml representation.
>
> But now with 1.5b2 and java 1.6 native jaxb it gives NullPointerException
> somewhere inside of  jaxb implementation.
> There is trace:
>
> org.xml.sax.helpers.AttributesImpl.getIndex(AttributesImpl.java:203)
>
>  com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor$AttributesImpl.getIndex(InterningXmlVisitor.java:76)
>
>  com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.selectLoader(XsiNilLoader.java:26)
>
>  com.sun.xml.internal.bind.v2.runtime.unmarshaller.ProxyLoader.startElement(ProxyLoader.java:17)
>
>  com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:402)
>
>  com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:380)
>
>  com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.startElement(InterningXmlVisitor.java:35)
>
>  com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:101)
>
>  org.apache.jackrabbit.commons.xml.Exporter.startElement(Exporter.java:438)
>
>  org.apache.jackrabbit.commons.xml.DocumentViewExporter.exportNode(DocumentViewExporter.java:76)
>      ....
> Could somebody point me where to find loosed ends? I googled entire day and
> found nothing.
> I ended changing code that uses temporary XML file and it works but too
> slooooow. :(
>
> Ofcourse I filled JIRA issue but I'm not sure it is jackrabbit only bug and
> developers have time for such exotic use case.
>
> --
> SY, Alex Lukin
> RIPE NIC HDL: LEXA1-RIPE
>