Package org.jboss.resource

Examples of org.jboss.resource.JBossResourceException


   private void checkIdentity(Subject subject, ConnectionRequestInfo cri) throws ResourceException
   {
      Properties newProps = mcf.getConnectionProperties(subject, cri);
      if (!props.equals(newProps))
      {
         throw new JBossResourceException("Wrong credentials passed to getConnection!");
      } // end of if ()
   }
View Full Code Here


   }

   protected void checkException(SQLException e) throws ResourceException
   {
      connectionError(e);
      throw new JBossResourceException("SQLException", e);
   }
View Full Code Here

               {
                  checkException(e);
               }
            }
            else
               throw new JBossResourceException("Trying to begin a nested local tx");
         }
      }
      finally
      {
         unlock();
View Full Code Here

   @Override
   public Object createConnectionFactory(ConnectionManager cm) throws ResourceException
   {
      // check some invariants before they come back to haunt us
      if(driverClass == null)
         throw new JBossResourceException("driverClass is null");
      if(connectionURL == null)
         throw new JBossResourceException("connectionURL is null");
     
      return super.createConnectionFactory(cm);
   }
View Full Code Here

     {
       String url = getConnectionURL();
       Driver d = getDriver(url);
       con = d.connect(url, copy);
       if (con == null)
         throw new JBossResourceException("Wrong driver class for this connection URL");

       return new LocalManagedConnection(this, con, props, transactionIsolation, preparedStatementCacheSize);
     }
     catch (Throwable e)
     {
         if (con != null)
         {
            try
            {
               con.close();
            }
            catch (Throwable ignored)
            {
            }
         }
       throw new JBossResourceException("Could not create connection", e);
     }
   }
View Full Code Here

        urlSelector.failedUrlObject(url);
        }
      }

      // we have supposedly tried all the urls
    throw new JBossResourceException(
           "Could not create connection using any of the URLs: " + urlSelector.getAllUrlObjects());
   }
View Full Code Here

      if (trace)
         log.trace("Checking driver for URL: " + url);

      if (driverClass == null)
      {
         throw new JBossResourceException("No Driver class specified (url = " + url + ")!");
      }

      // Check if the driver is already loaded, if not then try to load it

      if (isDriverLoadedForURL(url))
      {
         return driver;
      } // end of if ()

      try
      {
         //try to load the class... this should register with DriverManager.
         Class clazz = Class.forName(driverClass, true, Thread.currentThread().getContextClassLoader());
         if (isDriverLoadedForURL(url))
            //return immediately, some drivers (Cloudscape) do not let you create an instance.
            return driver;

         //We loaded the class, but either it didn't register
         //and is not spec compliant, or is the wrong class.
         driver = (Driver) clazz.newInstance();
         DriverManager.registerDriver(driver);
         if (isDriverLoadedForURL(url))
            return driver;
         //We can even instantiate one, it must be the wrong class for the URL.
      }
      catch (Exception e)
      {
         throw new JBossResourceException("Failed to register driver for: " + driverClass, e);
      }

      throw new JBossResourceException("Apparently wrong driver class specified for URL: class: " + driverClass
            + ", url: " + url);
   }
View Full Code Here

   private XADataSource createXaDataSource(Properties xaProps)
   throws JBossResourceException
   {
   if(getXADataSourceClass() == null)
   {
      throw new JBossResourceException("No XADataSourceClass supplied!");
   }

   XADataSource xads;
   try
   {
      Class clazz = Thread.currentThread().getContextClassLoader().loadClass(getXADataSourceClass());
      xads = (XADataSource)clazz.newInstance();
      Class[] NOCLASSES = new Class[]{};
      for(Iterator i = xaProps.keySet().iterator(); i.hasNext();)
      {
         String name = (String)i.next();
         String value = xaProps.getProperty(name);
         char firstCharName = Character.toUpperCase(name.charAt(0));
        if (name.length() > 1)
          name = firstCharName+name.substring(1);
        else
           name = ""+firstCharName;                                                                                                           
         //This is a bad solution.  On the other hand the only known example
         // of a setter with no getter is for Oracle with password.
         //Anyway, each xadatasource implementation should get its
         //own subclass of this that explicitly sets the
         //properties individually.
         Class type = null;
         try
         {
            Method getter = clazz.getMethod("get" + name, NOCLASSES);
            type = getter.getReturnType();
         }
         catch(NoSuchMethodException e)
         {
            type = String.class;
         } // end of try-catch

         Method setter = clazz.getMethod("set" + name, new Class[]{type});
         PropertyEditor editor = PropertyEditorManager.findEditor(type);
         if(editor == null)
         {
            throw new JBossResourceException("No property editor found for type: " + type);
         } // end of if ()
         editor.setAsText(value);
         setter.invoke(xads, new Object[]{editor.getValue()});

      } // end of for ()
   }
   catch(ClassNotFoundException cnfe)
   {
      throw new JBossResourceException("Class not found for XADataSource " + getXADataSourceClass(), cnfe);
   } // end of try-catch
   catch(InstantiationException ie)
   {
      throw new JBossResourceException("Could not create an XADataSource: ", ie);
   } // end of catch
   catch(IllegalAccessException iae)
   {
      throw new JBossResourceException("Could not set a property: ", iae);
   } // end of catch

   catch(IllegalArgumentException iae)
   {
      throw new JBossResourceException("Could not set a property: ", iae);
   } // end of catch

   catch(InvocationTargetException ite)
   {
      throw new JBossResourceException("Could not invoke setter on XADataSource: ", ite);
   } // end of catch
   catch(NoSuchMethodException nsme)
   {
      throw new JBossResourceException("Could not find accessor on XADataSource: ", nsme);
   } // end of catch

   return xads;
   }
View Full Code Here

         {
            xaProps.load(is);
         }
         catch (IOException ioe)
         {
            throw new JBossResourceException("Could not load connection properties", ioe);
         }
      }
      initSelector();
   }
View Full Code Here

       xadsSelector.failedUrlObject(xaData);
        }
     }
 
     // we have supposedly tried all the urls
     throw new JBossResourceException(
        "Could not create connection using any of the URLs: " + xadsSelector.getAllUrlObjects()
     );    
   }
View Full Code Here

TOP

Related Classes of org.jboss.resource.JBossResourceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.