1 Reply Latest reply on Jun 21, 2017 5:55 PM by lafr

    ojdbc6 driver not in classpath when deployed via Wildfly 10 admin console?

    rsoliveira_syn

      Hi all!

       

      We are using Wildfly 10 for the first time, upgrading from JBoss EAP 5.1.2. One thing that we need is to have our datasources using the ojdbc6 Oracle driver. I know there are 3 ways to configure them:

       

      1 - Installing the driver and configuring the modules and datasources via configuration files, as shown in this article:

       

      Installing Oracle JDBC-Driver On Wildfly / JBoss : Adam Bien's Weblog

       

      2 - Put the ojdbc6.jar in the D:\wildfly-10.1.0.Final\standalone\deployments folder, start the server. Via Wildfly 10 Administration Console, configure the datasource in Configuration -> Subsystems -> Datasources -> Non-XA usint the ojdbc6 driver we put in deployments folder;

       

      3 - Via Wildfly 10 Administration Console, deploy the ojdbc6.jar like any normal deploy in Deployment tab, and them via Wildfly 10 Administration Console, configure the datasource in Configuration -> Subsystems -> Datasources -> Non-XA usint the ojdbc6 driver we just deployed.

       

      Since our customers are used and demand instalations via administration consoles whenever possible, we choose way number 3 to configure the ojdbc6 driver and create our datasources.

       

      Now here's the problem: our application has an environment check that among other things checks the Oracle driver version to make sure we are using the ojdbc6 Oracle driver. This environment check is mandatory for our application to start. Or environment check class has the following code to check the Oracle driver:

       

      /**
       * @return Caminho do jar do driver Oracle
       * @see "http://www.javaxt.com/Tutorials/Jar/How_to_Get_the_Physical_Path_of_a_Jar_File"
       */
      private String getOracleJarPath() {
        try {
        // Oracle driver class
        final Class<?> clazz = oracle.jdbc.OracleDriver.class;
      
        final String path = clazz.getPackage().getName().replace(".", "/");
        String url = clazz.getClassLoader().getResource(path).toString();
      
        url = url.replace(" ", "%20"); // Normalize URI
        url = url.replace(path + "/", ""); // remove package from path
        final URI uri = new URI(url);
        return new File(uri.getPath()).getAbsolutePath();
        } catch (final Exception e) {
        // Nothing to do
        }
        return StringUtils.EMPTY;
      }
      

       

      When I deploy our application via Wildfly 10 Administration Console an error happens at line 38 (8 in the above code):

       

      2017-06-21 10:54:49,332 ERROR [br.com.synchro.framework.ambiente.service.impl.ValidadorAmbienteServiceImpl] (default task-2) Erro ao validar ambiente em todos os estágios.: java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
        at br.com.synchro.sfw.infra.ambiente.integration.impl.ValidadorAmbienteVersaoDriverJdbc.getOracleJarPath(ValidadorAmbienteVersaoDriverJdbc.java:38)
        at br.com.synchro.sfw.infra.ambiente.integration.impl.ValidadorAmbienteVersaoDriverJdbc.validarDriverOracle(ValidadorAmbienteVersaoDriverJdbc.java:149)
        at br.com.synchro.sfw.infra.ambiente.integration.impl.ValidadorAmbienteVersaoDriverJdbc.validar(ValidadorAmbienteVersaoDriverJdbc.java:106)
        at br.com.synchro.framework.ambiente.service.impl.ValidadorAmbienteServiceImpl.validarAmbienteSegundoEstagio(ValidadorAmbienteServiceImpl.java:137)
        at br.com.synchro.framework.ambiente.service.impl.ValidadorAmbienteServiceImpl.validarAmbienteTodosEstagios(ValidadorAmbienteServiceImpl.java:156)
        at br.com.synchro.framework.gui.presentation.filter.ValidacaoAmbienteFilter.doFilter(ValidacaoAmbienteFilter.java:55)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at br.com.synchro.framework.gui.presentation.filter.AplicacaoPatchFilter.doFilter(AplicacaoPatchFilter.java:53)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at br.com.synchro.framework.gui.presentation.filter.XUaCompatibleFilter.doFilter(XUaCompatibleFilter.java:28)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
      ...
      

       

      Thus mean, we can't find the driver in our application classpath!

       

      When I created the driver and datasource via method 1, our application works with no problem. But if I use method 2 or 3 the application cannot find the driver in the classpath at all. Since our customers demand instalation exclusively via Administration Console, what can I do or what am I doing wrong that the driver is not in our application classpath?!

       

      Thanks in advance!!!