Re: Configuring embedded Tomcat with @WebServlet annotations

2019-03-09 Thread Mark Thomas
On 09/03/2019 20:00, Raffaele Sgarro wrote:
> I apologize for the tone.
> 
> Already tried various StandardJarScanner options, but the root problem is
> that nothing works while developing because classes from source Java files
> are not packaged at all and are simply put on the classpath by the IDE (and
> I do not want to add the directory used by the compiler of the IDE to the
> path read by the scanner).

That is going to be tricky.

The JarScanner only finds "roots" of class collections. JAR files,
directories of classes etc. It is the JarScannerCallback that processes
them and there isn't any easy way limit what the callbacks scan - e.g.
to a given Java package. Even the non-easy ways involve some fairly
invasive code changes to Tomcat.

We did fix a bug for 9.0./15 onwards that added this method:

Tomcat.addWebapp(Strign URL)

The URL can point to a WAR within the JAR. Tomcat then extracts the WAR
to the local file system and runs it from there. Not exactly what you
were looking for but I mention it in case it is good enough.

Mark

> 
> Il sab 9 mar 2019, 20:45 Mark Thomas  ha scritto:
> 
>> On 08/03/2019 17:47, Raffaele Sgarro wrote:
>>> Hello all! How is one supposed to configure Tomcat (I'm on 9.x) to scan a
>>> given package looking for @WebServlet servlets?
>>>
>>> I cannot find any API and relevant examples in the Tomcat source.
>>>
>>> More insight: my app is currently packaged as a WAR and deployed to a
>>> running Tomcat instance. I want to build a fat JAR and starting Tomcat in
>>> my main() - but then I do not have any WAR/JAR because all classes are on
>>> classpath. Is there some utility in Tomcat? Is there any external library
>>> commonly used for this?
>>
>> Scanning for annotations (and various other bits and pieces) is
>> controlled by the JarScanner component.
>>
>> http://tomcat.apache.org/tomcat-9.0-doc/config/jar-scanner.html
>>
>> You might need to set scanBootstrapClassPath="true" depending on exactly
>> how your far JAR is packaged / structured.
>>
>> Another option is to use logEffectiveWebXml on the Context to create the
>> equivalent web.xml and then use that.
>>
>> Mark
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>>
> 


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



Re: Followup2: Changed behaviour of Tomcat Deployment/Context/Lifecycle Manager concerning symbolic links

2019-03-09 Thread Rainer Jung

Hi Guido,

Am 09.03.2019 um 10:09 schrieb Guido Jäkel:

Dear Mark,

thank you for comments and hints. I would say I have a wide knowledge about 
hard and software. But as I'm not working as a software developer, I'm not 
familiar with a lot of things in deep. I also don't have key-ready workbenches 
or buildchains. But I'll try to locate the corresponding commit using web 
access to the git. May I also contact you afterwards for further steps? Should 
I try to open an issue on the git or should I start a discussion in the Tomcat 
developer mailing list?


To add small hints: the project is available on Github, which provides 
an easy web interface for basic code archeology. E.g. the class you 
metioned can be viewed at


https://github.com/apache/tomcat/blob/master/java/org/apache/catalina/startup/ContextConfig.java

and that page contains buttons for "Blame" - which shows when and in 
which commit each line was changes last, and also "History" which shows 
the list of changes applied to that file.


The above link if for master (TC 9), but analogous pages exist for each 
branch, e.g.


https://github.com/apache/tomcat/blob/8.5.x/java/org/apache/catalina/startup/ContextConfig.java

Regards,

Rainer


On 08.03.19 21:58, Mark Thomas wrote:

On 08/03/2019 11:59, Jäkel, Guido wrote:

Good news!

I reverted the change and this solve my issue at once, i.e. all former 
installed applications will start up as expected.

So, please what was the reason or intention here to shift from  getPath() to  
getCanonicalPath()  in case of a link (detected by !file.isAbsolute() )? What's the 
motivation to "fully expand" the path here at Java level instead of delegating 
this to the underlying OS?


Tomcat is an open source project. git (and svn that we used until
recently) provides a feature that lets you identify the most recent
commit associated with any line of code. Every commit includes a log
message. That is usually where you'd find an explanation for why a
commit was made. Have you tried looking?

Mark



greetings

Guido


(I'm going to check this out right now)

May somebody point me to a ticket for the commit of this change and/or an issue 
ticket leading to this change? I want to know
the motivation for this change and I want to please to find a solution to keep 
the old behavior. Because in my eyes, the current
is inconsistent: For the context naming and so on, the well-known behavior is 
kept -- the context is named by the naming of the
link itself and not of it's destination. And therefore, this should also hold 
for all other aspects


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



Re: Configuring embedded Tomcat with @WebServlet annotations

2019-03-09 Thread Raffaele Sgarro
I apologize for the tone.

Already tried various StandardJarScanner options, but the root problem is
that nothing works while developing because classes from source Java files
are not packaged at all and are simply put on the classpath by the IDE (and
I do not want to add the directory used by the compiler of the IDE to the
path read by the scanner).

Il sab 9 mar 2019, 20:45 Mark Thomas  ha scritto:

> On 08/03/2019 17:47, Raffaele Sgarro wrote:
> > Hello all! How is one supposed to configure Tomcat (I'm on 9.x) to scan a
> > given package looking for @WebServlet servlets?
> >
> > I cannot find any API and relevant examples in the Tomcat source.
> >
> > More insight: my app is currently packaged as a WAR and deployed to a
> > running Tomcat instance. I want to build a fat JAR and starting Tomcat in
> > my main() - but then I do not have any WAR/JAR because all classes are on
> > classpath. Is there some utility in Tomcat? Is there any external library
> > commonly used for this?
>
> Scanning for annotations (and various other bits and pieces) is
> controlled by the JarScanner component.
>
> http://tomcat.apache.org/tomcat-9.0-doc/config/jar-scanner.html
>
> You might need to set scanBootstrapClassPath="true" depending on exactly
> how your far JAR is packaged / structured.
>
> Another option is to use logEffectiveWebXml on the Context to create the
> equivalent web.xml and then use that.
>
> Mark
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: Configuring embedded Tomcat with @WebServlet annotations

2019-03-09 Thread Mark Thomas
On 08/03/2019 17:47, Raffaele Sgarro wrote:
> Hello all! How is one supposed to configure Tomcat (I'm on 9.x) to scan a
> given package looking for @WebServlet servlets?
> 
> I cannot find any API and relevant examples in the Tomcat source.
> 
> More insight: my app is currently packaged as a WAR and deployed to a
> running Tomcat instance. I want to build a fat JAR and starting Tomcat in
> my main() - but then I do not have any WAR/JAR because all classes are on
> classpath. Is there some utility in Tomcat? Is there any external library
> commonly used for this?

Scanning for annotations (and various other bits and pieces) is
controlled by the JarScanner component.

http://tomcat.apache.org/tomcat-9.0-doc/config/jar-scanner.html

You might need to set scanBootstrapClassPath="true" depending on exactly
how your far JAR is packaged / structured.

Another option is to use logEffectiveWebXml on the Context to create the
equivalent web.xml and then use that.

Mark

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



Re: Configuring embedded Tomcat with @WebServlet annotations

2019-03-09 Thread Mark Thomas
On 09/03/2019 15:01, Raffaele Sgarro wrote:
> I wonder why you think I didn't read the fucking manual before posting my
> question here.

While the reply to your question wasn't helpful, that does not justify
the tone of your response.

I'd like to remind everyone of the code of conduct:
https://www.apache.org/foundation/policies/conduct.html

I'd also recommend everyone (re-)reads this from time to time:
http://community.apache.org/contributors/etiquette

Mark


> 
> You'd be surprised to know that I'm studying this thing since a couple of
> days and my conclusion is that it's something Tomcat can't do and I'll have
> to use something like Spring to achieve it.
> 
> So no, it's not documented in the website.
> 
> Il sab 9 mar 2019, 15:15 Phumelela Mdluli  ha scritto:
> 
>> Hey,
>>
>> Try reading this, I think you will be fine:
>>
>> http://tomcat.apache.org/tomcat-9.0-doc/index.html
>>
>> No one can do it for you.
>>
>> Regards,
>>
>> Phumelela
>>
>> On Fri, Mar 8, 2019 at 7:47 PM Raffaele Sgarro 
>> wrote:
>>>
>>> Hello all! How is one supposed to configure Tomcat (I'm on 9.x) to scan a
>>> given package looking for @WebServlet servlets?
>>>
>>> I cannot find any API and relevant examples in the Tomcat source.
>>>
>>> More insight: my app is currently packaged as a WAR and deployed to a
>>> running Tomcat instance. I want to build a fat JAR and starting Tomcat in
>>> my main() - but then I do not have any WAR/JAR because all classes are on
>>> classpath. Is there some utility in Tomcat? Is there any external library
>>> commonly used for this?
>>>
>>> Thanks,
>>> Raffaele
>>
>>
>>
>> --
>> Yours Sincerely,
>>
>> Phumelela Mdluli
>> Lake Forest College '15
>> Waterford Kamhlaba '10 '08
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>>
> 


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



Re: Configuring embedded Tomcat with @WebServlet annotations

2019-03-09 Thread Raffaele Sgarro
I wonder why you think I didn't read the fucking manual before posting my
question here.

You'd be surprised to know that I'm studying this thing since a couple of
days and my conclusion is that it's something Tomcat can't do and I'll have
to use something like Spring to achieve it.

So no, it's not documented in the website.

Il sab 9 mar 2019, 15:15 Phumelela Mdluli  ha scritto:

> Hey,
>
> Try reading this, I think you will be fine:
>
> http://tomcat.apache.org/tomcat-9.0-doc/index.html
>
> No one can do it for you.
>
> Regards,
>
> Phumelela
>
> On Fri, Mar 8, 2019 at 7:47 PM Raffaele Sgarro 
> wrote:
> >
> > Hello all! How is one supposed to configure Tomcat (I'm on 9.x) to scan a
> > given package looking for @WebServlet servlets?
> >
> > I cannot find any API and relevant examples in the Tomcat source.
> >
> > More insight: my app is currently packaged as a WAR and deployed to a
> > running Tomcat instance. I want to build a fat JAR and starting Tomcat in
> > my main() - but then I do not have any WAR/JAR because all classes are on
> > classpath. Is there some utility in Tomcat? Is there any external library
> > commonly used for this?
> >
> > Thanks,
> > Raffaele
>
>
>
> --
> Yours Sincerely,
>
> Phumelela Mdluli
> Lake Forest College '15
> Waterford Kamhlaba '10 '08
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Re: Configuring embedded Tomcat with @WebServlet annotations

2019-03-09 Thread Phumelela Mdluli
Hey,

Try reading this, I think you will be fine:

http://tomcat.apache.org/tomcat-9.0-doc/index.html

No one can do it for you.

Regards,

Phumelela

On Fri, Mar 8, 2019 at 7:47 PM Raffaele Sgarro  wrote:
>
> Hello all! How is one supposed to configure Tomcat (I'm on 9.x) to scan a
> given package looking for @WebServlet servlets?
>
> I cannot find any API and relevant examples in the Tomcat source.
>
> More insight: my app is currently packaged as a WAR and deployed to a
> running Tomcat instance. I want to build a fat JAR and starting Tomcat in
> my main() - but then I do not have any WAR/JAR because all classes are on
> classpath. Is there some utility in Tomcat? Is there any external library
> commonly used for this?
>
> Thanks,
> Raffaele



-- 
Yours Sincerely,

Phumelela Mdluli
Lake Forest College '15
Waterford Kamhlaba '10 '08

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



Re: Followup2: Changed behaviour of Tomcat Deployment/Context/Lifecycle Manager concerning symbolic links

2019-03-09 Thread John Dale
Nice investigative work, Guido.

Curious, are you debugging the source code?  Downloading any nightly builds?

If you're connected to the repo somehow you could get users named on
the commit logs and read commit messages?

Again - nice work!

Sincerely,

John


On 3/8/19, Jäkel, Guido  wrote:
> Good news!
>
> I reverted the change and this solve my issue at once, i.e. all former
> installed applications will start up as expected.
>
> So, please what was the reason or intention here to shift from  getPath() to
>  getCanonicalPath()  in case of a link (detected by !file.isAbsolute() )?
> What's the motivation to "fully expand" the path here at Java level instead
> of delegating this to the underlying OS?
>
> greetings
>
> Guido
>
>>-Original Message-
>>From: Jäkel, Guido [mailto:g.jae...@dnb.de]
>>Sent: Friday, March 08, 2019 11:39 AM
>>To: 'Tomcat Users List' 
>>Subject: Followup: Changed behaviour of Tomcat Deployment/Context/Lifecycle
>> Manager concerning symbolic links
>>
>> [...]
>>
>>And just from the names of the used methods, I wonder that the root cause
>> is the following change
>>
>>
>>  diff -r -u
>> /var/tmp/portage/www-servers/tomcat-8.5.23/work/apache-tomcat-8.5.23-
>>src/java/org/apache/catalina/startup/ContextConfig.java
>> /var/tmp/portage/www-servers/tomcat-8.5.37/work/apache-tomcat-8.5.37-
>>src/java/org/apache/catalina/startup/ContextConfig.java
>>
>>  [...]
>>  @@ -589,7 +583,7 @@
>>
>> File file = new File(docBase);
>> if (!file.isAbsolute()) {
>>-docBase = (new File(appBase, docBase)).getPath();
>>+docBase = (new File(appBase, docBase)).getCanonicalPath();
>> } else {
>> docBase = file.getCanonicalPath();
>> }
>>  [...]
>>
>>(I'm going to check this out right now)
>>
>>May somebody point me to a ticket for the commit of this change and/or an
>> issue ticket leading to this change? I want to know
>>the motivation for this change and I want to please to find a solution to
>> keep the old behavior. Because in my eyes, the current
>>is inconsistent: For the context naming and so on, the well-known behavior
>> is kept -- the context is named by the naming of the
>>link itself and not of it's destination. And therefore, this should also
>> hold for all other aspects
>>
>>
>>greetings
>>
>>Guido
>

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



Re: Followup2: Changed behaviour of Tomcat Deployment/Context/Lifecycle Manager concerning symbolic links

2019-03-09 Thread Mark Thomas
On March 9, 2019 9:09:42 AM UTC, "Guido Jäkel"  wrote:
>Dear Mark,
>
>thank you for comments and hints. I would say I have a wide knowledge
>about hard and software. But as I'm not working as a software
>developer, I'm not familiar with a lot of things in deep. I also don't
>have key-ready workbenches or buildchains. But I'll try to locate the
>corresponding commit using web access to the git. May I also contact
>you afterwards for further steps? Should I try to open an issue on the
>git or should I start a discussion in the Tomcat developer mailing
>list?
>
>Guido
>
>On 08.03.19 21:58, Mark Thomas wrote:
>> On 08/03/2019 11:59, Jäkel, Guido wrote:
>>> Good news!
>>>
>>> I reverted the change and this solve my issue at once, i.e. all
>former installed applications will start up as expected.
>>>
>>> So, please what was the reason or intention here to shift from 
>getPath() to  getCanonicalPath()  in case of a link (detected by
>!file.isAbsolute() )? What's the motivation to "fully expand" the path
>here at Java level instead of delegating this to the underlying OS?
>> 
>> Tomcat is an open source project. git (and svn that we used until
>> recently) provides a feature that lets you identify the most recent
>> commit associated with any line of code. Every commit includes a log
>> message. That is usually where you'd find an explanation for why a
>> commit was made. Have you tried looking?
>> 
>> Mark
>> 
>>>
>>> greetings
>>>
>>> Guido
>>>
 (I'm going to check this out right now)

 May somebody point me to a ticket for the commit of this change
>and/or an issue ticket leading to this change? I want to know
 the motivation for this change and I want to please to find a
>solution to keep the old behavior. Because in my eyes, the current
 is inconsistent: For the context naming and so on, the well-known
>behavior is kept -- the context is named by the naming of the
 link itself and not of it's destination. And therefore, this should
>also hold for all other aspects


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

This mailing list is the correct location should you have any follow-up 
questions.

Mark

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



Re: Followup2: Changed behaviour of Tomcat Deployment/Context/Lifecycle Manager concerning symbolic links

2019-03-09 Thread Guido Jäkel
Dear Mark,

thank you for comments and hints. I would say I have a wide knowledge about 
hard and software. But as I'm not working as a software developer, I'm not 
familiar with a lot of things in deep. I also don't have key-ready workbenches 
or buildchains. But I'll try to locate the corresponding commit using web 
access to the git. May I also contact you afterwards for further steps? Should 
I try to open an issue on the git or should I start a discussion in the Tomcat 
developer mailing list?

Guido

On 08.03.19 21:58, Mark Thomas wrote:
> On 08/03/2019 11:59, Jäkel, Guido wrote:
>> Good news!
>>
>> I reverted the change and this solve my issue at once, i.e. all former 
>> installed applications will start up as expected.
>>
>> So, please what was the reason or intention here to shift from  getPath() to 
>>  getCanonicalPath()  in case of a link (detected by !file.isAbsolute() )? 
>> What's the motivation to "fully expand" the path here at Java level instead 
>> of delegating this to the underlying OS?
> 
> Tomcat is an open source project. git (and svn that we used until
> recently) provides a feature that lets you identify the most recent
> commit associated with any line of code. Every commit includes a log
> message. That is usually where you'd find an explanation for why a
> commit was made. Have you tried looking?
> 
> Mark
> 
>>
>> greetings
>>
>> Guido
>>
>>> (I'm going to check this out right now)
>>>
>>> May somebody point me to a ticket for the commit of this change and/or an 
>>> issue ticket leading to this change? I want to know
>>> the motivation for this change and I want to please to find a solution to 
>>> keep the old behavior. Because in my eyes, the current
>>> is inconsistent: For the context naming and so on, the well-known behavior 
>>> is kept -- the context is named by the naming of the
>>> link itself and not of it's destination. And therefore, this should also 
>>> hold for all other aspects
>>>
>>>

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