Re: Best way to *programmatically* detect that all webapps are fully deployed and running?

2023-09-30 Thread Bruno Melloni

Thanks,

 * I really like the idea of either using JMX (although I am not yet
   familiar with it) or always implementing a health check endpoint for
   each REST service.
 * What would I use to query the list of *all* webapps (already up and
   running or not) on the tomcat server?

B.

On 9/30/2023 7:42 AM, Mark Thomas wrote:

On 29/09/2023 20:20, Bruno Melloni wrote:

On a tomcat server I have a number of REST services deployed as WARs.
There are interdependencies and even applications on other servers that
call them, so I really don't want to start calling services after
starting Tomcat until every single webapp is fully up and running.

Ideally, I would like to do it*programmatically*.

QUESTIONS

   * Is there a REST, other kind of API that I can call or a library 
that

 I can use?


You could check the status of each application via JMX.


   * Is there a known best practice on how to accomplish what I am
 looking for?  Perhaps a third party library that does the job?


Nothing comes to mind.


Things I know I can try, but none is an ideal solution:

   * Manually look at the logs.
   * Manually look at the Tomcat Application Management page.
   * Programmatically call the Tomcat Application Management page and
 scrape the information I need from it.
   * Scour through the code of the Tomcat Application Management page 
and
 replicate the pieces that I need, for example someone mentioned 
in a

 forum that I can look at
org.apache.catalina.manager.ManagerServlet.isDeployed(String name)
 to find out whether a webapp has been deployed or not.


If you are going the bespoke route, I'd suggest a health check / 
status endpoint for each app and call them in turn. It could easily be 
a standard component you deploy as part of each application.


Mark

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


Best way to *programmatically* detect that all webapps are fully deployed and running?

2023-09-29 Thread Bruno Melloni

On a tomcat server I have a number of REST services deployed as WARs.
There are interdependencies and even applications on other servers that
call them, so I really don't want to start calling services after
starting Tomcat until every single webapp is fully up and running.

Ideally, I would like to do it*programmatically*.

QUESTIONS

  * Is there a REST, other kind of API that I can call or a library that
I can use?
  * Is there a known best practice on how to accomplish what I am
looking for?  Perhaps a third party library that does the job?


Things I know I can try, but none is an ideal solution:

  * Manually look at the logs.
  * Manually look at the Tomcat Application Management page.
  * Programmatically call the Tomcat Application Management page and
scrape the information I need from it.
  * Scour through the code of the Tomcat Application Management page and
replicate the pieces that I need, for example someone mentioned in a
forum that I can look at
org.apache.catalina.manager.ManagerServlet.isDeployed(String name)
to find out whether a webapp has been deployed or not.


Thanks,


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



Re: How to have a custom classloader outside Tomcat's own lib-dir?

2023-04-17 Thread BRUNO MELLONI
Perhaps this info will help:

- Custom class loaders are supposed to be possible but very poorly documented.  
I was never able to make them work properly.   You might have some luck if you 
study the source code of Tomcat itself, as it does implement them.

- Webapps really expect all custom library jars to be loaded from web-inf/lib.

- up to Java 8 you could write code to dynamically add to the class path.  I 
used to use that ability extensively, even though I was not really using a 
custom classloader.   Starting in Java 9 they broke that capability.

- In tomcat/conf/catalina.prooerties you can add jars and folders to the common 
class path.  It is discouraged but it might get you out of trouble in a pinch.

Get Outlook for Android

From: Mark Thomas 
Sent: Monday, April 17, 2023 5:13:44 AM
To: users@tomcat.apache.org 
Subject: Re: How to have a custom classloader outside Tomcat's own lib-dir?

On 16/04/2023 12: 36, Thorsten Schöning wrote: > Hi everyone, > > I have some 
app consisting of a directory layout with some bundled > Tomcat, containing at 
least one exploded webapp. For various reasons, What are those reasons?
ZjQcmQRYFpfptBannerStart
CAUTION: This Message Is From an External Source
This message originated outside the Chickasaw Nation. Do not click links or 
open attachments unless you recognize the sender and know the content is safe!

Report Suspicious

ZjQcmQRYFpfptBannerEnd

On 16/04/2023 12:36, Thorsten Schöning wrote:
> Hi everyone,
>
> I have some app consisting of a directory layout with some bundled
> Tomcat, containing at least one exploded webapp. For various reasons,

What are those reasons? I'm wondering if the reasons have any impact on
the answer.

> that webbapp needs its own classloader, which is currently configured
> in context.xml of Tomcat and stored in its own lib-dir. I don't like
> putting custom JARs into the default deployment of Tomcat too much.
>
>> 
>> 
>
> So, is there some way to put the JAR elsewhere?

Yes, as long as you tell Tomcat where to find it.

> Whatever I tested didn't work, e.g. adding the JAR to "common.loader".

That should have worked and is the approach I'd recommend. Exactly what
did you change when you tried this?

> But I must admit that I didn't fully understand if common.loader is
> used to load the custom loader at all or only afterwards and stuff.
>
> Or is there some way to not use Tomcat's "Loader" above and only
> maintain a custom, webapp-specific classloader in the one webapp
> needing it?

No. Tomcat needs to be able to load the custom class loader in order to
configure it.

Mark


>
> I've searched for somethign like "setClassLoader" and found it for
> some servlet containers, but it doesn't seem to be standard and
> supported by Tomcat.
>
> Thanks for your input!
>
> Mit freundlichen Grüßen
>
> Thorsten Schöning
>

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




RE: Is Microsoft's spring-cloud-azure-starter-active-directory for Spring Boot 3 / Spring 6 compatible with Tomcat 10?

2023-04-14 Thread BRUNO MELLONI
That is the curious bit.  Nothing was needed in the previous version, and I 
found nothing mentioned for the latest version.
For my own logging (not needed before and presumably not now for the Azure 
stuff) I would use:

  org.apache.logging.log4j
  log4j-api
  ${log4j2.version}


  org.apache.logging.log4j
  log4j-core
  ${log4j2.version}


  org.apache.logging.log4j
  log4j-slf4j-impl
  ${log4j2.version}


  org.slf4j
  slf4j-api
  ${slf4j.version}


But it must have been a bug on spring-cloud-azure-starter-active-directory 
after all.  That is what was causing the logback exception, the problem would 
not happen without that dependency.   Interestingly… that particular problem 
went away this morning.  I noticed that when I did a clean build today (did not 
happen before during previous clean builds) a number of dependencies got 
downloaded/updated, and now the exception is not being thrown.

The particular problem is now solved, with no action from my part.  There are 
new issues but those I can handle.

From: Mark Thomas 
Sent: Friday, April 14, 2023 9:13 AM
To: users@tomcat.apache.org
Subject: Re: Is Microsoft's spring-cloud-azure-starter-active-directory for 
Spring Boot 3 / Spring 6 compatible with Tomcat 10?

On 13/04/2023 22: 48, BRUNO MELLONI wrote: > After further research let me ask 
the question in a different way: > > > * Tomcat 10 is configured to do log4j2 
logging. > * My log4j2 code works fine. > * 
Spring-cloud-azure-starter-active-directory
ZjQcmQRYFpfptBannerStart
CAUTION: This Message Is From an External Source
This message originated outside the Chickasaw Nation. Do not click links or 
open attachments unless you recognize the sender and know the content is safe!
Report Suspicious  
<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/IMeFMrRG1GeY!Jdtf_fv6_IHaYkOnqg0ntq7dHeM9BSmziea9b8WlFE6he1r79dw1kOFTAVUsrWKem_rpgDasu8Ac-LODZyrxoDgpRNpV9mHSNwH9ASQz$>
   ‌
ZjQcmQRYFpfptBannerEnd

On 13/04/2023 22:48, BRUNO MELLONI wrote:

> After further research let me ask the question in a different way:

>

>

>*   Tomcat 10 is configured to do log4j2 logging.

>*   My log4j2 code works fine.

>*   Spring-cloud-azure-starter-active-directory seems to use logback and 
> it is incompatible with my Tomcat 10 setup.

>

> Given the above… what do I need to add to Tomcat 10 to make it handle apps 
> that use logback for logging but still use my log4j2 Tomcat configuration for 
> the actual logging?



Whatever the logback documentation says you need to add to route logging

to log4j2.



> I would swear that Tomcat had slf4j and other logging translation libraries 
> built in…



Nope. That has never been the case.



> but perhaps Tomcat 10 no longer does for some and requires adding some jars?



Tomcat's internal logging routes to java.util.logging - you can re-route

that if required. Follow the directions to do that provided with your

logging framework of choice.



Assuming you are still seeing the:



"Cannot cast

ch.qos.logback.classic.servlet.LogbackServletContainerInitializer to

jakarta.servlet.ServletContainerInitializer" error, I'll repeat my

previous question:



Which version of which JAR is that ServletContainerInitializer coming from?



Mark





>

> b.

>

> From: Mark Thomas mailto:ma...@apache.org>>

> Sent: Tuesday, April 11, 2023 2:41 PM

> To: users@tomcat.apache.org<mailto:users@tomcat.apache.org>

> Subject: Re: Is Microsoft's spring-cloud-azure-starter-active-directory for 
> Spring Boot 3 / Spring 6 compatible with Tomcat 10?

>

> On 11/04/2023 20: 28, BRUNO MELLONI wrote: > I was able to migrate 
> applications to Spring Boot 3 / Spring 6 (standalone or running on Tomcat 10) 
> so long as authentication was NOT through Azure AD. > > But when I tried to 
> migrate applications

> ZjQcmQRYFpfptBannerStart

> CAUTION: This Message Is From an External Source

> This message originated outside the Chickasaw Nation. Do not click links or 
> open attachments unless you recognize the sender and know the content is safe!

>  Report Suspicious  
> <https://us-phishalarm-ewt.proofpoint.com/EWT/v1/IMeFMrRG1GeY!JdtUXLGR9ova4gOnS-0H1iEbkX_fwvLLfLoUe-WtR-fKP3iug2CA6Got_-7FykjdaEEVaYQaX_1JDstwjD_T9laTb_I1TVa4IKmJLM79$>
>‌

> ZjQcmQRYFpfptBannerEnd

>

> On 11/04/2023 20:28, BRUNO MELLONI wrote:

>

>> I was able to migrate applications to Spring Boot 3 / Spring 6 (standalone 
>> or running on Tomcat 10) so long as authentication was NOT through Azure AD.

>

>>

>

>> But when I tried to migrate applications that used Microsoft's 
>> spring-cloud-azure-starter-active-directory for authentication of 2-step 
>> authenticated webapps (the preferred approach) I started to get this error 
>> during application de

RE: Is Microsoft's spring-cloud-azure-starter-active-directory for Spring Boot 3 / Spring 6 compatible with Tomcat 10?

2023-04-13 Thread BRUNO MELLONI
After further research let me ask the question in a different way:


  *   Tomcat 10 is configured to do log4j2 logging.
  *   My log4j2 code works fine.
  *   Spring-cloud-azure-starter-active-directory seems to use logback and it 
is incompatible with my Tomcat 10 setup.

Given the above… what do I need to add to Tomcat 10 to make it handle apps that 
use logback for logging but still use my log4j2 Tomcat configuration for the 
actual logging?

I would swear that Tomcat had slf4j and other logging translation libraries 
built in… but perhaps Tomcat 10 no longer does for some and requires adding 
some jars?

b.

From: Mark Thomas 
Sent: Tuesday, April 11, 2023 2:41 PM
To: users@tomcat.apache.org
Subject: Re: Is Microsoft's spring-cloud-azure-starter-active-directory for 
Spring Boot 3 / Spring 6 compatible with Tomcat 10?

On 11/04/2023 20: 28, BRUNO MELLONI wrote: > I was able to migrate applications 
to Spring Boot 3 / Spring 6 (standalone or running on Tomcat 10) so long as 
authentication was NOT through Azure AD. > > But when I tried to migrate 
applications
ZjQcmQRYFpfptBannerStart
CAUTION: This Message Is From an External Source
This message originated outside the Chickasaw Nation. Do not click links or 
open attachments unless you recognize the sender and know the content is safe!
Report Suspicious  
<https://us-phishalarm-ewt.proofpoint.com/EWT/v1/IMeFMrRG1GeY!JdtUXLGR9ova4gOnS-0H1iEbkX_fwvLLfLoUe-WtR-fKP3iug2CA6Got_-7FykjdaEEVaYQaX_1JDstwjD_T9laTb_I1TVa4IKmJLM79$>
   ‌
ZjQcmQRYFpfptBannerEnd

On 11/04/2023 20:28, BRUNO MELLONI wrote:

> I was able to migrate applications to Spring Boot 3 / Spring 6 (standalone or 
> running on Tomcat 10) so long as authentication was NOT through Azure AD.

>

> But when I tried to migrate applications that used Microsoft's 
> spring-cloud-azure-starter-active-directory for authentication of 2-step 
> authenticated webapps (the preferred approach) I started to get this error 
> during application deploy to Tomcat 10:

>

> Cannot cast ch.qos.logback.classic.servlet.LogbackServletContainerInitializer 
> to jakarta.servlet.ServletContainerInitializer

>

>

> My suspicion is that Microsoft's latest implementation is not compatible with 
> Tomcat's approach to support log4j logging (as far as I know the approach has 
> been around since at least Tomcat 9).  But of course I could be wrong.   Has 
> anybody had any success?  Was there any trick to migrating to Spring Boot 3 / 
> Spring 6 / Tomcat 10 with 2-step authentication and authorization using Azure 
> AD?

>

>

>

> NOTE:  I did succeed with 2-step auth with Azure AD when I dropped the 
> Microsoft spring-cloud-azure-starter-active-directory dependency and instead 
> used the raw OAuth2 approach to connect to Azure AD.  The problem though is 
> that roles defined in Azure are not coming through to the GrantedAuthorities 
> of the SecurityContext or Principal.  I know I could extract the UPN from the 
> Principal and then define the AD Groups in the on-premises AD instead of 
> Azure AD, but that would require code changes and what is worse it would make 
> me hostage to the availability of sysadmins that manage our on-premises AD... 
> meaning weeks of delay for new AD groups.  It is a hack that I'd rather not 
> use if Azure authorization can be made to work properly.

>

> Any other advice will be welcome too.



No idea but some questions that might help.



Some sort of Java EE / Jakarta EE conflict?



A JAR present in the WAR that contains some of the Servlet API JARs?



Which version of which JAR is that ServletContainerInitializer coming from?



Mark



-

To unsubscribe, e-mail: 
users-unsubscr...@tomcat.apache.org<mailto:users-unsubscr...@tomcat.apache.org>

For additional commands, e-mail: 
users-h...@tomcat.apache.org<mailto:users-h...@tomcat.apache.org>




Is Microsoft's spring-cloud-azure-starter-active-directory for Spring Boot 3 / Spring 6 compatible with Tomcat 10?

2023-04-11 Thread BRUNO MELLONI
I was able to migrate applications to Spring Boot 3 / Spring 6 (standalone or 
running on Tomcat 10) so long as authentication was NOT through Azure AD.

But when I tried to migrate applications that used Microsoft's 
spring-cloud-azure-starter-active-directory for authentication of 2-step 
authenticated webapps (the preferred approach) I started to get this error 
during application deploy to Tomcat 10:

Cannot cast ch.qos.logback.classic.servlet.LogbackServletContainerInitializer 
to jakarta.servlet.ServletContainerInitializer


My suspicion is that Microsoft's latest implementation is not compatible with 
Tomcat's approach to support log4j logging (as far as I know the approach has 
been around since at least Tomcat 9).  But of course I could be wrong.   Has 
anybody had any success?  Was there any trick to migrating to Spring Boot 3 / 
Spring 6 / Tomcat 10 with 2-step authentication and authorization using Azure 
AD?



NOTE:  I did succeed with 2-step auth with Azure AD when I dropped the 
Microsoft spring-cloud-azure-starter-active-directory dependency and instead 
used the raw OAuth2 approach to connect to Azure AD.  The problem though is 
that roles defined in Azure are not coming through to the GrantedAuthorities of 
the SecurityContext or Principal.  I know I could extract the UPN from the 
Principal and then define the AD Groups in the on-premises AD instead of Azure 
AD, but that would require code changes and what is worse it would make me 
hostage to the availability of sysadmins that manage our on-premises AD... 
meaning weeks of delay for new AD groups.  It is a hack that I'd rather not use 
if Azure authorization can be made to work properly.

Any other advice will be welcome too.

Thanks.


RE: Database connection pooling ..

2023-04-11 Thread BRUNO MELLONI
I used org.apache.commons.dbcp2.BasicDataSource as my default DataSource for 
over a decade in both Tomcat and standalone apps.  Very reliable.  I do 
remember that “permanently running” apps like a custom job scheduler that we 
run would occasionally require a restart, sometimes once a week or once a 
month, although that eventually went away without any code changes so it was 
probably unrelated to DBCP.  Now we only have to restart if the app relies on 
Java’s default caching of DNS names to IPs and there is a server IP change, but 
I understand that there is code we can use to force Java to re-resolve DNS 
names to IP every “x amount of time”.

From: Christopher Schultz 
Sent: Tuesday, April 11, 2023 10:30 AM
To: users@tomcat.apache.org
Subject: Re: Database connection pooling ..

John, On 4/10/23 00: 40, John Dale (DB2DOM) wrote: > Has anyone tried using the 
Tomcat 10 DBCP from a standalone java app? I have not, but there isn't really 
anything Tomcat-specific about it. -chris 
-
ZjQcmQRYFpfptBannerStart
CAUTION: This Message Is From an External Source
This message originated outside the Chickasaw Nation. Do not click links or 
open attachments unless you recognize the sender and know the content is safe!
Report Suspicious  

   ‌
ZjQcmQRYFpfptBannerEnd

John,



On 4/10/23 00:40, John Dale (DB2DOM) wrote:

> Has anyone tried using the Tomcat 10 DBCP from a standalone java app?



I have not, but there isn't really anything Tomcat-specific about it.



-chris



-

To unsubscribe, e-mail: 
users-unsubscr...@tomcat.apache.org

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