You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Milan Trajkovic <mi...@gmail.com> on 2006/07/12 12:32:06 UTC

JackRabbit - Tomcat two problems

Hello.
I have Web application that should use jackrabbit repository.
Web server is Tomcat 5.5.15, Jackrabbit 1.0.1 distribution.

I am trying to make model 1 deployment to run.
1. I have followed instructions on site (copied necessary files, added
configuration to server.xml, and web.xml). However, as I have tried to
get (via JNDI) repository, I have got ConfigurationException:
Premature end of file exception. After several hours, I concluded that
message, even if it is thrown from configuration class, actually means
that there is no workspace.xml file in <REP_HOME>/workspace/default
i.e. there is file with that name, but with zero length. I have copied
file from my standalone repository (since configuration is basically
the same) and I have managed to start application. (In stand alone
test application,
that file was automatically created in the repository - so I have
expected that in webapp same will happen). Is there something that I
have done wrong?

2. As application is started, I have run few test methods (put, fetch
node etc.), and when I try to shut down Tomcat I get NPE, from
shutdown call

java.lang.NullPointerException at
org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:839)

I have attached source, and debugged code and it seems that logger is
null and it throws NPE.
I have also tried to add logger servlet from jackrabbit web
application, and to change my logger  configuration, but exception is
still there.
I would appreciate any help.

Regards,
Milan

Re: WebDav Client Example

Posted by Shanmugam Gopal <ha...@hotmail.com>.
Hi,

Once the web application is deployed in Tomcat, It will configure the 
repository under ../bin/jackrabit with the workspace called "default".

If you want to programatically add noes or files,
1) Can get the repository by using the code given 
below(RepositoryAccessServlet)
2) Using Jackrabbit API we can add nodes or files to the repository.

Otherwise we can browse the repository via any WebDAV Client.(Dreamweaver, 
FrontPage) etc.
In Dreamweaver, using manage sites option we can browse jackrabbit 
repository.

Also we can browse the repository content from browser by giving the url
http://localhost:8080/<webapp>/repository/<Workspacename>

Ex: http://localhost:8080/jack101/repository/default

Hoe this will help you.

Regards,
Shan




>From: Eric Peukert <er...@mail.inf.tu-dresden.de>
>Reply-To: users@jackrabbit.apache.org
>To: users@jackrabbit.apache.org
>Subject: Re: WebDav Client Example
>Date: Wed, 12 Jul 2006 14:29:52 +0200
>
>
>The WebDav Servlet puts a Repository Object in the JNDI-Context.  
>(Parameters specified in the web.xml)
>
>You can retrieve it from the JNDI-Context and then do what you like  to do 
>on the Repository.
>One idea is taking a look into the sources of the webdav-servlet.
>
>RepositoryAccessServlet:
>    /**
>      * tries to retrieve the repository using RMI
>      */
>     private static Repository getRepositoryByJNDI(ServletContext ctx) {
>         // acquire via JNDI
>         String repositoryName = (String) ctx.getAttribute 
>(CTX_ATTR_REPOSITORY_NAME);
>         InitialContext jndiContext = (InitialContext)  
>ctx.getAttribute(CTX_ATTR_REPOSITORY_JNDI_CONTEXT);
>         if (jndiContext == null) {
>             return null;
>         }
>         try {
>             Repository r = (Repository) jndiContext.lookup 
>(repositoryName);
>             log.info("Acquired repository via JNDI.");
>             return r;
>         } catch (NamingException e) {
>             log.error("Error while retrieving repository using JNDI  
>(name=" + repositoryName + "): " + e);
>             return null;
>         }
>     }
>
>
>Example Code for Repository Access can be found in the wiki:
>http://wiki.apache.org/jackrabbit/ExamplesPage
>
>hope this helps,
>
>Eric
>
>
>
>
>
>Am 12.07.2006 um 13:12 schrieb Umesh Singh:
>
>>Hi,
>>
>>I am able to configure the JackRabbit on Tomcat. I am also able to  enable 
>>the WebDab servlet using the given war in the samples.
>>
>>Can someone please point me to some sample client code to access  the 
>>WebDav enabled repository? Cant find any sample to access the  WebDav 
>>enabled repository using client code.
>>
>>Regards,
>>Umesh
>>
>>iO global limited, Registered in England No. 05269056 Reg. Offices:  G10 
>>B83 Columba House, Martlesham Heath, Ipswich, Suffolk. IP5 3RE
>>
>>This electronic message contains information from iO global limited  which 
>>may be privileged or confidential. The information is  intended to be for 
>>the use of the individual(s) or entity named  above. If you are not the 
>>intended recipient be aware that any  disclosure, copying, distribution or 
>>use of the contents of this  information is prohibited. If you have 
>>received this electronic  message in error, please notify us by telephone 
>>or email (to the  numbers or address above) immediately.
>>
>>This email does not constitute a contract. E&OE
>

_________________________________________________________________
Shah Rukh fan? Know all about the Baadshah of Bollywood. On MSN Search 
http://server1.msn.co.in/profile/shahrukh.asp


Re: WebDav Client Example

Posted by Eric Peukert <er...@mail.inf.tu-dresden.de>.
The WebDav Servlet puts a Repository Object in the JNDI-Context.  
(Parameters specified in the web.xml)

You can retrieve it from the JNDI-Context and then do what you like  
to do on the Repository.
One idea is taking a look into the sources of the webdav-servlet.

RepositoryAccessServlet:
    /**
      * tries to retrieve the repository using RMI
      */
     private static Repository getRepositoryByJNDI(ServletContext ctx) {
         // acquire via JNDI
         String repositoryName = (String) ctx.getAttribute 
(CTX_ATTR_REPOSITORY_NAME);
         InitialContext jndiContext = (InitialContext)  
ctx.getAttribute(CTX_ATTR_REPOSITORY_JNDI_CONTEXT);
         if (jndiContext == null) {
             return null;
         }
         try {
             Repository r = (Repository) jndiContext.lookup 
(repositoryName);
             log.info("Acquired repository via JNDI.");
             return r;
         } catch (NamingException e) {
             log.error("Error while retrieving repository using JNDI  
(name=" + repositoryName + "): " + e);
             return null;
         }
     }


Example Code for Repository Access can be found in the wiki:
http://wiki.apache.org/jackrabbit/ExamplesPage

hope this helps,

Eric





Am 12.07.2006 um 13:12 schrieb Umesh Singh:

> Hi,
>
> I am able to configure the JackRabbit on Tomcat. I am also able to  
> enable the WebDab servlet using the given war in the samples.
>
> Can someone please point me to some sample client code to access  
> the WebDav enabled repository? Cant find any sample to access the  
> WebDav enabled repository using client code.
>
> Regards,
> Umesh
>
> iO global limited, Registered in England No. 05269056 Reg. Offices:  
> G10 B83 Columba House, Martlesham Heath, Ipswich, Suffolk. IP5 3RE
>
> This electronic message contains information from iO global limited  
> which may be privileged or confidential. The information is  
> intended to be for the use of the individual(s) or entity named  
> above. If you are not the intended recipient be aware that any  
> disclosure, copying, distribution or use of the contents of this  
> information is prohibited. If you have received this electronic  
> message in error, please notify us by telephone or email (to the  
> numbers or address above) immediately.
>
> This email does not constitute a contract. E&OE


WebDav Client Example

Posted by Umesh Singh <um...@iogloballtd.com>.
Hi,

I am able to configure the JackRabbit on Tomcat. I am also able to 
enable the WebDab servlet using the given war in the samples.

Can someone please point me to some sample client code to access the 
WebDav enabled repository? Cant find any sample to access the WebDav 
enabled repository using client code.

Regards,
Umesh

iO global limited, Registered in England No. 05269056 Reg. Offices: G10 B83 Columba House, Martlesham Heath, Ipswich, Suffolk. IP5 3RE

This electronic message contains information from iO global limited which may be privileged or confidential. The information is intended to be for the use of the individual(s) or entity named above. If you are not the intended recipient be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic message in error, please notify us by telephone or email (to the numbers or address above) immediately.

This email does not constitute a contract. E&OE

Re: JackRabbit - Tomcat two problems

Posted by Milan Trajkovic <mi...@gmail.com>.
Thank you for response.
All libraries are located within web application.
I took jars, from jackrabbit.war and added specific
filter required libraries (poi, pdfbox etc.).

I will try to patch slf4j (or less likely Tomcat).

I would also like to repeat my previous question:
Is it safe to have one reference of repository object (in singleton),
and use it within web application? Each business method would get that
reference and
create Session object on the beginning of the method, and logout on the end.

Regards

2006/7/17, Jukka Zitting <ju...@gmail.com>:
> Hi,
>
> On 7/17/06, Milan Trajkovic wrote:
> > I have attached source to slf4j and tried to debug. It seems that all
> > loggers are released, before actual shutdown method is called (and
> > executed), so log instance is null.
>
> This sounds familiar with a problem reported as Tomcat issue #38579
> [1], or originally as SLF4J issue #15 [2]. Unfortunately I don't think
> the fix has yet made it to an official Tomcat release. Do you have all
> the jar files within the webapp, or some (slf4j, jackrabbit-core, some
> other) outside it?
>
> [1] http://issues.apache.org/bugzilla/show_bug.cgi?id=38579
> [2] http://bugzilla.slf4j.org/show_bug.cgi?id=15
>
> BR,
>
> Jukka Zitting
>

Re: JackRabbit - Tomcat two problems

Posted by Marcel Reutegger <ma...@gmx.net>.
Milan Trajkovic wrote:
> Could you point me to the exact version of java file RepositryImpl,
> that is used for 1.0.1 version of core. 839 line in version that I
> have is not exactly log.info...statement,

here you go:
http://svn.apache.org/repos/asf/jackrabbit/tags/1.0.1/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java

regards
  marcel

Re: JackRabbit - Tomcat two problems

Posted by Milan Trajkovic <mi...@gmail.com>.
Hello.
Thanks for the point. I have added servlet that controls startup and shutdown,
and it seems to work. NPE is gone. Thank everybody for help again.

Yes, the documentation could be a little more explicit on this.

Kind regards,
Milan

2006/7/23, Jukka Zitting :
> Hi,
>
> Ah, that explains the issue. The default JVM shutdown hook in
> RepositoryImpl is way too late for shutting down the repository within
> a web application. You need to explicitly call
> RepositoryImpl.shutdown() in a Servelt.destroy() or a similar context.
> Normally this is best handled by the same servlet that instantiates
> the repository in the first place.
>
> It seems that this information is not included in the model 1 howto on
> the web site. Sorry for that, I'll go on and fix the site.
>
> BR,
>
> Jukka Zitting
>
> --
> Yukatan - http://yukatan.fi/ - info@yukatan.fi
> Software craftsmanship, JCR consulting, and Java development
>

Re: JackRabbit - Tomcat two problems

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

On 7/21/06, Milan Trajkovic <mi...@gmail.com> wrote:
> I have deployed Jackrabbit in model 1 deployment (all jars within WEB-INF/lib).
> It is accessed through JNDI (Repository reference is held in singleton).
> When Tomcat is shut down Jackrabbit sequence is started, but obviously
> shutdown is called (as result of shutdown hook of JVM), after
> nullifying log instances . In Tomcat 5.5.17 patch that was mentioned
> (regarding slf4j) is applied (I have checked src), but it does not
> address this issue :(.

Ah, that explains the issue. The default JVM shutdown hook in
RepositoryImpl is way too late for shutting down the repository within
a web application. You need to explicitly call
RepositoryImpl.shutdown() in a Servelt.destroy() or a similar context.
Normally this is best handled by the same servlet that instantiates
the repository in the first place.

It seems that this information is not included in the model 1 howto on
the web site. Sorry for that, I'll go on and fix the site.

BR,

Jukka Zitting

-- 
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development

Re: JackRabbit - Tomcat two problems

Posted by Milan Trajkovic <mi...@gmail.com>.
Yes, that is the line  (I have checked  with 1.0.1 code base).

log instance is null and cause NPE.

I have deployed Jackrabbit in model 1 deployment (all jars within WEB-INF/lib).
It is accessed through JNDI (Repository reference is held in singleton).
When Tomcat is shut down Jackrabbit sequence is started, but obviously
shutdown is called (as result of shutdown hook of JVM), after
nullifying log instances . In Tomcat 5.5.17 patch that was mentioned
(regarding slf4j) is applied (I have checked src), but it does not
address this issue :(.

I have also tried to replace log calls within RepositoryImpl, and
related classes with
System.out.println(). After few replacements, that worked well at this place

org.apache.jackrabbit.core.query.lucene.IndexMerger.dispose(IndexMerger.java:206)

ClassNotFoundException occurs
for
org/apache/commons/collections/buffer/UnboundedFifoBuffer$1
(commons-collections is present at WEB-INF/lib).

So, it is probably another class load issue, that is not manifested
earlier, since execution never reached that point (due to NPE).

Regards,
Milan


2006/7/21, Jukka Zitting :
> The line you're looking for is:
>
>         log.info("Shutting down repository...");
>
> It seems that Tomcat has already cleared the "private static Logger
> log" variable when the shutdown() method gets called. This certainly
> should not happen. Either Tomcat moves too fast or for some reason the
> shutdown() method gets called too late.
>
> BR,
>
> Jukka Zitting
>
> --
> Yukatan - http://yukatan.fi/ - info@yukatan.fi
> Software craftsmanship, JCR consulting, and Java development
>

Re: JackRabbit - Tomcat two problems

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

On 7/21/06, Milan Trajkovic <mi...@gmail.com> wrote:
> Could you point me to the exact version of java file RepositryImpl,
> that is used for 1.0.1 version of core. 839 line in version that I
> have is not exactly log.info...statement,
> but somewhere outside shutdown method. However, stacktrace shows that
> exception is in shutdown, and debugger shows that log variable is
> null. It is first statement where NPE could be thrown.

The line you're looking for is:

        log.info("Shutting down repository...");

It seems that Tomcat has already cleared the "private static Logger
log" variable when the shutdown() method gets called. This certainly
should not happen. Either Tomcat moves too fast or for some reason the
shutdown() method gets called too late.

BR,

Jukka Zitting

-- 
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development

Re: JackRabbit - Tomcat two problems

Posted by Milan Trajkovic <mi...@gmail.com>.
Hello.
I have already tried Tomcat 5.5.17, with same results (same
NullPointerException).
I have tried to replace Tomcat class in 5.5.15, and obtained same
exception. I did not managed to replace slf4j class, since I could not
find it in distribution jar.

Further, i have checkout Jackrabbit from repository, and tried to
replace all log calls in shutdown method with System.out.println();
and (compiled with 1.4.11 java, and tried to put it to Jackrabbit core
jar, but exception remains......

java.lang.NullPointerException
at org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:839)

Could you point me to the exact version of java file RepositryImpl,
that is used for 1.0.1 version of core. 839 line in version that I
have is not exactly log.info...statement,
but somewhere outside shutdown method. However, stacktrace shows that
exception is in shutdown, and debugger shows that log variable is
null. It is first statement where NPE could be thrown.

Regards,
Milan


2006/7/20, Ceki Gulcu <ce...@qos.ch>:
> Hello Jukka,
>
> I think that Tomcat 5.5.17 contains the bug fix mentioned in issue #38579. If my
> memory serves me correctly, only TC 5.5.15 and 5.5.16 suffer from the
> afrementioned bug.
>
> Milan mentioned that he was using TomcaT 5.5.15. I suggest to upgrading to
> 5.5.17 before applying any patches.
>
> Hope this helps,

Re: JackRabbit - Tomcat two problems

Posted by Ceki Gulcu <ce...@qos.ch>.
Jukka Zitting <jukka.zitting <at> gmail.com> writes:

> This sounds familiar with a problem reported as Tomcat issue #38579
> [1], or originally as SLF4J issue #15 [2]. Unfortunately I don't think
> the fix has yet made it to an official Tomcat release. Do you have all
> the jar files within the webapp, or some (slf4j, jackrabbit-core, some
> other) outside it?

Hello Jukka,

I think that Tomcat 5.5.17 contains the bug fix mentioned in issue #38579. If my
memory serves me correctly, only TC 5.5.15 and 5.5.16 suffer from the
afrementioned bug.

Milan mentioned that he was using TomcaT 5.5.15. I suggest to upgrading to
5.5.17 before applying any patches.

Hope this helps,



Re: JackRabbit - Tomcat two problems

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

On 7/17/06, Milan Trajkovic <mi...@gmail.com> wrote:
> I have attached source to slf4j and tried to debug. It seems that all
> loggers are released, before actual shutdown method is called (and
> executed), so log instance is null.

This sounds familiar with a problem reported as Tomcat issue #38579
[1], or originally as SLF4J issue #15 [2]. Unfortunately I don't think
the fix has yet made it to an official Tomcat release. Do you have all
the jar files within the webapp, or some (slf4j, jackrabbit-core, some
other) outside it?

[1] http://issues.apache.org/bugzilla/show_bug.cgi?id=38579
[2] http://bugzilla.slf4j.org/show_bug.cgi?id=15

BR,

Jukka Zitting

Re: JackRabbit - Tomcat two problems

Posted by Milan Trajkovic <mi...@gmail.com>.
Hello again.

Here is a stack trace of Tomcat instance (configuration: Tc5.5.15,
Java 1.5, jr 1.0.1
deployed in deployment model 1), when server is shutdown.

Exception in thread "Thread-38" java.lang.NullPointerException
	at org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:839)
	at org.apache.jackrabbit.core.jndi.BindableRepository.shutdown(BindableRepository.java:261)
	at org.apache.jackrabbit.core.jndi.BindableRepository$1.run(BindableRepository.java:139)
	
	
I have created simple servlet, that put some content and fetch it from
repository,
and it works ok, shutdown is clean. However, in real application above
mentioned exception occurs.

I have attached source to slf4j and tried to debug. It seems that all
loggers are released,
before actual shutdown method is called (and executed), so log instance is null.
Is there some mechanism, or configuration so I can prevent this, since
repository cannot be cleanly
brought down (.lock file remains).


Also, I would like to know, can I safely hold global reference to the
repository in Singleton class
and use repository related methods from that class (all methods have login and
log out methods for session)?

Regards,
Milan



2006/7/13, Milan Trajkovic:
> Hello.
>
> Maybe it works with JDK 1.4, but I need Tomcat 5.5 and JDK 1.5.
> However, the other problem is much more important, since .lock file is
> left. In log it just inform that repository is not shutdown properly,
> but I fear that it also may leave data inconsistent.
>
> Regards,
> Milan
>
> 2006/7/13, Shanmugam Gopal <ha...@hotmail.com>:
> > Hi,
> >
> > I have also faced the first problem what you have mentioned. I got an error
> > like
> > "immature end of ile".
> >
> > But when I deployed the same in another machine with JDK 1,4 it works fine.
> >
> > Regards,
> > Shan
> >
>

Re: JackRabbit - Tomcat two problems

Posted by Milan Trajkovic <mi...@gmail.com>.
Hello.

Maybe it works with JDK 1.4, but I need Tomcat 5.5 and JDK 1.5.
However, the other problem is much more important, since .lock file is
left. In log it just inform that repository is not shutdown properly,
but I fear that it also may leave data inconsistent.

Regards,
Milan

2006/7/13, Shanmugam Gopal <ha...@hotmail.com>:
> Hi,
>
> I have also faced the first problem what you have mentioned. I got an error
> like
> "immature end of ile".
>
> But when I deployed the same in another machine with JDK 1,4 it works fine.
>
> Regards,
> Shan
>

RE: JackRabbit - Tomcat two problems

Posted by Shanmugam Gopal <ha...@hotmail.com>.
Hi,

I have also faced the first problem what you have mentioned. I got an error 
like
"immature end of ile".

But when I deployed the same in another machine with JDK 1,4 it works fine.

Regards,
Shan



>From: "Milan Trajkovic" <mi...@gmail.com>
>Reply-To: users@jackrabbit.apache.org
>To: users@jackrabbit.apache.org
>Subject: JackRabbit - Tomcat two problems
>Date: Wed, 12 Jul 2006 12:32:06 +0200
>
>Hello.
>I have Web application that should use jackrabbit repository.
>Web server is Tomcat 5.5.15, Jackrabbit 1.0.1 distribution.
>
>I am trying to make model 1 deployment to run.
>1. I have followed instructions on site (copied necessary files, added
>configuration to server.xml, and web.xml). However, as I have tried to
>get (via JNDI) repository, I have got ConfigurationException:
>Premature end of file exception. After several hours, I concluded that
>message, even if it is thrown from configuration class, actually means
>that there is no workspace.xml file in <REP_HOME>/workspace/default
>i.e. there is file with that name, but with zero length. I have copied
>file from my standalone repository (since configuration is basically
>the same) and I have managed to start application. (In stand alone
>test application,
>that file was automatically created in the repository - so I have
>expected that in webapp same will happen). Is there something that I
>have done wrong?
>
>2. As application is started, I have run few test methods (put, fetch
>node etc.), and when I try to shut down Tomcat I get NPE, from
>shutdown call
>
>java.lang.NullPointerException at
>org.apache.jackrabbit.core.RepositoryImpl.shutdown(RepositoryImpl.java:839)
>
>I have attached source, and debugged code and it seems that logger is
>null and it throws NPE.
>I have also tried to add logger servlet from jackrabbit web
>application, and to change my logger  configuration, but exception is
>still there.
>I would appreciate any help.
>
>Regards,
>Milan

_________________________________________________________________
How good are you in a Formula One car? Play now 
http://server1.msn.co.in/sp05/tataracing/onlinegame.asp