Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Tomcat Realm Security Almost Works but...
Tomcat Realm Security Almost Works but... [message #1837480] Sun, 31 January 2021 14:11 Go to next message
Brian Williamson is currently offline Brian WilliamsonFriend
Messages: 24
Registered: January 2012
Location: Blissfield, MI
Junior Member
For the most party project is in a pretty good place. I have configured VTS and have a very basic spring rest project running.

The one thing that I struggling with is security. Tomcat has JDBCRealm and DataSourceRealm. I'd prefer to use DataSourceRealm as JDBCRealm is deprecated however at this point I'd settle for either (I suspect it's the same problem).

I'd like to provide a single realm security config for all web bundles. Changes have been made to server-tomcat.xml:

<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.postgresql.Driver"
connectionURL="jdbc:postgresql://172.16.1.50:5432/SC15?user=USERNAME&amp;password=PASSWORD"
digest="MD5"
userTable="devices.vw_security_permissions"
userNameCol="user_name"
userCredCol="user_password"
userRoleTable="devices.vw_security_permissions"
roleNameCol="role_code"
/>

It appears to be trying; when accessing a protected path, the login dialog is displayed. The login fails and the log shows:

[2021-01-31 09:07:01.058] ERROR tp-nio-127.0.0.1-8080-exec-3 org.apache.catalina.core.ContainerBase.[Catalina] Exception performing authentication java.sql.SQLException: org.postgresql.Driver cannot be found by org.apache.catalina_8.5.56 in KernelBundleClassLoader: [bundle=org.apache.catalina_8.5.56]

So now I just need to know how to get the postgres driver to KernelBundleClassLoader. I've tried placing the jar into repository/etc, repository/usr, and the web app lib folder. I've even tried $SERVER/lib but no luck.

Any thoughts from the experts?
Re: Tomcat Realm Security Almost Works but... [message #1837481 is a reply to message #1837480] Sun, 31 January 2021 15:41 Go to previous messageGo to next message
GianMaria Romanato is currently offline GianMaria RomanatoFriend
Messages: 56
Registered: November 2015
Member
Hi

I believe you can either make the postgresql driver a fragment of the Catalina bundle or you have to import the packages of the driver in you web bundle because virgo will use the class loader of the bundle serving the request as the thread context class loader for loading the realm class and the driver.

You may find some tips here https://devshards.blogspot.com/search/label/Virgo?m=1
Including a possible approach for jndi.

Giamma.
Re: Tomcat Realm Security Almost Works but... [message #1837514 is a reply to message #1837481] Mon, 01 February 2021 13:48 Go to previous messageGo to next message
Brian Williamson is currently offline Brian WilliamsonFriend
Messages: 24
Registered: January 2012
Location: Blissfield, MI
Junior Member
Hi Giamma,

Thank you for your reply. I read the blog and found the instructions for jndi. I figured I'd make life easy on myself and just start with the postgreql jdbc driver. This didn't go so well. At first I updaed the manifest to include the fragment header. When that didn't work I replaced the entire manifest with the example. Both times I placed the updated jar in repository/usr. I also included a package import in my war manifest for postgres.

Oddly, PostgreSQL packages were available to my bundle but not to KernelBundleClassLoader.

Thanks - Brian
Re: Tomcat Realm Security Almost Works but... [message #1837879 is a reply to message #1837514] Tue, 09 February 2021 13:14 Go to previous message
GianMaria Romanato is currently offline GianMaria RomanatoFriend
Messages: 56
Registered: November 2015
Member
Hi Brian,

not sure what is wrong with your setup.
Could you briefly recap your status to see if anything comes to my mind?
Previous Topic:Virgo support for java 9
Goto Forum:
  


Current Time: Sun Apr 11 19:53:03 GMT 2021

Powered by FUDForum. Page generated in 0.01393 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top