14 Replies Latest reply: Jul 2, 2012 1:41 PM by papablopo RSS

    java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver

    papablopo Newbie

      Hello I newbie with jboss and java, im programming an aplication ion jboss 7.1, im having a problem when try to create my connection

       

      this its ok, config the master database connection using jndi

       

      public ConexionDirecta(){

             

                  InitialContext cxt;

                  try {

                  cxt = new InitialContext();

                 

                 

                  DataSource ds = (DataSource) cxt.lookup( "java:jboss/datasources/OracleDSJNDI");

                  ds.setLoginTimeout(5);

                  conn = ds.getConnection();

       

                  /*

                  try {

                      Class.forName("oracle.jdbc.OracleDriver").newInstance();

                  } catch (InstantiationException e) {

                      // TODO Auto-generated catch block

                      e.printStackTrace();

                  } catch (IllegalAccessException e) {

                      // TODO Auto-generated catch block

                      e.printStackTrace();

                  } catch (ClassNotFoundException e) {

                      // TODO Auto-generated catch block

                      e.printStackTrace();

                  }

                

                  System.out.println("conexion con la base EXITOSA " + conn.hashCode());

              } catch (SQLException ex) {

                  ex.printStackTrace();

              } catch (NamingException e) {

                  // TODO Auto-generated catch block

                  e.printStackTrace();

              }

          }

       

       

      but i need to create another connection, depending, we have 500 databases, one per store, im trying this.

       

      public ConexionDirecta(Long sBarrio){

              final String DB_DRIVER_CLASS = "oracle.jdbc.OracleDriver";

               RespuestaServidorFarmacia rsf= cg.getServidorFarmacia(sBarrio);

              

               if (rsf.getiError()==1){

                   System.out.println("Error al traer parametros de conexion");

                   return;

               }

              

              

              final String DB_URL = "jdbc:oracle:thin:user/pass@"+rsf.getsIp()+":1521"+":"+rsf.getsSid();

       

              conn = null;

       

              try {

                 

                  // Load the Driver.

                 // Class.forName(DB_DRIVER_CLASS).newInstance();

                   //Class.forName("oracle.jdbc.OracleDriver").newInstance();

                 

                  //Class.forName (DB_DRIVER_CLASS);

                  DriverManager.registerDriver (new oracle.jdbc.OracleDriver());

                 

                  conn= DriverManager.getConnection(DB_URL);;

       

              } catch (SQLException se) {

                   System.out.println("Error al traer parametros de conexion");

              } catch (Exception e) {

                   System.out.println("Error al traer parametros de conexion");

              }

       

       

          }

       

      i tried a lot of methods, i read an lot of post here and in other pages, but i cant resolve why i getting this error, we dont want to use jndi because every connection data are stored at the master database, want to do a programatically connection, please help me dont know what to do.

       

      thanks for ur time.

       

       

      org.jboss.resteasy.spi.UnhandledException: java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver

      org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:340)

      org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:214)

      org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:190)

      org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:540)

      org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502)

      org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)

      org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

      org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

      javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)

      causa raíz

      java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
           com.gpf.hubFacturacionPart3.ConexionDinamica.ConexionDirecta.<init>(ConexionDirecta.java:90)
           com.gpf.hubFacturacionPart3.rest.WebResourceRESTService.getConfiguracionFarmaciaCercana(WebResourceRESTService.java:96)
           com.gpf.hubFacturacionPart3.rest.WebResourceRESTService$Proxy$_$$_WeldClientProxy.getConfiguracionFarmaciaCercana(WebResourceRESTService$Proxy$_$$_WeldClientProxy.java)
           sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           java.lang.reflect.Method.invoke(Method.java:597)
           org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:155)
           org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
           org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
           org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)
           org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525)
           org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502)
           org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
           org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
           org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
           org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
           javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
           org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)

      causa raíz

      java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver from [Module "deployment.HUBFacturacion.war:main" from Service Module Loader]
           org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
           org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
           org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
           org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)
           org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
           org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
           com.gpf.hubFacturacionPart3.ConexionDinamica.ConexionDirecta.<init>(ConexionDirecta.java:90)
           com.gpf.hubFacturacionPart3.rest.WebResourceRESTService.getConfiguracionFarmaciaCercana(WebResourceRESTService.java:96)
           com.gpf.hubFacturacionPart3.rest.WebResourceRESTService$Proxy$_$$_WeldClientProxy.getConfiguracionFarmaciaCercana(WebResourceRESTService$Proxy$_$$_WeldClientProxy.java)
           sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           java.lang.reflect.Method.invoke(Method.java:597)
           org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:155)
           org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
           org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
           org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)
           org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525)
           org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502)
           org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
           org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
           org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
           org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
           javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
           org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)