Ahhhh

How silly of me. It's right there staring me in the face nested inside the
host in server.xml, right?

So, best practice is to remove contexts from host and place either under
[engine]/[host] or directly in META-INF in app?

On Thu, Nov 26, 2020 at 10:43 PM Hrafn Malmquist <hrafn.malmqu...@gmail.com>
wrote:

> Hello Rob and Mark and others
>
> Thanks for your input.
>
>  > >    2. In /home/lib/dspace/apache-tomcat-9.0.12/conf/server.xml I
> added the
>  > >    following Resource
>  > >
>  > >    <Resource name="jdbc/dspaceWeb"
>  > >
> factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
>  > >                  type="javax.sql.DataSource"
>  > >                  auth="Container"
>  > >                  username="*****"
>  > >                  password="******"
>  > >                  driverClassName="org.postgresql.Driver"
>  > >                  url="jdbc:postgresql://localhost:5432/dspace"
>  > >                  initialSize="5"
>  > >                  maxTotal="50"
>  > >                  maxIdle="15"
>  > >                  minIdle="5" />
>  >
>  > Exactly where in server.xml did you put this? What element was it nested
>  > under?
>
> I should have made clear, it's nested under <GlobalNamingResources> which
> is in turn nested under <Server>.
>
> I have removed the factory attribute and it now reads:
>
> <GlobalNamingResources>
>     <!-- Editable user database that can also be used by
>          UserDatabaseRealm to authenticate users
>     -->
>     <Resource name="UserDatabase" auth="Container"
>               type="org.apache.catalina.UserDatabase"
>               description="User database that can be updated and saved"
>               factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>               pathname="conf/tomcat-users.xml" />
>
>     <Resource name="jdbc/dspaceWeb"
>               type="javax.sql.DataSource"
>               auth="Container"
>               username="*******"
>               password="*******"
>               driverClassName="org.postgresql.Driver"
>               url="jdbc:postgresql://localhost:5432/dspace"
>               initialSize="5"
>               maxTotal="50"
>               maxIdle="15"
>               minIdle="5" />
>   </GlobalNamingResources>
>
> > >    3. Created a context.xml in /dspace/webapps/xmlui/META-INF/
> >
> > I think this is the problem. That location looks to be outside of the
> > default appBase. If I'm right, there is already a Context element
> > defined for this web application somewhere else. You need to find that
> > Context definition and add the ResourceLink to it.
>
> Right. It is indeed possible that the underlying configuration is not set
> up correctly.
>
> This is the relevant extract from server.xml:
>
> <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true">
>
>         <Valve className="org.apache.catalina.valves.AccessLogValve"
> directory="logs"
>                prefix="localhost_access_log" suffix=".txt"
>                pattern="%h %l %u %t &quot;%r&quot; %s %b" />
>
>         <Context path="/solr" docBase="/dspace/webapps/solr"/>
>       </Host>
>
> <Host name="********" appBase="/dspace/webapps"
>             unpackWARs="true" autoDeploy="true">
>
>
>         <Valve className="org.apache.catalina.valves.AccessLogValve"
> directory="logs"
>                prefix="localhost_access_log" suffix=".txt"
>                pattern="%h %l %u %t &quot;%r&quot; %s %b" />
>
>         <Context path="" docBase="/dspace/webapps/xmlui"/>
>         <Context path="/rest"  docBase="/dspace/webapps/rest" />
>         <Context path="/oai"  docBase="/dspace/webapps/oai" />
> </Host>
>
> Host appBase for the domain earlier said "webapps", like it still does for
> localhost, but I changed to "dspace/webapps".
>
> No change when I restart Tomcat.
>
> Under /home/lib/dspace/apache-tomcat-9.0.12/conf/Catalina there are
> folders for the hosts that have been set up on the server but none of them
> contain files.
>
> I am not sure where to look elsewhere for this Context element.
>
> Any ideas?
> Hrafn
>
>
>
> On Thu, Nov 26, 2020 at 9:30 PM Mark Thomas <ma...@apache.org> wrote:
>
>> On 26/11/2020 19:57, Hrafn Malmquist wrote:
>>
>> <snip/>
>>
>> > I am running:
>> >
>> > CentOS Linux release 7.8.2003
>> > Tomcat 9.0.12
>> > PostgreSQL 9.5.23
>> > openjdk version "1.8.0_262"
>> > OpenJDK Runtime Environment (build 1.8.0_262-b10)
>>
>> There are good reasons to update to a more recent Tomcat 9 release but
>> I'm not aware of any fixes that would impact the specific issue you are
>> currently seeing.
>>
>> >    1.  I downloaded postgresql-42.2.18.jar from
>> >    https://jdbc.postgresql.org/download/postgresql-42.2.18.jar and
>> placed
>> >    it in /home/lib/dspace/apache-tomcat-9.0.12/lib
>>
>> OK. That looks good.
>>
>> >    2. In /home/lib/dspace/apache-tomcat-9.0.12/conf/server.xml I added
>> the
>> >    following Resource
>> >
>> >    <Resource name="jdbc/dspaceWeb"
>> >                  factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
>> >                  type="javax.sql.DataSource"
>> >                  auth="Container"
>> >                  username="*****"
>> >                  password="******"
>> >                  driverClassName="org.postgresql.Driver"
>> >                  url="jdbc:postgresql://localhost:5432/dspace"
>> >                  initialSize="5"
>> >                  maxTotal="50"
>> >                  maxIdle="15"
>> >                  minIdle="5" />
>>
>> Exactly where in server.xml did you put this? What element was it nested
>> under?
>>
>> >    There are a couple of issues that confuse me:
>> >    a) the official documentation about JNDI datasource examples [0]
>> says "*This
>> >    author has not had success here, although others have reported so.
>> >    Clarification would be appreciated here."  *in the section about
>> >    Postgres. In other words, we can't be sure this works?
>>
>> That text needs to be removed. The author clearly made an error in their
>> config. This definitely works.
>>
>> >    b) in the official documtation about JDBC connection pool it says
>> that
>> >    if you want to define a JDBC connection pool in the Apache Container
>> (which
>> >    I understand to be trying to do) you have to specify the factory
>> attribute
>> >    and set the value to org.apache.tomcat.jdbc.pool.DataSourceFactory
>> [1]
>>
>> Do you want to use Tomcat's jdbc-pool? If so leave the factory attribute
>> as is. If you want to use Tomcat's built in copy for Apache Commons
>> DBCP2, remove the factory attribute.
>>
>> Personally, I'd go with DBCP2 but either should work.
>>
>> >    3. Created a context.xml in /dspace/webapps/xmlui/META-INF/
>>
>> I think this is the problem. That location looks to be outside of the
>> default appBase. If I'm right, there is already a Context element
>> defined for this web application somewhere else. You need to find that
>> Context definition and add the ResourceLink to it.
>>
>> >
>> >    <Context docBase="/dspace/webapps/xmlui">>        <ResourceLink
>> name="jdbc/dspace"
>> >                      global="jdbc/dspaceWeb"
>> >                      type="javax.sql.DataSource"
>> >        />
>> >    </Context>
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>>
>>

Reply via email to