RE: [EXT]Re: how to define database resource in just context.xml or server.xml

2024-04-01 Thread Rick Noel
Yes and that is just what we are trying to do.  On our dev servers all five 
different applications share the same database.
So it would seem best to have the resource link in the context.xml and not 
complicate things up by putting the database link in each web application's 
web.xml.

The idea being that a developer working on one application would think if he 
changed the web.xml for his application, hey maybe I should change the other 
application's web.xml also

Rick Noel
Systems Programmer | Westwood One
rn...@westwoodone.com

-Original Message-
From: Mark Thomas  
Sent: Sunday, March 31, 2024 1:55 PM
To: users@tomcat.apache.org
Subject: Re: [EXT]Re: how to define database resource in just context.xml or 
server.xml

On 29/03/2024 21:58, Christopher Schultz wrote:
> Rick,
> 
> On 3/29/24 14:33, Rick Noel wrote:
>> Our application is really a suite of 5applications.  And the 
>> server.xml  I am talking about is on our dev machine, where we want 
>> to run all 5 apps on the one web server.
>>
>> The context.xml has global enviroiment variables (like mail server 
>> related vars) that all the dev applications use. All the different 
>> dev applications also use the same database.
>>
>> So that is why we define resources in the context.xml  file
> It sounds like you really *do* want to define the JDBC/JNDI resource 
> in server.xml and the link it to your applications.
> 
> I think the correct way to do that is by defining it in server.xml and 
> then linking it through your applications' WEB-INF/web.xml files.
> 
> You should not have to touch CATALINA_BASE/conf/context.xml.

The only reason you might want to touch context.xml is if you want to provide 
the same resource link to all web applications rather than have to specify it 
in each web application.

Mark

> 
> -chris
> 
>> -Original Message-
>> From: Christopher Schultz 
>> Sent: Friday, March 29, 2024 2:21 PM
>> To: Tomcat Users List ; Rick Noel 
>> 
>> Subject: Re: [EXT]Re: how to define database resource in just 
>> context.xml or server.xml
>>
>> Rick,
>>
>> On 3/29/24 11:56, Rick Noel wrote:
>>> If have the resource defined in
>>> CATALINA_BASE/conf/context.xml
>>> And
>>> CATALINA_BASE/conf/server.xml
>>
>> You really shouldn't have anything custom in 
>> CATALINA_BASE/conf/context.xml. That will affect every application 
>> deployed on the server. Perhaps you only have a single application 
>> deployed, but things can get really confusing when you edit that file.
>> It also makes upgrades more difficult.
>>
>> I would recommend taking your  from 
>> CATALINA_BASE/conf/context.xml and putting it into the proper place:
>> your application's META-INF/context.xml file. You will need to 
>> surround it with  ...  since that file defines the 
>> context.
>>
>> If you have  in your CATALINA_BASE/conf/server.xml file, you 
>> should remove it. If you want to disable auto-deploy, then you can 
>> always copy your application's META-INF/context.xml file into 
>> CATALINA_BASE/conf/[engine]/[host]/[contextpath].xml.
>>
>> Finally, you should be able to delete your  from your 
>> CATALINA_BASE/conf/server.xml file entirely.
>>
>> Do you have anything in your web.xml that is related? For example:
>>
>>     
>>   jdbc/foo
>>   javax.sql.DataSource
>>   Container
>>     
>>
>> I have one of those in my web.xml, but it's not clear to be whether 
>> or not I actually need it. I have *one* of them but my application 
>> uses two different JDBC resources. Both are declared in 
>> META-INF/context.xml and both are available to the application.
>>
>> I think you need to use  in web.xml when you define 
>> "global naming resources" in server.xml. But if you put them into 
>> META-INF/context.xml it's obvious that (a) they aren't global and (b) 
>> the application expects them.
>>
>> So I would remove any global naming resources you may have in 
>> server.xml and also remove anything you don't need in web.xml.
>>
>> Doing all this will make upgrading Tomcat much easier.
>>
>> -chris
>>
>>> -Original Message-
>>> From: Christopher Schultz 
>>> Sent: Friday, March 29, 2024 11:47 AM
>>> To: users@tomcat.apache.org
>>> Subject: [EXT]Re: how to define database resource in just 
>>> context.xml or server.xml
>>>
>>> Rick,
>>>
>>> On 3/29/24 09:48, Rick Noel wrote:
 Can someone tell me why I need to have my database source defined 
 in both my context.xml and server.xml? I thought we are suppose to 
 define it in only one location?
>>> It's definitely not a requirement to specify it in both places.
>>>
 I can only log into my app if I have it defined in both my 
 context.xml and server.xml

 Below  is my database resource   as defined in server.xml..

 I have xxx out postgres URL for security reasons

 



     >>>  
 type="javax.sql.DataSource"  driverClassName="org.postgresql.Driver"
 

Re: Tomcat 9.0.87 - status 400 in css / images

2024-04-01 Thread DAngel
Hi!

 I am using http 1.1

 The browser connects directly to tomcat (in my environment, I directly
access localhost:8080/myApp )

 In my development environment I can do the necessary tests (without
restrictions)

 I can always reproduce the error by simply clearing the browser cache.
 In the first request the CSS resources do not load correctly, when I
refresh the page they load correctly.

In the browser console, the error on the first request is:
refused to apply style from "..." because its mime type 'text/html is not a
supported styleshee mime type

El lun, 25 mar 2024 a las 13:58, Christopher Schultz (<
ch...@christopherschultz.net>) escribió:

> DAngel,
>
> On 3/22/24 16:14, DAngel wrote:
> > Tomcat 9.0.87 (and Tomcat 9.0.76)
> > Ubuntu 22.04 (and Red hat 8)
> > java 8 : openjdk version "1.8.0_382"
> > protocol: HTTP
> >
> > I have migrated an application from tomcat 7 (7.0.76) to tomcat 9.0.76
> (and
> > also to tomcat 9.0.87)
> >
> > After upgrading to Tomcat 9.0.76, the web page is not displaying
> correctly
> > as some CSS/images are returning HTTP status 400. If we reload the
> browser,
> > it works fine.
> >
> >   When this happens, the "type" of the resources is text/html .
> >
> >   My error is similar to this:
> >
> https://stackoverflow.com/questions/77989064/intermittently-getting-status-400-for-js-css-images-after-upgrading-to-tomcat-9
> >
> >   Any configuration I may be missing?
> >   Any advice to solve this error is welcome.
>
> 400 indicates that the client sent a bad request.
>
> Are you using HTTP 1.1 or h2?
>
> Is there a reverse-proxy between your browser and Tomcat? If so, what
> product+protocol are you using to connect the two?
>
> Is this an environment where you could enable debug/trace logging, or is
> this production which would represent a big problem for you?
>
> Are you able to reproduce it, even non-predictably? Meaning, if you load
> a page 10 times can you make it happen, or is it only every 100,000 page
> loads or something?
>
> -chris
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>