You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ed Rouse <er...@milner.com> on 2014/11/17 22:52:54 UTC

DirResourceSet

I have 2 different issues setting up a DirResourceSet. I have an external war file I am trying to merge into the Root of my application. I have a custom root that extends StandardRoot.


1.       DirResourceSet drs = new DirResourceSet(wsRoot, "/WEB-INF/classes/", possible.getAbsolutePath() + "/classes/", "/");

This only seems to give me the top level directory of the classes directory as indicated by drs.listWebAppPaths("/WEB-INF/classes/"). Is there a way to get it to be recursive or is it just that the listWebAppPaths doesn't show it even though it actually does it?

2.       The reason I can't check the first is because this one gives me an exception.

DirResourceSet drs = new DirResourceSet(wsRoot, "/" + possible.getName(), possible.getAbsolutePath(), "/" + possible.getName()); It looks like the one that seems to work but I get a:

SEVERE [localhost-startStop-1] null.null Error setting up class path

java.lang.IllegalStateException: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.DirResourceSet@6a38848c]

at org.apache.catalina.webresources.DirResourceSet.<init>(DirResourceSet.java:83)

I have tried to follow through the source but keep getting lost. Line 83 is when it calls Start on StandardRoot. Is it because it was already started by the first call? But then how would you add in multiple resources?



I would like to step through it in debug mode, but the test server is remote and I don't know how to set up remote debugging. And it's remote due to other required resources that are not able to run locally.



Thanks for the help.

RE: DirResourceSet

Posted by Ed Rouse <er...@milner.com>.
I still have some confusion about the DirResourceSet. When I add the /WEB-INF/classes it looks through recursively and finds all of the class files. I know because one of them adds an additional link to a menu bar and it's there. But when I add a regular directory, say /report, it only adds the first level under that. I know because when I click on the menu link I get an error saying that the task.jsp file is missing. It should be added under /report/data/duration/task.jsp. Are class files or files in WEB-INF handled differently than other files? It didn't seem so when I looked through the code, but I could be missing something.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: DirResourceSet

Posted by Ed Rouse <er...@milner.com>.

> -----Original Message-----
> From: Ed Rouse [mailto:erouse@milner.com]
> Sent: Monday, November 17, 2014 4:53 PM
> To: Tomcat Users List
> Subject: DirResourceSet
> 
> I have 2 different issues setting up a DirResourceSet. I have an
> external war file I am trying to merge into the Root of my application.
> I have a custom root that extends StandardRoot.
> 
> 
> 1.       DirResourceSet drs = new DirResourceSet(wsRoot, "/WEB-
> INF/classes/", possible.getAbsolutePath() + "/classes/", "/");
> 
> This only seems to give me the top level directory of the classes
> directory as indicated by drs.listWebAppPaths("/WEB-INF/classes/"). Is
> there a way to get it to be recursive or is it just that the
> listWebAppPaths doesn't show it even though it actually does it?
> 
> 2.       The reason I can't check the first is because this one gives
> me an exception.
> 
> DirResourceSet drs = new DirResourceSet(wsRoot, "/" +
> possible.getName(), possible.getAbsolutePath(), "/" +
> possible.getName()); It looks like the one that seems to work but I get
> a:
> 
> SEVERE [localhost-startStop-1] null.null Error setting up class path
> 
> java.lang.IllegalStateException:
> org.apache.catalina.LifecycleException: Failed to initialize component
> [org.apache.catalina.webresources.DirResourceSet@6a38848c]
> 
> at
> org.apache.catalina.webresources.DirResourceSet.<init>(DirResourceSet.j
> ava:83)
> 
> I have tried to follow through the source but keep getting lost. Line
> 83 is when it calls Start on StandardRoot. Is it because it was already
> started by the first call? But then how would you add in multiple
> resources?
> 
> 
> 
> I would like to step through it in debug mode, but the test server is
> remote and I don't know how to set up remote debugging. And it's remote
> due to other required resources that are not able to run locally.
> 
> 
> 
> Thanks for the help.


I fixed #2. Turns out I needed to use "/" for the internal path. I don't 
suppose there is a how to on using these resource sets or a details on
what the internal structure is? I think the problem for me
is the base/internal path combination. Though my guess is that it won't
recurse through the structure by default so you add the files using the 
same base with differing internal paths?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: DirResourceSet

Posted by Mark Thomas <ma...@apache.org>.
On 18/11/2014 16:50, Ed Rouse wrote:
> 
> 
>> -----Original Message-----
>> From: Mark Thomas [mailto:markt@apache.org]
>> Sent: Tuesday, November 18, 2014 5:59 AM
>> To: Tomcat Users List
>> Subject: Re: DirResourceSet
>>
>> On 17/11/2014 22:52, Ed Rouse wrote:
>>> I have 2 different issues setting up a DirResourceSet. I have an
>>> external war file I am trying to merge into the Root of my
>>> application. I have a custom root that extends StandardRoot.
>>>
>>>
>>> 1.       DirResourceSet drs = new DirResourceSet(wsRoot,
>>> "/WEB-INF/classes/", possible.getAbsolutePath() + "/classes/", "/");
>>>
>>> This only seems to give me the top level directory of the classes
>>> directory as indicated by drs.listWebAppPaths("/WEB-INF/classes/").
>>> Is there a way to get it to be recursive or is it just that the
>>> listWebAppPaths doesn't show it even though it actually does it?
>>
>> A DirResourceSet will include all resources recursively under the
>> directory that is defined as the "top" of the resource set.
>>
>> I'm not sure if it really matters (I'd need to to back and review the
>> code carefully) but I'd remove the trailing slashes from those
>> directories. i.e. the above would be:
>>
>> DirResourceSet(wsRoot,
>>                "/WEB-INF/classes",
>>                possible.getAbsolutePath() + "/classes",
>>                "/");
>>
>>> 2.       The reason I can't check the first is because this one gives
>>> me an exception.
>>>
>>> DirResourceSet drs = new DirResourceSet(wsRoot, "/" +
>>> possible.getName(), possible.getAbsolutePath(), "/" +
>>> possible.getName());
>>
>> That doesn't look right. I'd expect the internalPath for a
>> DirResourceSet to always be "/". internalPath is really intended for
>> JAR files where the resources you want to include might not be located
>> at the root of the JAR.
>>
>> Something to consider is removing that parameter from the
>> DirResourceSet constructor and other constructors where it is unlikely
>> to be needed.
>>
>> Mark
>>
>>
>>  It looks like the one that seems to work but I
>>> get a:
>>>
>>> SEVERE [localhost-startStop-1] null.null Error setting up class path
>>>
>>> java.lang.IllegalStateException:
>>> org.apache.catalina.LifecycleException: Failed to initialize
>> component
>>> [org.apache.catalina.webresources.DirResourceSet@6a38848c]
>>>
>>> at
>>>
>> org.apache.catalina.webresources.DirResourceSet.<init>(DirResourceSet.
>>> java:83)
>>>
>>>  I have tried to follow through the source but keep getting lost.
>>> Line 83 is when it calls Start on StandardRoot. Is it because it was
>>> already started by the first call? But then how would you add in
>>> multiple resources?
>>>
>>>
>>>
>>> I would like to step through it in debug mode, but the test server is
>>> remote and I don't know how to set up remote debugging. And it's
>>> remote due to other required resources that are not able to run
>>> locally.
>>>
>>>
>>>
>>> Thanks for the help.
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> I finally figured it out. Everything I was doing was correct, but during all 
> of the changes I was making I accidentally removed the root.addPostResources 
> for that set. D'oh.
> 
> Sorry about that and thanks for all the help guys.

Glad you got it all working.

No need to apologise. Happy to help. Thanks for prompting the thought
about cleaning up the API for DirResourceSet.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: DirResourceSet

Posted by Ed Rouse <er...@milner.com>.

> -----Original Message-----
> From: Mark Thomas [mailto:markt@apache.org]
> Sent: Tuesday, November 18, 2014 5:59 AM
> To: Tomcat Users List
> Subject: Re: DirResourceSet
> 
> On 17/11/2014 22:52, Ed Rouse wrote:
> > I have 2 different issues setting up a DirResourceSet. I have an
> > external war file I am trying to merge into the Root of my
> > application. I have a custom root that extends StandardRoot.
> >
> >
> > 1.       DirResourceSet drs = new DirResourceSet(wsRoot,
> > "/WEB-INF/classes/", possible.getAbsolutePath() + "/classes/", "/");
> >
> > This only seems to give me the top level directory of the classes
> > directory as indicated by drs.listWebAppPaths("/WEB-INF/classes/").
> > Is there a way to get it to be recursive or is it just that the
> > listWebAppPaths doesn't show it even though it actually does it?
> 
> A DirResourceSet will include all resources recursively under the
> directory that is defined as the "top" of the resource set.
> 
> I'm not sure if it really matters (I'd need to to back and review the
> code carefully) but I'd remove the trailing slashes from those
> directories. i.e. the above would be:
> 
> DirResourceSet(wsRoot,
>                "/WEB-INF/classes",
>                possible.getAbsolutePath() + "/classes",
>                "/");
> 
> > 2.       The reason I can't check the first is because this one gives
> > me an exception.
> >
> > DirResourceSet drs = new DirResourceSet(wsRoot, "/" +
> > possible.getName(), possible.getAbsolutePath(), "/" +
> > possible.getName());
> 
> That doesn't look right. I'd expect the internalPath for a
> DirResourceSet to always be "/". internalPath is really intended for
> JAR files where the resources you want to include might not be located
> at the root of the JAR.
> 
> Something to consider is removing that parameter from the
> DirResourceSet constructor and other constructors where it is unlikely
> to be needed.
> 
> Mark
> 
> 
>  It looks like the one that seems to work but I
> > get a:
> >
> > SEVERE [localhost-startStop-1] null.null Error setting up class path
> >
> > java.lang.IllegalStateException:
> > org.apache.catalina.LifecycleException: Failed to initialize
> component
> > [org.apache.catalina.webresources.DirResourceSet@6a38848c]
> >
> > at
> >
> org.apache.catalina.webresources.DirResourceSet.<init>(DirResourceSet.
> > java:83)
> >
> >  I have tried to follow through the source but keep getting lost.
> > Line 83 is when it calls Start on StandardRoot. Is it because it was
> > already started by the first call? But then how would you add in
> > multiple resources?
> >
> >
> >
> > I would like to step through it in debug mode, but the test server is
> > remote and I don't know how to set up remote debugging. And it's
> > remote due to other required resources that are not able to run
> > locally.
> >
> >
> >
> > Thanks for the help.
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

I finally figured it out. Everything I was doing was correct, but during all 
of the changes I was making I accidentally removed the root.addPostResources 
for that set. D'oh.

Sorry about that and thanks for all the help guys.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: DirResourceSet

Posted by Mark Thomas <ma...@apache.org>.
On 17/11/2014 22:52, Ed Rouse wrote:
> I have 2 different issues setting up a DirResourceSet. I have an
> external war file I am trying to merge into the Root of my
> application. I have a custom root that extends StandardRoot.
> 
> 
> 1.       DirResourceSet drs = new DirResourceSet(wsRoot,
> "/WEB-INF/classes/", possible.getAbsolutePath() + "/classes/", "/");
> 
> This only seems to give me the top level directory of the classes
> directory as indicated by drs.listWebAppPaths("/WEB-INF/classes/").
> Is there a way to get it to be recursive or is it just that the
> listWebAppPaths doesn't show it even though it actually does it?

A DirResourceSet will include all resources recursively under the
directory that is defined as the "top" of the resource set.

I'm not sure if it really matters (I'd need to to back and review the
code carefully) but I'd remove the trailing slashes from those
directories. i.e. the above would be:

DirResourceSet(wsRoot,
               "/WEB-INF/classes",
               possible.getAbsolutePath() + "/classes",
               "/");

> 2.       The reason I can't check the first is because this one gives
> me an exception.
> 
> DirResourceSet drs = new DirResourceSet(wsRoot, "/" +
> possible.getName(), possible.getAbsolutePath(), "/" +
> possible.getName());

That doesn't look right. I'd expect the internalPath for a
DirResourceSet to always be "/". internalPath is really intended for JAR
files where the resources you want to include might not be located at
the root of the JAR.

Something to consider is removing that parameter from the DirResourceSet
constructor and other constructors where it is unlikely to be needed.

Mark


 It looks like the one that seems to work but I
> get a:
> 
> SEVERE [localhost-startStop-1] null.null Error setting up class path
> 
> java.lang.IllegalStateException:
> org.apache.catalina.LifecycleException: Failed to initialize
> component [org.apache.catalina.webresources.DirResourceSet@6a38848c]
> 
> at
> org.apache.catalina.webresources.DirResourceSet.<init>(DirResourceSet.java:83)
>
>  I have tried to follow through the source but keep getting lost.
> Line 83 is when it calls Start on StandardRoot. Is it because it was
> already started by the first call? But then how would you add in
> multiple resources?
> 
> 
> 
> I would like to step through it in debug mode, but the test server is
> remote and I don't know how to set up remote debugging. And it's
> remote due to other required resources that are not able to run
> locally.
> 
> 
> 
> Thanks for the help.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org