Issue Details (XML | Word | Printable)

Key: JDBC-490
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Mark Rotteveel
Reporter: Davide Z
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Jaybird JCA/JDBC Driver

Tomcat Realm JDBCRealm Authentication Error

Created: 20/Apr/17 12:45 PM   Updated: 10/Jun/17 07:02 AM
Component/s: JDBC driver
Affects Version/s: Jaybird 3.0.0-beta-3
Fix Version/s: Jaybird 3.0.0

Environment:
java version "1.8.0_121"
Apache Tomcat/8.5.14
Jaybird-3.0.0-beta-3-JDK_1.8
Firebird 3.0.LI-V3.0.2.32703 on linux64 lan (192.168.1.23) server
Issue Links:
Relate
 


 Description  « Hide
I have this error try start JDBCRealm on my tomcat application:

org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/exxxx]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
        at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [Realm[JDBCRealm]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5084)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 10 more
Caused by: java.util.ServiceConfigurationError: org.firebirdsql.gds.impl.GDSFactoryPlugin: Provider org.firebirdsql.gds.impl.wire.WireGDSFactoryPlugin not a subtype
        at java.util.ServiceLoader.fail(ServiceLoader.java:239)
        at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
        at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
        at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
        at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
        at org.firebirdsql.gds.impl.GDSFactory.loadPluginsFromClassLoader(GDSFactory.java:118)
        at org.firebirdsql.gds.impl.GDSFactory.<clinit>(GDSFactory.java:75)
        at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:110)
        at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:670)
        at org.apache.catalina.realm.JDBCRealm.startInternal(JDBCRealm.java:733)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 12 more

this is Realm extract from my application context.xml
  <!-- JDBCRealm Authentication -->
  <Realm className="org.apache.catalina.realm.JDBCRealm"
         connectionURL="jdbc:firebirdsql://192.168.1.23:3050/dev?encoding=NONE"
         connectionName="SYSDBA"
         connectionPassword="masterkey"
         driverName="org.firebirdsql.jdbc.FBDriver"
         roleNameCol="sRolName"
         userCredCol="sUsrPassword"
         userNameCol="sUsrName"
         userRoleTable="VUserRoles"
         userTable="TUser"
         />

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mark Rotteveel added a comment - 20/Apr/17 01:14 PM
Do you by any chance have the Jaybird driver both in the tomcat lib folder and in your web application? The error seems to point to WireGDSFactoryPlugin being loaded from a different classloader than the interface GDSFactoryPlugin.

Davide Z added a comment - 20/Apr/17 02:45 PM
You are rigth. I have the Jaybird driver (same Jaybird 3.0.0-beta-3 driver) in both folder.
Removed from web application and it works!

thanks

N.B. with FB2.5 and Jaybird 2.2.x it works with driver in both.

Mark Rotteveel added a comment - 20/Apr/17 03:11 PM
Thanks. In comparison to Jaybird 2.2, I made a number of changes to how these pluggable parts of the implementation are loaded, but it looks like in this specific case that actually contributes to the problem. I'll see if I can make it more robust. However, in general, the driver should only be present once: either in tomcat or in the webapplication.

PS To avoid confusion: Jaybird 3 also works with Firebird 2.5 (just like Jaybird 2.2 also works with Firebird 3).

Davide Z added a comment - 20/Apr/17 03:21 PM
" the driver should only be present once: either in tomcat or in the webapplication. "

I agree

Mark Rotteveel added a comment - 25/Apr/17 04:42 PM
Thanks for reporting, on closer inspection the problem is with an 'incomplete' catch. In Jaybird 3 we switched to java.util.ServiceLoader which throws a ServiceConfigurationError in case of incompatible class hierarchies, and subclasses of Error are - of course - not caught by a catch(Exception e) block, which means this error now bubbled all the way up.

In Jaybird 2.2 this same situation would lead to a ClassCastException which would then trigger a fallback scenario (which might again cause a ClassCastException, but that was then 'ignored' by a catch(Exception e) block.

I'm in the process of fixing this.

Mark Rotteveel added a comment - 25/Apr/17 05:36 PM
Changed code to catch ServiceConfigurationError and made some other changes to improve robustness of loading the plugins.