Hi Woonsan

I can work with that.

But our requirement is slightly different, we will not be able to embed
jackrabbit inside the webapp.
So I will have to deploy jackrabbit separately.

As per our previous discussion,

There are 2 servlets defined in web.xml of my jackrabbit-webapp module.
<servlet-class>org.apache.jackrabbit.j2ee.RepositoryAccessServlet</servlet-class>
<servlet-class>org.apache.jackrabbit.j2ee.RepositoryStartupServlet</servlet-class>


Are you asking me to discard this and use
org.apache.jackrabbit.servlet.jackrabbit.JackrabbitRepositoryServlet
instead ?

Thanks
Jimmy

On Tue, Jun 25, 2019 at 6:10 PM Woonsan Ko <[email protected]> wrote:

> On Tue, Jun 25, 2019 at 1:47 AM jimy page <[email protected]> wrote:
> >
> > Hi Woonsan
> >
> > Are you saying we need to use
> >
> http://svn.apache.org/repos/asf/jackrabbit/site/live/jcr/embedded-repository.html
> > this deployment model instead of current one I am using ?
>
> Yes, that's what I think is the solution as described in the "Embedded
> repository in a web application" section.
> If you configure the StatisticsServlet in the web.xml where
> org.apache.jackrabbit.servlet.jackrabbit.JackrabbitRepositoryServlet
> is defined, the JackrabbitRepositoryServlet will expose the
> RepositoryContext through servletContext, and so the StatisticsServlet
> won't fail.
>
> "repository lock" happens when you initialize a new repository while
> the data directory is already used by another repository instance. You
> shouldn't try to recreate a repository with the data directory.
> StatisticsServlet just tries to retrieve the RepositoryContext object
> initialized by the existing repository. Don't need to customize
> StatisticsServlet to recreate a repository with RepositoryConfig.
>
> Regards,
>
> Woonsan
>
> >
> > Currently I am deploying jackrabbit-webapp.
> >
> > Thanks
> > Jimmy
> >
> > On Tue, Jun 25, 2019 at 9:15 AM jimy page <[email protected]> wrote:
> >
> > > Hi Woonsan
> > >
> > > Thanks for your input.
> > >
> > > So I can write my custom webapplication with
> JackrabbitRepositoryServlet.
> > > But I will still need to deploy jackrabbit-webapp for all the other
> > > functionalities.
> > > In that case will not my custom-app still suffer from repository lock
> as
> > > jackrabbit-webapp will still have lock on the repo ?
> > >
> > > Regards
> > > Jimmy
> > >
> > > On Mon, Jun 24, 2019 at 9:20 PM Woonsan Ko <[email protected]> wrote:
> > >
> > >> On Mon, Jun 24, 2019 at 11:02 AM jimy page <[email protected]>
> wrote:
> > >> >
> > >> > Thanks Woonsan for your quick response.
> > >> >
> > >> > I tried configuring StatisticsServlet. What I did was, in
> > >> jackrabbit-webapp
> > >> > I have added StatisticsServlet.
> > >> > But RepositoryContext context =
> > >> >
> (RepositoryContext)this.getServletContext().getAttribute(name);----> at
> > >> > this line I am unable to retrievecontext.
> > >> > This is always coming null.
> > >>
> > >> jackrabbit-webapp doesn't seem to expose a RepositoryContext. So, I
> > >> don't think you can use StatisticsServlet with it.
> > >> You can perhaps use JackrabbitRepositoryServlet [1] in a custom web
> > >> application to initialize your repository instance instead of
> > >> jackrabbit-webapp. Then RepositoryContext will become available.
> > >>
> > >> Regards,
> > >>
> > >> Woonsan
> > >>
> > >> [1]
> > >>
> http://jackrabbit.apache.org/api/trunk/org/apache/jackrabbit/servlet/jackrabbit/JackrabbitRepositoryServlet.html
> > >>
> > >> >
> > >> > So I did it in a hacky way, created a new MetricsServlet overriding
> > >> > StatisticsServlet's methods.
> > >> >
> > >> >
> > >> > So my question is, what is the best way to retrieve RepositoryConfig
> > >> object
> > >> > ?
> > >> >
> > >> > The following code is giving me stat for newly created repo:
> > >> >
> > >> > RepositoryConfig config = null;
> > >> >     try {
> > >> >       config = RepositoryConfig.create(new
> > >> File("/Users/xxxxx/repo2"));//
> > >> >       //**some try
> > >> >       // **some try ends here
> > >> >     } catch (ConfigurationException e) {
> > >> >       e.printStackTrace();
> > >> >     }
> > >> >     RepositoryContext context = null;
> > >> >     try {
> > >> >       context = RepositoryContext.create(config);
> > >> >       if (context != null) {
> > >> >         RepositoryStatistics statistics =
> > >> context.getRepositoryStatistics();
> > >> > ==========================>
> > >> >
> > >> > *I need help in how to instantiate RepositoryConfig, which will
> point to
> > >> > the same repo that my jackrabbit instance is using.*
> > >> >
> > >> > *There is no documentation found for this :(.*
> > >> >
> > >> >
> > >> >
> > >> > *Thanks *
> > >> > *Jimy*
> > >> >
> > >> >
> > >> >
> > >> > On Mon, Jun 24, 2019 at 7:01 PM Woonsan Ko <[email protected]>
> wrote:
> > >> >
> > >> > > On Mon, Jun 24, 2019 at 7:19 AM jimy page <[email protected]>
> > >> wrote:
> > >> > > >
> > >> > > > I have jackrabbit runnig with repo /users/xyz/repo1
> > >> > > > Inside this I have repository.xml
> > >> > > >
> > >> > > >
> > >> > > > I want to call
> > >> org.apache.jackrabbit.servlet.jackrabbit.StatisticsServlet
> > >> > > > to show different metrices.
> > >> > > >
> > >> > > >
> > >> > > > *But the problem I am facing here is: --> In order to create
> > >> > > > RepositoryConfig, I need to pass in the repo folder path, but
> > >> Jackrabbit
> > >> > > > process is already kept it locked. What is the alternative here
> ?*
> > >> > > >
> > >> > > > *I can copy over "/Users/xyz/repository/", to some other folder
> and
> > >> use
> > >> > > > that, but my question is in that case will I get all the
> repository
> > >> > > > information ?*
> > >> > >
> > >> > > I don't think so.
> > >> > > If you copy the data such as directories and *recreate* a. new
> > >> > > repository instance, it will show new statistics of the new
> running
> > >> > > repository.
> > >> > > I think you should just configure the StatisticsServlet on the
> same
> > >> > > web application which initializes the repository.
> > >> > >
> > >> > > Regards,
> > >> > >
> > >> > > Woonsan
> > >> > >
> > >> > > >
> > >> > > > ----> Here is my sample code
> > >> > > >
> > >> > > > HttpServletRequest request, HttpServletResponse response)
> > >> > > >       throws ServletException, IOException {
> > >> > > >     String klass = RepositoryContext.class.getName();
> > >> > > >     String name = getServletConfig().getInitParameter(klass);
> > >> > > >     if (name == null) {
> > >> > > >       name = klass;
> > >> > > >     }
> > >> > > >
> > >> > > > //    RepositoryContext context = (RepositoryContext)
> > >> > > > //        getServletContext().getAttribute(name);
> > >> > > >     RepositoryConfig config = null;
> > >> > > >     try {
> > >> > > >       config = RepositoryConfig.create(new
> > >> > > File("/Users/xyz/repository/"));
> > >> > > >       //**some try
> > >> > > >       // **some try ends here
> > >> > > >     } catch (ConfigurationException e) {
> > >> > > >       e.printStackTrace();
> > >> > > >     }
> > >> > > >     RepositoryContext context = null;
> > >> > > >     try {
> > >> > > >       context = RepositoryContext.create(config);
> > >> > >
> > >>
> > >
>

Reply via email to