Seems to cause the same error. I'll test some more tomorrow but it's getting late here...
Thanks for the suggestion. On Tue, Mar 30, 2010 at 12:44 AM, <[email protected]> wrote: > Righto, then add jackrabbit-api-2.0.0.jar and > jackrabbit-jcr-commons-2.0.0.jar into the same directory and see what > happens. > > (This is what I have in my servlet application). > > Rob Brown <[email protected]> wrote on 30/03/2010 05:39:49 PM: > > > > From: Rob Brown <[email protected]> > > > To: [email protected] > > Date: 30/03/2010 05:40 PM > > Subject: Re: NoClassDefFoundError accessing jackrabbit jar from > > servlet [SEC=UNCLASSIFIED] > > > > Good question - this results in a different error: > > > > java.lang.NoClassDefFoundError: > org/apache/jackrabbit/core/TransientRepository > > > > > > > > > > On Mon, Mar 29, 2010 at 11:46 PM, <[email protected]> wrote: > > > > > What happens if you put the specific jar file jcr-2.0.jar in the > > > WEB-INF/lib directory? > > > > > > > > > > > > > > > Rob Brown <[email protected]> wrote on 30/03/2010 03:13:34 PM: > > > > > > > From: Rob Brown <[email protected]> > > > > To: [email protected] > > > > 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 > > > > > > > > > -- > > > This message contains privileged and confidential information only > > > for use by the intended recipient. If you are not the intended > > > recipient of this message, you must not disseminate, copy or use > > > it in any manner. If you have received this message in error, > > > please advise the sender by reply e-mail. Please ensure all > > > e-mail attachments are scanned for viruses prior to opening or > > > using. > > > > > > > > > -- > This message contains privileged and confidential information only > for use by the intended recipient. If you are not the intended > recipient of this message, you must not disseminate, copy or use > it in any manner. If you have received this message in error, > please advise the sender by reply e-mail. Please ensure all > e-mail attachments are scanned for viruses prior to opening or > using. > >
