jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ross.Dy...@ipaustralia.gov.au
Subject Re: NoClassDefFoundError accessing jackrabbit jar from servlet [SEC=UNCLASSIFIED]
Date Tue, 30 Mar 2010 05:46:41 GMT
What happens if you put the specific jar file jcr-2.0.jar in the 
WEB-INF/lib directory?




Rob Brown <rlb.south@gmail.com> wrote on 30/03/2010 03:13:34 PM:

> From: Rob Brown <rlb.south@gmail.com>
> To: users@jackrabbit.apache.org
> Date: 30/03/2010 03:14 PM
> Subject: NoClassDefFoundError accessing jackrabbit jar from servlet
> 
> Hello,
> 
> My first attempt at sending this failed b/c I attached a zip file. Sorry 
if
> this is a duplicate message for some.
> 
> I'm getting the above mentioned error when trying to access a repository
> using jackrabbit-standalone-2.0.0.jar from a servlet. I didn't use the
> jackrabbit war because I already have a thick client app working and I 
want
> to reuse as much code as possible. I just assumed doing this was 
possible.
> 
> If I do the exact same thing from a thick client (Swing) window the 
error
> does not occur. The problem seems to be related to class loading from a
> servlet. I have got the same results in Tomcat 5.5 and in the eclipse
> embedded web server.
> 
> To test I created a small web application. Since I cannot attach a zip 
file
> I will just copy the doPost() method below:
> 
>     protected void doPost(HttpServletRequest request, 
HttpServletResponse
> response) throws ServletException, IOException {
> 
>         Repository repository = new TransientRepository(
>                 "repository.xml", //embedded within the war
>                 "path/to/home/dir");
>             Session session = null;
>         try {
>             session = repository.login();
>             System.out.println("root node identifier: " +
> session.getRootNode().getIdentifier());
>         } catch (Exception e) {
>             e.printStackTrace();
>         } finally {
>             session.logout();
>         }
>     }
> 
> When I post to this servlet from an html form the exception has 2 parts:
>     java.lang.NoClassDefFoundError: javax/jcr/Repository
>     java.lang.ClassNotFoundException: javax.jcr.Repository
> 
> I found a link to a similar issue that may relate to what's happening:
> http://www.eclipse.org/forums/index.php?t=tree&goto=87658&#page_top
> 
> The first reply to this query says:
> "That can happen e.g. if your class is found but it executes a static
> initialiser (i.e. a public static final assignment) that uses another 
class
> that's not exported by the system bundle."
> 
> I'm not using Equinox or anything other than Eclipse for EE developers.
> Perhaps it's related to a bundle issue within jackrabbit.
> 
> Is accessing a repository in this way from a servlet (i.e. using the
> jackrabbit jar not war) not a supported function, or just not a good 
idea in
> general? My goals are to keep the code as simple as possible and 
minimize
> the attack surface for troublemakers (i.e. I do not want to expose REST 
or
> any other jackrabbit servlet api to an experienced hacker who might
> recognize what library I am using). I'm handling all user authentication 
in
> my app already and only want my java domain objects to make calls to the
> repository.
> 
> Thanks in advance for any assistance you can offer. Comments about the
> security implications of this approach vs. the jackrabbit war are also 
most
> welcome.
> 
> Rob

Mime
View raw message