Uploaded image for project: 'TomEE'
  1. TomEE
  2. TOMEE-2989

ClassCastException for javax.sql.DataSource on app reload

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 8.0.6
    • None
    • TomEE Core Server
    • None
    • Windows 10 (64), OpenJDK 15, TomEE PLUME 8.0.6

    Description

      On application relaod I recieve the following error:

      java.lang.ClassCastException: class org.apache.openejb.core.ivm.naming.IvmContext cannot be cast to class javax.sql.DataSource (org.apache.openejb.core.ivm.naming.IvmContext is in unnamed module of loader java.net.URLClassLoader @2aaf7cc2; javax.sql.DataSource is in module java.sql of loader 'platform')

      Root Cause seems to be here:

      java.lang.ClassCastException: class org.apache.openejb.core.ivm.naming.IvmContext cannot be cast to class javax.sql.DataSource (org.apache.openejb.core.ivm.naming.IvmContext is in unnamed module of loader java.net.URLClassLoader @2aaf7cc2; javax.sql.DataSource is in module java.sql of loader 'platform')
      {{ org.apache.tomee.security.identitystore.TomEEDatabaseIdentityStore.lookup(TomEEDatabaseIdentityStore.java:171)}}
      {{ org.apache.tomee.security.identitystore.TomEEDatabaseIdentityStore.query(TomEEDatabaseIdentityStore.java:143)}}
      {{ org.apache.tomee.security.identitystore.TomEEDatabaseIdentityStore.validate(TomEEDatabaseIdentityStore.java:94)}}
      {{ org.apache.tomee.security.identitystore.TomEEDatabaseIdentityStore$$OwbNormalScopeProxy7.validate(org/apache/tomee/security/identitystore/TomEEDatabaseIdentityStore.java)}}
      {{ org.apache.tomee.security.identitystore.TomEEIdentityStoreHandler.validate(TomEEIdentityStoreHandler.java:74)}}
      {{ org.apache.tomee.security.identitystore.TomEEIdentityStoreHandler$$OwbNormalScopeProxy11.validate(org/apache/tomee/security/identitystore/TomEEIdentityStoreHandler.java)}}
      {{ org.apache.tomee.security.cdi.CustomFormAuthenticationMechanism.validateRequest(CustomFormAuthenticationMechanism.java:50)}}
      {{ jdk.internal.reflect.GeneratedMethodAccessor214.invoke(Unknown Source)}}
      {{ java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)}}
      {{ java.base/java.lang.reflect.Method.invoke(Method.java:564)}}
      {{ org.apache.webbeans.intercept.AbstractInvocationContext.directProceed(AbstractInvocationContext.java:113)}}
      {{ org.apache.webbeans.intercept.AbstractInvocationContext.proceed(AbstractInvocationContext.java:106)}}
      {{ org.apache.webbeans.intercept.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:78)}}
      {{ org.apache.tomee.security.cdi.LoginToContinueInterceptor.processContainerInitiatedAuthentication(LoginToContinueInterceptor.java:143)}}
      {{ org.apache.tomee.security.cdi.LoginToContinueInterceptor.validateRequest(LoginToContinueInterceptor.java:78)}}
      {{ org.apache.tomee.security.cdi.LoginToContinueInterceptor.intercept(LoginToContinueInterceptor.java:63)}}
      {{ jdk.internal.reflect.GeneratedMethodAccessor213.invoke(Unknown Source)}}
      {{ java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)}}
      {{ java.base/java.lang.reflect.Method.invoke(Method.java:564)}}
      {{ org.apache.webbeans.component.InterceptorBean.intercept(InterceptorBean.java:136)}}
      {{ org.apache.webbeans.intercept.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:65)}}
      {{ org.apache.tomee.security.cdi.AutoApplySessionInterceptor.validateRequest(AutoApplySessionInterceptor.java:60)}}
      {{ org.apache.tomee.security.cdi.AutoApplySessionInterceptor.intercept(AutoApplySessionInterceptor.java:47)}}
      {{ jdk.internal.reflect.GeneratedMethodAccessor212.invoke(Unknown Source)}}
      {{ java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)}}
      {{ java.base/java.lang.reflect.Method.invoke(Method.java:564)}}
      {{ org.apache.webbeans.component.InterceptorBean.intercept(InterceptorBean.java:136)}}
      {{ org.apache.webbeans.intercept.InterceptorInvocationContext.proceed(InterceptorInvocationContext.java:65)}}
      {{ org.apache.webbeans.intercept.DefaultInterceptorHandler.invoke(DefaultInterceptorHandler.java:139)}}
      {{ org.apache.tomee.security.cdi.CustomFormAuthenticationMechanism$$OwbInterceptProxy11.validateRequest(org/apache/tomee/security/cdi/CustomFormAuthenticationMechanism.java)}}
      {{ org.apache.tomee.security.cdi.CustomFormAuthenticationMechanism$$OwbNormalScopeProxy12.validateRequest(org/apache/tomee/security/cdi/CustomFormAuthenticationMechanism.java)}}
      {{ org.apache.tomee.security.cdi.DefaultAuthenticationMechanism.validateRequest(DefaultAuthenticationMechanism.java:43)}}
      {{ org.apache.tomee.security.cdi.DefaultAuthenticationMechanism$$OwbNormalScopeProxy12.validateRequest(org/apache/tomee/security/cdi/DefaultAuthenticationMechanism.java)}}
      {{ org.apache.tomee.security.provider.TomEESecurityServerAuthModule.validateRequest(TomEESecurityServerAuthModule.java:106)}}
      {{ org.apache.tomee.security.provider.TomEESecurityServerAuthContext.validateRequest(TomEESecurityServerAuthContext.java:50)}}
      {{ org.apache.tomee.security.TomEESecurityContext.authenticate(TomEESecurityContext.java:92)}}

      I have defined  a custom web authentication using a JDBC Data source define in context.xml:

      {{ <Resource auth="Container" }}
      {{ driverClassName="org.apache.derby.client.ClientAutoloadedDriver" }}
      {{ initialSize="1" logAbandoned="true" maxIdle="1" maxTotal="2" }}
      {{ name="jdbc/authority" password="pw" removeAbandoned="true"}}
      {{ type="javax.sql.DataSource" url="jdbc:derby://localhost:1527//Authority;create=true" username="name"/>}}

       

      The custom authentication credentials are stored in this database and are declared via:

      @DatabaseIdentityStoreDefinition(
      {{ dataSourceLookup = "jdbc/authority",}}
      {{ callerQuery = "select user_pass from users where user_name = ?",}}
      {{ groupsQuery = "select role_name from user_roles where user_name = ?",}}
      {{ hashAlgorithm = Pbkdf2PasswordHash.class,}}
      {{ hashAlgorithmParameters = {}}
      {{ "Pbkdf2PasswordHash.Algorithm=PBKDF2WithHmacSHA512",}}
      {{ "Pbkdf2PasswordHash.Iterations=10000",}}
      {{ "Pbkdf2PasswordHash.KeySizeBytes=256",}}
      {{ "Pbkdf2PasswordHash.SaltSizeBytes=16"}}
      {{ }}}
      )

      The problem is: On first start everything is fine. But when doing a webapp reload, the following code (and obviously any attemts to resolve the resource) will not return a DataSource but a org.apache.openejb.core.ivm.naming.IvmContext:

      InitialContext ic = new InitialContext();
      {{ Object obj = ic.lookup("java:comp/env/jdbc/authority");}}

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            Makkus Makkus B.
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: