Exception Fact Sheet for "jboss"

The goal of an Exception Fact Sheet is to reveal the design of exception handling in an application.

--Maxence, Martin

For feedback, please contact Martin

Table of contents

Basic Statistics

Number of Classes 1142
Number of Domain Exception Types (Thrown or Caught) 9
Number of Domain Checked Exception Types 3
Number of Domain Runtime Exception Types 3
Number of Domain Unknown Exception Types 3
nTh = Number of Throw 1510
nTh = Number of Throw in Catch 665
Number of Catch-Rethrow (may not be correct) 126
nC = Number of Catch 1012
nCTh = Number of Catch with Throw 581
Number of Empty Catch (really Empty) 60
Number of Empty Catch (with comments) 30
Number of Empty Catch 90
nM = Number of Methods 6251
nbFunctionWithCatch = Number of Methods with Catch 639 / 6251
nbFunctionWithThrow = Number of Methods with Throw 895 / 6251
nbFunctionWithThrowS = Number of Methods with ThrowS 1447 / 6251
nbFunctionTransmitting = Number of Methods with "Throws" but NO catch, NO throw (only transmitting) 893 / 6251
P1 = nCTh / nC 57.4% (0.574)
P2 = nMC / nM 10.2% (0.102)
P3 = nbFunctionWithThrow / nbFunction 14.3% (0.143)
P4 = nbFunctionTransmitting / nbFunction 14.3% (0.143)
P5 = nbThrowInCatch / nbThrow 44% (0.44)
R2 = nCatch / nThrow 0.67
A1 = Number of Caught Exception Types From External Libraries 59
A2 = Number of Reused Exception Types From External Libraries (thrown from application code) 49

W1 is a rough estimation of the richness of the exception model. It does not take into account the inheritance relationships between domain exceptions.

Proportion P1 measures the overall exception flow. According to our experience, it varies from 5% to 70%. Early-catch design generally yields a low P1, libraries that must warn clients about errors (e.g. databases) generally have a high P1.

Proportion P2 measures the dispersion of catch blocks in the application. According to our experience, it varies from 2% to 15%. A small P2 indicates a rather centralized management of errors.

R1 shows how many exceptions types from libraries (incl. JDK) are thrown from application code. For instance, IllegalArgumentException comes from the JDK but is used in many applications.

A1 measures the awareness of the application to library exceptions. A high value of A1 means either that the application is polluted with checked exceptions or that it is able to apply specific recovery depending on the library exception.

Exception Hierachy

Exception Map

Each exception that is used at least once in the project is a dot. A orange dot represents a domain exception that is defined in the application. A blue dot exception is defined in the JDK or in a library. The x-axis represents the number of times an exception is caught, the y-axis the number of times an exception is thrown.

Exceptions With State

State means fields. Number of exceptions with state: 3
InvocationException
              package org.jboss.invocation;public class InvocationException
    extends Exception
{
   private Throwable cause = null;

   public InvocationException(Throwable cause)
   {
      super();
      this.cause = cause;
   }
   
   public InvocationException(String msg, Throwable cause)
   {
      super(msg);
      this.cause = cause;
   }

   public Throwable getTargetException()
   {
      return cause;
   }

}
            
InvokerAdaptorException
              package org.jboss.jmx.connector.invoker.client;public class InvokerAdaptorException extends Exception implements Serializable
{
   // Constants -----------------------------------------------------
   
   private static final long serialVersionUID = 24842201105890823L;
   
   // Attributes ----------------------------------------------------
   
   /** The wrapped exception */
   private Throwable wrapped;
   
   // Constructors --------------------------------------------------

   public InvokerAdaptorException()
   {
      // For serialization
   }
   
   public InvokerAdaptorException(Throwable wrapped)
   {
      this.wrapped = wrapped;
   }
   
   // Public --------------------------------------------------------

   public Throwable getWrapped() 
   {
      return wrapped;
   }

   // Private -------------------------------------------------------
   
   // Inner classes -------------------------------------------------
}
            
UnknownPathException
              package org.jboss.ejb.plugins.cmp.ejbql;public final class UnknownPathException extends RuntimeException {
   private final String reason;
   private final String path;
   private final String fieldName;
   private final int errorLine;
   private final int errorColumn;
   
   public UnknownPathException(
         String reason,
         String path,
         String fieldName,
         int errorLine,
         int errorColumn) {

      super(reason + ": at line " + errorLine + ", "+
            "column " + errorColumn + ".  " +
            "Encountered: \"" + fieldName + "\"" +
            ((path==null) ? "" : " after: \"" + path + "\"") );

      this.reason = reason;
      this.path = path;
      this.fieldName = fieldName;
      this.errorLine = errorLine;
      this.errorColumn = errorColumn;
   }
   public String getReason() {
      return reason;
   }
   public String getCurrentPath() {
      return path;
   }
   public String getFieldName() {
      return fieldName;
   }
   public int getErrorLine() {
      return errorLine;
   }
   public int getErrorColumn() {
      return errorColumn;
   }
}
            

Thrown Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be thrown, thrown from within a catch, or declared in the signature of a method (usually for checked exceptions). Hovering over a number triggers showing code snippets from the application code.

Type Exception Thrown Thrown
from Catch
Declared
- Unknown 260
              
//in src/main/java/org/jboss/invocation/http/interfaces/Util.java
throw (Exception) value;

              
//in src/main/java/org/jboss/invocation/http/interfaces/Util.java
throw e;

              
//in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
throw (Exception) t;

              
//in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
throw (Error) t;

              
//in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
throw e;

              
//in src/main/java/org/jboss/invocation/InvokerInterceptor.java
throw (Exception) t2;

              
//in src/main/java/org/jboss/invocation/InvokerInterceptor.java
throw (Exception) t2;

              
//in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
//in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
//in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
//in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
//in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
//in src/main/java/org/jboss/invocation/local/LocalInvoker.java
throw e;

              
//in src/main/java/org/jboss/invocation/local/LocalInvoker.java
throw ex;

              
//in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
throw ((Exception) response);

              
//in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
throw aex;

              
//in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
throw (Exception) throwable;

              
//in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
throw e;

              
//in src/main/java/org/jboss/client/ReflectionLauncher.java
throw e.getTargetException();

              
//in src/main/java/org/jboss/jmx/connector/invoker/client/InvokerAdaptorClientInterceptor.java
throw e.getWrapped();

              
//in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
throw (Exception) t;

              
//in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
throw e;

              
//in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
throw e;

              
//in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
throw ex;

              
//in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
throw (Exception) t;

              
//in src/main/java/org/jboss/metadata/XmlFileLoader.java
throw ex;

              
//in src/main/java/org/jboss/metadata/XmlFileLoader.java
throw ex;

              
//in src/main/java/org/jboss/metadata/XmlFileLoader.java
throw e;

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw xae;

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw e;

              
//in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw e;

              
//in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e);

              
//in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t);

              
//in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e);

              
//in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e);

              
//in src/main/java/org/jboss/naming/ExternalContext.java
throw ne;

              
//in src/main/java/org/jboss/naming/ExternalContext.java
throw e.getTargetException();

              
//in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
throw ex;

              
//in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
throw ex;

              
//in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
throw e;

              
//in src/main/java/org/jboss/naming/JNDIBindingService.java
throw ne;

              
//in src/main/java/org/jboss/naming/NamingService.java
throw (Exception) t;

              
//in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
throw e;

              
//in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
throw ce;

              
//in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
throw sue;

              
//in src/main/java/org/jboss/naming/JndiBinder.java
throw namingException;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
//in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
throw ex;

              
//in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
throw ex;

              
//in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
throw (Exception) t;

              
//in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
throw e;

              
//in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
throw ex;

              
//in src/main/java/org/jboss/ejb/SecurityActions.java
throw e.getException();

              
//in src/main/java/org/jboss/ejb/SecurityActions.java
throw (PolicyContextException) ex;

              
//in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
throw (Exception)ex;

              
//in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
throw (Exception)ex;

              
//in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
throw (Error)ex;

              
//in src/main/java/org/jboss/ejb/EjbModule.java
throw e;

              
//in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
throw (EJBException) t;

              
//in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
throw (Exception) t;

              
//in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
throw (Error) t;

              
//in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
throw (EJBException)t;

              
//in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
throw (Exception)t;

              
//in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
throw (Error)t;

              
//in src/main/java/org/jboss/ejb/Container.java
throw (EJBException)t;

              
//in src/main/java/org/jboss/ejb/Container.java
throw (Exception)t;

              
//in src/main/java/org/jboss/ejb/Container.java
throw (Error)t;

              
//in src/main/java/org/jboss/ejb/Container.java
throw e;

              
//in src/main/java/org/jboss/ejb/Container.java
throw ex;

              
//in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e);

              
//in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw exception;

              
//in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
throw t;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (CreateException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Exception)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Error)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (CreateException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Exception)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Error)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoveException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (FinderException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Exception)e;

              
//in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Error)e;

              
//in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
throw (FileNotFoundException) e.getException();

              
//in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
throw (FileNotFoundException) e.getException();

              
//in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
throw deadlock;

              
//in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
throw (PolicyContextException) ex;

              
//in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
throw throwable;

              
//in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
throw (RuntimeException)t;

              
//in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
throw (Error)t;

              
//in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (Exception) e;

              
//in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (Exception) e;

              
//in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (Error) e;

              
//in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (TransactionRolledbackLocalException) cause;

              
//in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (TransactionRolledbackException) cause;

              
//in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (EJBException) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (Exception) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (Error) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (EJBException) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (Exception) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (Error) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (RemoteException) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (EJBException) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (RemoveException) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (RemoteException) e;

              
//in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (EJBException) e;

              
//in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
throw re;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw ejbe;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw fe;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw ejbe;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw fe;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
throw ejbe;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
throw ce;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
throw ejbe;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
throw fe;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
throw (RuntimeException) t;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
throw (Error) t;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
throw de;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
throw (PolicyContextException) ex;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
throw (FinderException) ex;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
throw processException(e);

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
throw (CreateException) e;

              
//in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
throw handleException(e, invocation);

              
//in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
throw handleException(e, invocation);

              
//in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw ex;

              
//in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
throw e;

              
//in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
throw (EJBException) causeByException;

              
//in src/main/java/org/jboss/ejb/EntityContainer.java
throw e;

              
//in src/main/java/org/jboss/ejb/EntityContainer.java
throw e;

              
//in src/main/java/org/jboss/ejb/AllowedOperationsAssociation.java
throw ex;

              
//in src/main/java/org/jboss/Shutdown.java
throw e.getUndeclaredThrowable();

              
//in src/main/java/org/jboss/web/WebServer.java
throw e;

              
//in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e);

              
//in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e);

              
//in src/main/java/org/jboss/web/deployers/WARStructure.java
throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);

              
//in src/main/java/org/jboss/proxy/compiler/Proxies.java
throw e.getTargetException();

              
//in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
throw e;

              
//in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
throw e;

            
- -
- Builder 29
              
// in src/main/java/org/jboss/client/ReflectionLauncher.java
throw e.getTargetException();

              
// in src/main/java/org/jboss/jmx/connector/invoker/client/InvokerAdaptorClientInterceptor.java
throw e.getWrapped();

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw check(e);

              
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e);

              
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t);

              
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e);

              
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e);

              
// in src/main/java/org/jboss/naming/ExternalContext.java
throw e.getTargetException();

              
// in src/main/java/org/jboss/ejb/SecurityActions.java
throw e.getException();

              
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e);

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
throw (FileNotFoundException) e.getException();

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
throw (FileNotFoundException) e.getException();

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
throw processException(e);

              
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
throw handleException(e, invocation);

              
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
throw handleException(e, invocation);

              
// in src/main/java/org/jboss/Shutdown.java
throw e.getUndeclaredThrowable();

              
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e);

              
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e);

              
// in src/main/java/org/jboss/web/deployers/WARStructure.java
throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);

              
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
throw e.getTargetException();

            
- -
- Variable 233
              
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
throw (Exception) value;

              
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
throw e;

              
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
throw (Exception) t;

              
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
throw (Error) t;

              
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
throw e;

              
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
throw (Exception) t2;

              
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
throw (Exception) t2;

              
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
throw ise;

              
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
throw e;

              
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
throw ex;

              
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
throw ((Exception) response);

              
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
throw aex;

              
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
throw (Exception) throwable;

              
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
throw e;

              
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
throw (Exception) t;

              
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
throw e;

              
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
throw e;

              
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
throw ex;

              
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
throw (Exception) t;

              
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
throw ex;

              
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
throw ex;

              
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
throw e;

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw xae;

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw e;

              
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
throw e;

              
// in src/main/java/org/jboss/naming/ExternalContext.java
throw ne;

              
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
throw ex;

              
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
throw ex;

              
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
throw e;

              
// in src/main/java/org/jboss/naming/JNDIBindingService.java
throw ne;

              
// in src/main/java/org/jboss/naming/NamingService.java
throw (Exception) t;

              
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
throw e;

              
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
throw ce;

              
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
throw sue;

              
// in src/main/java/org/jboss/naming/JndiBinder.java
throw namingException;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
throw e;

              
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
throw ex;

              
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
throw ex;

              
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
throw (Exception) t;

              
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
throw e;

              
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
throw ex;

              
// in src/main/java/org/jboss/ejb/SecurityActions.java
throw (PolicyContextException) ex;

              
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
throw (Exception)ex;

              
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
throw (Exception)ex;

              
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
throw (Error)ex;

              
// in src/main/java/org/jboss/ejb/EjbModule.java
throw e;

              
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
throw (EJBException) t;

              
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
throw (Exception) t;

              
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
throw (Error) t;

              
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
throw (EJBException)t;

              
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
throw (Exception)t;

              
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
throw (Error)t;

              
// in src/main/java/org/jboss/ejb/Container.java
throw (EJBException)t;

              
// in src/main/java/org/jboss/ejb/Container.java
throw (Exception)t;

              
// in src/main/java/org/jboss/ejb/Container.java
throw (Error)t;

              
// in src/main/java/org/jboss/ejb/Container.java
throw e;

              
// in src/main/java/org/jboss/ejb/Container.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw exception;

              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
throw t;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (CreateException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Exception)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Error)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (CreateException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Exception)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Error)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoveException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (FinderException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (RemoteException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (EJBException)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Exception)e;

              
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
throw (Error)e;

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
throw (FileNotFoundException) e.getException();

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
throw (FileNotFoundException) e.getException();

              
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
throw deadlock;

              
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
throw (PolicyContextException) ex;

              
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
throw throwable;

              
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
throw (RuntimeException)t;

              
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
throw (Error)t;

              
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (Exception) e;

              
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (Exception) e;

              
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (Error) e;

              
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (TransactionRolledbackLocalException) cause;

              
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw (TransactionRolledbackException) cause;

              
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (EJBException) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (Exception) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (Error) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (EJBException) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (Exception) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (Error) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (RemoteException) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (EJBException) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (RemoveException) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (RemoteException) e;

              
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
throw (EJBException) e;

              
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
throw re;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw ejbe;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw fe;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw ejbe;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
throw fe;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
throw ejbe;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
throw ce;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
throw ejbe;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
throw fe;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
throw (RuntimeException) t;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
throw (Error) t;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
throw de;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
throw (PolicyContextException) ex;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
throw (FinderException) ex;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
throw (CreateException) e;

              
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw ex;

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
throw e;

              
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
throw (EJBException) causeByException;

              
// in src/main/java/org/jboss/ejb/EntityContainer.java
throw e;

              
// in src/main/java/org/jboss/ejb/EntityContainer.java
throw e;

              
// in src/main/java/org/jboss/ejb/AllowedOperationsAssociation.java
throw ex;

              
// in src/main/java/org/jboss/web/WebServer.java
throw e;

              
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
throw e;

              
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
throw e;

            
- -
(Lib) DeploymentException 278
              
// in src/main/java/org/jboss/jmx/connector/invoker/MBeanProxyRemote.java
protected void startService() throws Exception { if (MBeanProxyExt.remote != null) throw new IllegalStateException("Remote MBeanServerConnection is already set " + MBeanProxyExt.remote); Object o = server.getAttribute(mbeanServerConnection, "Proxy"); if (o instanceof MBeanServerConnection == false) throw new DeploymentException(mbeanServerConnection + " does not define an MBeanServerConnection"); MBeanProxyExt.remote = (MBeanServerConnection) o; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public ApplicationMetaData load(URL alternativeDD) throws Exception { URL ejbjarUrl = null; if (alternativeDD != null) { log.debug("Using alternativeDD: " + alternativeDD); ejbjarUrl = alternativeDD; } else { ejbjarUrl = getClassLoader().getResource("META-INF/ejb-jar.xml"); } if (ejbjarUrl == null) { throw new DeploymentException("no ejb-jar.xml found"); } // create the metadata JBossMetaData realMetaData = new JBossMetaData(); metaData = new ApplicationMetaData(realMetaData); Document ejbjarDocument = getDocumentFromURL(ejbjarUrl); // the url may be used to report errors metaData.setUrl(ejbjarUrl); metaData.importEjbJarXml(ejbjarDocument.getDocumentElement()); // Load jbossdefault.xml from the default classLoader // we always load defaults first // we use the context classloader, because this guy has to know where // this file is URL defaultJbossUrl = Thread.currentThread().getContextClassLoader().getResource("standardjboss.xml"); if (defaultJbossUrl == null) { throw new DeploymentException("no standardjboss.xml found"); } Document defaultJbossDocument = null; try { defaultJbossDocument = getDocumentFromURL(defaultJbossUrl); metaData.setUrl(defaultJbossUrl); metaData.importJbossXml(defaultJbossDocument.getDocumentElement()); } catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; } // Load jboss.xml // if this file is provided, then we override the defaults try { URL jbossUrl = getClassLoader().getResource("META-INF/jboss.xml"); if (jbossUrl != null) { Document jbossDocument = getDocumentFromURL(jbossUrl); metaData.setUrl(jbossUrl); metaData.importJbossXml(jbossDocument.getDocumentElement()); } } catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; } return metaData; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocumentFromURL(URL url) throws DeploymentException { InputStream is = null; try { is = url.openStream(); return getDocument(is, url.toExternalForm()); } catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); } }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocument(InputSource is, String inPath) throws DeploymentException { try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); // Enable DTD validation based on our validateDTDs flag docBuilderFactory.setValidating(validateDTDs); // make the parser namespace-aware in case we deal // with ejb2.1 descriptors, will not break dtd parsing in any way // in which case there would be just a default namespace docBuilderFactory.setNamespaceAware(true); // this will (along JAXP in conjunction with // validation+namespace-awareness) enable xml schema checking. // Will currently fail because some J2EE1.4/W3C schemas // are still lacking. //docBuilderFactory.setAttribute // ("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema"); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); JBossEntityResolver lr = new JBossEntityResolver(); LocalErrorHandler eh = new LocalErrorHandler( inPath, lr ); docBuilder.setEntityResolver(lr); docBuilder.setErrorHandler(eh ); Document doc = docBuilder.parse(is); if(validateDTDs && eh.hadError()) { throw new DeploymentException("Invalid XML: file=" + inPath, eh.getException()); } return doc; } catch (DeploymentException e) { throw e; } catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); } catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); } catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); } }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
protected void startService() throws Exception { // validate the configuration if (queueFactoryRef == null) throw new DeploymentException("missing required attribute: QueueFactoryRef"); if (topicFactoryRef == null) throw new DeploymentException("missing required attribute: TopicFactoryRef"); Class cls = Thread.currentThread().getContextClassLoader().loadClass(providerAdapterClass); providerAdapter = (JMSProviderAdapter) cls.newInstance(); providerAdapter.setName(providerName); providerAdapter.setProperties(properties); providerAdapter.setFactoryRef(factoryRef); providerAdapter.setQueueFactoryRef(queueFactoryRef); providerAdapter.setTopicFactoryRef(topicFactoryRef); InitialContext context = new InitialContext(); try { // Bind in JNDI if (jndiName == null) { String name = providerAdapter.getName(); jndiName = "java:/" + name; } bind(context, jndiName, providerAdapter); log.debug("Bound adapter to " + jndiName); } finally { context.close(); } }
// in src/main/java/org/jboss/deployment/J2eeModuleMetaData.java
public void importXml(Element rootElement) throws DeploymentException { String rootTag = rootElement.getOwnerDocument().getDocumentElement().getTagName(); if (rootTag.equals("application")) importXml(rootElement, false); else if (rootTag.equals("jboss-app")) importXml(rootElement, true); else throw new DeploymentException("Unrecognized root tag: " + rootTag); }
// in src/main/java/org/jboss/deployment/J2eeModuleMetaData.java
protected void importXml(Element element, boolean jbossSpecific) throws DeploymentException { String name = element.getTagName(); if (name.equals("module")) { boolean done = false; // only one of the tags can hit! for (int i = 0; done == false && i < tags.length; ++i) { Element child = getOptionalChild(element, tags[i]); if (child == null) { continue; } type = i; switch (type) { case SERVICE: if (jbossSpecific == false) { throw new DeploymentException("Service archives must be in jboss-app.xml"); } // end of if () //fall through. case HAR: if (jbossSpecific == false) { throw new DeploymentException("Hibernate archives must be in jboss-app.xml"); } case EJB: case CLIENT: case CONNECTOR: fileName = getElementContent(child); alternativeDD = getElementContent(getOptionalChild(element, "alt-dd")); break; case WEB: fileName = getElementContent(getUniqueChild(child, "web-uri")); webContext = getElementContent(getOptionalChild(child, "context-root")); alternativeDD = getElementContent(getOptionalChild(element, "alt-dd")); break; } done = true; } // If the module content is not recognized throw an exception if (done == false) { StringBuffer msg = new StringBuffer("Invalid module content, must be one of: "); for (int i = 0; i < tags.length; i ++) { msg.append(tags[i]); msg.append(", "); } throw new DeploymentException(msg.toString()); } } else { throw new DeploymentException("non-module tag in application dd: " + name); } }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (deploymentName == null) throw new IllegalArgumentException("Null deployment name"); if (loaderMetaData == null) throw new IllegalArgumentException("Null loader repository metadata"); LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig(); repositoryConfig.repositoryClassName = loaderMetaData.getLoaderRepositoryClass(); if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0) repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS; // Get the object name of the repository String name = loaderMetaData.getName(); if (name != null) { try { repositoryConfig.repositoryName = new ObjectName(name.trim()); } catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); } } StringBuilder configData = new StringBuilder(); Set<LoaderRepositoryConfigMetaData> children = loaderMetaData.getLoaderRepositoryConfig(); if (children != null) { for (LoaderRepositoryConfigMetaData child : children) { // This looks stupid? Why inside a loop? String parserClassName = child.getConfigParserClass(); if (parserClassName == null || parserClassName.length() == 0) repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS; else repositoryConfig.configParserClassName = parserClassName; // Append all config String childConfig = child.getConfig(); if (childConfig != null) configData.append(childConfig); } } repositoryConfig.repositoryConfig = configData.toString().trim(); return LoaderRepositoryConfigHelper.create(name, repositoryConfig, parentDelegation); }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
private JBossMetaData getStandardMetaData() throws DeploymentException { if (standardMetaData == null) { try { if(standardJBossXmlPath == null) { // Use default server conf/standardjboss.xml location final String configPropName = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_CONF_URL; String configPath = System.getProperty(configPropName); if(configPath == null ) { if(ignoreMissingStandardJBossXml == false) throw new DeploymentException("standardjboss.xml not specified and "+configPropName+" does not exist"); return null; } URL configUrl = new URL(configPath); standardJBossXmlPath = new URL(configUrl, "standardjboss.xml"); } VirtualFile stdJBoss = VFS.getChild(standardJBossXmlPath); if (stdJBoss == null && ignoreMissingStandardJBossXml == false) { throw new DeploymentException("standardjboss.xml not found in config dir: " + standardJBossXmlPath); } standardMetaData = super.parse(stdJBoss); } catch (Exception ex) { DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex); } } return standardMetaData; }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
Override public void deploy(DeploymentUnit unit, JBossAppMetaData deployment) throws DeploymentException { //Perform JACC Policy Configuration String contextID = shortNameFromDeploymentName(unit.getSimpleName()); PolicyConfigurationFactory pcFactory = null; try { pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true); unit.addAttachment(PolicyConfiguration.class, pc); } catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); } catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
public void internalDeploy(DeploymentUnit unit) throws DeploymentException { JBossMetaData ejbMetaData = unit.getAttachment(JBossMetaData.class); JBossWebMetaData webMetaData = unit.getAttachment(JBossWebMetaData.class); JBossClientMetaData clientMetaData = unit.getAttachment(JBossClientMetaData.class); if(ejbMetaData == null && webMetaData == null && clientMetaData == null) return; // Create a map of the reference endpoints if it does not exist in the top unit DeploymentUnit top = unit.getTopLevel(); Map<String, ContainerDependencyMetaData> endpointMap = top.getAttachment(ENDPOINT_MAP_KEY, Map.class); Map<String, String> endpointAlternateMap = top.getAttachment(ALTERNATE_MAP_KEY, Map.class); if(endpointMap == null) { endpointMap = new ConcurrentHashMap<String, ContainerDependencyMetaData>(); endpointAlternateMap = new ConcurrentHashMap<String, String>(); mapEndpoints(top, endpointMap, endpointAlternateMap); top.addAttachment(ENDPOINT_MAP_KEY, endpointMap, Map.class); top.addAttachment(ALTERNATE_MAP_KEY, endpointAlternateMap); DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver(endpointMap, endpointAlternateMap, unit.getRelativePath()); top.addAttachment(DeploymentEndpointResolver.class, resolver); } DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver( endpointMap, endpointAlternateMap, unit.getRelativePath()); List<String> unresolvedPaths = new ArrayList<String>(); if(ejbMetaData != null) { JBossEnterpriseBeansMetaData beans = ejbMetaData.getEnterpriseBeans(); // Process ejb references try { resolve(unit, endpointMap, beans, resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossMetaData:"+unresolvedPaths); } if(webMetaData != null) { // Process web app references ContainerDependencyMetaData webAppCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "web-app", unit.getRelativePath()); try { resolve(webAppCDMD, unit, endpointMap, webMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossWebMetaData:"+unresolvedPaths); } if(clientMetaData != null) { // Process client app references ContainerDependencyMetaData clientCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "client", unit.getRelativePath()); try { resolve(clientCDMD, unit, endpointMap, clientMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossClientMetaData: "+unresolvedPaths); } // Add the unique set of ContainerDependencyMetaData Set<ContainerDependencyMetaData> depends = new HashSet<ContainerDependencyMetaData>(); for(ContainerDependencyMetaData cdmd : endpointMap.values()) { depends.add(cdmd); } top.addAttachment(DEPENDS_SET_KEY, depends, Set.class); unit.addAttachment(DeploymentEndpointResolver.class, resolver); dump(unit); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
public void deploy(VFSDeploymentUnit unit) throws DeploymentException { VirtualFile root = unit.getRoot(); String relativePath = unit.getRelativePath(); VirtualFile ear = unit.getFile(relativePath); if (ear == null) throw new DeploymentException("No such ear file, relative path: '" + relativePath + "', root: " + root); deploy(unit, root, ear); }
// in src/main/java/org/jboss/deployment/ModuleNameDeployer.java
private String establishUniqueModuleName(DeploymentUnit unit, String configuredName, JBossAppMetaData appMetaData) throws DeploymentException { String name = configuredName == null ? trimExtension(unit.getRelativePath()): configuredName; String modulePath = unit.getRelativePath(); ModulesMetaData modules = appMetaData.getModules(); if (modules == null) { throw new DeploymentException(unit + " has attached " + JBossAppMetaData.class.getSimpleName() + " but it has no associated " + ModulesMetaData.class.getSimpleName()); } ModuleMetaData ourModule = null; String uniqueName = null; // Synchronize on the modules to ensure concurrent deployments of the // modules pass serially through this logic synchronized(modules) { ourModule = modules.get(modulePath); if (ourModule == null) { String parentUnitName = unit.getParent().getName(); throw new DeploymentException("No module with relative path " + modulePath + " found in set of modules for " + parentUnitName + " " + modules.keySet()); } uniqueName = name; if (!isNameUnique(uniqueName, ourModule, modules)) { // Try the relative path w/ extension removed uniqueName = trimExtension(unit.getRelativePath()); if (uniqueName.equals(name) || !isNameUnique(uniqueName, ourModule, modules)) { // Try leaving the extension uniqueName = unit.getRelativePath(); if (!isNameUnique(uniqueName, ourModule, modules)) { // To get here, people would have to configure in xml a // module name that conflicts with the relative path of // another module. Not likely, but... // Append a digit until the name is unique int i = 0; do { i++; uniqueName = name + "-" + i; } while (!isNameUnique(uniqueName, ourModule, modules)); } } } ourModule.setUniqueName(uniqueName); } // Log a WARN if we had to change the module name if (configuredName != null && !configuredName.equals(uniqueName)) { log.warn("Module name " + configuredName + " specified in deployment descriptor for " + unit + " was not unique within the application; using module name " + uniqueName + " instead"); } else if (!name.equals(uniqueName)) { log.warn("Module name " + name + " derived from the modules relative path in " + unit + " was not unique within the application; using module name " + uniqueName + " instead"); } return uniqueName; }
// in src/main/java/org/jboss/naming/LinkRefPairService.java
protected void startService() throws Exception { if (jndiName == null) throw new DeploymentException("The jndiName is null for LinkRefPair " + getServiceName()); if (remoteJndiName == null) throw new DeploymentException("The remoteJndiName is null for LinkRefPair " + getServiceName()); if (localJndiName == null) throw new DeploymentException("The localJndiName is null for LinkRefPair " + getServiceName()); LinkRefPair pair = new LinkRefPair(remoteJndiName, localJndiName); InitialContext ctx = new InitialContext(); try { Util.bind(ctx, jndiName, pair); } finally { ctx.close(); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void addContainer(Container con) throws DeploymentException { String ejbName = con.getBeanMetaData().getEjbName(); if (containers.containsKey(ejbName)) throw new DeploymentException("Duplicate ejb-name. Container for " + ejbName + " already exists."); containers.put(ejbName, con); containerOrdering.add(con); con.setEjbModule(this); }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void initializeContainer(Container container, ConfigurationMetaData conf, BeanMetaData bean, int transType, DeploymentUnit unit) throws NamingException, DeploymentException { // Create local classloader for this container // For loading resources that must come from the local jar. Not for loading classes! // The VFS should be used for this // container.setLocalClassLoader(new URLClassLoader(new URL[0], localCl)); // Set metadata (do it *before* creating the container's WebClassLoader) container.setEjbModule(this); container.setBeanMetaData(bean); ClassLoader unitCl = unit.getClassLoader(); // Create the container's WebClassLoader // and register it with the web service. String webClassLoaderName = getWebClassLoader(conf, bean); log.debug("Creating WebClassLoader of class " + webClassLoaderName); WebClassLoader wcl = null; try { Class clazz = unitCl.loadClass(webClassLoaderName); wcl = WebClassLoaderFactory.createWebClassLoader(clazz, container.getJmxName(), (RealClassLoader) unitCl); } catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); } if (webServiceName != null) { WebServiceMBean webServer = (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName); URL[] codebase = {webServer.addClassLoader(wcl)}; wcl.setWebURLs(codebase); } // end of if () container.setWebClassLoader(wcl); // Create classloader for this container // Only used to unique the bean ENC and does not augment class loading container.setClassLoader(new DelegatingClassLoader(wcl)); // Set transaction manager InitialContext iniCtx = new InitialContext(); container.setTransactionManager(tmFactory.getTransactionManager()); // Set container.setTimerService(timerService); // Set security domain manager String securityDomain = bean.getApplicationMetaData().getSecurityDomain(); // JBAS-5960: Set default security domain if there is security metadata boolean hasSecurityMetaData = hasSecurityMetaData(bean); if (securityDomain == null && hasSecurityMetaData) { securityDomain = SecurityConstants.DEFAULT_EJB_APPLICATION_POLICY; } String confSecurityDomain = conf.getSecurityDomain(); // Default the config security to the application security manager if (confSecurityDomain == null) confSecurityDomain = securityDomain; // Check for an empty confSecurityDomain which signifies to disable security if (confSecurityDomain != null && confSecurityDomain.length() == 0) confSecurityDomain = null; if (confSecurityDomain != null) { // Either the application has a security domain or the container has security setup try { String unprefixed = SecurityUtil.unprefixSecurityDomain(confSecurityDomain); log.debug("Setting security domain from: " + confSecurityDomain); String domainCtx = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + unprefixed + "/domainContext"; SecurityDomainContext sdc = (SecurityDomainContext) iniCtx.lookup(domainCtx); Object securityMgr = sdc.getSecurityManager(); // Object securityMgr = iniCtx.lookup(confSecurityDomain); AuthenticationManager ejbS = (AuthenticationManager) securityMgr; RealmMapping rM = (RealmMapping) securityMgr; container.setSecurityManager(ejbS); container.setRealmMapping(rM); container.setSecurityManagement(securityManagement); container.setPolicyRegistration(policyRegistration); container.setDefaultSecurityDomain((String) unit.getAttachment("EJB.defaultSecurityDomain")); container.setSecurityContextClassName((String) unit.getAttachment("EJB.securityContextClassName")); } catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); } catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); } } else { if ("".equals(securityDomain) && hasSecurityMetaData) log.warn("EJB configured to bypass security. Please verify if this is intended. Bean=" + bean.getEjbName() + " Deployment=" + unit.getName()); } // Load the security proxy instance if one was configured String securityProxyClassName = bean.getSecurityProxy(); if (securityProxyClassName != null) { try { Class proxyClass = unitCl.loadClass(securityProxyClassName); Object proxy = proxyClass.newInstance(); container.setSecurityProxy(proxy); log.debug("setSecurityProxy, " + proxy); } catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); } } // Install the container interceptors based on the configuration addInterceptors(container, transType, conf.getContainerInterceptorsConf()); }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static String getWebClassLoader(ConfigurationMetaData conf, BeanMetaData bmd) throws DeploymentException { String webClassLoader = null; Iterator it = bmd.getInvokerBindings(); int count = 0; while (it.hasNext()) { String invoker = (String) it.next(); ApplicationMetaData amd = bmd.getApplicationMetaData(); InvokerProxyBindingMetaData imd = amd.getInvokerProxyBindingMetaDataByName(invoker); if (imd == null) { String msg = "Failed to find InvokerProxyBindingMetaData for: '" + invoker + "'. Check the invoker-proxy-binding-name to " + "invoker-proxy-binding/name mappings in jboss.xml"; throw new DeploymentException(msg); } Element proxyFactoryConfig = imd.getProxyFactoryConfig(); String webCL = MetaData.getOptionalChildContent(proxyFactoryConfig, "web-class-loader"); if (webCL != null) { log.debug("Invoker " + invoker + " specified WebClassLoader class" + webCL); webClassLoader = webCL; count++; } } if (count > 1) { log.warn(count + " invokers have WebClassLoader specifications."); log.warn("Using the last specification seen (" + webClassLoader + ")."); } else if (count == 0) { webClassLoader = conf.getWebClassLoader(); if (webClassLoader == null) webClassLoader = "org.jboss.web.WebClassLoader"; } return webClassLoader; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static void createProxyFactories(BeanMetaData conf, Container container) throws Exception { ClassLoader cl = container.getClassLoader(); Iterator it = conf.getInvokerBindings(); boolean foundOne = false; while (it.hasNext()) { String invoker = (String) it.next(); String jndiBinding = conf.getInvokerBinding(invoker); log.debug("creating binding for " + jndiBinding + ":" + invoker); InvokerProxyBindingMetaData imd = conf.getApplicationMetaData().getInvokerProxyBindingMetaDataByName(invoker); EJBProxyFactory ci = null; // create a ProxyFactory instance try { ci = (EJBProxyFactory) cl.loadClass(imd.getProxyFactory()).newInstance(); ci.setContainer(container); ci.setInvokerMetaData(imd); ci.setInvokerBinding(jndiBinding); if (ci instanceof XmlLoadable) { // the container invoker can load its configuration from the jboss.xml element ((XmlLoadable) ci).importXml(imd.getProxyFactoryConfig()); } container.addProxyFactory(invoker, ci); foundOne = true; } catch (Exception e) { log.warn("The Container Invoker " + invoker + " (in jboss.xml or standardjboss.xml) could not be created because of " + e + " We will ignore this error, but you may miss a transport for this bean."); } } if (!foundOne) { throw new DeploymentException("Missing or invalid Container Invokers (in jboss.xml or standardjboss.xml)."); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static BeanLockManager createBeanLockManager(Container container, boolean reentrant, String beanLock, ClassLoader cl) throws Exception { // The bean lock manager BeanLockManager lockManager = new BeanLockManager(container); Class lockClass = null; try { if (beanLock == null) beanLock = "org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock"; lockClass = cl.loadClass(beanLock); } catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); } lockManager.setLockCLass(lockClass); lockManager.setReentrant(reentrant); return lockManager; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static InstancePool createInstancePool(ConfigurationMetaData conf, ClassLoader cl) throws Exception { // Set instance pool InstancePool ip = null; try { ip = (InstancePool) cl.loadClass(conf.getInstancePool()).newInstance(); } catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); } if (ip instanceof XmlLoadable) ((XmlLoadable) ip).importXml(conf.getContainerPoolConf()); return ip; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static InstanceCache createInstanceCache(ConfigurationMetaData conf, ClassLoader cl) throws Exception { // Set instance cache InstanceCache ic = null; try { ic = (InstanceCache) cl.loadClass(conf.getInstanceCache()).newInstance(); } catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); } if (ic instanceof XmlLoadable) ((XmlLoadable) ic).importXml(conf.getContainerCacheConf()); return ic; }
// in src/main/java/org/jboss/ejb/Container.java
private void setupEnvironment() throws Exception { BeanMetaData beanMetaData = getBeanMetaData(); // debug log.debug("Begin java:comp/env for EJB: " + beanMetaData.getEjbName()); ClassLoader tcl = SecurityActions.getContextClassLoader(); log.debug("TCL: " + tcl); ORB orb = null; HandleDelegate hd = null; try { orb = (ORB)server.getAttribute(ORB_NAME, "ORB"); hd = (HandleDelegate)server.getAttribute(ORB_NAME, "HandleDelegate"); } catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); } // Since the BCL is already associated with this thread we can start // using the java: namespace directly Context ctx = (Context)new InitialContext().lookup("java:comp"); Object id = ENCFactory.getCurrentId(); log.debug("Using java:comp using id=" + id); // Bind the orb if (orb != null) { NonSerializableFactory.rebind(ctx, "ORB", orb); log.debug("Bound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName()); NonSerializableFactory.rebind(ctx, "HandleDelegate", hd); log.debug("Bound java:comp/HandleDelegate for EJB: " + getBeanMetaData().getEjbName()); } // JTA links ctx.bind("TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry")); log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry"); Context envCtx = ctx.createSubcontext("env"); // Bind environment properties { Iterator i = beanMetaData.getEnvironmentEntries(); while (i.hasNext()) { EnvEntryMetaData entry = (EnvEntryMetaData)i.next(); log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue()); EnvEntryBinder.bindEnvEntry(envCtx, entry); } } // Bind EJB references { Iterator i = beanMetaData.getEjbReferences(); while (i.hasNext()) { EjbRefMetaData ref = (EjbRefMetaData)i.next(); log.debug("Binding an EJBReference " + ref.getName()); if (ref.getLink() != null) { // Internal link String linkName = ref.getLink(); String jndiName = ref.getJndiName(); log.debug("Binding " + ref.getName() + " to ejb-link: " + linkName + " -> " + jndiName); if (jndiName == null) { String msg = "Failed to resolve ejb-link: " + linkName + " from ejb-ref: " + ref.getName() + " in ejb: " + beanMetaData.getEjbName(); throw new DeploymentException(msg); } Util.bind(envCtx, ref.getName(), new LinkRef(jndiName)); } else { // Get the invoker specific ejb-ref mappings Iterator it = beanMetaData.getInvokerBindings(); Reference reference = null; while (it.hasNext()) { String invokerBinding = (String)it.next(); // Check for an invoker level jndi-name String name = ref.getInvokerBinding(invokerBinding); // Check for an global jndi-name if (name == null) name = ref.getJndiName(); if (name == null) { throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml or " + "jndi-name in jboss.xml"); } StringRefAddr addr = new StringRefAddr(invokerBinding, name); log.debug("adding " + invokerBinding + ":" + name + " to Reference"); if (reference == null) { reference = new Reference("javax.naming.LinkRef", ENCThreadLocalKey.class.getName(), null); } reference.add(addr); } // If there were invoker bindings create bind the reference if (reference != null) { if (ref.getJndiName() != null) { // Add default for the bean level ejb-ref/jndi-name StringRefAddr addr = new StringRefAddr("default", ref.getJndiName()); reference.add(addr); } if (reference.size() == 1 && reference.get("default") == null) { /* There is only one invoker binding and its not default so create a default binding to allow the link to have a value when accessed without an invoker active. */ StringRefAddr addr = (StringRefAddr)reference.get(0); String target = (String)addr.getContent(); StringRefAddr addr1 = new StringRefAddr("default", target); reference.add(addr1); } Util.bind(envCtx, ref.getName(), reference); } else { // Bind the bean level ejb-ref/jndi-name if (ref.getJndiName() == null) { throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or jndi-name in jboss.xml"); } Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } } // Bind Local EJB references { Iterator i = beanMetaData.getEjbLocalReferences(); while (i.hasNext()) { EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next(); String refName = ref.getName(); log.debug("Binding an EJBLocalReference " + ref.getName()); if (ref.getLink() != null) { // Internal link log.debug("Binding " + refName + " to bean source: " + ref.getLink()); String jndiName = ref.getJndiName(); Util.bind(envCtx, ref.getName(), new LinkRef(jndiName)); } else { // Bind the bean level ejb-local-ref/local-jndi-name if (ref.getJndiName() == null) { throw new DeploymentException("ejb-local-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or local-jndi-name in jboss.xml"); } Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } // Bind service references { ClassLoader loader = unit.getClassLoader(); UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot()); Iterator<ServiceReferenceMetaData> serviceReferences = beanMetaData.getServiceReferences(); if (serviceReferences != null) { while (serviceReferences.hasNext()) { ServiceReferenceMetaData sref = serviceReferences.next(); String refName = sref.getServiceRefName(); new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref); } } } // Bind resource references { Iterator i = beanMetaData.getResourceReferences(); // let's play guess the cast game ;) New metadata should fix this. ApplicationMetaData application = beanMetaData.getApplicationMetaData(); while (i.hasNext()) { ResourceRefMetaData ref = (ResourceRefMetaData)i.next(); String resourceName = ref.getResourceName(); String finalName = application.getResourceByName(resourceName); String resType = ref.getType(); // If there was no resource-manager specified then an immeadiate // jndi-name or res-url name should have been given if (finalName == null) finalName = ref.getJndiName(); if (finalName == null && resType.equals("java.net.URL") == false) { // the application assembler did not provide a resource manager // if the type is javax.sql.Datasoure use the default one if (ref.getType().equals("javax.sql.DataSource")) { // Go through JNDI and look for DataSource - use the first one Context dsCtx = new InitialContext(); try { // Check if it is available in JNDI dsCtx.lookup("java:/DefaultDS"); finalName = "java:/DefaultDS"; } catch (Exception e) { log.debug("failed to lookup DefaultDS; ignoring", e); } finally { dsCtx.close(); } } // Default failed? Warn user and move on // POTENTIALLY DANGEROUS: should this be a critical error? if (finalName == null) { log.warn("No resource manager found for " + ref.getResourceName()); continue; } } if (resType.equals("java.net.URL")) { // URL bindings if (ref.getResURL() != null) { // The URL string was given by the res-url log.debug("Binding URL: " + ref.getRefName() + " to JDNI ENC as: " + ref.getResURL()); URL resURL = new URL(ref.getResURL()); Util.bind(envCtx, ref.getRefName(), resURL); } else { log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName); Object bind = null; if (ref.getJndiName() != null) { // Was the url given as a jndi-name reference to link to it bind = new LinkRef(finalName); } else { // The url string was given via a resource-name mapping bind = new URL(finalName); } Util.bind(envCtx, ref.getRefName(), bind); } } else { // Resource Manager bindings, should validate the type... log.debug("Binding resource manager: " + ref.getRefName() + " to JDNI ENC as: " + finalName); Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName)); } } } // Bind resource env references { Iterator i = beanMetaData.getResourceEnvReferences(); while (i.hasNext()) { ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData)i.next(); String encName = resRef.getRefName(); String jndiName = resRef.getJndiName(); // Should validate the type... log.debug("Binding env resource: " + encName + " to JDNI ENC as: " + jndiName); Util.bind(envCtx, encName, new LinkRef(jndiName)); } } // Bind message destination references { Iterator i = beanMetaData.getMessageDestinationReferences(); while (i.hasNext()) { MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next(); String refName = ref.getRefName(); String jndiName = ref.getJNDIName(); String link = ref.getLink(); if (link != null) { if (jndiName == null) { MessageDestinationMetaData messageDestination = getMessageDestination(link); if (messageDestination == null) throw new DeploymentException("message-destination-ref '" + refName + "' message-destination-link '" + link + "' not found and no jndi-name in jboss.xml"); else { String linkJNDIName = messageDestination.getJndiName(); if (linkJNDIName == null) log.warn("message-destination '" + link + "' has no jndi-name in jboss.xml"); else jndiName = linkJNDIName; } } else log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss.xml"); } else if (jndiName == null) throw new DeploymentException("message-destination-ref '" + refName + "' has no message-destination-link in ejb-jar.xml and no jndi-name in jboss.xml"); Util.bind(envCtx, refName, new LinkRef(jndiName)); } } // Create a java:comp/env/security/security-domain link to the container // or application security-domain if one exists so that access to the // security manager can be made without knowing the global jndi name. String securityDomain = metaData.getContainerConfiguration().getSecurityDomain(); if (securityDomain == null) securityDomain = metaData.getApplicationMetaData().getSecurityDomain(); if (securityDomain != null) { //JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix if(securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false) securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain; log.debug("Binding securityDomain: " + securityDomain + " to JDNI ENC as: security/security-domain"); Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain)); Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject")); Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain + "/realmMapping")); Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain + "/authorizationMgr")); } log.debug("End java:comp/env for EJB: " + beanMetaData.getEjbName()); }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); JBossMetaData metaData = unit.getAttachment(JBossMetaData.class); // Check for an annotated view String key = AnnotationMetaDataDeployer.EJB_ANNOTATED_ATTACHMENT_NAME; JBossMetaData annotatedMetaData = unit.getAttachment(key, JBossMetaData.class); if(ejbJarMetaData == null && metaData == null && annotatedMetaData == null) return; JBossMetaData specMetaData = new JBoss50MetaData(); if(ejbJarMetaData != null) { specMetaData.merge(null, ejbJarMetaData); if(annotatedMetaData != null) { JBossMetaData specMerged = new JBoss50MetaData(); specMerged.merge(specMetaData, annotatedMetaData); specMetaData = specMerged; } } else specMetaData = annotatedMetaData; // Create a merged view JBossMetaData mergedMetaData = new JBossMetaData(); mergedMetaData.merge(metaData, specMetaData); // Incorporate any ear level overrides DeploymentUnit topUnit = unit.getTopLevel(); if(topUnit != null && topUnit.getAttachment(JBossAppMetaData.class) != null) { JBossAppMetaData earMetaData = topUnit.getAttachment(JBossAppMetaData.class); // Security domain String securityDomain = earMetaData.getSecurityDomain(); if(securityDomain != null && mergedMetaData.getSecurityDomain() == null) mergedMetaData.setSecurityDomain(securityDomain); //Security Roles SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles(); if(earSecurityRolesMetaData != null) { JBossAssemblyDescriptorMetaData jadmd = mergedMetaData.getAssemblyDescriptor(); if( jadmd == null) { jadmd = new JBossAssemblyDescriptorMetaData(); mergedMetaData.setAssemblyDescriptor(jadmd); } SecurityRolesMetaData mergedSecurityRolesMetaData = jadmd.getSecurityRoles(); if(mergedSecurityRolesMetaData == null) jadmd.setSecurityRoles(earSecurityRolesMetaData); //perform a merge to rebuild the principalVersusRolesMap if(mergedSecurityRolesMetaData != null ) { mergedSecurityRolesMetaData.merge(mergedSecurityRolesMetaData, earSecurityRolesMetaData); } } } // Create interceptors metadata by processing interceptor classes (from the merged // jboss metadata) Collection<String> interceptorClassNames = JBossMetaData.getAllInterceptorClasses(mergedMetaData); Collection<Class<?>> interceptorClasses = null; try { interceptorClasses = this.loadClasses(unit.getClassLoader(), interceptorClassNames); } catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); } // Process the interceptor classes AnnotationFinder<AnnotatedElement> annotationFinder = new DefaultAnnotationFinder<AnnotatedElement>(); InterceptorMetaDataCreator interceptorMetaDataCreator = new InterceptorMetaDataCreator(annotationFinder); // create interceptors metadata from the interceptor classes InterceptorsMetaData annotatedInterceptorsMetaData = interceptorMetaDataCreator.create(interceptorClasses); InterceptorsMetaData mergedInterceptorsMetaData = new InterceptorsMetaData(); // merge the interceptors metadata mergedInterceptorsMetaData.merge(mergedMetaData.getInterceptors(), annotatedInterceptorsMetaData); // now set the merged interceptors metadata into the merged jboss metadata mergedMetaData.setInterceptors(mergedInterceptorsMetaData); // Output the merged JBossMetaData unit.getTransientManagedObjects().addAttachment(JBossMetaData.class, mergedMetaData); unit.addAttachment(EJB_MERGED_ATTACHMENT_NAME, mergedMetaData, JBossMetaData.class); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
Override public void deploy(VFSDeploymentUnit unit, JBossMetaData deployment) throws DeploymentException { // If it is a deployment with ejbVersion unknown or 3 if (!deployment.isEJB2x() && !deployment.isEJB1x()) return; // let EJB3 deployer handle this ApplicationMetaData legacyMD = new ApplicationMetaData(deployment); if( verifyDeployments ) { // we have a positive attitude boolean allOK = true; // wrapping this into a try - catch block to prevent errors in // verifier from stopping the deployment try { BeanVerifier verifier = new BeanVerifier(); // add a listener so we can log the results verifier.addVerificationListener(new VerificationListener() { Logger verifierLog = Logger.getLogger(EjbDeployer.class, "verifier"); public void beanChecked(VerificationEvent event) { verifierLog.debug( "Bean checked: " + event.getMessage() ); } public void specViolation(VerificationEvent event) { verifierLog.warn( "EJB spec violation: " + (verifierVerbose ? event.getVerbose() : event.getMessage())); } }); log.debug("Verifying " + unit.getRoot().toURL()); verifier.verify(unit.getRoot().toURL(), legacyMD, unit.getClassLoader()); allOK = verifier.getSuccess(); } catch (Throwable t) { log.warn("Verify failed; continuing", t ); allOK = false; } // If the verifier is in strict mode and an error/warning // was found in the Verification process, throw a Deployment // Exception if( strictVerifier && !allOK ) { throw new DeploymentException("Verification of Enterprise Beans failed, see above for error messages."); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void resolveResourceAdapter() throws DeploymentException { resourceAdapterName = resolveResourceAdapterName(); try { resourceAdapterObjectName = new ObjectName("jboss.jca:service=RARDeployment,name='" + resourceAdapterName + "'"); int state = ((Integer) server.getAttribute(resourceAdapterObjectName, "State")).intValue(); if (state != STARTED) throw new DeploymentException("The resource adapter is not started " + resourceAdapterName); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Cannot locate resource adapter deployment " + resourceAdapterName, e); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void setupProxyParameters() throws DeploymentException { // Set the interfaces interfaces = new Class[] { MessageEndpoint.class, messagingTypeClass }; // Set the interceptors interceptors = new ArrayList<Class<?>>(); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element endpointInterceptors = MetaData.getOptionalChild(proxyConfig, "endpoint-interceptors", null); if (endpointInterceptors == null) throw new DeploymentException("No endpoint interceptors found"); else { NodeList children = endpointInterceptors.getElementsByTagName("interceptor"); for (int i = 0; i < children.getLength(); ++i) { Node currentChild = children.item(i); if (currentChild.getNodeType() == Node.ELEMENT_NODE) { Element interceptor = (Element) children.item(i); String className = MetaData.getElementContent(interceptor); try { Class<?> clazz = container.getClassLoader().loadClass(className); interceptors.add(clazz); } catch (Throwable t) { DeploymentException.rethrowAsDeploymentException("Error loading interceptor class " + className, t); } } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void augmentActivationConfigProperties() throws DeploymentException { // Allow activation config properties from invoker proxy binding Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element activationConfig = MetaData.getOptionalChild(proxyConfig, "activation-config"); if (activationConfig != null) { Iterator<Element> iterator = MetaData.getChildrenByTagName(activationConfig, "activation-config-property"); while (iterator.hasNext()) { Element xml = iterator.next(); org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData md = new org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData(); ActivationConfigPropertyMetaData metaData = new ActivationConfigPropertyMetaData(md); String name = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-name")); String value = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-value")); if (name == null || name.trim().length() == 0) throw new DeploymentException("activation-config-property doesn't have a name"); if (Strings.isValidJavaIdentifier(name) == false) throw new DeploymentException("activation-config-property '" + name + "' is not a valid java identifier"); md.setName(name); md.setValue(value); if (properties.containsKey(metaData.getName()) == false) properties.put(metaData.getName(), metaData); } } // Message Destination Link String link = metaData.getDestinationLink(); if (link != null) { link = link.trim(); if (link.length() > 0) { if (properties.containsKey("destination")) log.warn("Ignoring message-destination-link '" + link + "' when the destination " + "is already in the activation-config."); else { MessageDestinationMetaData destinationMetaData = container.getMessageDestination(link); if (destinationMetaData == null) throw new DeploymentException("Unresolved message-destination-link '" + link + "' no message-destination in ejb-jar.xml"); String jndiName = destinationMetaData.getJndiName(); if (jndiName == null) throw new DeploymentException("The message-destination '" + link + "' has no jndi-name in jboss.xml"); org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData acpmd = new org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData(); acpmd.setActivationConfigPropertyName("destination"); acpmd.setValue(jndiName); ActivationConfigPropertyMetaData wrapper = new ActivationConfigPropertyMetaData(acpmd); properties.put("destination", wrapper); } } } }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
public void importXml(Element element) throws DeploymentException { String min = MetaData.getElementContent(MetaData.getOptionalChild(element, "min-capacity")); String max = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-capacity")); String op = MetaData.getElementContent(MetaData.getOptionalChild(element, "overager-period")); String rp = MetaData.getElementContent(MetaData.getOptionalChild(element, "resizer-period")); String ma = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-bean-age")); String map = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-cache-miss-period")); String mip = MetaData.getElementContent(MetaData.getOptionalChild(element, "min-cache-miss-period")); String fa = MetaData.getElementContent(MetaData.getOptionalChild(element, "cache-load-factor")); try { if (min != null) { int s = Integer.parseInt(min); if (s <= 0) { throw new DeploymentException("Min cache capacity can't be <= 0"); } m_minCapacity = s; } if (max != null) { int s = Integer.parseInt(max); if (s <= 0) { throw new DeploymentException("Max cache capacity can't be <= 0"); } m_maxCapacity = s; } if (op != null) { int p = Integer.parseInt(op); if (p <= 0) {throw new DeploymentException("Overager period can't be <= 0");} m_overagerPeriod = p * 1000; } if (rp != null) { int p = Integer.parseInt(rp); if (p <= 0) {throw new DeploymentException("Resizer period can't be <= 0");} m_resizerPeriod = p * 1000; } if (ma != null) { int a = Integer.parseInt(ma); if (a <= 0) {throw new DeploymentException("Max bean age can't be <= 0");} m_maxBeanAge = a * 1000; } if (map != null) { int p = Integer.parseInt(map); if (p <= 0) {throw new DeploymentException("Max cache miss period can't be <= 0");} m_maxPeriod = p * 1000; } if (mip != null) { int p = Integer.parseInt(mip); if (p <= 0) {throw new DeploymentException("Min cache miss period can't be <= 0");} m_minPeriod = p * 1000; } if (fa != null) { double f = Double.parseDouble(fa); if (f <= 0.0) {throw new DeploymentException("Cache load factor can't be <= 0");} m_factor = f; } } catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void importXml(Element element) throws DeploymentException { // This one is mandatory String p = MetaData.getElementContent(MetaData.getUniqueChild(element, "cache-policy")); try { Class cls = SecurityActions.getContextClassLoader().loadClass(p); Constructor ctor = cls.getConstructor(new Class[] {AbstractInstanceCache.class}); m_cache = (CachePolicy)ctor.newInstance(new Object[] {this}); } catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); } Element policyConf = MetaData.getOptionalChild(element, "cache-policy-conf"); if (policyConf != null) { if (m_cache instanceof XmlLoadable) { try { ((XmlLoadable)m_cache).importXml(policyConf); } catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2) manager.getEntityBridge(); log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName()); final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields(); if(pkFields.length > 1) { throw new DeploymentException("This entity-command cannot be used with composite primary keys!"); } this.pkField = (JDBCCMPFieldBridge2) pkFields[0]; JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand(); pkSql = metadata.getAttribute("pk-sql"); if(pkSql == null) { throw new DeploymentException("pk-sql attribute must be set for entity " + entityBridge.getEntityName()); } if(log.isDebugEnabled()) { log.debug("entity-command generate pk sql: " + pkSql); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
public void init() throws DeploymentException { Method findByPkMethod; Class home = entity.getHomeClass(); if(home != null) { try { findByPkMethod = home.getMethod("findByPrimaryKey", new Class[]{entity.getPrimaryKeyClass()}); } catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } FindByPrimaryKeyCommand findByPk = new FindByPrimaryKeyCommand(entity); queriesByMethod.put(findByPkMethod, findByPk); } Class local = entity.getLocalHomeClass(); if(local != null) { try { findByPkMethod = local.getMethod("findByPrimaryKey", new Class[]{entity.getPrimaryKeyClass()}); } catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } FindByPrimaryKeyCommand findByPk = new FindByPrimaryKeyCommand(entity); queriesByMethod.put(findByPkMethod, findByPk); } // // Defined finders - Overrides automatic finders. // Iterator definedFinders = entity.getMetaData().getQueries().iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData q = (JDBCQueryMetaData) definedFinders.next(); if(!queriesByMethod.containsKey(q.getMethod())) { if(q instanceof JDBCJBossQLQueryMetaData) { QueryCommand queryCommand = new JBossQLQueryCommand(entity, (JDBCJBossQLQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCQlQueryMetaData) { QueryCommand queryCommand = new EJBQLQueryCommand(entity, (JDBCQlQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCDeclaredQueryMetaData) { QueryCommand queryCommand = new DeclaredSQLQueryCommand(entity, (JDBCDeclaredQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCDynamicQLQueryMetaData) { QueryCommand queryCommand = new DynamicQueryCommand(entity, (JDBCDynamicQLQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else { throw new DeploymentException("Unsupported query metadata: method=" + q.getMethod().getName() + ", metadata=" + q); } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void start() throws DeploymentException { final JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); relationsTotal = (cmrFields != null ? cmrFields.length : 0); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); // DELETE SQL deleteSql = "delete from " + tableName + " where "; deleteSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { deleteSql += " and " + pkFields[i].getColumnName() + "=?"; } log.debug("delete sql: " + deleteSql); // INSERT SQL insertSql = "insert into " + tableName + "("; insertSql += tableFields[0].getColumnName(); for(int i = 1; i < tableFields.length; ++i) { insertSql += ", " + tableFields[i].getColumnName(); } insertSql += ") values (?"; for(int i = 1; i < tableFields.length; ++i) { insertSql += ", ?"; } insertSql += ")"; log.debug("insert sql: " + insertSql); // UPDATE SQL updateSql = "update " + tableName + " set "; int setFields = 0; for(int i = 0; i < tableFields.length; ++i) { JDBCCMPFieldBridge2 field = tableFields[i]; if(!field.isPrimaryKeyMember()) { if(setFields++ > 0) { updateSql += ", "; } updateSql += field.getColumnName() + "=?"; } } updateSql += " where "; updateSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { updateSql += " and " + pkFields[i].getColumnName() + "=?"; } if(entity.getVersionField() != null) { updateSql += " and " + entity.getVersionField().getColumnName() + "=?"; } log.debug("update sql: " + updateSql); // SELECT SQL String selectColumns = tableFields[0].getColumnName(); for(int i = 1; i < tableFields.length; ++i) { JDBCCMPFieldBridge2 field = tableFields[i]; selectColumns += ", " + field.getColumnName(); } String whereColumns = pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { whereColumns += " and " + pkFields[i].getColumnName() + "=?"; } if(entity.getMetaData().hasRowLocking()) { JDBCEntityPersistenceStore manager = entity.getManager(); JDBCTypeFactory typeFactory = manager.getJDBCTypeFactory(); JDBCTypeMappingMetaData typeMapping = typeFactory.getTypeMapping(); JDBCFunctionMappingMetaData rowLockingTemplate = typeMapping.getRowLockingTemplate(); if(rowLockingTemplate == null) { throw new DeploymentException("Row locking template is not defined for mapping: " + typeMapping.getName()); } selectSql = rowLockingTemplate.getFunctionSql(new Object[]{selectColumns, tableName, whereColumns, null}, new StringBuffer()).toString(); } else { selectSql = "select "; selectSql += selectColumns; selectSql += " from " + tableName + " where "; selectSql += whereColumns; } log.debug("select sql: " + selectSql); // DUPLICATE KEY if(dontFlushCreated) { duplicatePkSql = "select "; duplicatePkSql += pkFields[0].getColumnName(); for(int i = 1; i < pkFields.length; ++i) { duplicatePkSql += ", " + pkFields[i].getColumnName(); } duplicatePkSql += " from " + tableName + " where "; duplicatePkSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { duplicatePkSql += " and " + pkFields[i].getColumnName() + "=?"; } log.debug("duplicate pk sql: " + duplicatePkSql); } if(cacheName != null) { try { serviceController.start(cacheName); } catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DeclaredSQLQueryCommand.java
private void initResultReader(JDBCEntityBridge2 entity, JDBCDeclaredQueryMetaData metadata) throws DeploymentException { String entityName = metadata.getEJBName(); if(entityName != null) { Catalog catalog = entity.getManager().getCatalog(); JDBCEntityBridge2 otherEntity = (JDBCEntityBridge2) catalog.getEntityByEJBName(entityName); if(otherEntity == null) { throw new DeploymentException("Unknown entity: " + entityName); } this.entity = otherEntity; } else { this.entity = entity; } String fieldName = metadata.getFieldName(); if(fieldName == null) { setEntityReader(this.entity, metadata.isSelectDistinct()); } else { selectedField = (JDBCCMPFieldBridge2) entity.getFieldByName(fieldName); if(selectedField == null) { throw new DeploymentException("Unknown cmp field: " + fieldName); } setFieldReader(selectedField); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DeclaredSQLQueryCommand.java
protected String parseParameters(String sql, JDBCDeclaredQueryMetaData metadata) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); ArrayList params = new ArrayList(); // Replace placeholders {0} with ? if(sql != null) { sql = sql.trim(); StringTokenizer tokens = new StringTokenizer(sql, "{}", true); while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); if(token.equals("{")) { token = tokens.nextToken(); if(Character.isDigit(token.charAt(0))) { QueryParameter parameter = new QueryParameter(entity.getManager(), metadata.getMethod(), token); // of if we are here we can assume that we have // a parameter and not a function sqlBuf.append("?"); params.add(parameter); if(!tokens.nextToken().equals("}")) { throw new DeploymentException("Invalid parameter - missing closing '}' : " + sql); } } else { // ok we don't have a parameter, we have a function // push the tokens on the buffer and continue sqlBuf.append("{").append(token); } } else { // not parameter... just append it sqlBuf.append(token); } } } setParameters(params); return sqlBuf.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
protected void startStoreManager() throws Exception { queryFactory = new QueryFactory(entityBridge); queryFactory.init(); instanceFactory = new InstanceFactory(this, entityBridge); startCmd = new JDBCStartCommand(this); startCmd.execute(); final JDBCEntityCommandMetaData entityCommand = getMetaData().getEntityCommand(); if(entityCommand == null || "default".equals(entityCommand.getCommandName())) { createCmd = new ApplicationPkCreateCommand(); } else { final Class cmdClass = entityCommand.getCommandClass(); if(cmdClass == null) { throw new DeploymentException( "entity-command class name is not specified for entity " + entityBridge.getEntityName() ); } try { createCmd = (CreateCommand)cmdClass.newInstance(); } catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); } } createCmd.init(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
private JDBCEntityMetaData loadJDBCEntityMetaData() throws DeploymentException { ApplicationMetaData amd = container.getBeanMetaData().getApplicationMetaData(); // Get JDBC MetaData JDBCApplicationMetaData jamd = (JDBCApplicationMetaData)amd.getPluginData(CMP_JDBC); if(jamd == null) { // we are the first cmp entity to need jbosscmp-jdbc. // Load jbosscmp-jdbc.xml for the whole application JDBCXmlFileLoader jfl = new JDBCXmlFileLoader(container, log); jamd = jfl.load(); amd.addPluginData(CMP_JDBC, jamd); } // Get JDBC Bean MetaData String ejbName = container.getBeanMetaData().getEjbName(); JDBCEntityMetaData metadata = jamd.getBeanByEjbName(ejbName); if(metadata == null) { throw new DeploymentException("No metadata found for bean " + ejbName); } return metadata; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
private static Map createFieldMap(JDBCEntityBridge2 entityBridge) throws DeploymentException { Map abstractAccessors = getAbstractAccessors(entityBridge.getMetaData().getEntityClass()); List fields = entityBridge.getFields(); Map map = new HashMap(fields.size() * 2); for(int i = 0; i < fields.size(); i++) { FieldBridge field = (FieldBridge) fields.get(i); // get the names String fieldName = field.getFieldName(); String fieldBaseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getterName = "get" + fieldBaseName; String setterName = "set" + fieldBaseName; // get the accessor methods Method getterMethod = (Method) abstractAccessors.get(getterName); Method setterMethod = (Method) abstractAccessors.get(setterName); // getters and setters must come in pairs if(getterMethod != null && setterMethod == null) { throw new DeploymentException("Getter was found but, no setter was found for field: " + fieldName); } else if(getterMethod == null && setterMethod != null) { throw new DeploymentException("Setter was found but, no getter was found for field: " + fieldName); } else if(getterMethod != null && setterMethod != null) { // add methods map.put(getterMethod.getName(), new EntityBridgeInvocationHandler.FieldGetInvoker(field)); map.put(setterMethod.getName(), new EntityBridgeInvocationHandler.FieldSetInvoker(field)); // remove the accessors (they have been used) abstractAccessors.remove(getterName); abstractAccessors.remove(setterName); } } return Collections.unmodifiableMap(map); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
private static Map createSelectorMap(JDBCEntityBridge2 entityBridge, QueryFactory queryFactory) throws DeploymentException { Collection queries = entityBridge.getMetaData().getQueries(); Map selectorsByMethod = new HashMap(queries.size()); Iterator definedFinders = queries.iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData metadata = (JDBCQueryMetaData)definedFinders.next(); if(metadata.getMethod().getName().startsWith("ejbSelect")) { try { QueryCommand queryCommand = queryFactory.getQueryCommand(metadata.getMethod()); Schema schema = ((JDBCStoreManager2)entityBridge.getManager()).getSchema(); EJBSelectBridge ejbSelectBridge = new EJBSelectBridge(entityBridge.getContainer(), schema, metadata, queryCommand); selectorsByMethod.put(metadata.getMethod(), ejbSelectBridge); } catch(FinderException e) { throw new DeploymentException(e.getMessage()); } } } return selectorsByMethod; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void resolveRelationship() throws DeploymentException { // // Set handles to the related entity's container, cache, manager, and invoker // // Related Entity Name String relatedEntityName = metadata.getRelatedRole().getEntity().getName(); // Related Entity Catalog catalog = (Catalog)manager.getApplicationData("CATALOG"); relatedEntity = (JDBCEntityBridge2)catalog.getEntityByEJBName(relatedEntityName); if(relatedEntity == null) { throw new DeploymentException("Related entity not found: " + "entity=" + entity.getEntityName() + ", " + "cmrField=" + getFieldName() + ", " + "relatedEntity=" + relatedEntityName ); } // Related CMR Field JDBCCMRFieldBridge2[] cmrFields = (JDBCCMRFieldBridge2[])relatedEntity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge2 cmrField = cmrFields[i]; if(metadata.getRelatedRole() == cmrField.getMetaData()) { relatedCMRField = cmrField; break; } } // if we didn't find the related CMR field throw an exception with a detailed message if(relatedCMRField == null) { String message = "Related CMR field not found in " + relatedEntity.getEntityName() + " for relationship from "; message += entity.getEntityName() + "."; if(getFieldName() != null) { message += getFieldName(); } else { message += "<no-field>"; } message += " to "; message += relatedEntityName + "."; if(metadata.getRelatedRole().getCMRFieldName() != null) { message += metadata.getRelatedRole().getCMRFieldName(); } else { message += "<no-field>"; } throw new DeploymentException(message); } // Related Container relatedContainer = relatedEntity.getContainer(); // // Initialize the key fields // if(metadata.getRelationMetaData().isTableMappingStyle()) { // initialize relation table key fields Collection tableKeys = metadata.getKeyFields(); List keyFieldsList = new ArrayList(tableKeys.size()); // first phase is to create fk fields Map pkFieldsToFKFields = new HashMap(tableKeys.size()); for(Iterator i = tableKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData)i.next(); FieldBridge pkField = entity.getFieldByName(cmpFieldMetaData.getFieldName()); if(pkField == null) { throw new DeploymentException("Primary key not found for key-field " + cmpFieldMetaData.getFieldName()); } pkFieldsToFKFields.put(pkField, new JDBCCMPFieldBridge2(manager, entity, cmpFieldMetaData, -1)); } // second step is to order fk fields to match the order of pk fields JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { Object fkField = pkFieldsToFKFields.get(pkFields[i]); if(fkField == null) { throw new DeploymentException("Primary key " + pkFields[i].getFieldName() + " is not mapped."); } keyFieldsList.add(fkField); } tableKeyFields = (JDBCCMPFieldBridge2[])keyFieldsList.toArray(new JDBCCMPFieldBridge2[keyFieldsList.size()]); } else { initializeForeignKeyFields(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void init() throws DeploymentException { loadCMPFields(metadata); loadCMRFields(metadata); JDBCOptimisticLockingMetaData olMD = metadata.getOptimisticLocking(); if(olMD != null) { if(olMD.getLockingStrategy() != JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY) { throw new DeploymentException( "Only version-column optimistic locking strategy is supported at the moment."); } JDBCCMPFieldMetaData versionMD = olMD.getLockingField(); versionField = (JDBCCMPFieldBridge2) getFieldByName(versionMD.getFieldName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2)manager.getEntityBridge(); this.log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName()); final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields(); if(pkFields.length > 1) { throw new DeploymentException("This entity-command cannot be used with composite primary keys!"); } this.pkField = (JDBCCMPFieldBridge2) pkFields[0]; this.pkSql = ""; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { log = Logger.getLogger(getClass().getName() + '.' + manager.getMetaData().getName()); debug = log.isDebugEnabled(); trace = log.isTraceEnabled(); entity = (JDBCEntityBridge) manager.getEntityBridge(); securityManager = manager.getContainer().getSecurityManager(); insertAfterEjbPostCreate = manager.getContainer() .getBeanMetaData().getContainerConfiguration().isInsertAfterEjbPostCreate(); // set create allowed createAllowed = true; JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; i++) { if(pkFields[i].isReadOnly()) { createAllowed = false; log.debug("Create will not be allowed because pk field " + pkFields[i].getFieldName() + "is read only."); break; } } initGeneratedFields(); JDBCEntityCommandMetaData entityCommand = manager.getMetaData().getEntityCommand(); if(entityCommand == null) { throw new DeploymentException("entity-command is null"); } initEntityCommand(entityCommand); initInsertFields(); initInsertSQL(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { String objectName = entityCommand.getAttribute("SQLExceptionProcessor"); if(objectName != null) { try { exceptionProcessor = (SQLExceptionProcessorMBean) MBeanProxyExt.create(SQLExceptionProcessorMBean.class, objectName); } catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected JDBCCMPFieldBridge getGeneratedPKField() throws DeploymentException { // extract the pk field to be generated JDBCCMPFieldBridge pkField = null; JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { if(pkField != null) throw new DeploymentException("Generation only supported with single PK field"); pkField = (JDBCCMPFieldBridge)pkFields[i]; } return pkField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void initGeneratedFields() throws DeploymentException { createdPrincipal = entity.getCreatedPrincipalField(); if(securityManager == null && createdPrincipal != null) { throw new DeploymentException("No security-domain configured but created-by specified"); } updatedPrincipal = entity.getUpdatedPrincipalField(); if(securityManager == null && updatedPrincipal != null) { throw new DeploymentException("No security-domain configured but updated-by specified"); } createdTime = entity.getCreatedTimeField(); updatedTime = entity.getUpdatedTimeField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/MetaDataLibrary.java
public void startService() throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL stdJDBCUrl = classLoader.getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if(debug) { log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); } Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); Element typeMaps = MetaData.getOptionalChild(stdJDBCElement, "type-mappings"); if(typeMaps != null) { for(Iterator i = MetaData.getChildrenByTagName(typeMaps, "type-mapping"); i.hasNext();) { Element typeMappingElement = (Element)i.next(); JDBCTypeMappingMetaData typeMapping = new JDBCTypeMappingMetaData(typeMappingElement); typeMappings.put(typeMapping.getName(), typeMapping); log.debug("added type-mapping: " + typeMapping.getName()); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationshipRoleMetaData.java
private Map loadKeyFields(Element element) throws DeploymentException { Element keysElement = MetaData.getOptionalChild(element, "key-fields"); // no field overrides, we're done if(keysElement == null) { return loadKeyFields(); } // load overrides Iterator iter = MetaData.getChildrenByTagName(keysElement, "key-field"); // if key-fields element empty, no key should be used if(!iter.hasNext()) { return Collections.EMPTY_MAP; } else if(relationMetaData.isForeignKeyMappingStyle() && isMultiplicityMany()) { throw new DeploymentException("Role: " + relationshipRoleName + " with multiplicity many using " + "foreign-key mapping is not allowed to have key-fields"); } // load the default field values Map defaultFields = getPrimaryKeyFields(); // load overrides Map fields = new HashMap(defaultFields.size()); while(iter.hasNext()) { Element keyElement = (Element) iter.next(); String fieldName = MetaData.getUniqueChildContent(keyElement, "field-name"); JDBCCMPFieldMetaData cmpField = (JDBCCMPFieldMetaData) defaultFields.remove(fieldName); if(cmpField == null) { throw new DeploymentException( "Role '" + relationshipRoleName + "' on Entity Bean '" + entity.getName() + "' : CMP field for key not found: field " + "name='" + fieldName + "'"); } String isIndexedtmp = MetaData.getOptionalChildContent(keyElement, "dbindex"); boolean isIndexed; if(isIndexedtmp != null) isIndexed = true; else isIndexed = false; genIndex = isIndexed; cmpField = new JDBCCMPFieldMetaData( entity, keyElement, cmpField, false, relationMetaData.isTableMappingStyle(), relationMetaData.isReadOnly(), relationMetaData.getReadTimeOut(), relationMetaData.isTableMappingStyle()); fields.put(cmpField.getFieldName(), cmpField); } // all fields must be overriden if(!defaultFields.isEmpty()) { throw new DeploymentException("Mappings were not provided for all " + "fields: unmaped fields=" + defaultFields.keySet() + " in role=" + relationshipRoleName); } return Collections.unmodifiableMap(fields); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private int loadMappingStyle(Element element, JDBCRelationMetaData defaultValues) throws DeploymentException { // if defaults check for preferred-relation-mapping if ("defaults".equals(element.getTagName())) { // set mapping style based on preferred-relation-mapping (if possible) String perferredRelationMapping = MetaData.getOptionalChildContent(element, "preferred-relation-mapping"); if ("relation-table".equals(perferredRelationMapping) || defaultValues.isManyToMany()) { return TABLE; } else { return FOREIGN_KEY; } } // check for table mapping style if (MetaData.getOptionalChild(element, "relation-table-mapping") != null) { return TABLE; } // check for foreign-key mapping style if (MetaData.getOptionalChild(element, "foreign-key-mapping") != null) { if (defaultValues.isManyToMany()) { throw new DeploymentException("Foreign key mapping-style " + "is not allowed for many-to-many relationsips."); } return FOREIGN_KEY; } // no mapping style element, will use defaultValues return defaultValues.mappingStyle; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private static Element getEJBRelationshipRoleElement(Element element, JDBCRelationshipRoleMetaData defaultRole) throws DeploymentException { String roleName = defaultRole.getRelationshipRoleName(); if (roleName == null) throw new DeploymentException("No ejb-relationship-role-name element found"); Iterator iter = MetaData.getChildrenByTagName(element, "ejb-relationship-role"); if (!iter.hasNext()) { throw new DeploymentException("No ejb-relationship-role " + "elements found"); } Element roleElement = null; for (int i = 0; iter.hasNext(); i++) { // only 2 roles are allowed if (i > 1) { throw new DeploymentException("Expected only 2 " + "ejb-relationship-role but found more then 2"); } Element tempElement = (Element) iter.next(); if (roleName.equals(MetaData.getUniqueChildContent(tempElement, "ejb-relationship-role-name"))) { roleElement = tempElement; } } if (roleElement == null) { throw new DeploymentException("An ejb-relationship-role element was " + "not found for role '" + roleName + "'"); } return roleElement; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
private void loadLoadGroupsXml(Element element) throws DeploymentException { Element loadGroupsElement = MetaData.getOptionalChild(element, "load-groups"); if(loadGroupsElement == null) { // no info, default work already done in constructor return; } // only allowed for cmp 2.x if(isCMP1x) { throw new DeploymentException( "load-groups are only allowed " + "for CMP 2.x" ); } // load each group Iterator groups = MetaData.getChildrenByTagName(loadGroupsElement, "load-group"); while(groups.hasNext()) { Element groupElement = (Element) groups.next(); // get the load-group-name String loadGroupName = MetaData.getUniqueChildContent(groupElement, "load-group-name"); if(loadGroups.containsKey(loadGroupName)) { throw new DeploymentException( "Load group already defined: " + " load-group-name=" + loadGroupName ); } if(loadGroupName.equals("*")) { throw new DeploymentException( "The * load group is automatically " + "defined and can't be overriden" ); } ArrayList group = new ArrayList(); // add each field Iterator fields = MetaData.getChildrenByTagName(groupElement, "field-name"); while(fields.hasNext()) { String fieldName = MetaData.getElementContent((Element) fields.next()); // check if the field is a cmp field that it is not a pk memeber JDBCCMPFieldMetaData field = getCMPFieldByName(fieldName); if(field != null && field.isPrimaryKeyMember()) { throw new DeploymentException( "Primary key fields can not be" + " a member of a load group: " + " load-group-name=" + loadGroupName + " field-name=" + fieldName ); } group.add(fieldName); } loadGroups.put(loadGroupName, Collections.unmodifiableList(group)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
private void loadLazyLoadGroupsXml(Element element) throws DeploymentException { Element lazyLoadGroupsElement = MetaData.getOptionalChild(element, "lazy-load-groups"); // If no info, we're done. Default work was already done in constructor. if(lazyLoadGroupsElement == null) { return; } // only allowed for cmp 2.x if(isCMP1x) { throw new DeploymentException("lazy-load-groups is only allowed for CMP 2.x"); } // get the fields Iterator loadGroupNames = MetaData.getChildrenByTagName(lazyLoadGroupsElement, "load-group-name"); while(loadGroupNames.hasNext()) { String loadGroupName = MetaData.getElementContent((Element) loadGroupNames.next()); if(!loadGroupName.equals("*") && !loadGroups.containsKey(loadGroupName)) { throw new DeploymentException( "Lazy load group not found: " + "load-group-name=" + loadGroupName ); } lazyLoadGroups.add(loadGroupName); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public List getLoadGroup(String name) throws DeploymentException { List group = (List) loadGroups.get(name); if(group == null) { throw new DeploymentException("Unknown load group: name=" + name); } return group; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public static JDBCTypeMappingMetaData obtainTypeMappingFromLibrary(String dataSourceName) throws DeploymentException { JDBCTypeMappingMetaData typeMapping = null; String datasource; if(dataSourceName.startsWith("java:")) { datasource = dataSourceName.substring("java:".length()); if(datasource.startsWith("/")) { datasource = datasource.substring(1); } } else { datasource = dataSourceName; } final ObjectName metadataService; final String str = "jboss.jdbc:service=metadata,datasource=" + datasource; try { metadataService = new ObjectName(str); } catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); } try { final MBeanServer server = MBeanServerLocator.locateJBoss(); if(server.isRegistered(metadataService)) { typeMapping = (JDBCTypeMappingMetaData)server.getAttribute(metadataService, "TypeMappingMetaData"); } } catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); } /* if(typeMapping == null) { throw new DeploymentException( "type-mapping for datasource " + datasource + " not found in the library. " + "Check the value of metadata/type-mapping in the -ds.xml file." ); } */ return typeMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
private Class loadFieldType(JDBCEntityMetaData entity, String fieldName) throws DeploymentException { if(entity.isCMP1x()) { // CMP 1.x field Style try { return entity.getEntityClass().getField(fieldName).getType(); } catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); } } else { // CMP 2.x abstract accessor style String baseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getName = "get" + baseName; String setName = "set" + baseName; Method[] methods = entity.getEntityClass().getMethods(); for(int i = 0; i < methods.length; i++) { // is this a public abstract method? if(Modifier.isPublic(methods[i].getModifiers()) && Modifier.isAbstract(methods[i].getModifiers())) { // get accessor if(getName.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 0 && !methods[i].getReturnType().equals(Void.TYPE)) { return methods[i].getReturnType(); } // set accessor if(setName.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 1 && methods[i].getReturnType().equals(Void.TYPE)) { return methods[i].getParameterTypes()[0]; } } } throw new DeploymentException("No abstract accessors for field " + "named '" + fieldName + "' found in entity class " + entity.getEntityClass().getName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
public JDBCApplicationMetaData load() throws DeploymentException { JDBCApplicationMetaData jamd = new JDBCApplicationMetaData( container.getBeanMetaData().getApplicationMetaData(), container.getClassLoader() ); // Load standardjbosscmp-jdbc.xml from the default classLoader // we always load defaults first URL stdJDBCUrl = container.getClassLoader().getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if (debug) log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); // first create the metadata jamd = new JDBCApplicationMetaData(stdJDBCElement, jamd); // Load jbosscmp-jdbc.xml if provided URL jdbcUrl = null; VirtualFile dd = container.getDeploymentUnit().getMetaDataFile("jbosscmp-jdbc.xml"); if(dd != null) { try { jdbcUrl = dd.toURL(); } catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); } } if(jdbcUrl != null) { if (debug) log.debug(jdbcUrl.toString() + " found. Overriding defaults"); Element jdbcElement = XmlFileLoader.getDocument(jdbcUrl, true).getDocumentElement(); jamd = new JDBCApplicationMetaData(jdbcElement, jamd); } return jamd; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
private JDBCCMPFieldMetaData constructLockingField( JDBCEntityMetaData entity, Element element) throws DeploymentException { // field name String fieldName = MetaData.getOptionalChildContent(element, "field-name"); if(fieldName == null || fieldName.trim().length() < 1) fieldName = (lockingStrategy == VERSION_COLUMN_STRATEGY ? "version_lock" : (lockingStrategy == TIMESTAMP_COLUMN_STRATEGY ? "timestamp_lock" : "generated_lock")); // column name String columnName = MetaData.getOptionalChildContent(element, "column-name"); if(columnName == null || columnName.trim().length() < 1) columnName = (lockingStrategy == VERSION_COLUMN_STRATEGY ? "version_lock" : (lockingStrategy == TIMESTAMP_COLUMN_STRATEGY ? "timestamp_lock" : "generated_lock")); // field type Class fieldType = null; if(lockingStrategy == VERSION_COLUMN_STRATEGY) fieldType = java.lang.Long.class; else if(lockingStrategy == TIMESTAMP_COLUMN_STRATEGY) fieldType = java.util.Date.class; String fieldTypeStr = MetaData.getOptionalChildContent(element, "field-type"); if(fieldTypeStr != null) { try { fieldType = GetTCLAction. getContextClassLoader().loadClass(fieldTypeStr); } catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); } } // JDBC/SQL Type int jdbcType; String sqlType; String jdbcTypeName = MetaData.getOptionalChildContent(element, "jdbc-type"); if(jdbcTypeName != null) { jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcTypeName); sqlType = MetaData.getUniqueChildContent(element, "sql-type"); } else { jdbcType = Integer.MIN_VALUE; sqlType = null; } return new JDBCCMPFieldMetaData( entity, fieldName, fieldType, columnName, jdbcType, sqlType ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCMappingMetaData.java
public static int getJdbcTypeFromName(String name) throws DeploymentException { if(name == null) { throw new DeploymentException("jdbc-type cannot be null"); } try { Integer constant = (Integer)Types.class.getField(name).get(null); return constant.intValue(); } catch(Exception e) { log.warn("Unrecognized jdbc-type: " + name + ", using Types.OTHER", e); return Types.OTHER; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
private static JDBCCMPFieldMetaData constructAuditField( JDBCEntityMetaData entity, Element element, String defaultName) throws DeploymentException { // field name String fieldName = MetaData.getOptionalChildContent(element, "field-name"); if (fieldName == null || fieldName.trim().length() < 1) fieldName = defaultName; // column name String columnName = MetaData.getOptionalChildContent(element, "column-name"); if (columnName == null || columnName.trim().length() < 1) columnName = defaultName; // field type Class fieldType; String fieldTypeStr = MetaData.getOptionalChildContent(element, "field-type"); if (fieldTypeStr != null) { try { fieldType = GetTCLAction.getContextClassLoader().loadClass(fieldTypeStr); } catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); } } else { if (defaultName.endsWith("by")) fieldType = String.class; else fieldType = java.util.Date.class; } // JDBC/SQL Type int jdbcType; String sqlType; String jdbcTypeName = MetaData.getOptionalChildContent(element, "jdbc-type"); if (jdbcTypeName != null) { jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcTypeName); sqlType = MetaData.getUniqueChildContent(element, "sql-type"); } else { jdbcType = Integer.MIN_VALUE; sqlType = null; } // Is the field exposed? JDBCCMPFieldMetaData result = entity.getCMPFieldByName(fieldName); if (result == null) result = new JDBCCMPFieldMetaData(entity, fieldName, fieldType, columnName, jdbcType, sqlType); return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
private void initFromString(String sql) throws DeploymentException { ArrayList chunkList = new ArrayList(); ArrayList parameterList = new ArrayList(); // add a dummy chunk so we can be assured that the sql started with chunk before a number if(sql.charAt(0) == '?') { chunkList.add(""); } // break the sql into chunks and parameters StringBuffer chunk = new StringBuffer(); StringReader reader = new StringReader(sql); try { for(int c = reader.read(); c >= 0; c = reader.read()) { if(c != '?') { chunk.append((char)c); } else { chunkList.add(chunk.toString()); chunk = new StringBuffer(); // read the number StringBuffer number = new StringBuffer(); for(int digit = reader.read(); digit >= 0; digit = reader.read()) { if(Character.isDigit((char)digit)) { number.append((char)digit); } else { if(digit >= 0) { chunk.append((char)digit); } break; } } if(number.length() == 0) { throw new DeploymentException("Invalid parameter in function-sql: " + sql); } Integer parameter; try { parameter = new Integer(number.toString()); } catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); } parameterList.add(parameter); } } } catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); } chunkList.add(chunk.toString()); // save out the chunks sqlChunks = new String[chunkList.size()]; chunkList.toArray(sqlChunks); // save out the parameter order parameters = new int[parameterList.size()]; for(int i = 0; i < parameters.length; i++) { parameters[i] = ((Integer)parameterList.get(i)).intValue() - 1; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
public static JDBCQueryMetaData createJDBCQueryMetaData(JDBCQueryMetaData jdbcQueryMetaData, JDBCReadAheadMetaData readAhead, Class qlCompiler) throws DeploymentException { // RAW-SQL if(jdbcQueryMetaData instanceof JDBCRawSqlQueryMetaData) { return new JDBCRawSqlQueryMetaData(jdbcQueryMetaData.getMethod(), qlCompiler, false); } // JBOSS-QL if(jdbcQueryMetaData instanceof JDBCJBossQLQueryMetaData) { return new JDBCJBossQLQueryMetaData( (JDBCJBossQLQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // DYNAMIC-SQL if(jdbcQueryMetaData instanceof JDBCDynamicQLQueryMetaData) { return new JDBCDynamicQLQueryMetaData( (JDBCDynamicQLQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // DECLARED-SQL if(jdbcQueryMetaData instanceof JDBCDeclaredQueryMetaData) { return new JDBCDeclaredQueryMetaData( (JDBCDeclaredQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // EJB-QL: default if(jdbcQueryMetaData instanceof JDBCQlQueryMetaData) { return new JDBCQlQueryMetaData( (JDBCQlQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } throw new DeploymentException( "Error in query specification for method " + jdbcQueryMetaData.getMethod().getName() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private JDBCQueryMetaData createJDBCQueryMetaData(JDBCQueryMetaData jdbcQueryMetaData, Element queryElement, Method method, JDBCReadAheadMetaData readAhead) throws DeploymentException { final Class qlCompiler = JDBCQueryManager.getQLCompiler(queryElement, entity); final boolean isResultTypeMappingLocal = (jdbcQueryMetaData == null ? false : jdbcQueryMetaData.isResultTypeMappingLocal()); final boolean lazyResultSetLoading = Collection.class.isAssignableFrom(method.getReturnType()) && MetaData.getOptionalChildBooleanContent(queryElement, "lazy-resultset-loading"); // RAW-SQL Element rawSql = MetaData.getOptionalChild(queryElement, "raw-sql"); if(rawSql != null) { return new JDBCRawSqlQueryMetaData(method, qlCompiler, lazyResultSetLoading); } // JBOSS-QL Element jbossQL = MetaData.getOptionalChild(queryElement, "jboss-ql"); if(jbossQL != null) { return new JDBCJBossQLQueryMetaData( isResultTypeMappingLocal, jbossQL, method, readAhead, qlCompiler, lazyResultSetLoading ); } // DYNAMIC-SQL Element dynamicQL = MetaData.getOptionalChild(queryElement, "dynamic-ql"); if(dynamicQL != null) { return new JDBCDynamicQLQueryMetaData(isResultTypeMappingLocal, method, readAhead, qlCompiler, lazyResultSetLoading); } // DECLARED-SQL Element delcaredSql = MetaData.getOptionalChild(queryElement, "declared-sql"); if(delcaredSql != null) { return new JDBCDeclaredQueryMetaData( isResultTypeMappingLocal, delcaredSql, method, readAhead, qlCompiler, lazyResultSetLoading ); } // EJB-QL: default if(jdbcQueryMetaData instanceof JDBCQlQueryMetaData) { return new JDBCQlQueryMetaData( (JDBCQlQueryMetaData) jdbcQueryMetaData, method, readAhead ); } throw new DeploymentException("Error in query specification for method " + method.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(Element queryElement) throws DeploymentException { // query-method sub-element Element queryMethod = MetaData.getUniqueChild(queryElement, "query-method"); // method name String methodName = MetaData.getUniqueChildContent(queryMethod, "method-name"); // method params ArrayList methodParams = new ArrayList(); Element methodParamsElement = MetaData.getUniqueChild(queryMethod, "method-params"); Iterator iterator = MetaData.getChildrenByTagName(methodParamsElement, "method-param"); while(iterator.hasNext()) { methodParams.add(MetaData.getElementContent((Element) iterator.next())); } try { Class[] parameters = Classes.convertToJavaClasses(methodParams.iterator(), entity.getClassLoader()); return getQueryMethods(methodName, parameters); } catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(QueryMetaData queryData) throws DeploymentException { String methodName = queryData.getMethodName(); try { Class[] parameters = Classes.convertToJavaClasses(queryData.getMethodParams(), entity.getClassLoader()); return getQueryMethods(methodName, parameters); } catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(String methodName, Class parameters[]) throws DeploymentException { // find the query and load the xml ArrayList methods = new ArrayList(2); if(methodName.startsWith("ejbSelect")) { // bean method Method method = getQueryMethod(methodName, parameters, entity.getEntityClass()); if(method != null) { methods.add(method); } } else { // remote home Class homeClass = entity.getHomeClass(); if(homeClass != null) { Method method = getQueryMethod(methodName, parameters, homeClass); if(method != null) { methods.add(method); } } // local home Class localHomeClass = entity.getLocalHomeClass(); if(localHomeClass != null) { Method method = getQueryMethod(methodName, parameters, localHomeClass); if(method != null) { methods.add(method); } } } if(methods.size() == 0) { StringBuffer sb = new StringBuffer(300); sb.append("Query method not found: ") .append(methodName).append('('); for(int i = 0; i < parameters.length; i++) { if(i > 0) { sb.append(','); } sb.append(parameters[i].getName()); } sb.append(')'); throw new DeploymentException(sb.toString()); } return (Method[]) methods.toArray(new Method[methods.size()]); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected void setSelectEntity(JDBCEntityBridge selectEntity) throws DeploymentException { if(queryMetaData.getMethod().getName().startsWith("find") && this.selectEntity != null && this.selectEntity != selectEntity) { throw new DeploymentException("Finder " + queryMetaData.getMethod().getName() + " defined on " + this.selectEntity.getEntityName() + " should return only instances of " + this.selectEntity.getEntityName() + " but the query results in instances of " + selectEntity.getEntityName()); } this.selectField = null; this.selectFunction = null; this.selectEntity = selectEntity; this.selectManager = (JDBCStoreManager) selectEntity.getManager(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected String parseParameters(String sql) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); ArrayList params = new ArrayList(); // Replace placeholders {0} with ? if(sql != null) { sql = sql.trim(); StringTokenizer tokens = new StringTokenizer(sql, "{}", true); while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); if(token.equals("{")) { token = tokens.nextToken(); if(Character.isDigit(token.charAt(0))) { QueryParameter parameter = new QueryParameter(selectManager, queryMetaData.getMethod(), token); // of if we are here we can assume that we have // a parameter and not a function sqlBuf.append("?"); params.add(parameter); if(!tokens.nextToken().equals("}")) { throw new DeploymentException("Invalid parameter - missing closing '}' : " + sql); } } else { // ok we don't have a parameter, we have a function // push the tokens on the buffer and continue sqlBuf.append("{").append(token); } } else { // not parameter... just append it sqlBuf.append(token); } } } parameters = params; return sqlBuf.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public static List getLeftJoinCMRNodes(JDBCEntityBridge entity, String path, Iterator leftJoinIter, Set declaredPaths) throws DeploymentException { List leftJoinCMRNodes; if(leftJoinIter.hasNext()) { leftJoinCMRNodes = new ArrayList(); while(leftJoinIter.hasNext()) { JDBCLeftJoinMetaData leftJoin = (JDBCLeftJoinMetaData) leftJoinIter.next(); JDBCCMRFieldBridge cmrField = entity.getCMRFieldByName(leftJoin.getCmrField()); if(cmrField == null) { throw new DeploymentException("cmr-field in left-join was not found: cmr-field=" + leftJoin.getCmrField() + ", entity=" + entity.getEntityName()); } List subNodes; JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity(); String childPath = path + '.' + cmrField.getFieldName(); if(declaredPaths != null) { declaredPaths.add(childPath); } subNodes = getLeftJoinCMRNodes(relatedEntity, childPath, leftJoin.getLeftJoins(), declaredPaths); boolean[] mask = relatedEntity.getLoadGroupMask(leftJoin.getEagerLoadGroup()); LeftJoinCMRNode node = new LeftJoinCMRNode(childPath, cmrField, mask, subNodes); leftJoinCMRNodes.add(node); } } else { leftJoinCMRNodes = Collections.EMPTY_LIST; } return leftJoinCMRNodes; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public static final CMPFieldStateFactory getCMPFieldStateFactory(JDBCTypeFactory factory, String implClassName, Class clazz) throws DeploymentException { CMPFieldStateFactory stateFactory; // if the state factory is not provided on the field level use the one from the user type mapping if any if(implClassName == null) { JDBCUserTypeMappingMetaData userMapping = (JDBCUserTypeMappingMetaData)factory.userTypeMappings.get(clazz.getName()); if(userMapping != null) { implClassName = userMapping.getStateFactory(); } } if(implClassName != null) { try { Class implClass = TCLAction.UTIL.getContextClassLoader().loadClass(implClassName); stateFactory = (CMPFieldStateFactory)implClass.newInstance(); } catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); } catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); } } else if(Map.class.isAssignableFrom(clazz)) { stateFactory = MAP; } else if(List.class.isAssignableFrom(clazz)) { stateFactory = LIST; } else if(Set.class.isAssignableFrom(clazz)) { stateFactory = SET; } else if(clazz.isArray()) { stateFactory = ARRAY; } else if(usedWithEqualsStateFactory(clazz)) { stateFactory = EQUALS; } else { stateFactory = INVALID_UNLESS_NULL; } return stateFactory; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private JDBCTypeSimple createTypeSimple(JDBCCMPFieldMetaData cmpField) throws DeploymentException { String columnName = cmpField.getColumnName(); Class javaType = cmpField.getFieldType(); JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType); String paramSetter = typeMappingMD.getParamSetter(); String resultReader = typeMappingMD.getResultReader(); int jdbcType; String sqlType = cmpField.getSQLType(); if(sqlType != null) { jdbcType = cmpField.getJDBCType(); } else { // get jdbcType and sqlType from typeMapping sqlType = typeMappingMD.getSqlType(); jdbcType = typeMappingMD.getJdbcType(); } boolean notNull = cmpField.isNotNull(); boolean autoIncrement = cmpField.isAutoIncrement(); Mapper mapper = null; JDBCUserTypeMappingMetaData userTypeMapping = (JDBCUserTypeMappingMetaData)userTypeMappings.get(javaType.getName()); if(userTypeMapping != null) { String mappedTypeStr = userTypeMapping.getMappedType(); try { final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader(); Class mapperClass = contextClassLoader.loadClass(userTypeMapping.getMapper()); mapper = (Mapper)mapperClass.newInstance(); javaType = contextClassLoader.loadClass(mappedTypeStr); if(cmpField.getSQLType() == null) { JDBCMappingMetaData mappingMD = typeMapping.getTypeMappingMetaData(javaType); sqlType = mappingMD.getSqlType(); jdbcType = mappingMD.getJdbcType(); paramSetter = mappingMD.getParamSetter(); resultReader = mappingMD.getResultReader(); } } catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); } catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); } } JDBCParameterSetter paramSetterImpl; if(paramSetter == null) { paramSetterImpl = JDBCUtil.getParameterSetter(jdbcType, javaType); } else { paramSetterImpl = (JDBCParameterSetter)newInstance(paramSetter); } JDBCResultSetReader resultReaderImpl; if(resultReader == null) { resultReaderImpl = JDBCUtil.getResultSetReader(jdbcType, javaType); } else { resultReaderImpl = (JDBCResultSetReader)newInstance(resultReader); } return new JDBCTypeSimple( columnName, javaType, jdbcType, sqlType, notNull, autoIncrement, mapper, paramSetterImpl, resultReaderImpl ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private Object newInstance(String className) throws DeploymentException { Class clazz = loadClass(className); try { return clazz.newInstance(); } catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private Class loadClass(String className) throws DeploymentException { try { final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader(); return contextClassLoader.loadClass(className); } catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCreateBeanClassInstanceCommand.java
private Map createFieldMap() throws DeploymentException { Map abstractAccessors = getAbstractAccessors(); List fields = entityBridge.getFields(); Map map = new HashMap(fields.size() * 2); for(int i = 0; i < fields.size(); i++) { FieldBridge field = (FieldBridge) fields.get(i); // get the names String fieldName = field.getFieldName(); String fieldBaseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getterName = "get" + fieldBaseName; String setterName = "set" + fieldBaseName; // get the accessor methods Method getterMethod = (Method) abstractAccessors.get(getterName); Method setterMethod = (Method) abstractAccessors.get(setterName); // getters and setters must come in pairs if(getterMethod != null && setterMethod == null) { throw new DeploymentException("Getter was found but no setter was found for field " + fieldName + " in entity " + entityBridge.getEntityName()); } else if(getterMethod == null && setterMethod != null) { throw new DeploymentException("Setter was found but no getter was found for field " + fieldName + " in entity " + entityBridge.getEntityName()); } else if(getterMethod != null && setterMethod != null) { // add methods map.put(getterMethod.getName(), new EntityBridgeInvocationHandler.FieldGetInvoker(field)); map.put(setterMethod.getName(), new EntityBridgeInvocationHandler.FieldSetInvoker(field)); // remove the accessors (they have been used) abstractAccessors.remove(getterName); abstractAccessors.remove(setterName); } } return Collections.unmodifiableMap(map); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void alterTable(DataSource dataSource, JDBCFunctionMappingMetaData mapping, String tableName, String fieldName, String fieldStructure) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); mapping.getFunctionSql( new String[]{tableName, fieldName, fieldStructure}, sqlBuf ); String sql = sqlBuf.toString(); if(log.isDebugEnabled()) log.debug("Executing: " + sql); // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); } try { Connection con = null; Statement statement = null; try { con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); } } // success if ( log.isDebugEnabled() ) log.debug("Table altered successfully."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createTable(DataSource dataSource, String tableName, String sql) throws DeploymentException { // does this table already exist if(SQLUtil.tableExists(tableName, dataSource)) { log.debug("Table '" + tableName + "' already exists"); return; } // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); } try { Connection con = null; Statement statement = null; try { // execute sql if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } // success Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); createdTables.add(tableName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createIndex(DataSource dataSource, String tableName, String indexName, String sql) throws DeploymentException { // we are only called directly after creating a table // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); } try { Connection con = null; Statement statement = null; try { // execute sql if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void issuePostCreateSQL(DataSource dataSource, List sql, String table) throws DeploymentException { if(sql == null) { // no work to do. log.trace("issuePostCreateSQL: sql is null"); return; } log.debug("issuePostCreateSQL::sql: " + sql.toString() + " on table " + table); TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); } String currentCmd = ""; try { Connection con = null; Statement statement = null; try { con = dataSource.getConnection(); statement = con.createStatement(); // execute sql for(int i = 0; i < sql.size(); i++) { currentCmd = (String) sql.get(i); /* * Replace %%t in the sql command with the current table name */ currentCmd = replaceTable(currentCmd, table); currentCmd = replaceIndexCounter(currentCmd); log.debug("Executing SQL: " + currentCmd); statement.executeUpdate(currentCmd); } } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } } // success log.debug("Issued SQL " + sql + " successfully."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addForeignKeyConstraint(DataSource dataSource, String tableName, String cmrFieldName, JDBCFieldBridge[] fields, String referencesTableName, JDBCFieldBridge[] referencesFields) throws DeploymentException { // can only alter tables we created Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); if(!createdTables.contains(tableName)) { return; } JDBCFunctionMappingMetaData fkConstraint = manager.getMetaData().getTypeMapping().getFkConstraintTemplate(); if(fkConstraint == null) { throw new IllegalStateException("Foreign key constraint is not allowed for this type of datastore"); } String a = SQLUtil.getColumnNamesClause(fields, new StringBuffer(50)).toString(); String b = SQLUtil.getColumnNamesClause(referencesFields, new StringBuffer(50)).toString(); String[] args = new String[]{ tableName, SQLUtil.fixConstraintName("fk_" + tableName + "_" + cmrFieldName, dataSource), a, referencesTableName, b}; String sql = fkConstraint.getFunctionSql(args, new StringBuffer(100)).toString(); // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); } try { Connection con = null; Statement statement = null; try { if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private JDBCEntityMetaData loadJDBCEntityMetaData() throws DeploymentException { ApplicationMetaData amd = container.getBeanMetaData().getApplicationMetaData(); // Get JDBC MetaData JDBCApplicationMetaData jamd = (JDBCApplicationMetaData)amd.getPluginData(CMP_JDBC); if(jamd == null) { // we are the first cmp entity to need jbosscmp-jdbc. // Load jbosscmp-jdbc.xml for the whole application JDBCXmlFileLoader jfl = new JDBCXmlFileLoader(container, log); jamd = jfl.load(); amd.addPluginData(CMP_JDBC, jamd); } // Get JDBC Bean MetaData String ejbName = container.getBeanMetaData().getEjbName(); JDBCEntityMetaData metadata = jamd.getBeanByEjbName(ejbName); if(metadata == null) { throw new DeploymentException("No metadata found for bean " + ejbName); } return metadata; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeclaredSQLQuery.java
private void initSelectObject(JDBCStoreManager manager) throws DeploymentException { String entityName = metadata.getEJBName(); // if no name is specified we are done if(entityName == null) { return; } Catalog catalog = manager.getCatalog(); JDBCEntityBridge entity = (JDBCEntityBridge)catalog.getEntityByEJBName(entityName); if(entity == null) { throw new DeploymentException("Unknown entity: " + entityName); } String fieldName = metadata.getFieldName(); if(fieldName == null) { setSelectEntity(entity); } else { JDBCCMPFieldBridge field = entity.getCMPFieldByName(fieldName); if(field == null) { throw new DeploymentException("Unknown cmp field: " + fieldName); } setSelectField(field); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCCreateCommand createCreateEntityCommand() throws DeploymentException { JDBCCreateCommand cec; try { cec = (JDBCCreateCommand)manager.getMetaData(). getEntityCommand().getCommandClass().newInstance(); cec.init(manager); } catch(DeploymentException de) { throw de; } catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); } if(log.isDebugEnabled()) log.debug("entity-command: " + manager.getMetaData().getEntityCommand()); return cec; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public static final Class getQLCompiler(Element query, JDBCEntityMetaData entity) throws DeploymentException { String compiler = MetaData.getOptionalChildContent(query, "ql-compiler"); Class impl; if(compiler == null || compiler.trim().length() == 0) { impl = entity.getQLCompiler(); } else { try { impl = TCLAction.UTIL.getContextClassLoader().loadClass(compiler); } catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); } } return impl; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public static final QLCompiler getInstance(Class impl, Catalog catalog) throws DeploymentException { if(impl == null) { throw new DeploymentException("ql-compiler is not specified."); } final Constructor constructor; try { constructor = impl.getConstructor(new Class[]{Catalog.class}); } catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); } try { return (QLCompiler)constructor.newInstance(new Object[]{catalog}); } catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public void start() throws DeploymentException { Logger log = Logger.getLogger( this.getClass().getName() + "." + manager.getMetaData().getName()); JDBCCommandFactory factory = manager.getCommandFactory(); Class homeClass = manager.getContainer().getHomeClass(); Class localHomeClass = manager.getContainer().getLocalHomeClass(); // // findByPrimaryKey // JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge(); if(homeClass != null) { try { // try to get the finder method on the home interface Method method = homeClass.getMethod(FIND_BY_PK, new Class[]{entity.getPrimaryKeyClass()}); JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method); JDBCReadAheadMetaData readAhead = (findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead()); // got it add it to known finders JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData( method, readAhead, entity.getMetaData().getQLCompiler(), false ); knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q)); if(log.isDebugEnabled()) log.debug("Added findByPrimaryKey query command for home interface"); } catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); } } if(localHomeClass != null) { Method method; try { // try to get the finder method on the local home interface method = localHomeClass.getMethod(FIND_BY_PK, new Class[] { entity.getPrimaryKeyClass() }); } catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } // got it add it to known finders JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method); JDBCReadAheadMetaData readAhead = (findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead()); JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false); knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q)); if(log.isDebugEnabled()) log.debug("Added findByPrimaryKey query command for local home interface"); } // // Custom finders - Overrides defined and automatic finders. // Class ejbClass = manager.getMetaData().getEntityClass(); Method[] customMethods = ejbClass.getMethods(); for (int i = 0; i < customMethods.length; i++) { Method m = customMethods[i]; String methodName = m.getName(); if(methodName.startsWith(EJB_FIND)) { String interfaceName = 'f' + methodName.substring(4); if(homeClass != null) { try { // try to get the finder method on the home interface Method interfaceMethod = homeClass.getMethod( interfaceName, m.getParameterTypes()); // got it add it to known finders knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m)); if(log.isDebugEnabled()) log.debug("Added custom finder " + methodName + " on home interface"); } catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface } } if(localHomeClass != null) { try { // try to get the finder method on the local home interface Method interfaceMethod = localHomeClass.getMethod( interfaceName, m.getParameterTypes()); // got it add it to known finders knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m)); if(log.isDebugEnabled()) log.debug("Added custom finder " + methodName + " on local home interface"); } catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface } } } } // // Defined finders - Overrides automatic finders. // Iterator definedFinders = manager.getMetaData().getQueries().iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData q = (JDBCQueryMetaData)definedFinders.next(); if(!knownQueries.containsKey(q.getMethod()) ) { if(q instanceof JDBCJBossQLQueryMetaData) { knownQueries.put(q.getMethod(), factory.createJBossQLQuery(q)); } else if(q instanceof JDBCDynamicQLQueryMetaData) { knownQueries.put(q.getMethod(), factory.createDynamicQLQuery(q)); } else if(q instanceof JDBCDeclaredQueryMetaData) { knownQueries.put(q.getMethod(), factory.createDeclaredSQLQuery(q)); } else if(q instanceof JDBCQlQueryMetaData) { knownQueries.put(q.getMethod(), factory.createEJBQLQuery(q)); } } } // // Automatic finders - The last resort // if(homeClass != null) { addAutomaticFinders(manager, homeClass.getMethods(), log); } if(localHomeClass != null) { addAutomaticFinders(manager, localHomeClass.getMethods(), log); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String fixTableName(String tableName, DataSource dataSource) throws DeploymentException { // don't fix the quited table name char firstChar = tableName.charAt(0); if(firstChar == '"' || firstChar == '\'') { return tableName; } // Separate schema name and table name String strSchema = ""; int iIndex; if((iIndex = tableName.indexOf('.')) != -1) { strSchema = tableName.substring(0, iIndex); tableName = tableName.substring(iIndex + 1); } // check for SQL reserved word and escape it with prepending a "X" // IMHO one should reject reserved words and throw a // DeploymentException - pilhuhn if(rwords != null) { for(int i = 0; i < rwords.size(); i++) { if(((String)rwords.elementAt(i)).equalsIgnoreCase(tableName)) { tableName = "X" + tableName; break; } } } Connection con = null; try { con = dataSource.getConnection(); DatabaseMetaData dmd = con.getMetaData(); // fix length int maxLength = dmd.getMaxTableNameLength(); if(maxLength > 0 && tableName.length() > maxLength) { CRC32 crc = new CRC32(); crc.update(tableName.getBytes()); String nameCRC = Long.toString(crc.getValue(), 36); tableName = tableName.substring( 0, maxLength - nameCRC.length() - 2); tableName += "_" + nameCRC; } // fix case if(dmd.storesLowerCaseIdentifiers()) { tableName = tableName.toLowerCase(); } else if(dmd.storesUpperCaseIdentifiers()) { tableName = tableName.toUpperCase(); } // now put the schema name back on the table name if(strSchema.length() > 0) { tableName = strSchema + "." + tableName; } return tableName; } catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); } finally { JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static boolean tableExists(String tableName, DataSource dataSource) throws DeploymentException { Connection con = null; ResultSet rs = null; try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; String quote = dmd.getIdentifierQuoteString(); if(tableName.startsWith(quote)) { if(tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); if(dmd.storesLowerCaseQuotedIdentifiers()) tableName = tableName.toLowerCase(); else if(dmd.storesUpperCaseQuotedIdentifiers()) tableName = tableName.toUpperCase(); } else { if(dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if(dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); } // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getTables(catalog, schema, tableName, null); return rs.next(); } catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static OldColumns getOldColumns(String tableName, DataSource dataSource) throws DeploymentException { Connection con = null; ResultSet rs = null; ArrayList columnNames = new ArrayList(); ArrayList typeNames = new ArrayList(); ArrayList columnSizes = new ArrayList(); try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; String quote = dmd.getIdentifierQuoteString(); if (tableName.startsWith(quote)) { if (tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); if (dmd.storesLowerCaseQuotedIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseQuotedIdentifiers()) tableName = tableName.toUpperCase(); } else { if (dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); } // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getColumns(catalog, schema, tableName, null); while (rs.next()) { String columnName = rs.getString("COLUMN_NAME"); columnNames.add(columnName == null ? null : columnName.toUpperCase()); typeNames.add(rs.getString("TYPE_NAME")); columnSizes.add(new Integer(rs.getInt("COLUMN_SIZE"))); } return new OldColumns(columnNames, typeNames, columnSizes); } catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static OldIndexes getOldIndexes(String tableName, DataSource dataSource) throws DeploymentException { tableName = unquote(tableName, dataSource); Connection con = null; ResultSet rs = null; ArrayList indexNames = new ArrayList(); ArrayList columnNames = new ArrayList(); ArrayList ascDesc = new ArrayList(); try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; if (dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getIndexInfo(catalog, schema, tableName, false, false); while (rs.next()) { indexNames.add(rs.getString("INDEX_NAME")); columnNames.add(rs.getString("COLUMN_NAME")); ascDesc.add(rs.getString("ASC_OR_DESC")); } return new OldIndexes(indexNames, columnNames, ascDesc); } catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String unquote(String tableName, DataSource ds) throws DeploymentException { Connection con = null; try { con = ds.getConnection(); String quote = con.getMetaData().getIdentifierQuoteString(); if (tableName.startsWith(quote)) { if (tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); } } catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); } finally { JDBCUtil.safeClose(con); } return tableName; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static void dropTable(DataSource dataSource, String tableName) throws DeploymentException { Logger log = Logger.getLogger("CLEANER"); String sql = "DROP TABLE " + tableName; try { Connection con = null; Statement statement = null; try { // execute sql con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); } log.info("Dropped table "+tableName+" succesfuly"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void init() throws DeploymentException { try { InitialContext ic = new InitialContext(); dataSource = (DataSource)ic.lookup(metadata.getDataSourceName()); } catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); } qualifiedTableName = SQLUtil.fixTableName(metadata.getDefaultTableName(), dataSource); int dotIndex = qualifiedTableName.indexOf('.'); tableName = dotIndex == -1 ? qualifiedTableName : qualifiedTableName.substring(dotIndex + 1); // CMP fields loadCMPFields(metadata); // CMR fields loadCMRFields(metadata); // create locking field JDBCOptimisticLockingMetaData lockMetaData = metadata.getOptimisticLocking(); if(lockMetaData != null && lockMetaData.getLockingField() != null) { Integer strategy = lockMetaData.getLockingStrategy(); JDBCCMPFieldMetaData versionMD = lockMetaData.getLockingField(); versionField = getCMPFieldByName(versionMD.getFieldName()); boolean hidden = versionField == null; if(strategy == JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCLongVersionFieldBridge(manager, versionMD); else versionField = new JDBCLongVersionFieldBridge((JDBCCMP2xFieldBridge)versionField); } else if(strategy == JDBCOptimisticLockingMetaData.TIMESTAMP_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCTimestampVersionFieldBridge(manager, versionMD); else versionField = new JDBCTimestampVersionFieldBridge((JDBCCMP2xFieldBridge)versionField); } else if(strategy == JDBCOptimisticLockingMetaData.KEYGENERATOR_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCKeyGenVersionFieldBridge( manager, versionMD, lockMetaData.getKeyGeneratorFactory()); else versionField = new JDBCKeyGenVersionFieldBridge( (JDBCCMP2xFieldBridge)versionField, lockMetaData.getKeyGeneratorFactory()); } if(hidden) addCMPField(versionField); else tableFields[versionField.getTableIndex()] = versionField; } // audit fields JDBCAuditMetaData auditMetaData = metadata.getAudit(); if(auditMetaData != null) { JDBCCMPFieldMetaData auditField = auditMetaData.getCreatedPrincipalField(); if(auditField != null) { createdPrincipalField = getCMPFieldByName(auditField.getFieldName()); if(createdPrincipalField == null) { createdPrincipalField = new JDBCCMP2xFieldBridge(manager, auditField); addCMPField(createdPrincipalField); } } else { createdPrincipalField = null; } auditField = auditMetaData.getCreatedTimeField(); if(auditField != null) { createdTimeField = getCMPFieldByName(auditField.getFieldName()); if(createdTimeField == null) { createdTimeField = new JDBCCMP2xFieldBridge(manager, auditField, JDBCTypeFactory.EQUALS, false); addCMPField(createdTimeField); } else { // just to override state factory and check-dirty-after-get createdTimeField = new JDBCCMP2xFieldBridge( (JDBCCMP2xFieldBridge)createdTimeField, JDBCTypeFactory.EQUALS, false); tableFields[createdTimeField.getTableIndex()] = createdTimeField; } } else { createdTimeField = null; } auditField = auditMetaData.getUpdatedPrincipalField(); if(auditField != null) { updatedPrincipalField = getCMPFieldByName(auditField.getFieldName()); if(updatedPrincipalField == null) { updatedPrincipalField = new JDBCCMP2xUpdatedPrincipalFieldBridge(manager, auditField); addCMPField(updatedPrincipalField); } else { updatedPrincipalField = new JDBCCMP2xUpdatedPrincipalFieldBridge( (JDBCCMP2xFieldBridge)updatedPrincipalField); tableFields[updatedPrincipalField.getTableIndex()] = updatedPrincipalField; } } else { updatedPrincipalField = null; } auditField = auditMetaData.getUpdatedTimeField(); if(auditField != null) { updatedTimeField = getCMPFieldByName(auditField.getFieldName()); if(updatedTimeField == null) { updatedTimeField = new JDBCCMP2xUpdatedTimeFieldBridge(manager, auditField); addCMPField(updatedTimeField); } else { updatedTimeField = new JDBCCMP2xUpdatedTimeFieldBridge((JDBCCMP2xFieldBridge)updatedTimeField); tableFields[updatedTimeField.getTableIndex()] = updatedTimeField; } } else { updatedTimeField = null; } } // ejbSelect methods loadSelectors(metadata); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private boolean[] loadGroupMask(String groupName, boolean[] defaultGroup) throws DeploymentException { List fieldNames = metadata.getLoadGroup(groupName); boolean[] group = new boolean[tableFields.length]; if(defaultGroup != null) System.arraycopy(defaultGroup, 0, group, 0, group.length); for(Iterator iter = fieldNames.iterator(); iter.hasNext();) { String fieldName = (String)iter.next(); JDBCFieldBridge field = (JDBCFieldBridge)getFieldByName(fieldName); if(field == null) throw new DeploymentException( "Field " + fieldName + " not found for entity " + getEntityName()); if(field instanceof JDBCCMRFieldBridge) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)field; if(cmrField.hasForeignKey()) { JDBCCMPFieldBridge[] fkFields = (JDBCCMPFieldBridge[]) cmrField.getForeignKeyFields(); for(int i = 0; i < fkFields.length; ++i) { group[fkFields[i].getTableIndex()] = true; } } else { throw new DeploymentException("Only CMR fields that have " + "a foreign-key may be a member of a load group: " + "fieldName=" + fieldName); } } else { group[((JDBCCMPFieldBridge)field).getTableIndex()] = true; } } return group; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void resolveRelationship() throws DeploymentException { // // Set handles to the related entity's container, cache, // manager, and invoker // // Related Entity Name String relatedEntityName = metadata.getRelatedRole().getEntity().getName(); // Related Entity Catalog catalog = (Catalog) manager.getApplicationData("CATALOG"); relatedEntity = (JDBCEntityBridge) catalog.getEntityByEJBName(relatedEntityName); if(relatedEntity == null) { throw new DeploymentException("Related entity not found: " + "entity=" + entity.getEntityName() + ", " + "cmrField=" + getFieldName() + ", " + "relatedEntity=" + relatedEntityName); } // Related CMR Field JDBCCMRFieldBridge[] cmrFields = (JDBCCMRFieldBridge[]) relatedEntity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge cmrField = cmrFields[i]; if(metadata.getRelatedRole() == cmrField.getMetaData()) { relatedCMRField = cmrField; break; } } // if we didn't find the related CMR field throw an exception // with a detailed message if(relatedCMRField == null) { String message = "Related CMR field not found in " + relatedEntity.getEntityName() + " for relationship from"; message += entity.getEntityName() + "."; if(getFieldName() != null) { message += getFieldName(); } else { message += "<no-field>"; } message += " to "; message += relatedEntityName + "."; if(metadata.getRelatedRole().getCMRFieldName() != null) { message += metadata.getRelatedRole().getCMRFieldName(); } else { message += "<no-field>"; } throw new DeploymentException(message); } // Related Manager relatedManager = (JDBCStoreManager) relatedEntity.getManager(); // Related Container EntityContainer relatedContainer = relatedManager.getContainer(); this.relatedContainerRef = new WeakReference(relatedContainer); // related findByPrimaryKey Class homeClass = (relatedContainer.getLocalHomeClass() != null ? relatedContainer.getLocalHomeClass() : relatedContainer.getHomeClass()); try { relatedFindByPrimaryKey = homeClass.getMethod("findByPrimaryKey", new Class[]{relatedEntity.getPrimaryKeyClass()}); } catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); } // // Initialize the key fields // if(metadata.getRelationMetaData().isTableMappingStyle()) { // initialize relation table key fields Collection tableKeys = metadata.getKeyFields(); List keyFieldsList = new ArrayList(tableKeys.size()); // first phase is to create fk fields Map pkFieldsToFKFields = new HashMap(tableKeys.size()); for(Iterator i = tableKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData) i.next(); FieldBridge pkField = entity.getFieldByName(cmpFieldMetaData.getFieldName()); if(pkField == null) { throw new DeploymentException("Primary key not found for key-field " + cmpFieldMetaData.getFieldName()); } pkFieldsToFKFields.put(pkField, new JDBCCMP2xFieldBridge(manager, cmpFieldMetaData)); } // second step is to order fk fields to match the order of pk fields JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { Object fkField = pkFieldsToFKFields.get(pkFields[i]); if(fkField == null) { throw new DeploymentException("Primary key " + pkFields[i].getFieldName() + " is not mapped."); } keyFieldsList.add(fkField); } tableKeyFields = (JDBCCMP2xFieldBridge[]) keyFieldsList.toArray( new JDBCCMP2xFieldBridge[keyFieldsList.size()]); dataSource = metadata.getRelationMetaData().getDataSource(); } else { initializeForeignKeyFields(); dataSource = hasForeignKey() ? entity.getDataSource() : relatedEntity.getDataSource(); } // Fix table name // // This code doesn't work here... The problem each side will generate // the table name and this will only work for simple generation. qualifiedTableName = SQLUtil.fixTableName(metadata.getRelationMetaData().getDefaultTableName(), dataSource); tableName = SQLUtil.getTableNameWithoutSchema(qualifiedTableName); relationManager = relatedCMRField.initRelationManager(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
private KeyGenerator initKeyGenerator(String keygenFactoryName) throws DeploymentException { try { InitialContext ctx = new InitialContext(); KeyGeneratorFactory keygenFactory = (KeyGeneratorFactory)ctx.lookup(keygenFactoryName); return keygenFactory.getKeyGenerator(); } catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); } catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); ClassLoader loader = GetTCLAction.getContextClassLoader(); try { Class psClass = loader.loadClass(className); method = psClass.getMethod(methodName, null); } catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); } catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); } try { Class wrapperClass = loader.loadClass("org.jboss.resource.adapter.jdbc.StatementAccess"); getUnderlyingStatement = wrapperClass.getMethod("getUnderlyingStatement", null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); } catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { if (CONNECTION_PREPARE == null) { throw new DeploymentException("Create command requires JDBC 3.0 (JDK1.4+)"); } super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); String factoryName = entityCommand.getAttribute("key-generator-factory"); if(factoryName == null) { throw new DeploymentException("key-generator-factory attribute must be set for entity " + entity.getEntityName()); } try { KeyGeneratorFactory keyGeneratorFactory = (KeyGeneratorFactory) new InitialContext().lookup(factoryName); keyGenerator = keyGeneratorFactory.getKeyGenerator(); } catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); } catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { throw new DeploymentException("pk-sql attribute must be set for entity " + entity.getEntityName()); } if(debug) { log.debug("Generate PK sql is: " + pkSQL); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); ClassLoader loader = GetTCLAction.getContextClassLoader(); try { Class psClass = loader.loadClass(className); method = psClass.getMethod(methodName, null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); } catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); } try { Class wrapperClass = loader.loadClass("org.jboss.resource.adapter.jdbc.StatementAccess"); getUnderlyingStatement = wrapperClass.getMethod("getUnderlyingStatement", null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); } catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence = entityCommand.getAttribute("sequence"); if (sequence == null) { throw new DeploymentException("Sequence must be specified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence_name = entityCommand.getAttribute("sequence_name"); if (sequence_name == null) { throw new DeploymentException("sequence_name attribute must be specified inside <entity-command>"); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
public void importXml(Element element) throws DeploymentException { String maximumSize = MetaData.getElementContent(MetaData.getUniqueChild(element, "MaximumSize")); try { this.maxSize = Integer.parseInt(maximumSize); } catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); } // Get whether the pool will block when MaximumSize instances are active String strictValue = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictMaximumSize")); this.isStrict = Boolean.valueOf(strictValue); String delay = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictTimeout")); try { if( delay != null ) this.strictTimeout = Long.parseLong(delay); } catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); } }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
public void importXml(Element element) throws DeploymentException { super.importXml(element); String rp = MetaData.getElementContent(MetaData.getOptionalChild(element, "remover-period")); String ml = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-bean-life")); try { if (rp != null) { int p = Integer.parseInt(rp); if (p <= 0) { throw new DeploymentException("Remover period can't be <= 0"); } m_removerPeriod = p * 1000; } if (ml != null) { int a = Integer.parseInt(ml); if (a <= 0) { throw new DeploymentException("Max bean life can't be <= 0"); } m_maxBeanLife = a * 1000; } } catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); } }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { synchronized (this) { if ((sharedWebMetaData == null && webXml != null) || (sharedJBossWebMetaData == null && jbossWebXml != null)) { UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); SchemaBindingResolver resolver = SingletonSchemaResolverFactory .getInstance().getSchemaBindingResolver(); if (webXml != null) { try { sharedWebMetaData = (WebMetaData) unmarshaller.unmarshal(webXml, resolver); } catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); } } if (jbossWebXml != null) { try { sharedJBossWebMetaData = (JBossWebMetaData) unmarshaller.unmarshal(jbossWebXml, resolver); } catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); } } } } if (sharedWebMetaData != null || sharedJBossWebMetaData != null) { JBossWebMetaData clone = new JBoss60WebMetaData(); clone.merge(sharedJBossWebMetaData, sharedWebMetaData); unit.addAttachment(SHARED_JBOSSWEB_ATTACHMENT_NAME, clone); } }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public synchronized void stopModule() throws DeploymentException { String warURL = unit.getName(); try { WebApplication webApp = container.removeDeployedApp(warURL); if (deployment != null && webApp != null) { deployment.stop(unit, webApp); } else { log.debug("Failed to find deployer/deployment for war: " + warURL); } } catch (Exception e) { throw new DeploymentException("Error during stop", e); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
Override public void deploy(DeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException { log.debug("Begin deploy, " + metaData); // Merge any settings from the ear level JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class); if (earMetaData != null) { String path = unit.getRelativePath(); ModuleMetaData webModule = earMetaData.getModule(path); if (webModule != null) { // Check for a context-root setting String contextRoot = metaData.getContextRoot(); if (contextRoot == null) { WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue(); contextRoot = wmodule.getContextRoot(); metaData.setContextRoot(contextRoot); } // Add any alt-dd setting metaData.setAlternativeDD(webModule.getAlternativeDD()); } // Merge security domain/roles if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null) metaData.setSecurityDomain(earMetaData.getSecurityDomain()); // TODO metaData.mergeSecurityRoles(earMetaData.getSecurityRoles()); } try { /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since * the vfs deals with the distinction between a true directory, the only way we can tell from * this level of the api is to look for a url that ends in '/'. Here we assume that the name is * the root url. */ String warName = unit.getName(); /** * Ignore the jacc policy service bean */ if (warName.startsWith("jboss:") && warName.contains("id=")) return; if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit; VirtualFile root = vfsUnit.getRoot(); final URL expandedWarURL = root.getPhysicalFile().toURI().toURL(); // Map String warPathName = root.getPathName(); if (warPathName.endsWith("/") == false) warPathName += "/"; List<VirtualFile> classpathVFs = vfsUnit.getClassPath(); if (classpathVFs != null) { List<URL> classpath = new ArrayList<URL>(); for (VirtualFile vf : classpathVFs) { try { String path = vf.getPathName(); if (path.startsWith(warPathName)) { path = path.substring(warPathName.length()); URL pathURL = new URL(expandedWarURL, path); classpath.add(pathURL); } else { log.debug("Ignoring path element: " + vf); } } catch (Exception e) { log.debug("Ignoring path element: " + vf, e); } } unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath); } // Indicate that an expanded URL exists unit.addAttachment("org.jboss.web.expandedWarURL", expandedWarURL, URL.class); // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file String altDDPath = metaData.getAlternativeDD(); if (altDDPath != null) { // First see if this is already a war local dd VirtualFile altDD = vfsUnit.getMetaDataFile(altDDPath); if (altDD == null) { // Pass absolute paths through File file = new File(altDDPath); if (!file.exists() || !file.isAbsolute()) { // Should be an relative to the top deployment VFSDeploymentUnit topUnit = vfsUnit.getTopLevel(); if (topUnit == unit) throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path"); altDD = topUnit.getFile(altDDPath); if (altDD == null) throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path"); VirtualFile altDDFile = root.getChild("WEB-INF/" + altDD.getName()); log.debug("Copying the altDD to: " + altDDFile); VFSUtils.writeFile(altDDFile, altDD.openStream()); metaData.setAlternativeDD(altDDFile.getPathName()); } } } } ClassLoadingMetaData classLoading = metaData.getClassLoading(); if (classLoading == null) classLoading = new ClassLoadingMetaData(); // pass in the java2ClassLoadingCompliance if it was not set at the war level if (classLoading.wasJava2ClassLoadingComplianceSet() == false) classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance); metaData.setClassLoading(classLoading); // Build the context root if its not been set or is specified at the ear String webContext = metaData.getContextRoot(); webContext = buildWebContext(webContext, warName, metaData, unit); metaData.setContextRoot(webContext); AbstractWarDeployment deployment = getDeployment(unit, metaData); deployment.setMainDeployer(mainDeployer); // TODO: until deployment is a MC bean deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver); deployWebModule(unit, metaData, deployment); } catch (Exception e) { throw new DeploymentException("Failed to create web module", e); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
public void build(DeploymentUnit unit, Set<String> outputs, Map<String, ManagedObject> managedObjects) throws DeploymentException { JBossWebMetaData meta = unit.getAttachment(JBossWebMetaData.class); if (meta == null) return; ManagedObject mo = ManagedObjectFactory.getInstance().createManagedObject(ContextMO.class); if (mo == null) throw new DeploymentException("could not create managed object"); mo.getProperty("contextRoot").setValue(SimpleValueSupport.wrap(meta.getContextRoot())); managedObjects.put("ContextMO", mo); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
public void deploy(final DeploymentUnit unit) throws DeploymentException { // we require a VFSDeploymentUnit, to be able to pick up context relative // config files if (unit instanceof VFSDeploymentUnit == false) { return; } final VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; // get hold of the parsed web.xml metadata WebMetaData webMetaData = unit.getAttachment(WebMetaData.class); // shouldn't really happen, because we have set WebMetaData as a required input. if (webMetaData == null) { return; } List<ParamValueMetaData> contextParams = webMetaData.getContextParams(); if (contextParams == null || contextParams.isEmpty()) { return; } JSFDeployment jsfDeployment = vfsDeploymentUnit.getAttachment(JSFDeployment.class); if (jsfDeployment == null) { // create and attach jsfDeployment = new JSFDeployment(); vfsDeploymentUnit.addAttachment(JSFDeployment.class, jsfDeployment); } for (ParamValueMetaData contextParam : contextParams) { if (contextParam == null) { continue; } if (JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME.equals(contextParam.getParamName())) { try { logger.debug("Found " + JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME + " param with values: " + contextParam.getParamValue() + " in unit " + vfsDeploymentUnit); // process each of the paths specified in the context param value this.processConfigFilesContextParamValue(vfsDeploymentUnit, jsfDeployment, contextParam.getParamValue()); } catch (Exception e) { throw new DeploymentException(e); } } } }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (!unit.getSimpleName().endsWith(".war")) { return; } synchronized (this) { if (sharedTldMetaData == null && tldJars != null) { UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); SchemaBindingResolver resolver = SingletonSchemaResolverFactory .getInstance().getSchemaBindingResolver(); // Parse shared JARs for TLDs sharedTldMetaData = new ArrayList<TldMetaData>(); if (tldJars != null) { VirtualFileFilter tldFilter = new SuffixMatchFilter(".tld", VisitorAttributes.DEFAULT); for (URL tldJar : tldJars) { try { VirtualFile virtualFile = VFS.getChild(tldJar); VirtualFile metaInf = virtualFile.getChild("META-INF"); if (metaInf != null) { List<VirtualFile> tlds = metaInf.getChildren(tldFilter); for (VirtualFile tld : tlds) { TldMetaData tldMetaData = (TldMetaData) unmarshaller.unmarshal(tld.toURL().toString(), resolver); sharedTldMetaData.add(tldMetaData); } } } catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); } } } } } if (sharedTldMetaData != null) { List<TldMetaData> clone = new ArrayList<TldMetaData>(); clone.addAll(sharedTldMetaData); unit.addAttachment(SHARED_TLDS_ATTACHMENT_NAME, clone); } }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { WebMetaData specMetaData = unit.getAttachment(WebMetaData.class); JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); if(specMetaData == null && metaData == null) return; // Check metadata-complete (see AnnotationMetaDataDeployer) boolean isComplete = this.isMetaDataCompleteIsDefault(); if(specMetaData != null) { if (specMetaData instanceof Web25MetaData) { isComplete |= ((Web25MetaData)specMetaData).isMetadataComplete(); } else if (specMetaData instanceof Web30MetaData) { isComplete |= ((Web30MetaData)specMetaData).isMetadataComplete(); } else { // Any web.xml 2.4 or earlier deployment is metadata complete isComplete = true; } } // Find all fragments that have been processed by deployers, and place them in a map keyed by location LinkedList<String> order = new LinkedList<String>(); List<WebOrdering> orderings = new ArrayList<WebOrdering>(); HashSet<String> jarsSet = new HashSet<String>(); Set<VirtualFile> overlays = new HashSet<VirtualFile>(); Map<String, VirtualFile> scis = new HashMap<String, VirtualFile>(); VirtualFile webInfLib = null; boolean fragmentFound = false; HashMap<String, WebFragmentMetaData> webFragments = new HashMap<String, WebFragmentMetaData>(); if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit; webInfLib = vfsUnit.getFile("WEB-INF/lib"); if (webInfLib != null) { List<VirtualFile> jars = webInfLib.getChildren(); for (VirtualFile jar : jars) { jarsSet.add(jar.getName()); // Find overlays VirtualFile overlay = jar.getChild("META-INF/resources"); if (overlay.exists()) { overlays.add(overlay); } // Find ServletContainerInitializer services VirtualFile sci = jar.getChild("META-INF/services/javax.servlet.ServletContainerInitializer"); if (sci.exists()) { scis.put(jar.getName(), sci); } } } if (!isComplete) { String base = unit.getName(); int pos = base.indexOf(':'); if (pos > 0) { base = base.substring(pos); } Iterator<String> attachementNames = unit.getAttachments().keySet().iterator(); HashSet<String> jarsWithoutFragmentsSet = new HashSet<String>(); jarsWithoutFragmentsSet.addAll(jarsSet); while (attachementNames.hasNext()) { String location = attachementNames.next(); Object attachement = unit.getAttachment(location); if (attachement != null && attachement instanceof WebFragmentMetaData) { if (!location.startsWith(WebFragmentMetaData.class.getName() + ":")) { // If there is only one fragment, it will also get mapped as this attachement continue; } String relativeLocation = "/" + location.substring(WebFragmentMetaData.class.getName().length() + 1); String jarName = null; if (relativeLocation.startsWith("/WEB-INF/lib/")) { jarName = relativeLocation.substring("/WEB-INF/lib/".length()); pos = jarName.indexOf('/'); if (pos > 0) jarName = jarName.substring(0, pos); } if (jarName == null) { continue; } fragmentFound = true; WebFragmentMetaData fragmentMetaData = (WebFragmentMetaData) attachement; webFragments.put(jarName, fragmentMetaData); WebOrdering webOrdering = new WebOrdering(); webOrdering.setName(fragmentMetaData.getName()); webOrdering.setJar(jarName); jarsWithoutFragmentsSet.remove(jarName); if (fragmentMetaData.getOrdering() != null) { if (fragmentMetaData.getOrdering().getAfter() != null) { for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getAfter().getOrdering()) { if (orderingElementMetaData.isOthers()) { webOrdering.setAfterOthers(true); } else { webOrdering.addAfter(orderingElementMetaData.getName()); } } } if (fragmentMetaData.getOrdering().getBefore() != null) { for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getBefore().getOrdering()) { if (orderingElementMetaData.isOthers()) { webOrdering.setBeforeOthers(true); } else { webOrdering.addBefore(orderingElementMetaData.getName()); } } } } orderings.add(webOrdering); } } // If there is no fragment, still consider it for ordering as a // fragment specifying no name and no order for (String jarName : jarsWithoutFragmentsSet) { WebOrdering ordering = new WebOrdering(); ordering.setJar(jarName); orderings.add(ordering); } } } if (!fragmentFound) { // Drop the order as there is no fragment in the webapp orderings.clear(); } // Generate web fragments parsing order AbsoluteOrderingMetaData absoluteOrderingMetaData = null; if (!isComplete && specMetaData instanceof Web30MetaData) { absoluteOrderingMetaData = ((Web30MetaData) specMetaData).getAbsoluteOrdering(); } if (absoluteOrderingMetaData != null) { // Absolute ordering from web.xml, any relative fragment ordering is ignored int otherPos = -1; int i = 0; for (OrderingElementMetaData orderingElementMetaData : absoluteOrderingMetaData.getOrdering()) { if (orderingElementMetaData.isOthers()) { if (otherPos >= 0) { throw new DeploymentException("Duplicate others in absolute ordering"); } otherPos = i; } else { for (WebOrdering ordering : orderings) { if (orderingElementMetaData.getName().equals(ordering.getName())) { order.add(ordering.getJar()); jarsSet.remove(ordering.getJar()); break; } } } i++; } if (otherPos >= 0) { order.addAll(otherPos, jarsSet); jarsSet.clear(); } } else if (orderings.size() > 0) { // Resolve relative ordering try { resolveOrder(orderings, order); } catch (IllegalStateException e) { DeploymentException.rethrowAsDeploymentException("Invalid ordering", e); } jarsSet.clear(); } else { // No order specified order.addAll(jarsSet); jarsSet.clear(); unit.addAttachment(WEB_NOORDER_ATTACHMENT_NAME, Boolean.TRUE); } if (log.isDebugEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("Resolved order: [ "); for (String jar : order) { builder.append(jar).append(' '); } builder.append(']'); log.debug(builder.toString()); } unit.addAttachment(WEB_ORDER_ATTACHMENT_NAME, order); unit.addAttachment(WEB_OVERLAYS_ATTACHMENT_NAME, overlays); unit.addAttachment(WEB_SCIS_ATTACHMENT_NAME, scis); // The fragments and corresponding annotations will need to be merged in order // For each JAR in the order: // - Merge the annotation metadata into the fragment meta data // (unless the fragment exists and is meta data complete) // - Merge the fragment metadata into merged fragment meta data WebCommonMetaData mergedFragmentMetaData = new WebCommonMetaData(); if (specMetaData == null) { // If there is no web.xml, it has to be considered to be the latest version specMetaData = new Web30MetaData(); specMetaData.setVersion("3.0"); } String key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":classes"; // Augment with meta data from annotations in /WEB-INF/classes WebMetaData classesAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if (classesAnnotatedMetaData != null) { if (isComplete) { // Discard @WebFilter, @WebListener and @WebServlet classesAnnotatedMetaData.setFilters(null); classesAnnotatedMetaData.setFilterMappings(null); classesAnnotatedMetaData.setListeners(null); classesAnnotatedMetaData.setServlets(null); classesAnnotatedMetaData.setServletMappings(null); } specMetaData.augment(classesAnnotatedMetaData, null, true); } // Augment with meta data from fragments and annotations from the corresponding JAR for (String jar : order) { WebFragmentMetaData webFragmentMetaData = webFragments.get(jar); if (webFragmentMetaData == null) { webFragmentMetaData = new WebFragmentMetaData(); // Add non overriding default distributable flag webFragmentMetaData.setDistributable(new EmptyMetaData()); } key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":" + jar; WebMetaData jarAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if ((isComplete || webFragmentMetaData.isMetadataComplete()) && jarAnnotatedMetaData != null) { // Discard @WebFilter, @WebListener and @WebServlet jarAnnotatedMetaData.setFilters(null); jarAnnotatedMetaData.setFilterMappings(null); jarAnnotatedMetaData.setListeners(null); jarAnnotatedMetaData.setServlets(null); jarAnnotatedMetaData.setServletMappings(null); } if (jarAnnotatedMetaData != null) { // Merge annotations corresponding to the JAR webFragmentMetaData.augment(jarAnnotatedMetaData, null, true); } // Merge fragment meta data according to the conflict rules try { mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); } } // Augment with meta data from annotations from JARs excluded from the order for (String jar : jarsSet) { WebFragmentMetaData webFragmentMetaData = new WebFragmentMetaData(); // Add non overriding default distributable flag webFragmentMetaData.setDistributable(new EmptyMetaData()); key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":" + jar; WebMetaData jarAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if (jarAnnotatedMetaData != null) { // Discard @WebFilter, @WebListener and @WebServlet jarAnnotatedMetaData.setFilters(null); jarAnnotatedMetaData.setFilterMappings(null); jarAnnotatedMetaData.setListeners(null); jarAnnotatedMetaData.setServlets(null); jarAnnotatedMetaData.setServletMappings(null); } if (jarAnnotatedMetaData != null) { // Merge annotations corresponding to the JAR webFragmentMetaData.augment(jarAnnotatedMetaData, null, true); } // Merge fragment meta data according to the conflict rules try { mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); } } specMetaData.augment(mergedFragmentMetaData, null, true); // Override with meta data (JBossWebMetaData) // Create a merged view JBossWebMetaData mergedMetaData = new JBossWebMetaData(); mergedMetaData.merge(metaData, specMetaData); // Incorporate any ear level overrides DeploymentUnit topUnit = unit.getTopLevel(); if(topUnit != null && topUnit.getAttachment(JBossAppMetaData.class) != null) { JBossAppMetaData earMetaData = topUnit.getAttachment(JBossAppMetaData.class); // Security domain String securityDomain = earMetaData.getSecurityDomain(); if(securityDomain != null && mergedMetaData.getSecurityDomain() == null) mergedMetaData.setSecurityDomain(securityDomain); //Security Roles SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles(); if(earSecurityRolesMetaData != null) { SecurityRolesMetaData mergedSecurityRolesMetaData = mergedMetaData.getSecurityRoles(); if(mergedSecurityRolesMetaData == null) mergedMetaData.setSecurityRoles(earSecurityRolesMetaData); //perform a merge to rebuild the principalVersusRolesMap if(mergedSecurityRolesMetaData != null ) { mergedSecurityRolesMetaData.merge(mergedSecurityRolesMetaData, earSecurityRolesMetaData); } } } // Output the merged JBossWebMetaData unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, mergedMetaData); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void initInterceptorClasses() throws Exception { HashMap interceptors = new HashMap(); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element clientInterceptors = MetaData.getOptionalChild( proxyConfig, "client-interceptors", null ); if(clientInterceptors != null) { String value = MetaData.getElementAttribute(clientInterceptors, "exposeContainer"); this.includeIClientIface = Boolean.valueOf(value).booleanValue(); NodeList children = clientInterceptors.getChildNodes(); for(int i = 0; i < children.getLength(); i++) { Node currentChild = children.item(i); if(currentChild.getNodeType() == Node.ELEMENT_NODE) { Element interceptor = (Element) children.item(i); interceptors.put(interceptor.getTagName(), interceptor); } } } else { log.debug("client interceptors element is null"); } Element homeInterceptorConf = (Element) interceptors.get(HOME_INTERCEPTOR); loadInterceptorClasses(homeInterceptorClasses, homeInterceptorConf); if(homeInterceptorClasses.size() == 0) { throw new DeploymentException("There are no home interface interceptors configured"); } Element beanInterceptorConf = (Element) interceptors.get(BEAN_INTERCEPTOR); loadInterceptorClasses(beanInterceptorClasses, beanInterceptorConf); if(beanInterceptorClasses.size() == 0) { throw new DeploymentException("There are no bean interface interceptors configured"); } Element listEntityInterceptorConf = (Element) interceptors.get(LIST_ENTITY_INTERCEPTOR); loadInterceptorClasses(listEntityInterceptorClasses, listEntityInterceptorConf); }
122
              
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create EJB module " + unit.getName() + ": malformed EjbModule name", e); }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(NamingException e) { throw new DeploymentException("Filed to lookup: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to register table cache for " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/EJBQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
catch(FinderException e) { throw new DeploymentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JBossQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "alias-max-length " + aliasMaxLengthString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Failed to parse int value '" + str + "' for max-keys-in-delete", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCApplicationMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("Unable to load persistence manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCReadAheadMetaData.java
catch(NumberFormatException ex) { throw new DeploymentException("Invalid number format in read-ahead page-size '" + pageSizeStr + "': " + ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("entity class not found for ejb-name: " + entityName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "could not load primary key class: " + entity.getPrimaryKeyClass() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("home class not found: " + home); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "remote class not found: " + entity.getRemote() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local home class not found: " + localHome ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local class not found: " + entity.getLocal() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in read-" + "ahead list-cache-max '" + listCacheMaxStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "fetch-size '" + fetchSizeStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("could not load the class for " + " unknown primary key: " + unknownPkClass); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find getter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find setter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValueClassMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("dependent-value-class not found: " + className); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCJBossQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL " + "statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(NoSuchFieldException e) { // Non recoverable internal exception throw new DeploymentException("No field named '" + getFieldName() + "' found in entity class."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); }
// in src/main/java/org/jboss/web/deployers/WebModule.java
catch (Exception e) { throw new DeploymentException("Error during stop", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw new DeploymentException("Failed to create web module", e); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); }
307
              
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public static Document getDocument(URL url) throws DeploymentException { return getDocument(url, defaultValidateDTDs); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public static Document getDocument(URL url, boolean validateDTDs) throws DeploymentException { XmlFileLoader loader = new XmlFileLoader(validateDTDs); return loader.getDocumentFromURL(url); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocumentFromURL(URL url) throws DeploymentException { InputStream is = null; try { is = url.openStream(); return getDocument(is, url.toExternalForm()); } catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); } }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocument(InputStream is, String inPath) throws DeploymentException { InputSource is2 = new InputSource(is); is2.setSystemId(inPath); Document doc = null; try { doc = getDocument(is2, inPath); } finally { // close the InputStream to get around "too many open files" errors // with large heaps try { if( is != null ) is.close(); } catch (Exception e) { // ignore } } return doc; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocument(InputSource is, String inPath) throws DeploymentException { try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); // Enable DTD validation based on our validateDTDs flag docBuilderFactory.setValidating(validateDTDs); // make the parser namespace-aware in case we deal // with ejb2.1 descriptors, will not break dtd parsing in any way // in which case there would be just a default namespace docBuilderFactory.setNamespaceAware(true); // this will (along JAXP in conjunction with // validation+namespace-awareness) enable xml schema checking. // Will currently fail because some J2EE1.4/W3C schemas // are still lacking. //docBuilderFactory.setAttribute // ("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema"); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); JBossEntityResolver lr = new JBossEntityResolver(); LocalErrorHandler eh = new LocalErrorHandler( inPath, lr ); docBuilder.setEntityResolver(lr); docBuilder.setErrorHandler(eh ); Document doc = docBuilder.parse(is); if(validateDTDs && eh.hadError()) { throw new DeploymentException("Invalid XML: file=" + inPath, eh.getException()); } return doc; } catch (DeploymentException e) { throw e; } catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); } catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); } catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); } }
// in src/main/java/org/jboss/deployment/J2eeModuleMetaData.java
public void importXml(Element rootElement) throws DeploymentException { String rootTag = rootElement.getOwnerDocument().getDocumentElement().getTagName(); if (rootTag.equals("application")) importXml(rootElement, false); else if (rootTag.equals("jboss-app")) importXml(rootElement, true); else throw new DeploymentException("Unrecognized root tag: " + rootTag); }
// in src/main/java/org/jboss/deployment/J2eeModuleMetaData.java
protected void importXml(Element element, boolean jbossSpecific) throws DeploymentException { String name = element.getTagName(); if (name.equals("module")) { boolean done = false; // only one of the tags can hit! for (int i = 0; done == false && i < tags.length; ++i) { Element child = getOptionalChild(element, tags[i]); if (child == null) { continue; } type = i; switch (type) { case SERVICE: if (jbossSpecific == false) { throw new DeploymentException("Service archives must be in jboss-app.xml"); } // end of if () //fall through. case HAR: if (jbossSpecific == false) { throw new DeploymentException("Hibernate archives must be in jboss-app.xml"); } case EJB: case CLIENT: case CONNECTOR: fileName = getElementContent(child); alternativeDD = getElementContent(getOptionalChild(element, "alt-dd")); break; case WEB: fileName = getElementContent(getUniqueChild(child, "web-uri")); webContext = getElementContent(getOptionalChild(child, "context-root")); alternativeDD = getElementContent(getOptionalChild(element, "alt-dd")); break; } done = true; } // If the module content is not recognized throw an exception if (done == false) { StringBuffer msg = new StringBuffer("Invalid module content, must be one of: "); for (int i = 0; i < tags.length; i ++) { msg.append(tags[i]); msg.append(", "); } throw new DeploymentException(msg.toString()); } } else { throw new DeploymentException("non-module tag in application dd: " + name); } }
// in src/main/java/org/jboss/deployment/EarClassLoaderDeployer.java
Override public void deploy(DeploymentUnit unit, JBossAppMetaData metaData) throws DeploymentException { ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class); if (classLoadingMetaData != null) return; LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository(); if (lrmd != null && LoaderRepositoryMetaDataHelper.create(unit, lrmd) != null) return; // For isolated automatically create the classloader in a new domain if (isolated) { String domain = null; // let's first try CLDomainMD ClassLoadingDomainMetaData cldmd = unit.getAttachment(ClassLoadingDomainMetaData.class); if (cldmd != null) { String name = cldmd.getName(); if (name == null || "<unknown>".equals(name)) domain = unit.getName(); else domain = name; } if (domain == null) { domain = EARDeployment.getJMXName(metaData, unit) + ",extension=LoaderRepository"; try { ObjectName canonical = ObjectName.getInstance(domain); domain = canonical.getCanonicalName(); } catch (MalformedObjectNameException ignored) { // Not a JMX ObjectName??? } } classLoadingMetaData = new ClassLoadingMetaData(); classLoadingMetaData.setName(unit.getName()); classLoadingMetaData.setDomain(domain); classLoadingMetaData.setExportAll(ExportAll.NON_EMPTY); classLoadingMetaData.setImportAll(true); classLoadingMetaData.setVersion(Version.DEFAULT_VERSION); classLoadingMetaData.setJ2seClassLoadingCompliance(false); unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData); } }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException { return create(unit, loaderMetaData, false); }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (unit == null) throw new IllegalArgumentException("Null unit"); ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class); if (clmd != null) return clmd; clmd = create(unit.getName(), loaderMetaData, parentDelegation); if (clmd != null) unit.addAttachment(ClassLoadingMetaData.class, clmd); return clmd; }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException { return create(deploymentName, loaderMetaData, false); }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (deploymentName == null) throw new IllegalArgumentException("Null deployment name"); if (loaderMetaData == null) throw new IllegalArgumentException("Null loader repository metadata"); LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig(); repositoryConfig.repositoryClassName = loaderMetaData.getLoaderRepositoryClass(); if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0) repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS; // Get the object name of the repository String name = loaderMetaData.getName(); if (name != null) { try { repositoryConfig.repositoryName = new ObjectName(name.trim()); } catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); } } StringBuilder configData = new StringBuilder(); Set<LoaderRepositoryConfigMetaData> children = loaderMetaData.getLoaderRepositoryConfig(); if (children != null) { for (LoaderRepositoryConfigMetaData child : children) { // This looks stupid? Why inside a loop? String parserClassName = child.getConfigParserClass(); if (parserClassName == null || parserClassName.length() == 0) repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS; else repositoryConfig.configParserClassName = parserClassName; // Append all config String childConfig = child.getConfig(); if (childConfig != null) configData.append(childConfig); } } repositoryConfig.repositoryConfig = configData.toString().trim(); return LoaderRepositoryConfigHelper.create(name, repositoryConfig, parentDelegation); }
// in src/main/java/org/jboss/deployment/EARStructure.java
public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException { ContextInfo context; boolean valid; boolean trace = log.isTraceEnabled(); VirtualFile file = structureContext.getFile(); try { if (hasValidName(file) == false) return false; context = createContext(structureContext, "META-INF"); context.setComparatorClassName(comparatorClassName); VirtualFile applicationXml = getMetaDataFile(file, "META-INF/application.xml"); VirtualFile jbossAppXml = getMetaDataFile(file, "META-INF/jboss-app.xml"); VirtualFile lib; boolean scan = true; Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setValidation(useValidation); EarMetaData specMetaData = null; JBossAppMetaData appMetaData = null; if (applicationXml != null) { InputStream in = applicationXml.openStream(); try { specMetaData = (EarMetaData) unmarshaller.unmarshal(in, resolver); } finally { in.close(); } scan = false; } if (jbossAppXml != null) { InputStream in = jbossAppXml.openStream(); try { appMetaData = (JBossAppMetaData) unmarshaller.unmarshal(in, resolver); } finally { in.close(); } } // Need a metadata instance and there will not be one if there are no descriptors if (appMetaData == null) { appMetaData = new JBossAppMetaData(); } // Create the merged view appMetaData.merge(appMetaData, specMetaData); String libDir = appMetaData.getLibraryDirectory(); if (libDir == null || libDir.length() > 0) { if (libDir == null) libDir = "lib"; // Add the ear lib contents to the classpath if(trace) log.trace("Checking for ear lib directory: "+libDir); try { lib = file.getChild(libDir); if (lib.exists()) { if(trace) log.trace("Found ear lib directory: "+lib); List<VirtualFile> archives = lib.getChildren(earLibFilter); for (VirtualFile archive : archives) { Automounter.mount(file, archive); addClassPath(structureContext, archive, true, true, context); // add any jars with persistence.xml as a deployment VirtualFile child = archive.getChild("META-INF/persistence.xml"); if (child.exists()) { log.trace(archive.getName() + " in ear lib directory has persistence units"); addMetaDataPath(structureContext, context, child.getParent().getPathNameRelativeTo(file), MetaDataType.ALTERNATIVE); } else if (trace) log.trace(archive.getPathName() + " does not contain META-INF/persistence.xml"); } } else if (trace) log.trace("No lib directory in ear archive."); } catch (IOException e) { // TODO - should we throw this fwd? log.warn("Exception while searching for lib dir: " + e); } } else if (trace) { log.trace("Ignoring library directory, got empty library-directory element."); } // Add the ear manifest locations? addClassPath(structureContext, file, includeEarRootInClasspath, true, context); // TODO: need to scan for annotationss if( scan ) { scanEar(file, appMetaData); } // Create subdeployments for the ear modules ModulesMetaData modules = appMetaData.getModules(); if(modules != null) { for (ModuleMetaData mod : modules) { String fileName = mod.getFileName(); if (fileName != null && (fileName = fileName.trim()).length() > 0) { if (log.isTraceEnabled()) log.trace("Checking application.xml module: " + fileName); VirtualFile module = file.getChild(fileName); if (module.exists() == false) { throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + file.toURI()); } // Ask the deployers to analyze this if(structureContext.determineChildStructure(module) == false) { throw new RuntimeException(fileName + " module listed in application.xml is not a recognized deployment, .ear: " + file.getName()); } } } if (appMetaData.getModuleOrderEnum() == ModuleOrder.STRICT || (specMetaData instanceof Ear6xMetaData && ((Ear6xMetaData)specMetaData).getInitializeInOrder())) { context.setComparatorClassName(RelativeDeploymentContextComparator.class.getName()); int i = 0; for (ContextInfo ctx : structureContext.getMetaData().getContexts()) { ctx.setRelativeOrder(i++); } } } valid = true; } catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); } return valid; }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
protected void createMetaData(DeploymentUnit unit, Set<String> names, String suffix, String key) throws DeploymentException { // First see whether it already exists WebFragmentMetaData result = getMetaData(unit, key); if (result != null && allowsReparse() == false) return; // Create it try { result = parse(unit, getName(), suffix, result); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e); } // Doesn't exist if (result == null) return; // Register it unit.getTransientManagedObjects().addAttachment(key, result, getOutput()); }
// in src/main/java/org/jboss/deployment/ResourcesIndexDeployer.java
public void deploy(DeploymentUnit unit, JBossWebMetaData deployment) throws DeploymentException { AnnotationIndex ai = unit.getAttachment(AnnotationIndex.class); if (ai == null) return; HierarchyIndex hi = unit.getAttachment(HierarchyIndex.class); if (hi == null) return; ResourcesIndex ri = new DefaultResourcesIndex(ai, hi); unit.addAttachment(ResourcesIndex.class, ri); }
// in src/main/java/org/jboss/deployment/ResourceUtilSetupDeployer.java
Override public void deploy(DeploymentUnit unit, Module deployment) throws DeploymentException { unit.addAttachment(ReflectProvider.class, new CachingReflectProvider(provider)); // wrap with cache if (handler != null) unit.addAttachment(ErrorHandler.class, handler); if (finder != null) unit.addAttachment(ResourceOwnerFinder.class, finder); }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
Override protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException { super.createMetaData(unit, name, suffix); JBossMetaData jbossMetaData = unit.getAttachment(getOutput()); EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); if (ejbJarMetaData != null || jbossMetaData != null) { // Save this as a transient(non-managed) attachment // only for EJB2.x and earlier beans (since standardjboss.xml does not apply for EJB3.x and // later) if (this.isPreEJB3x(ejbJarMetaData, jbossMetaData)) { JBossMetaData stdMetaData = getStandardMetaData(); if(stdMetaData != null) unit.addAttachment("standardjboss.xml", stdMetaData); } if (jbossMetaData != null) { // For legacy - but its totally redundant???? ApplicationMetaData amd = new ApplicationMetaData(jbossMetaData); unit.addAttachment(ApplicationMetaData.class, amd); } } }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
private JBossMetaData getStandardMetaData() throws DeploymentException { if (standardMetaData == null) { try { if(standardJBossXmlPath == null) { // Use default server conf/standardjboss.xml location final String configPropName = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_CONF_URL; String configPath = System.getProperty(configPropName); if(configPath == null ) { if(ignoreMissingStandardJBossXml == false) throw new DeploymentException("standardjboss.xml not specified and "+configPropName+" does not exist"); return null; } URL configUrl = new URL(configPath); standardJBossXmlPath = new URL(configUrl, "standardjboss.xml"); } VirtualFile stdJBoss = VFS.getChild(standardJBossXmlPath); if (stdJBoss == null && ignoreMissingStandardJBossXml == false) { throw new DeploymentException("standardjboss.xml not found in config dir: " + standardJBossXmlPath); } standardMetaData = super.parse(stdJBoss); } catch (Exception ex) { DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex); } } return standardMetaData; }
// in src/main/java/org/jboss/deployment/ResourceUtilCleanupDeployer.java
public void deploy(DeploymentUnit unit, Module deployment) throws DeploymentException { ReflectProvider provider = unit.removeAttachment(ReflectProvider.class); if (provider != null && provider instanceof CachingReflectProvider) { CachingReflectProvider crp = (CachingReflectProvider)provider; crp.reset(); } }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
Override public void deploy(DeploymentUnit unit, JBossAppMetaData deployment) throws DeploymentException { //Perform JACC Policy Configuration String contextID = shortNameFromDeploymentName(unit.getSimpleName()); PolicyConfigurationFactory pcFactory = null; try { pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true); unit.addAttachment(PolicyConfiguration.class, pc); } catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); } catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); } }
// in src/main/java/org/jboss/deployment/ReferenceMetaDataResolverDeployer.java
public void internalDeploy(DeploymentUnit unit) throws DeploymentException { JBossMetaData ejbMetaData = unit.getAttachment(JBossMetaData.class); JBossWebMetaData webMetaData = unit.getAttachment(JBossWebMetaData.class); JBossClientMetaData clientMetaData = unit.getAttachment(JBossClientMetaData.class); if(ejbMetaData == null && webMetaData == null && clientMetaData == null) return; // Create a map of the ejbs dump(unit); if(ejbMetaData != null) { JBossEnterpriseBeansMetaData beans = ejbMetaData.getEnterpriseBeans(); // Map the ejbs this.mapEjbs(unit.getRelativePath(), beans); // Process ejb references List<String> unresolvedPaths = resolve(unit, beans); if(unresolvedPaths != null && unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossMetaData: "+unresolvedPaths); } if(webMetaData != null) { // Process web app references List<String> unresolvedPaths = new ArrayList<String>(); resolve(unit, webMetaData.getJndiEnvironmentRefsGroup(), unresolvedPaths); if(unresolvedPaths != null && unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossWebMetaData: "+unresolvedPaths); } if(clientMetaData != null) { // Process client app references List<String> unresolvedPaths = new ArrayList<String>(); resolve(unit, clientMetaData.getJndiEnvironmentRefsGroup(), unresolvedPaths); if(unresolvedPaths != null && unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossClientMetaData: "+unresolvedPaths); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
public void internalDeploy(DeploymentUnit unit) throws DeploymentException { JBossMetaData ejbMetaData = unit.getAttachment(JBossMetaData.class); JBossWebMetaData webMetaData = unit.getAttachment(JBossWebMetaData.class); JBossClientMetaData clientMetaData = unit.getAttachment(JBossClientMetaData.class); if(ejbMetaData == null && webMetaData == null && clientMetaData == null) return; // Create a map of the reference endpoints if it does not exist in the top unit DeploymentUnit top = unit.getTopLevel(); Map<String, ContainerDependencyMetaData> endpointMap = top.getAttachment(ENDPOINT_MAP_KEY, Map.class); Map<String, String> endpointAlternateMap = top.getAttachment(ALTERNATE_MAP_KEY, Map.class); if(endpointMap == null) { endpointMap = new ConcurrentHashMap<String, ContainerDependencyMetaData>(); endpointAlternateMap = new ConcurrentHashMap<String, String>(); mapEndpoints(top, endpointMap, endpointAlternateMap); top.addAttachment(ENDPOINT_MAP_KEY, endpointMap, Map.class); top.addAttachment(ALTERNATE_MAP_KEY, endpointAlternateMap); DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver(endpointMap, endpointAlternateMap, unit.getRelativePath()); top.addAttachment(DeploymentEndpointResolver.class, resolver); } DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver( endpointMap, endpointAlternateMap, unit.getRelativePath()); List<String> unresolvedPaths = new ArrayList<String>(); if(ejbMetaData != null) { JBossEnterpriseBeansMetaData beans = ejbMetaData.getEnterpriseBeans(); // Process ejb references try { resolve(unit, endpointMap, beans, resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossMetaData:"+unresolvedPaths); } if(webMetaData != null) { // Process web app references ContainerDependencyMetaData webAppCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "web-app", unit.getRelativePath()); try { resolve(webAppCDMD, unit, endpointMap, webMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossWebMetaData:"+unresolvedPaths); } if(clientMetaData != null) { // Process client app references ContainerDependencyMetaData clientCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "client", unit.getRelativePath()); try { resolve(clientCDMD, unit, endpointMap, clientMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossClientMetaData: "+unresolvedPaths); } // Add the unique set of ContainerDependencyMetaData Set<ContainerDependencyMetaData> depends = new HashSet<ContainerDependencyMetaData>(); for(ContainerDependencyMetaData cdmd : endpointMap.values()) { depends.add(cdmd); } top.addAttachment(DEPENDS_SET_KEY, depends, Set.class); unit.addAttachment(DeploymentEndpointResolver.class, resolver); dump(unit); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { /* If there is a META-INF/application.xml we don't process this. */ if (unit.isAttachmentPresent(EarMetaData.class)) { log.tracef("Ignoring ear with META-INF/application.xml: %1s", unit.getSimpleName()); return; } // Ignore non-vfs deployments if (unit instanceof VFSDeploymentUnit == false) { log.tracef("Not a vfs deployment: %1s", unit.getName()); return; } // See if the suffix matches the .ear requirement if (requiresEarSuffix && unit.getSimpleName().endsWith(".ear") == false) { log.tracef("Unit name does not end in .ear: %1s", unit.getSimpleName()); return; } VFSDeploymentUnit vfsunit = VFSDeploymentUnit.class.cast(unit); deploy(vfsunit); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
public void deploy(VFSDeploymentUnit unit) throws DeploymentException { VirtualFile root = unit.getRoot(); String relativePath = unit.getRelativePath(); VirtualFile ear = unit.getFile(relativePath); if (ear == null) throw new DeploymentException("No such ear file, relative path: '" + relativePath + "', root: " + root); deploy(unit, root, ear); }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { PolicyConfiguration pc = unit.getAttachment(PolicyConfiguration.class); if (pc == null) return; DeploymentUnit parent = unit.getParent(); if (parent == null) throw new IllegalStateException("Unit has not parent: " + unit); PolicyConfiguration parentPc = parent.getAttachment(PolicyConfiguration.class); try { if (parentPc != null && pc != parentPc) { parentPc.linkConfiguration(pc); } pc.commit(); } catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); } }
// in src/main/java/org/jboss/deployment/PUHackDeployer.java
Override public void deploy(DeploymentUnit unit, PersistenceUnitMetaData deployment) throws DeploymentException { DeploymentUnit wrapper = wrap(unit); delegate.deploy(wrapper, deployment); }
// in src/main/java/org/jboss/deployment/PUHackDeployer.java
public boolean createClassLoader(ClassLoaderFactory factory) throws DeploymentException { return delegate.createClassLoader(factory); }
// in src/main/java/org/jboss/deployment/PUHackDeployer.java
public void visit(DeploymentUnitVisitor visitor) throws DeploymentException { delegate.visit(visitor); }
// in src/main/java/org/jboss/deployment/JBossAppParsingDeployer.java
Override protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException { EarMetaData specMetaData = unit.getAttachment(EarMetaData.class); JBossAppMetaData metaData = unit.getAttachment(JBossAppMetaData.class); // from ear contents deployer // do parse super.createMetaData(unit, name, suffix); // new parsed metadata JBossAppMetaData parsed = unit.getAttachment(JBossAppMetaData.class); if (metaData != null && parsed != null) { ModulesMetaData mmd = metaData.getModules(); if (mmd != null && mmd.isEmpty() == false) { ModulesMetaData parsedMMD = parsed.getModules(); if (parsedMMD == null) { parsedMMD = new ModulesMetaData(); parsed.setModules(parsedMMD); } parsedMMD.merge(parsedMMD, mmd); } } // parsed is the one we use after merged modules metaData = parsed; if(specMetaData == null && metaData == null) return; // If there no JBossMetaData was created from a jboss-app.xml, create one if (metaData == null) metaData = new JBossAppMetaData(); // Create a merged view JBossAppMetaData mergedMetaData = new JBossAppMetaData(); mergedMetaData.merge(metaData, specMetaData); // Set the merged as the output unit.getTransientManagedObjects().addAttachment(JBossAppMetaData.class, mergedMetaData); // Keep the raw parsed metadata as well unit.addAttachment("Raw"+JBossAppMetaData.class.getName(), metaData, JBossAppMetaData.class); // Pass the ear callByValue setting if (isCallByValue()) unit.addAttachment("EAR.callByValue", Boolean.TRUE, Boolean.class); //Pass the unauthenticated identity if (this.unauthenticatedIdentity != null) unit.addAttachment("EAR.unauthenticatedIdentity", this.unauthenticatedIdentity, String.class); }
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
Override protected <U> void deploy(DeploymentUnit unit, DeploymentVisitor<U> visitor) throws DeploymentException { U deployment = unit.getAttachment(attachmentName, visitor.getVisitorType()); try { visitor.deploy(unit, deployment); } catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); } }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (unit instanceof VFSDeploymentUnit == false) return; VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; deploy(vfsDeploymentUnit); }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
protected void deploy(VFSDeploymentUnit unit) throws DeploymentException { /* Ignore any spec metadata complete deployments. This expects that a deployment unit only represents one of the client, ejb or web deployments and its metadata completeness applies to the unit in terms of whether annotations should be scanned for. */ boolean isComplete = this.isMetaDataCompleteIsDefault(); EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); if(ejbJarMetaData != null && ejbJarMetaData instanceof EjbJar3xMetaData) { isComplete |= ((EjbJar3xMetaData) ejbJarMetaData).isMetadataComplete(); } else if(ejbJarMetaData != null) { // Any ejb-jar.xml 2.1 or earlier deployment is metadata complete isComplete = true; } WebMetaData webMetaData = unit.getAttachment(WebMetaData.class); if(webMetaData != null) { if (webMetaData instanceof Web25MetaData) { isComplete |= ((Web25MetaData)webMetaData).isMetadataComplete(); } else if (webMetaData instanceof Web30MetaData) { isComplete |= ((Web30MetaData)webMetaData).isMetadataComplete(); } else { // Any web.xml 2.4 or earlier deployment is metadata complete isComplete = true; } } ApplicationClientMetaData clientMetaData = unit.getAttachment(ApplicationClientMetaData.class); if(clientMetaData != null) isComplete |= clientMetaData.isMetadataComplete(); // OSGi bundle deployments are metadata-complete // [TODO] Replace with a check for OSGiMetaData once this becomes generally available in AS String symbolicName = (String) unit.getAttachment("org.jboss.osgi.bundle.symbolic.name"); isComplete |= (symbolicName != null); if(isComplete) { log.debug("Deployment is metadata-complete, skipping annotation processing" + ", ejbJarMetaData="+ejbJarMetaData + ", jbossWebMetaData="+webMetaData + ", jbossClientMetaData="+clientMetaData + ", bundleSymbolicName="+symbolicName + ", metaDataCompleteIsDefault="+metaDataCompleteIsDefault ); return; } VirtualFile root = unit.getRoot(); if(root.isLeaf()) return; List<VirtualFile> classpath = unit.getClassPath(); if(classpath == null || classpath.isEmpty()) return; if (log.isTraceEnabled()) log.trace("Deploying annotations for unit: " + unit + ", classpath: " + classpath); try { processMetaData(unit, webMetaData, clientMetaData, classpath); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); } }
// in src/main/java/org/jboss/deployment/LegacyWebXmlLessDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (unit.getSimpleName().endsWith(".war")) { if (unit.isAttachmentPresent(JBossWebMetaData.class)) return; // only care about true deployments if (unit instanceof VFSDeploymentUnit == false) return; // Detect and ignore OSGi WAR deployments // FIXME Use typed OSGiMetaData when we have it available at runtime String bundleSymbolicName = unit.getAttachment("org.jboss.osgi.bundle.symbolic.name", String.class); if (bundleSymbolicName != null) { log.debug("Ignore OSGi webapp: " + bundleSymbolicName); return; } log.debug("Web archive doesn't contain web.xml: " + unit.getName()); unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, new JBossWebMetaData()); } }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { boolean accepted = false; for (String accept : acceptedAttachments) { if (unit.isAttachmentPresent(accept)) { accepted = true; break; } } if (accepted == false) return; String contextID = unit.getName(); PolicyConfiguration pc = null; try { PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); pc = pcFactory.getPolicyConfiguration(contextID, true); } catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); } unit.addAttachment(PolicyConfiguration.class, pc); }
// in src/main/java/org/jboss/deployment/ModuleNameDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { // Find all the metadata types assoc w/ unit that specify a moduleName List<NamedModule> metadatas = null; for (Class<? extends NamedModule> type : inputTypes) { NamedModule nm = unit.getAttachment(type); if (nm != null) { if (metadatas == null) { metadatas = new ArrayList<NamedModule>(); } metadatas.add(nm); } } if (metadatas == null) { return; } String moduleName = null; // See if any of the existing metadata specifies a module name for (NamedModule nm : metadatas) { moduleName = nm.getModuleName(); if (moduleName != null) { break; } } // Enforce EAR rules from EE 6 EE.8.1.1 JBossAppMetaData appMetaData = null; DeploymentUnit parent = unit.getParent(); if (parent != null) { appMetaData = parent.getAttachment(JBossAppMetaData.class); } if (appMetaData != null) { moduleName = establishUniqueModuleName(unit, moduleName, appMetaData); } else if (moduleName == null) { // Not in an EAR and no name was configured. // Create a default module name as per EE 6 EE.8.1.2: // "when a stand-alone module is deployed.... [t]he module name can be // explicitly set in the module deployment descriptor. If not set, the // name of the module is the base name of the module file with any // extension (.war, .jar, .rar) removed and with any directory names removed." moduleName = trimExtension(unit.getSimpleName()); } // Apply the name to all metadata for (NamedModule nm : metadatas) { nm.setModuleName(moduleName); } // Let other deployers get the module name w/o having to search // for all the possible metadata types unit.addAttachment(NamedModule.class, metadatas.get(0)); }
// in src/main/java/org/jboss/deployment/ModuleNameDeployer.java
private String establishUniqueModuleName(DeploymentUnit unit, String configuredName, JBossAppMetaData appMetaData) throws DeploymentException { String name = configuredName == null ? trimExtension(unit.getRelativePath()): configuredName; String modulePath = unit.getRelativePath(); ModulesMetaData modules = appMetaData.getModules(); if (modules == null) { throw new DeploymentException(unit + " has attached " + JBossAppMetaData.class.getSimpleName() + " but it has no associated " + ModulesMetaData.class.getSimpleName()); } ModuleMetaData ourModule = null; String uniqueName = null; // Synchronize on the modules to ensure concurrent deployments of the // modules pass serially through this logic synchronized(modules) { ourModule = modules.get(modulePath); if (ourModule == null) { String parentUnitName = unit.getParent().getName(); throw new DeploymentException("No module with relative path " + modulePath + " found in set of modules for " + parentUnitName + " " + modules.keySet()); } uniqueName = name; if (!isNameUnique(uniqueName, ourModule, modules)) { // Try the relative path w/ extension removed uniqueName = trimExtension(unit.getRelativePath()); if (uniqueName.equals(name) || !isNameUnique(uniqueName, ourModule, modules)) { // Try leaving the extension uniqueName = unit.getRelativePath(); if (!isNameUnique(uniqueName, ourModule, modules)) { // To get here, people would have to configure in xml a // module name that conflicts with the relative path of // another module. Not likely, but... // Append a digit until the name is unique int i = 0; do { i++; uniqueName = name + "-" + i; } while (!isNameUnique(uniqueName, ourModule, modules)); } } } ourModule.setUniqueName(uniqueName); } // Log a WARN if we had to change the module name if (configuredName != null && !configuredName.equals(uniqueName)) { log.warn("Module name " + configuredName + " specified in deployment descriptor for " + unit + " was not unique within the application; using module name " + uniqueName + " instead"); } else if (!name.equals(uniqueName)) { log.warn("Module name " + name + " derived from the modules relative path in " + unit + " was not unique within the application; using module name " + uniqueName + " instead"); } return uniqueName; }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
public void deploy(VFSDeploymentUnit unit, JBossAppMetaData jBossAppMetaData) throws DeploymentException { try { VirtualFile root = unit.getRoot(); String libDir = jBossAppMetaData.getLibraryDirectory(); if (libDir == null || libDir.length() == 0) // take 'lib' even on empty libDir = "lib"; VirtualFile lib = root.getChild(libDir); if (lib != null) { ResourceFilter recurseFilter = new UrlExcludeResourceFilter(lib.toURL()); unit.addAttachment(ResourceFilter.class.getName() + ".recurse", recurseFilter, ResourceFilter.class); log.debug("Excluding ear's lib directory: " + lib); } } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e); } }
// in src/main/java/org/jboss/deployment/EjbClassLoaderDeployer.java
Override public void deploy(DeploymentUnit unit, JBossMetaData metaData) throws DeploymentException { ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class); if (classLoadingMetaData != null) return; LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository(); if (lrmd != null) LoaderRepositoryMetaDataHelper.create(unit, lrmd); }
// in src/main/java/org/jboss/deployment/JBossWebAppParsingDeployer.java
Override protected boolean accepts(final DeploymentUnit unit) throws DeploymentException { return unit.getSimpleName().endsWith(".war"); }
// in src/main/java/org/jboss/deployment/JBossWebAppParsingDeployer.java
Override protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException { super.createMetaData(unit, name, suffix); JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); // If there no JBossWebMetaData was created from a jboss-web.xml, create one if (metaData == null) { metaData = new JBossWebMetaData(); } unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, metaData); unit.addAttachment("Raw"+JBossWebMetaData.class.getName(), metaData, JBossWebMetaData.class); }
// in src/main/java/org/jboss/deployment/JBossWebAppParsingDeployer.java
Override protected void createMetaData(DeploymentUnit unit, String name, String suffix, String key) throws DeploymentException { super.createMetaData(unit, name, suffix, key); JBossWebMetaData result = unit.getTransientManagedObjects().getAttachment(getOutput()); if (result == null) { result = new JBossWebMetaData(); unit.getTransientManagedObjects().addAttachment(key, result, getOutput()); } }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { T metaData = unit.getAttachment(getMetaDataClassType()); if (metaData == null) return; String contextId = unit.getSimpleName(); // Is the war the top level deployment? // DeploymentUnit topUnit = unit.getTopLevel(); if (unit.getParent() == null || getParentJaccPolicyBean(unit) == null) { createTopLevelServiceBeanWithMetaData(contextId, unit, metaData); } else { ServiceMetaData subjaccPolicy = getServiceMetaData(); String deploymentName = unit.getSimpleName(); try { subjaccPolicy.setObjectName(new ObjectName(getObjectName(unit))); } catch (Exception e) { throw new RuntimeException(e); } // Provide a constructor for the service bean ServiceConstructorMetaData serviceConstructor = new ServiceConstructorMetaData(); serviceConstructor.setSignature(new String[]{String.class.getName(), getMetaDataClassType().getName()}); serviceConstructor.setParameters(new Object[]{deploymentName, metaData}); subjaccPolicy.setConstructor(serviceConstructor); ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>(); services.add(subjaccPolicy); unit.addAttachment(JACC_ATTACHMENT_NAME, subjaccPolicy, ServiceMetaData.class); // Add a dependence into the parent JaccPolicy ServiceMetaData parentServiceMetaData = this.getParentJaccPolicyBean(unit); if (parentServiceMetaData != null) { ServiceDependencyMetaData serviceDependencyMetaData = new ServiceDependencyMetaData(); serviceDependencyMetaData.setIDependOnObjectName(subjaccPolicy.getObjectName()); parentServiceMetaData.addDependency(serviceDependencyMetaData); // Add an attribute in the parent service ServiceAttributeMetaData serviceAttributeMetaData = new ServiceAttributeMetaData(); serviceAttributeMetaData.setName("PolicyConfigurationFacadeMBean"); ServiceDependencyValueMetaData dependencyValue = new ServiceDependencyValueMetaData(); dependencyValue.setDependency(subjaccPolicy.getObjectName().toString()); dependencyValue.setProxyType("attribute"); serviceAttributeMetaData.setValue(dependencyValue); parentServiceMetaData.addAttribute(serviceAttributeMetaData); } } /** Register XACML/ACL policies if present in the deployment */ if(this.policyRegistration != null) { String xacmlType = PolicyRegistration.XACML; JAXBElement<?> policyConfig = (JAXBElement<?>) unit.getAttachment(XACML_ATTACHMENT_NAME); if(policyConfig != null) this.policyRegistration.registerPolicyConfig(contextId, xacmlType, policyConfig); String aclType = PolicyRegistration.ACL; ACLConfiguration aclConfig = (ACLConfiguration) unit.getAttachment(ACLConfiguration.class.getName()); if(aclConfig != null) this.policyRegistration.registerPolicyConfig(contextId, aclType, aclConfig); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void addContainer(Container con) throws DeploymentException { String ejbName = con.getBeanMetaData().getEjbName(); if (containers.containsKey(ejbName)) throw new DeploymentException("Duplicate ejb-name. Container for " + ejbName + " already exists."); containers.put(ejbName, con); containerOrdering.add(con); con.setEjbModule(this); }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void initializeContainer(Container container, ConfigurationMetaData conf, BeanMetaData bean, int transType, DeploymentUnit unit) throws NamingException, DeploymentException { // Create local classloader for this container // For loading resources that must come from the local jar. Not for loading classes! // The VFS should be used for this // container.setLocalClassLoader(new URLClassLoader(new URL[0], localCl)); // Set metadata (do it *before* creating the container's WebClassLoader) container.setEjbModule(this); container.setBeanMetaData(bean); ClassLoader unitCl = unit.getClassLoader(); // Create the container's WebClassLoader // and register it with the web service. String webClassLoaderName = getWebClassLoader(conf, bean); log.debug("Creating WebClassLoader of class " + webClassLoaderName); WebClassLoader wcl = null; try { Class clazz = unitCl.loadClass(webClassLoaderName); wcl = WebClassLoaderFactory.createWebClassLoader(clazz, container.getJmxName(), (RealClassLoader) unitCl); } catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); } if (webServiceName != null) { WebServiceMBean webServer = (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName); URL[] codebase = {webServer.addClassLoader(wcl)}; wcl.setWebURLs(codebase); } // end of if () container.setWebClassLoader(wcl); // Create classloader for this container // Only used to unique the bean ENC and does not augment class loading container.setClassLoader(new DelegatingClassLoader(wcl)); // Set transaction manager InitialContext iniCtx = new InitialContext(); container.setTransactionManager(tmFactory.getTransactionManager()); // Set container.setTimerService(timerService); // Set security domain manager String securityDomain = bean.getApplicationMetaData().getSecurityDomain(); // JBAS-5960: Set default security domain if there is security metadata boolean hasSecurityMetaData = hasSecurityMetaData(bean); if (securityDomain == null && hasSecurityMetaData) { securityDomain = SecurityConstants.DEFAULT_EJB_APPLICATION_POLICY; } String confSecurityDomain = conf.getSecurityDomain(); // Default the config security to the application security manager if (confSecurityDomain == null) confSecurityDomain = securityDomain; // Check for an empty confSecurityDomain which signifies to disable security if (confSecurityDomain != null && confSecurityDomain.length() == 0) confSecurityDomain = null; if (confSecurityDomain != null) { // Either the application has a security domain or the container has security setup try { String unprefixed = SecurityUtil.unprefixSecurityDomain(confSecurityDomain); log.debug("Setting security domain from: " + confSecurityDomain); String domainCtx = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + unprefixed + "/domainContext"; SecurityDomainContext sdc = (SecurityDomainContext) iniCtx.lookup(domainCtx); Object securityMgr = sdc.getSecurityManager(); // Object securityMgr = iniCtx.lookup(confSecurityDomain); AuthenticationManager ejbS = (AuthenticationManager) securityMgr; RealmMapping rM = (RealmMapping) securityMgr; container.setSecurityManager(ejbS); container.setRealmMapping(rM); container.setSecurityManagement(securityManagement); container.setPolicyRegistration(policyRegistration); container.setDefaultSecurityDomain((String) unit.getAttachment("EJB.defaultSecurityDomain")); container.setSecurityContextClassName((String) unit.getAttachment("EJB.securityContextClassName")); } catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); } catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); } } else { if ("".equals(securityDomain) && hasSecurityMetaData) log.warn("EJB configured to bypass security. Please verify if this is intended. Bean=" + bean.getEjbName() + " Deployment=" + unit.getName()); } // Load the security proxy instance if one was configured String securityProxyClassName = bean.getSecurityProxy(); if (securityProxyClassName != null) { try { Class proxyClass = unitCl.loadClass(securityProxyClassName); Object proxy = proxyClass.newInstance(); container.setSecurityProxy(proxy); log.debug("setSecurityProxy, " + proxy); } catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); } } // Install the container interceptors based on the configuration addInterceptors(container, transType, conf.getContainerInterceptorsConf()); }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static String getWebClassLoader(ConfigurationMetaData conf, BeanMetaData bmd) throws DeploymentException { String webClassLoader = null; Iterator it = bmd.getInvokerBindings(); int count = 0; while (it.hasNext()) { String invoker = (String) it.next(); ApplicationMetaData amd = bmd.getApplicationMetaData(); InvokerProxyBindingMetaData imd = amd.getInvokerProxyBindingMetaDataByName(invoker); if (imd == null) { String msg = "Failed to find InvokerProxyBindingMetaData for: '" + invoker + "'. Check the invoker-proxy-binding-name to " + "invoker-proxy-binding/name mappings in jboss.xml"; throw new DeploymentException(msg); } Element proxyFactoryConfig = imd.getProxyFactoryConfig(); String webCL = MetaData.getOptionalChildContent(proxyFactoryConfig, "web-class-loader"); if (webCL != null) { log.debug("Invoker " + invoker + " specified WebClassLoader class" + webCL); webClassLoader = webCL; count++; } } if (count > 1) { log.warn(count + " invokers have WebClassLoader specifications."); log.warn("Using the last specification seen (" + webClassLoader + ")."); } else if (count == 0) { webClassLoader = conf.getWebClassLoader(); if (webClassLoader == null) webClassLoader = "org.jboss.web.WebClassLoader"; } return webClassLoader; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void addInterceptors(Container container, int transType, Element element) throws DeploymentException { // Get the interceptor stack(either jboss.xml or standardjboss.xml) Iterator interceptorElements = MetaData.getChildrenByTagName(element, "interceptor"); String transTypeString = stringTransactionValue(transType); ClassLoader loader = container.getClassLoader(); /* * First build the container interceptor stack from interceptorElements match transType values */ ArrayList istack = new ArrayList(); while (interceptorElements != null && interceptorElements.hasNext()) { Element ielement = (Element) interceptorElements.next(); /* * Check that the interceptor is configured for the transaction mode of the bean by comparing its 'transaction' * attribute to the string representation of transType */ String transAttr = ielement.getAttribute("transaction"); if (transAttr == null || transAttr.length() == 0) transAttr = ANY_VALUE; if (transAttr.equalsIgnoreCase(ANY_VALUE) || transAttr.equalsIgnoreCase(transTypeString)) { // The transaction type matches the container bean trans type String className = null; try { className = MetaData.getFirstElementContent(ielement, null); Class clazz = loader.loadClass(className); Interceptor interceptor = (Interceptor) clazz.newInstance(); if (interceptor instanceof XmlLoadable) { ((XmlLoadable) interceptor).importXml(ielement); } istack.add(interceptor); } catch (ClassNotFoundException e) { log.warn("Could not load the " + className + " interceptor", e); } catch (Exception e) { log.warn("Could not load the " + className + " interceptor for this container", e); } } } if (istack.size() == 0) log.warn("There are no interceptors configured. Check the standardjboss.xml file"); // Now add the interceptors to the container for (int i = 0; i < istack.size(); i++) { Interceptor interceptor = (Interceptor) istack.get(i); container.addInterceptor(interceptor); } /* * If there is a security proxy associated with the container add its interceptor just before the container * interceptor */ if (container.getSecurityProxy() != null) container.addInterceptor(new SecurityProxyInterceptor()); // Finally we add the last interceptor from the container container.addInterceptor(container.createContainerInterceptor()); }
// in src/main/java/org/jboss/ejb/deployers/SimpleCreateDestinationMatcher.java
public boolean isMatch(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException { if (noMatch(messageListener, mdb.getMessagingType(), isDefault())) return false; if (noMatch(rarName, mdb.getResourceAdapterName(), isDefault())) return false; return true; }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); JBossMetaData metaData = unit.getAttachment(JBossMetaData.class); // Check for an annotated view String key = AnnotationMetaDataDeployer.EJB_ANNOTATED_ATTACHMENT_NAME; JBossMetaData annotatedMetaData = unit.getAttachment(key, JBossMetaData.class); if(ejbJarMetaData == null && metaData == null && annotatedMetaData == null) return; JBossMetaData specMetaData = new JBoss50MetaData(); if(ejbJarMetaData != null) { specMetaData.merge(null, ejbJarMetaData); if(annotatedMetaData != null) { JBossMetaData specMerged = new JBoss50MetaData(); specMerged.merge(specMetaData, annotatedMetaData); specMetaData = specMerged; } } else specMetaData = annotatedMetaData; // Create a merged view JBossMetaData mergedMetaData = new JBossMetaData(); mergedMetaData.merge(metaData, specMetaData); // Incorporate any ear level overrides DeploymentUnit topUnit = unit.getTopLevel(); if(topUnit != null && topUnit.getAttachment(JBossAppMetaData.class) != null) { JBossAppMetaData earMetaData = topUnit.getAttachment(JBossAppMetaData.class); // Security domain String securityDomain = earMetaData.getSecurityDomain(); if(securityDomain != null && mergedMetaData.getSecurityDomain() == null) mergedMetaData.setSecurityDomain(securityDomain); //Security Roles SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles(); if(earSecurityRolesMetaData != null) { JBossAssemblyDescriptorMetaData jadmd = mergedMetaData.getAssemblyDescriptor(); if( jadmd == null) { jadmd = new JBossAssemblyDescriptorMetaData(); mergedMetaData.setAssemblyDescriptor(jadmd); } SecurityRolesMetaData mergedSecurityRolesMetaData = jadmd.getSecurityRoles(); if(mergedSecurityRolesMetaData == null) jadmd.setSecurityRoles(earSecurityRolesMetaData); //perform a merge to rebuild the principalVersusRolesMap if(mergedSecurityRolesMetaData != null ) { mergedSecurityRolesMetaData.merge(mergedSecurityRolesMetaData, earSecurityRolesMetaData); } } } // Create interceptors metadata by processing interceptor classes (from the merged // jboss metadata) Collection<String> interceptorClassNames = JBossMetaData.getAllInterceptorClasses(mergedMetaData); Collection<Class<?>> interceptorClasses = null; try { interceptorClasses = this.loadClasses(unit.getClassLoader(), interceptorClassNames); } catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); } // Process the interceptor classes AnnotationFinder<AnnotatedElement> annotationFinder = new DefaultAnnotationFinder<AnnotatedElement>(); InterceptorMetaDataCreator interceptorMetaDataCreator = new InterceptorMetaDataCreator(annotationFinder); // create interceptors metadata from the interceptor classes InterceptorsMetaData annotatedInterceptorsMetaData = interceptorMetaDataCreator.create(interceptorClasses); InterceptorsMetaData mergedInterceptorsMetaData = new InterceptorsMetaData(); // merge the interceptors metadata mergedInterceptorsMetaData.merge(mergedMetaData.getInterceptors(), annotatedInterceptorsMetaData); // now set the merged interceptors metadata into the merged jboss metadata mergedMetaData.setInterceptors(mergedInterceptorsMetaData); // Output the merged JBossMetaData unit.getTransientManagedObjects().addAttachment(JBossMetaData.class, mergedMetaData); unit.addAttachment(EJB_MERGED_ATTACHMENT_NAME, mergedMetaData, JBossMetaData.class); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
Override public void deploy(VFSDeploymentUnit unit, JBossMetaData deployment) throws DeploymentException { // If it is a deployment with ejbVersion unknown or 3 if (!deployment.isEJB2x() && !deployment.isEJB1x()) return; // let EJB3 deployer handle this ApplicationMetaData legacyMD = new ApplicationMetaData(deployment); if( verifyDeployments ) { // we have a positive attitude boolean allOK = true; // wrapping this into a try - catch block to prevent errors in // verifier from stopping the deployment try { BeanVerifier verifier = new BeanVerifier(); // add a listener so we can log the results verifier.addVerificationListener(new VerificationListener() { Logger verifierLog = Logger.getLogger(EjbDeployer.class, "verifier"); public void beanChecked(VerificationEvent event) { verifierLog.debug( "Bean checked: " + event.getMessage() ); } public void specViolation(VerificationEvent event) { verifierLog.warn( "EJB spec violation: " + (verifierVerbose ? event.getVerbose() : event.getMessage())); } }); log.debug("Verifying " + unit.getRoot().toURL()); verifier.verify(unit.getRoot().toURL(), legacyMD, unit.getClassLoader()); allOK = verifier.getSuccess(); } catch (Throwable t) { log.warn("Verify failed; continuing", t ); allOK = false; } // If the verifier is in strict mode and an error/warning // was found in the Verification process, throw a Deployment // Exception if( strictVerifier && !allOK ) { throw new DeploymentException("Verification of Enterprise Beans failed, see above for error messages."); } }
// in src/main/java/org/jboss/ejb/deployers/StandardJBossMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { // Get the jboss.xml attachment JBossMetaData metaData = unit.getAttachment(JBossMetaData.class); // Get the standardjboss.xml attachment JBossMetaData stdMetaData = unit.getAttachment("standardjboss.xml", JBossMetaData.class); if(metaData == null || stdMetaData == null) return; JBossMetaDataWrapper wrapper = new JBossMetaDataWrapper(metaData, stdMetaData); // Set the wrapper as the output unit.getTransientManagedObjects().addAttachment(JBossMetaData.class, wrapper); // Keep the raw parsed metadata as well unit.addAttachment(RAW_ATTACHMENT_NAME, metaData, JBossMetaData.class); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
public void deploy(DeploymentUnit unit, JBossMetaData deployment) throws DeploymentException { if (factories.isEmpty()) return; JBossEnterpriseBeansMetaData beans = deployment.getEnterpriseBeans(); if (beans != null && beans.isEmpty() == false) { ArrayList<JBossMessageDrivenBeanMetaData> deployed = new ArrayList<JBossMessageDrivenBeanMetaData>(); for (JBossEnterpriseBeanMetaData bean : beans) { if (bean.isMessageDriven()) { try { JBossMessageDrivenBeanMetaData messageDriven = (JBossMessageDrivenBeanMetaData) bean; if (isCreateDestination(unit, messageDriven)) { deploy(unit, messageDriven); deployed.add(messageDriven); } } catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); } } } } }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
protected void deploy(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException { for (CreateDestination createDestination : factories) { if (createDestination.getMatcher().isMatch(unit, mdb)) { Object attachment = createDestination.getFactory().create(unit, mdb); if (attachment != null) { unit.addAttachment(getAttachmentName(unit, mdb), attachment); return; } } } }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
protected void undeploy(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException { unit.removeAttachment(getAttachmentName(unit, mdb)); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
protected boolean isCreateDestination(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException { return mdb.isCreateDestination(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void resolveMessageListener() throws DeploymentException { String messagingType = metaData.getMessagingType(); try { messagingTypeClass = GetTCLAction.getContextClassLoader().loadClass(messagingType); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Could not load messaging-type class " + messagingType, e); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected String resolveResourceAdapterName() throws DeploymentException { return metaData.getResourceAdapterName(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void resolveResourceAdapter() throws DeploymentException { resourceAdapterName = resolveResourceAdapterName(); try { resourceAdapterObjectName = new ObjectName("jboss.jca:service=RARDeployment,name='" + resourceAdapterName + "'"); int state = ((Integer) server.getAttribute(resourceAdapterObjectName, "State")).intValue(); if (state != STARTED) throw new DeploymentException("The resource adapter is not started " + resourceAdapterName); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Cannot locate resource adapter deployment " + resourceAdapterName, e); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void setupProxyParameters() throws DeploymentException { // Set the interfaces interfaces = new Class[] { MessageEndpoint.class, messagingTypeClass }; // Set the interceptors interceptors = new ArrayList<Class<?>>(); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element endpointInterceptors = MetaData.getOptionalChild(proxyConfig, "endpoint-interceptors", null); if (endpointInterceptors == null) throw new DeploymentException("No endpoint interceptors found"); else { NodeList children = endpointInterceptors.getElementsByTagName("interceptor"); for (int i = 0; i < children.getLength(); ++i) { Node currentChild = children.item(i); if (currentChild.getNodeType() == Node.ELEMENT_NODE) { Element interceptor = (Element) children.item(i); String className = MetaData.getElementContent(interceptor); try { Class<?> clazz = container.getClassLoader().loadClass(className); interceptors.add(clazz); } catch (Throwable t) { DeploymentException.rethrowAsDeploymentException("Error loading interceptor class " + className, t); } } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void augmentActivationConfigProperties() throws DeploymentException { // Allow activation config properties from invoker proxy binding Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element activationConfig = MetaData.getOptionalChild(proxyConfig, "activation-config"); if (activationConfig != null) { Iterator<Element> iterator = MetaData.getChildrenByTagName(activationConfig, "activation-config-property"); while (iterator.hasNext()) { Element xml = iterator.next(); org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData md = new org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData(); ActivationConfigPropertyMetaData metaData = new ActivationConfigPropertyMetaData(md); String name = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-name")); String value = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-value")); if (name == null || name.trim().length() == 0) throw new DeploymentException("activation-config-property doesn't have a name"); if (Strings.isValidJavaIdentifier(name) == false) throw new DeploymentException("activation-config-property '" + name + "' is not a valid java identifier"); md.setName(name); md.setValue(value); if (properties.containsKey(metaData.getName()) == false) properties.put(metaData.getName(), metaData); } } // Message Destination Link String link = metaData.getDestinationLink(); if (link != null) { link = link.trim(); if (link.length() > 0) { if (properties.containsKey("destination")) log.warn("Ignoring message-destination-link '" + link + "' when the destination " + "is already in the activation-config."); else { MessageDestinationMetaData destinationMetaData = container.getMessageDestination(link); if (destinationMetaData == null) throw new DeploymentException("Unresolved message-destination-link '" + link + "' no message-destination in ejb-jar.xml"); String jndiName = destinationMetaData.getJndiName(); if (jndiName == null) throw new DeploymentException("The message-destination '" + link + "' has no jndi-name in jboss.xml"); org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData acpmd = new org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData(); acpmd.setActivationConfigPropertyName("destination"); acpmd.setValue(jndiName); ActivationConfigPropertyMetaData wrapper = new ActivationConfigPropertyMetaData(acpmd); properties.put("destination", wrapper); } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void createActivationSpec() throws DeploymentException { properties = new HashMap(metaData.getActivationConfigProperties()); augmentActivationConfigProperties(); Object[] params = new Object[] { messagingTypeClass, properties.values() }; try { activationSpec = (ActivationSpec) server.invoke(resourceAdapterObjectName, "createActivationSpec", params, createActivationSpecSig); } catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Unable to create activation spec ra=" + resourceAdapterObjectName + " messaging-type=" + messagingTypeClass.getName() + " properties=" + metaData.getActivationConfigProperties(), t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void activate() throws DeploymentException { if (deliveryActive.get() == false) { log.info("Delivery is disabled: " + getServiceName()); return; } Object[] params = new Object[] { this, activationSpec }; try { server.invoke(resourceAdapterObjectName, "endpointActivation", params, activationSig); } catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
Override protected String resolveResourceAdapterName() throws DeploymentException { // No resource adapter specified assume jms String result = super.resolveResourceAdapterName(); if (result == null) { getLog().warn("Metadata is missing JMS resource adpater name. The default will be " + jmsra); result = jmsra; } return result; }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
Override protected void resolveMessageListener() throws DeploymentException { // No messaging type use jms if (metaData.getMessagingType() == null) messagingTypeClass = MessageListener.class; else super.resolveMessageListener(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
protected void augmentActivationConfigProperties() throws DeploymentException { super.augmentActivationConfigProperties(); // Hack for old style deployments (jms) if (messagingTypeClass.equals(MessageListener.class)) { checkActivationConfig("destination", metaData.getDestinationJndiName()); checkActivationConfig("destinationType", metaData.getDestinationType()); checkActivationConfig("messageSelector", metaData.getMessageSelector()); if (Session.DUPS_OK_ACKNOWLEDGE == metaData.getAcknowledgeMode()) checkActivationConfig("acknowledgeMode", "DUPS_OK_ACKNOWLEDGE"); else checkActivationConfig("acknowledgeMode", "AUTO_ACKNOWLEDGE"); if (MessageDrivenMetaData.DURABLE_SUBSCRIPTION == metaData.getSubscriptionDurability()) checkActivationConfig("subscriptionDurability", "Durable"); else checkActivationConfig("subscriptionDurability", "NonDurable"); checkActivationConfig("clientId", metaData.getClientId()); checkActivationConfig("subscriptionName", metaData.getSubscriptionId()); // Only for JBoss's resource adapter if (jmsra.equals(resourceAdapterName)) { checkActivationConfig("user", metaData.getUser()); checkActivationConfig("password", metaData.getPasswd()); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); checkActivationConfig("maxMessages", MetaData.getOptionalChildContent(proxyConfig, "MaxMessages")); checkActivationConfig("minSession", MetaData.getOptionalChildContent(proxyConfig, "MinimumSize")); checkActivationConfig("maxSession", MetaData.getOptionalChildContent(proxyConfig, "MaximumSize")); checkActivationConfig("keepAlive", MetaData.getOptionalChildContent(proxyConfig, "KeepAliveMillis")); Element mdbConfig = MetaData.getOptionalChild(proxyConfig, "MDBConfig"); if (mdbConfig != null) { try { if ("false".equalsIgnoreCase(MetaData.getElementContent(MetaData.getUniqueChild(mdbConfig, "DeliveryActive")))) { setDeliveryActive(false); } } catch (Exception ignore) { } checkActivationConfig("reconnectInterval", MetaData.getOptionalChildContent(proxyConfig, "ReconnectIntervalSec")); checkActivationConfig("deliveryActive", MetaData.getOptionalChildContent(proxyConfig, "DeliveryActive")); checkActivationConfig("providerAdapterJNDI", MetaData.getOptionalChildContent(proxyConfig, "JMSProviderAdapterJNDI")); Element dlqEl = MetaData.getOptionalChild(mdbConfig, "DLQConfig"); if (dlqEl != null) { checkActivationConfig("useDLQ", "true"); checkActivationConfig("DLQJNDIName", MetaData.getElementContent(MetaData.getUniqueChild(dlqEl, "DestinationQueue"))); try { checkActivationConfig("DLQMaxResent", MetaData.getElementContent(MetaData.getUniqueChild(dlqEl, "MaxTimesRedelivered"))); } catch (Exception ignored) { // backwards comaptibility } // TODO TimeToLive checkActivationConfig("DLQUser", MetaData.getElementContent(MetaData.getOptionalChild(dlqEl, "DLQUser"))); checkActivationConfig("DLQPassword", MetaData.getElementContent(MetaData.getOptionalChild(dlqEl, "DLQPassword"))); } else { // backwards compatibility - no DLQConfig in MDBConfig means no DLQ checkActivationConfig("useDLQ", "false"); } } } } }
// in src/main/java/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
protected void setupProxyParameters() throws DeploymentException { // Set the interfaces interfaces = new Class[] { MessageEndpoint.class, MessageListener.class }; // Set the interceptors interceptors = new ArrayList<Class<?>>(); interceptors.add(ClientMethodInterceptor.class); interceptors.add(MessageEndpointInterceptor.class); interceptors.add(TransactionInterceptor.class); interceptors.add(InvokerInterceptor.class); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void initSequence(String tableName, String sequenceColumn, String sequenceName, String idColumnName) throws SQLException, DeploymentException { if(createTable) { createTableIfNotExists(tableName); } Connection con = null; Statement st = null; ResultSet rs = null; try { String sql = "select " + idColumnName + " from " + tableName + " where " + sequenceColumn + "='" + sequenceName + "'"; log.debug("Executing SQL: " + sql); con = ds.getConnection(); st = con.createStatement(); rs = st.executeQuery(sql); if(!rs.next()) { sql = "insert into " + tableName + "(" + sequenceColumn + ", " + idColumnName + ") values ('" + sequenceName + "', 0)"; log.debug("Executing SQL: " + sql); final Statement insertSt = con.createStatement(); try { final int i = insertSt.executeUpdate(sql); if(i != 1) { throw new SQLException("Expected one updated row but got: " + i); } } finally { JDBCUtil.safeClose(insertSt); } } else { HiLoKeyGenerator.setHighestHi(rs.getLong(1)); } } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void createTableIfNotExists(String tableName) throws SQLException, DeploymentException { Connection con = null; Statement st = null; try { if(!SQLUtil.tableExists(tableName, ds)) { log.debug("Executing DDL: " + createTableDdl); con = ds.getConnection(); st = con.createStatement(); st.executeUpdate(createTableDdl); } } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void dropTableIfExists(String tableName) throws SQLException, DeploymentException { Connection con = null; Statement st = null; try { if(SQLUtil.tableExists(tableName, ds)) { final String ddl = "drop table " + tableName; log.debug("Executing DDL: " + ddl); con = ds.getConnection(); st = con.createStatement(); st.executeUpdate(ddl); } } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
public void importXml(Element element) throws DeploymentException { String min = MetaData.getElementContent(MetaData.getOptionalChild(element, "min-capacity")); String max = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-capacity")); String op = MetaData.getElementContent(MetaData.getOptionalChild(element, "overager-period")); String rp = MetaData.getElementContent(MetaData.getOptionalChild(element, "resizer-period")); String ma = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-bean-age")); String map = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-cache-miss-period")); String mip = MetaData.getElementContent(MetaData.getOptionalChild(element, "min-cache-miss-period")); String fa = MetaData.getElementContent(MetaData.getOptionalChild(element, "cache-load-factor")); try { if (min != null) { int s = Integer.parseInt(min); if (s <= 0) { throw new DeploymentException("Min cache capacity can't be <= 0"); } m_minCapacity = s; } if (max != null) { int s = Integer.parseInt(max); if (s <= 0) { throw new DeploymentException("Max cache capacity can't be <= 0"); } m_maxCapacity = s; } if (op != null) { int p = Integer.parseInt(op); if (p <= 0) {throw new DeploymentException("Overager period can't be <= 0");} m_overagerPeriod = p * 1000; } if (rp != null) { int p = Integer.parseInt(rp); if (p <= 0) {throw new DeploymentException("Resizer period can't be <= 0");} m_resizerPeriod = p * 1000; } if (ma != null) { int a = Integer.parseInt(ma); if (a <= 0) {throw new DeploymentException("Max bean age can't be <= 0");} m_maxBeanAge = a * 1000; } if (map != null) { int p = Integer.parseInt(map); if (p <= 0) {throw new DeploymentException("Max cache miss period can't be <= 0");} m_maxPeriod = p * 1000; } if (mip != null) { int p = Integer.parseInt(mip); if (p <= 0) {throw new DeploymentException("Min cache miss period can't be <= 0");} m_minPeriod = p * 1000; } if (fa != null) { double f = Double.parseDouble(fa); if (f <= 0.0) {throw new DeploymentException("Cache load factor can't be <= 0");} m_factor = f; } } catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void importXml(Element element) throws DeploymentException { // This one is mandatory String p = MetaData.getElementContent(MetaData.getUniqueChild(element, "cache-policy")); try { Class cls = SecurityActions.getContextClassLoader().loadClass(p); Constructor ctor = cls.getConstructor(new Class[] {AbstractInstanceCache.class}); m_cache = (CachePolicy)ctor.newInstance(new Object[] {this}); } catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); } Element policyConf = MetaData.getOptionalChild(element, "cache-policy-conf"); if (policyConf != null) { if (m_cache instanceof XmlLoadable) { try { ((XmlLoadable)m_cache).importXml(policyConf); } catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); } } } }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void importXml(Element element) throws DeploymentException { String flushString = MetaData.getElementContent(MetaData.getOptionalChild(element, "flush-enabled")); flushEnabled = Boolean.valueOf(flushString).booleanValue(); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
public void importXml(Element element) throws DeploymentException { Element synch = MetaData.getUniqueChild(element, "Synchronized"); isSynchronized = Boolean.valueOf(MetaData.getElementContent(synch)).booleanValue(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2) manager.getEntityBridge(); log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName()); final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields(); if(pkFields.length > 1) { throw new DeploymentException("This entity-command cannot be used with composite primary keys!"); } this.pkField = (JDBCCMPFieldBridge2) pkFields[0]; JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand(); pkSql = metadata.getAttribute("pk-sql"); if(pkSql == null) { throw new DeploymentException("pk-sql attribute must be set for entity " + entityBridge.getEntityName()); } if(log.isDebugEnabled()) { log.debug("entity-command generate pk sql: " + pkSql); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
public void init() throws DeploymentException { Method findByPkMethod; Class home = entity.getHomeClass(); if(home != null) { try { findByPkMethod = home.getMethod("findByPrimaryKey", new Class[]{entity.getPrimaryKeyClass()}); } catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } FindByPrimaryKeyCommand findByPk = new FindByPrimaryKeyCommand(entity); queriesByMethod.put(findByPkMethod, findByPk); } Class local = entity.getLocalHomeClass(); if(local != null) { try { findByPkMethod = local.getMethod("findByPrimaryKey", new Class[]{entity.getPrimaryKeyClass()}); } catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } FindByPrimaryKeyCommand findByPk = new FindByPrimaryKeyCommand(entity); queriesByMethod.put(findByPkMethod, findByPk); } // // Defined finders - Overrides automatic finders. // Iterator definedFinders = entity.getMetaData().getQueries().iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData q = (JDBCQueryMetaData) definedFinders.next(); if(!queriesByMethod.containsKey(q.getMethod())) { if(q instanceof JDBCJBossQLQueryMetaData) { QueryCommand queryCommand = new JBossQLQueryCommand(entity, (JDBCJBossQLQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCQlQueryMetaData) { QueryCommand queryCommand = new EJBQLQueryCommand(entity, (JDBCQlQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCDeclaredQueryMetaData) { QueryCommand queryCommand = new DeclaredSQLQueryCommand(entity, (JDBCDeclaredQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCDynamicQLQueryMetaData) { QueryCommand queryCommand = new DynamicQueryCommand(entity, (JDBCDynamicQLQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else { throw new DeploymentException("Unsupported query metadata: method=" + q.getMethod().getName() + ", metadata=" + q); } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
public EntityTable createEntityTable(JDBCEntityMetaData metadata, JDBCEntityBridge2 entity) throws DeploymentException { if(entityTables == null) { entityTables = new EntityTable[1]; } else { EntityTable[] tmp = entityTables; entityTables = new EntityTable[tmp.length + 1]; System.arraycopy(tmp, 0, entityTables, 0, tmp.length); } EntityTable table = new EntityTable(metadata, entity, this, entityTables.length - 1); entityTables[entityTables.length - 1] = table; return table; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
public RelationTable createRelationTable(JDBCCMRFieldBridge2 leftField, JDBCCMRFieldBridge2 rightField) throws DeploymentException { if(relationTables == null) { relationTables = new RelationTable[1]; } else { RelationTable[] tmp = relationTables; relationTables = new RelationTable[tmp.length + 1]; System.arraycopy(tmp, 0, relationTables, 0, tmp.length); } RelationTable table = new RelationTable(leftField, rightField, this, relationTables.length - 1); relationTables[relationTables.length - 1] = table; return table; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void start() throws DeploymentException { final JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); relationsTotal = (cmrFields != null ? cmrFields.length : 0); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); // DELETE SQL deleteSql = "delete from " + tableName + " where "; deleteSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { deleteSql += " and " + pkFields[i].getColumnName() + "=?"; } log.debug("delete sql: " + deleteSql); // INSERT SQL insertSql = "insert into " + tableName + "("; insertSql += tableFields[0].getColumnName(); for(int i = 1; i < tableFields.length; ++i) { insertSql += ", " + tableFields[i].getColumnName(); } insertSql += ") values (?"; for(int i = 1; i < tableFields.length; ++i) { insertSql += ", ?"; } insertSql += ")"; log.debug("insert sql: " + insertSql); // UPDATE SQL updateSql = "update " + tableName + " set "; int setFields = 0; for(int i = 0; i < tableFields.length; ++i) { JDBCCMPFieldBridge2 field = tableFields[i]; if(!field.isPrimaryKeyMember()) { if(setFields++ > 0) { updateSql += ", "; } updateSql += field.getColumnName() + "=?"; } } updateSql += " where "; updateSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { updateSql += " and " + pkFields[i].getColumnName() + "=?"; } if(entity.getVersionField() != null) { updateSql += " and " + entity.getVersionField().getColumnName() + "=?"; } log.debug("update sql: " + updateSql); // SELECT SQL String selectColumns = tableFields[0].getColumnName(); for(int i = 1; i < tableFields.length; ++i) { JDBCCMPFieldBridge2 field = tableFields[i]; selectColumns += ", " + field.getColumnName(); } String whereColumns = pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { whereColumns += " and " + pkFields[i].getColumnName() + "=?"; } if(entity.getMetaData().hasRowLocking()) { JDBCEntityPersistenceStore manager = entity.getManager(); JDBCTypeFactory typeFactory = manager.getJDBCTypeFactory(); JDBCTypeMappingMetaData typeMapping = typeFactory.getTypeMapping(); JDBCFunctionMappingMetaData rowLockingTemplate = typeMapping.getRowLockingTemplate(); if(rowLockingTemplate == null) { throw new DeploymentException("Row locking template is not defined for mapping: " + typeMapping.getName()); } selectSql = rowLockingTemplate.getFunctionSql(new Object[]{selectColumns, tableName, whereColumns, null}, new StringBuffer()).toString(); } else { selectSql = "select "; selectSql += selectColumns; selectSql += " from " + tableName + " where "; selectSql += whereColumns; } log.debug("select sql: " + selectSql); // DUPLICATE KEY if(dontFlushCreated) { duplicatePkSql = "select "; duplicatePkSql += pkFields[0].getColumnName(); for(int i = 1; i < pkFields.length; ++i) { duplicatePkSql += ", " + pkFields[i].getColumnName(); } duplicatePkSql += " from " + tableName + " where "; duplicatePkSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { duplicatePkSql += " and " + pkFields[i].getColumnName() + "=?"; } log.debug("duplicate pk sql: " + duplicatePkSql); } if(cacheName != null) { try { serviceController.start(cacheName); } catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DeclaredSQLQueryCommand.java
private void initResultReader(JDBCEntityBridge2 entity, JDBCDeclaredQueryMetaData metadata) throws DeploymentException { String entityName = metadata.getEJBName(); if(entityName != null) { Catalog catalog = entity.getManager().getCatalog(); JDBCEntityBridge2 otherEntity = (JDBCEntityBridge2) catalog.getEntityByEJBName(entityName); if(otherEntity == null) { throw new DeploymentException("Unknown entity: " + entityName); } this.entity = otherEntity; } else { this.entity = entity; } String fieldName = metadata.getFieldName(); if(fieldName == null) { setEntityReader(this.entity, metadata.isSelectDistinct()); } else { selectedField = (JDBCCMPFieldBridge2) entity.getFieldByName(fieldName); if(selectedField == null) { throw new DeploymentException("Unknown cmp field: " + fieldName); } setFieldReader(selectedField); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DeclaredSQLQueryCommand.java
protected String parseParameters(String sql, JDBCDeclaredQueryMetaData metadata) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); ArrayList params = new ArrayList(); // Replace placeholders {0} with ? if(sql != null) { sql = sql.trim(); StringTokenizer tokens = new StringTokenizer(sql, "{}", true); while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); if(token.equals("{")) { token = tokens.nextToken(); if(Character.isDigit(token.charAt(0))) { QueryParameter parameter = new QueryParameter(entity.getManager(), metadata.getMethod(), token); // of if we are here we can assume that we have // a parameter and not a function sqlBuf.append("?"); params.add(parameter); if(!tokens.nextToken().equals("}")) { throw new DeploymentException("Invalid parameter - missing closing '}' : " + sql); } } else { // ok we don't have a parameter, we have a function // push the tokens on the buffer and continue sqlBuf.append("{").append(token); } } else { // not parameter... just append it sqlBuf.append(token); } } } setParameters(params); return sqlBuf.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
private void startEntity() throws DeploymentException { entityBridge.start(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
private JDBCEntityMetaData loadJDBCEntityMetaData() throws DeploymentException { ApplicationMetaData amd = container.getBeanMetaData().getApplicationMetaData(); // Get JDBC MetaData JDBCApplicationMetaData jamd = (JDBCApplicationMetaData)amd.getPluginData(CMP_JDBC); if(jamd == null) { // we are the first cmp entity to need jbosscmp-jdbc. // Load jbosscmp-jdbc.xml for the whole application JDBCXmlFileLoader jfl = new JDBCXmlFileLoader(container, log); jamd = jfl.load(); amd.addPluginData(CMP_JDBC, jamd); } // Get JDBC Bean MetaData String ejbName = container.getBeanMetaData().getEjbName(); JDBCEntityMetaData metadata = jamd.getBeanByEjbName(ejbName); if(metadata == null) { throw new DeploymentException("No metadata found for bean " + ejbName); } return metadata; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
private static Map createFieldMap(JDBCEntityBridge2 entityBridge) throws DeploymentException { Map abstractAccessors = getAbstractAccessors(entityBridge.getMetaData().getEntityClass()); List fields = entityBridge.getFields(); Map map = new HashMap(fields.size() * 2); for(int i = 0; i < fields.size(); i++) { FieldBridge field = (FieldBridge) fields.get(i); // get the names String fieldName = field.getFieldName(); String fieldBaseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getterName = "get" + fieldBaseName; String setterName = "set" + fieldBaseName; // get the accessor methods Method getterMethod = (Method) abstractAccessors.get(getterName); Method setterMethod = (Method) abstractAccessors.get(setterName); // getters and setters must come in pairs if(getterMethod != null && setterMethod == null) { throw new DeploymentException("Getter was found but, no setter was found for field: " + fieldName); } else if(getterMethod == null && setterMethod != null) { throw new DeploymentException("Setter was found but, no getter was found for field: " + fieldName); } else if(getterMethod != null && setterMethod != null) { // add methods map.put(getterMethod.getName(), new EntityBridgeInvocationHandler.FieldGetInvoker(field)); map.put(setterMethod.getName(), new EntityBridgeInvocationHandler.FieldSetInvoker(field)); // remove the accessors (they have been used) abstractAccessors.remove(getterName); abstractAccessors.remove(setterName); } } return Collections.unmodifiableMap(map); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
private static Map createSelectorMap(JDBCEntityBridge2 entityBridge, QueryFactory queryFactory) throws DeploymentException { Collection queries = entityBridge.getMetaData().getQueries(); Map selectorsByMethod = new HashMap(queries.size()); Iterator definedFinders = queries.iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData metadata = (JDBCQueryMetaData)definedFinders.next(); if(metadata.getMethod().getName().startsWith("ejbSelect")) { try { QueryCommand queryCommand = queryFactory.getQueryCommand(metadata.getMethod()); Schema schema = ((JDBCStoreManager2)entityBridge.getManager()).getSchema(); EJBSelectBridge ejbSelectBridge = new EJBSelectBridge(entityBridge.getContainer(), schema, metadata, queryCommand); selectorsByMethod.put(metadata.getMethod(), ejbSelectBridge); } catch(FinderException e) { throw new DeploymentException(e.getMessage()); } } } return selectorsByMethod; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void resolveRelationship() throws DeploymentException { // // Set handles to the related entity's container, cache, manager, and invoker // // Related Entity Name String relatedEntityName = metadata.getRelatedRole().getEntity().getName(); // Related Entity Catalog catalog = (Catalog)manager.getApplicationData("CATALOG"); relatedEntity = (JDBCEntityBridge2)catalog.getEntityByEJBName(relatedEntityName); if(relatedEntity == null) { throw new DeploymentException("Related entity not found: " + "entity=" + entity.getEntityName() + ", " + "cmrField=" + getFieldName() + ", " + "relatedEntity=" + relatedEntityName ); } // Related CMR Field JDBCCMRFieldBridge2[] cmrFields = (JDBCCMRFieldBridge2[])relatedEntity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge2 cmrField = cmrFields[i]; if(metadata.getRelatedRole() == cmrField.getMetaData()) { relatedCMRField = cmrField; break; } } // if we didn't find the related CMR field throw an exception with a detailed message if(relatedCMRField == null) { String message = "Related CMR field not found in " + relatedEntity.getEntityName() + " for relationship from "; message += entity.getEntityName() + "."; if(getFieldName() != null) { message += getFieldName(); } else { message += "<no-field>"; } message += " to "; message += relatedEntityName + "."; if(metadata.getRelatedRole().getCMRFieldName() != null) { message += metadata.getRelatedRole().getCMRFieldName(); } else { message += "<no-field>"; } throw new DeploymentException(message); } // Related Container relatedContainer = relatedEntity.getContainer(); // // Initialize the key fields // if(metadata.getRelationMetaData().isTableMappingStyle()) { // initialize relation table key fields Collection tableKeys = metadata.getKeyFields(); List keyFieldsList = new ArrayList(tableKeys.size()); // first phase is to create fk fields Map pkFieldsToFKFields = new HashMap(tableKeys.size()); for(Iterator i = tableKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData)i.next(); FieldBridge pkField = entity.getFieldByName(cmpFieldMetaData.getFieldName()); if(pkField == null) { throw new DeploymentException("Primary key not found for key-field " + cmpFieldMetaData.getFieldName()); } pkFieldsToFKFields.put(pkField, new JDBCCMPFieldBridge2(manager, entity, cmpFieldMetaData, -1)); } // second step is to order fk fields to match the order of pk fields JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { Object fkField = pkFieldsToFKFields.get(pkFields[i]); if(fkField == null) { throw new DeploymentException("Primary key " + pkFields[i].getFieldName() + " is not mapped."); } keyFieldsList.add(fkField); } tableKeyFields = (JDBCCMPFieldBridge2[])keyFieldsList.toArray(new JDBCCMPFieldBridge2[keyFieldsList.size()]); } else { initializeForeignKeyFields(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void initLoader() throws DeploymentException { if(metadata.getRelationMetaData().isTableMappingStyle()) { relationTable = relatedCMRField.getRelationTable(); loader = new RelationTableLoader(); } else { if(foreignKeyFields != null) { loader = new ContextForeignKeyLoader(); } else { loader = new ForeignKeyLoader(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private void initializeForeignKeyFields() throws DeploymentException { Collection foreignKeys = metadata.getRelatedRole().getKeyFields(); // temporary map used later to write fk fields in special order Map fkFieldsByRelatedPKFields = new HashMap(); for(Iterator i = foreignKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData fkFieldMetaData = (JDBCCMPFieldMetaData)i.next(); JDBCCMPFieldBridge2 relatedPKField = (JDBCCMPFieldBridge2)relatedEntity.getFieldByName(fkFieldMetaData.getFieldName()); // now determine whether the fk is mapped to a pk column String fkColumnName = fkFieldMetaData.getColumnName(); JDBCCMPFieldBridge2 fkField = null; // look among the CMP fields for the field with the same column name JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[])entity.getTableFields(); for(int tableInd = 0; tableInd < tableFields.length && fkField == null; ++tableInd) { JDBCCMPFieldBridge2 cmpField = tableFields[tableInd]; if(fkColumnName.equals(cmpField.getColumnName())) { // construct the foreign key field fkField = new JDBCCMPFieldBridge2(cmpField, relatedPKField); /* cmpField.getManager(), // this cmpField's manager relatedPKField.getFieldName(), relatedPKField.getFieldType(), cmpField.getJDBCType(), // this cmpField's jdbc type relatedPKField.isReadOnly(), relatedPKField.getReadTimeOut(), relatedPKField.getPrimaryKeyClass(), relatedPKField.getPrimaryKeyField(), cmpField, // CMP field I am mapped to this, fkColumnName ); */ } } // if the fk is not a part of pk then create a new field if(fkField == null) { fkField = entity.addTableField(fkFieldMetaData); } fkFieldsByRelatedPKFields.put(relatedPKField, fkField); // temporary map } // Note: this important to order the foreign key fields so that their order matches // the order of related entity's pk fields in case of complex primary keys. // The order is important in fk-constraint generation and in SELECT when loading if(fkFieldsByRelatedPKFields.size() > 0) { JDBCFieldBridge[] pkFields = relatedEntity.getPrimaryKeyFields(); List fkList = new ArrayList(pkFields.length); List relatedPKList = new ArrayList(pkFields.length); for(int i = 0; i < pkFields.length; ++i) { JDBCFieldBridge relatedPKField = pkFields[i]; JDBCFieldBridge fkField = (JDBCCMPFieldBridge2)fkFieldsByRelatedPKFields.remove(relatedPKField); fkList.add(fkField); relatedPKList.add(relatedPKField); } foreignKeyFields = (JDBCCMPFieldBridge2[])fkList.toArray(new JDBCCMPFieldBridge2[fkList.size()]); relatedPKFields = (JDBCCMPFieldBridge2[])relatedPKList.toArray(new JDBCCMPFieldBridge2[relatedPKList.size()]); if(metadata.hasForeignKeyConstraint()) { fkConstraint = entity.getTable().addFkConstraint(foreignKeyFields, relatedEntity.getTable()); } } else { foreignKeyFields = null; relatedPKFields = null; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private RelationTable getRelationTable() throws DeploymentException { if(relationTable == null) { relationTable = manager.getSchema().createRelationTable(this, relatedCMRField); } return relationTable; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void init() throws DeploymentException { loadCMPFields(metadata); loadCMRFields(metadata); JDBCOptimisticLockingMetaData olMD = metadata.getOptimisticLocking(); if(olMD != null) { if(olMD.getLockingStrategy() != JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY) { throw new DeploymentException( "Only version-column optimistic locking strategy is supported at the moment."); } JDBCCMPFieldMetaData versionMD = olMD.getLockingField(); versionField = (JDBCCMPFieldBridge2) getFieldByName(versionMD.getFieldName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void resolveRelationships() throws DeploymentException { for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].resolveRelationship(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void start() throws DeploymentException { if(versionField != null) { versionField.initVersion(); } table.start(); if(cmrFields != null) { for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].initLoader(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
JDBCCMPFieldBridge2 addTableField(JDBCCMPFieldMetaData metadata) throws DeploymentException { table.addField(); if(tableFields == null) { tableFields = new JDBCCMPFieldBridge2[1]; } else { JDBCCMPFieldBridge2[] tmp = tableFields; tableFields = new JDBCCMPFieldBridge2[tableFields.length + 1]; System.arraycopy(tmp, 0, tableFields, 0, tmp.length); } int tableIndex = tableFields.length - 1; JDBCCMPFieldBridge2 cmpField = new JDBCCMPFieldBridge2(manager, this, metadata, tableIndex); tableFields[tableFields.length - 1] = cmpField; return cmpField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
private void loadCMPFields(JDBCEntityMetaData metadata) throws DeploymentException { // only non pk fields are stored here at first and then later // the pk fields are added to the front (makes sql easier to read) List cmpFieldsList = new ArrayList(metadata.getCMPFields().size()); // primary key cmp fields List pkFieldsList = new ArrayList(metadata.getCMPFields().size()); // create each field Iterator iter = metadata.getCMPFields().iterator(); while(iter.hasNext()) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData) iter.next(); JDBCCMPFieldBridge2 cmpField = addTableField(cmpFieldMetaData); if(cmpFieldMetaData.isPrimaryKeyMember()) { pkFieldsList.add(cmpField); } else { cmpFieldsList.add(cmpField); } } // save the pk fields in the pk field array pkFields = new JDBCCMPFieldBridge2[pkFieldsList.size()]; for(int i = 0; i < pkFieldsList.size(); ++i) { pkFields[i] = (JDBCCMPFieldBridge2) pkFieldsList.get(i); } // add the pk fields to the front of the cmp list, per guarantee above cmpFields = new JDBCCMPFieldBridge2[metadata.getCMPFields().size() - pkFields.length]; int cmpFieldIndex = 0; for(int i = 0; i < cmpFieldsList.size(); ++i) { cmpFields[cmpFieldIndex++] = (JDBCCMPFieldBridge2) cmpFieldsList.get(i); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
private void loadCMRFields(JDBCEntityMetaData metadata) throws DeploymentException { cmrFields = new JDBCCMRFieldBridge2[metadata.getRelationshipRoles().size()]; // create each field int cmrFieldIndex = 0; for(Iterator iter = metadata.getRelationshipRoles().iterator(); iter.hasNext();) { JDBCRelationshipRoleMetaData relationshipRole = (JDBCRelationshipRoleMetaData) iter.next(); JDBCCMRFieldBridge2 cmrField = new JDBCCMRFieldBridge2(this, manager, relationshipRole); cmrFields[cmrFieldIndex++] = cmrField; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2) manager.getEntityBridge(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2)manager.getEntityBridge(); this.log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName()); final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields(); if(pkFields.length > 1) { throw new DeploymentException("This entity-command cannot be used with composite primary keys!"); } this.pkField = (JDBCCMPFieldBridge2) pkFields[0]; this.pkSql = ""; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/PostgreSQLCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { super.init(manager); JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand(); String sequence = metadata.getAttribute("sequence"); if (sequence == null) { sequence = entityBridge.getQualifiedTableName() + '_' + SQLUtil.getColumnNamesClause(pkField, new StringBuffer(20)) + "_seq"; } pkSql = "SELECT nextval('" + sequence + "')"; if(log.isDebugEnabled()) { log.debug("entity-command generate pk sql: " + pkSql); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/HsqldbCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { super.init(manager); JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand(); pkSql = metadata.getAttribute("pk-sql"); if(pkSql == null) { pkSql = "CALL IDENTITY()"; } if(log.isDebugEnabled()) { log.debug("entity-command generate pk sql: " + pkSql); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { log = Logger.getLogger(getClass().getName() + '.' + manager.getMetaData().getName()); debug = log.isDebugEnabled(); trace = log.isTraceEnabled(); entity = (JDBCEntityBridge) manager.getEntityBridge(); securityManager = manager.getContainer().getSecurityManager(); insertAfterEjbPostCreate = manager.getContainer() .getBeanMetaData().getContainerConfiguration().isInsertAfterEjbPostCreate(); // set create allowed createAllowed = true; JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; i++) { if(pkFields[i].isReadOnly()) { createAllowed = false; log.debug("Create will not be allowed because pk field " + pkFields[i].getFieldName() + "is read only."); break; } } initGeneratedFields(); JDBCEntityCommandMetaData entityCommand = manager.getMetaData().getEntityCommand(); if(entityCommand == null) { throw new DeploymentException("entity-command is null"); } initEntityCommand(entityCommand); initInsertFields(); initInsertSQL(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { String objectName = entityCommand.getAttribute("SQLExceptionProcessor"); if(objectName != null) { try { exceptionProcessor = (SQLExceptionProcessorMBean) MBeanProxyExt.create(SQLExceptionProcessorMBean.class, objectName); } catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected JDBCCMPFieldBridge getGeneratedPKField() throws DeploymentException { // extract the pk field to be generated JDBCCMPFieldBridge pkField = null; JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { if(pkField != null) throw new DeploymentException("Generation only supported with single PK field"); pkField = (JDBCCMPFieldBridge)pkFields[i]; } return pkField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void initGeneratedFields() throws DeploymentException { createdPrincipal = entity.getCreatedPrincipalField(); if(securityManager == null && createdPrincipal != null) { throw new DeploymentException("No security-domain configured but created-by specified"); } updatedPrincipal = entity.getUpdatedPrincipalField(); if(securityManager == null && updatedPrincipal != null) { throw new DeploymentException("No security-domain configured but updated-by specified"); } createdTime = entity.getCreatedTimeField(); updatedTime = entity.getUpdatedTimeField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public static CascadeDeleteStrategy getCascadeDeleteStrategy(JDBCCMRFieldBridge cmrField) throws DeploymentException { CascadeDeleteStrategy result; JDBCRelationshipRoleMetaData relatedRole = cmrField.getMetaData().getRelatedRole(); if(relatedRole.isBatchCascadeDelete()) { result = new BatchCascadeDeleteStrategy(cmrField); } else if(relatedRole.isCascadeDelete()) { result = new DefaultCascadeDeleteStrategy(cmrField); } else { result = new NoneCascadeDeleteStrategy(cmrField); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationshipRoleMetaData.java
public void init(JDBCRelationshipRoleMetaData relatedRole) throws DeploymentException { init(relatedRole, null); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationshipRoleMetaData.java
public void init(JDBCRelationshipRoleMetaData relatedRole, Element element) throws DeploymentException { this.relatedRole = relatedRole; if(element == null || "defaults".equals(element.getTagName())) { keyFields = loadKeyFields(); } else { keyFields = loadKeyFields(element); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationshipRoleMetaData.java
private Map loadKeyFields(Element element) throws DeploymentException { Element keysElement = MetaData.getOptionalChild(element, "key-fields"); // no field overrides, we're done if(keysElement == null) { return loadKeyFields(); } // load overrides Iterator iter = MetaData.getChildrenByTagName(keysElement, "key-field"); // if key-fields element empty, no key should be used if(!iter.hasNext()) { return Collections.EMPTY_MAP; } else if(relationMetaData.isForeignKeyMappingStyle() && isMultiplicityMany()) { throw new DeploymentException("Role: " + relationshipRoleName + " with multiplicity many using " + "foreign-key mapping is not allowed to have key-fields"); } // load the default field values Map defaultFields = getPrimaryKeyFields(); // load overrides Map fields = new HashMap(defaultFields.size()); while(iter.hasNext()) { Element keyElement = (Element) iter.next(); String fieldName = MetaData.getUniqueChildContent(keyElement, "field-name"); JDBCCMPFieldMetaData cmpField = (JDBCCMPFieldMetaData) defaultFields.remove(fieldName); if(cmpField == null) { throw new DeploymentException( "Role '" + relationshipRoleName + "' on Entity Bean '" + entity.getName() + "' : CMP field for key not found: field " + "name='" + fieldName + "'"); } String isIndexedtmp = MetaData.getOptionalChildContent(keyElement, "dbindex"); boolean isIndexed; if(isIndexedtmp != null) isIndexed = true; else isIndexed = false; genIndex = isIndexed; cmpField = new JDBCCMPFieldMetaData( entity, keyElement, cmpField, false, relationMetaData.isTableMappingStyle(), relationMetaData.isReadOnly(), relationMetaData.getReadTimeOut(), relationMetaData.isTableMappingStyle()); fields.put(cmpField.getFieldName(), cmpField); } // all fields must be overriden if(!defaultFields.isEmpty()) { throw new DeploymentException("Mappings were not provided for all " + "fields: unmaped fields=" + defaultFields.keySet() + " in role=" + relationshipRoleName); } return Collections.unmodifiableMap(fields); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
private void addDefaultFunctionMapping() throws DeploymentException { JDBCFunctionMappingMetaData function; // concat function = new JDBCFunctionMappingMetaData("concat", new String[]{ "{fn concat(", ", ", ")}" }, new int[]{0, 1}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // substring function = new JDBCFunctionMappingMetaData("substring", new String[]{ "{fn substring(", ", ", ", ", ")}" }, new int[]{0, 1, 2}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // lcase function = new JDBCFunctionMappingMetaData("lcase", new String[]{ "{fn lcase(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // ucase function = new JDBCFunctionMappingMetaData("ucase", new String[]{ "{fn ucase(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // length function = new JDBCFunctionMappingMetaData("length", new String[]{ "{fn length(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // locate function = new JDBCFunctionMappingMetaData("locate", new String[]{ "{fn locate(", ", ", ", ", ")}" }, new int[]{0, 1, 2}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // abs function = new JDBCFunctionMappingMetaData("abs", new String[]{ "{fn abs(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // sqrt function = new JDBCFunctionMappingMetaData("sqrt", new String[]{ "{fn sqrt(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // mod function = new JDBCFunctionMappingMetaData("mod", "mod(?1, ?2)"); functionMappings.put(function.getFunctionName().toLowerCase(), function); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private int loadMappingStyle(Element element, JDBCRelationMetaData defaultValues) throws DeploymentException { // if defaults check for preferred-relation-mapping if ("defaults".equals(element.getTagName())) { // set mapping style based on preferred-relation-mapping (if possible) String perferredRelationMapping = MetaData.getOptionalChildContent(element, "preferred-relation-mapping"); if ("relation-table".equals(perferredRelationMapping) || defaultValues.isManyToMany()) { return TABLE; } else { return FOREIGN_KEY; } } // check for table mapping style if (MetaData.getOptionalChild(element, "relation-table-mapping") != null) { return TABLE; } // check for foreign-key mapping style if (MetaData.getOptionalChild(element, "foreign-key-mapping") != null) { if (defaultValues.isManyToMany()) { throw new DeploymentException("Foreign key mapping-style " + "is not allowed for many-to-many relationsips."); } return FOREIGN_KEY; } // no mapping style element, will use defaultValues return defaultValues.mappingStyle; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private static Element getMappingElement(Element element) throws DeploymentException { // if defaults check for preferred-relation-mapping if ("defaults".equals(element.getTagName())) { return element; } // check for table mapping style Element tableMappingElement = MetaData.getOptionalChild(element, "relation-table-mapping"); if (tableMappingElement != null) { return tableMappingElement; } // check for foreign-key mapping style Element foreignKeyMappingElement = MetaData.getOptionalChild(element, "foreign-key-mapping"); if (foreignKeyMappingElement != null) { return foreignKeyMappingElement; } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private static Element getEJBRelationshipRoleElement(Element element, JDBCRelationshipRoleMetaData defaultRole) throws DeploymentException { String roleName = defaultRole.getRelationshipRoleName(); if (roleName == null) throw new DeploymentException("No ejb-relationship-role-name element found"); Iterator iter = MetaData.getChildrenByTagName(element, "ejb-relationship-role"); if (!iter.hasNext()) { throw new DeploymentException("No ejb-relationship-role " + "elements found"); } Element roleElement = null; for (int i = 0; iter.hasNext(); i++) { // only 2 roles are allowed if (i > 1) { throw new DeploymentException("Expected only 2 " + "ejb-relationship-role but found more then 2"); } Element tempElement = (Element) iter.next(); if (roleName.equals(MetaData.getUniqueChildContent(tempElement, "ejb-relationship-role-name"))) { roleElement = tempElement; } } if (roleElement == null) { throw new DeploymentException("An ejb-relationship-role element was " + "not found for role '" + roleName + "'"); } return roleElement; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCLeftJoinMetaData.java
public static List readLeftJoinList(Iterator leftJoinIterator) throws DeploymentException { List leftJoinList; if(leftJoinIterator.hasNext()) { leftJoinList = new ArrayList(); while(leftJoinIterator.hasNext()) { Element leftJoinElement = (Element)leftJoinIterator.next(); JDBCLeftJoinMetaData leftJoin = new JDBCLeftJoinMetaData(leftJoinElement); leftJoinList.add(leftJoin); } } else { leftJoinList = Collections.EMPTY_LIST; } return leftJoinList; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
private void loadLoadGroupsXml(Element element) throws DeploymentException { Element loadGroupsElement = MetaData.getOptionalChild(element, "load-groups"); if(loadGroupsElement == null) { // no info, default work already done in constructor return; } // only allowed for cmp 2.x if(isCMP1x) { throw new DeploymentException( "load-groups are only allowed " + "for CMP 2.x" ); } // load each group Iterator groups = MetaData.getChildrenByTagName(loadGroupsElement, "load-group"); while(groups.hasNext()) { Element groupElement = (Element) groups.next(); // get the load-group-name String loadGroupName = MetaData.getUniqueChildContent(groupElement, "load-group-name"); if(loadGroups.containsKey(loadGroupName)) { throw new DeploymentException( "Load group already defined: " + " load-group-name=" + loadGroupName ); } if(loadGroupName.equals("*")) { throw new DeploymentException( "The * load group is automatically " + "defined and can't be overriden" ); } ArrayList group = new ArrayList(); // add each field Iterator fields = MetaData.getChildrenByTagName(groupElement, "field-name"); while(fields.hasNext()) { String fieldName = MetaData.getElementContent((Element) fields.next()); // check if the field is a cmp field that it is not a pk memeber JDBCCMPFieldMetaData field = getCMPFieldByName(fieldName); if(field != null && field.isPrimaryKeyMember()) { throw new DeploymentException( "Primary key fields can not be" + " a member of a load group: " + " load-group-name=" + loadGroupName + " field-name=" + fieldName ); } group.add(fieldName); } loadGroups.put(loadGroupName, Collections.unmodifiableList(group)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
private void loadLazyLoadGroupsXml(Element element) throws DeploymentException { Element lazyLoadGroupsElement = MetaData.getOptionalChild(element, "lazy-load-groups"); // If no info, we're done. Default work was already done in constructor. if(lazyLoadGroupsElement == null) { return; } // only allowed for cmp 2.x if(isCMP1x) { throw new DeploymentException("lazy-load-groups is only allowed for CMP 2.x"); } // get the fields Iterator loadGroupNames = MetaData.getChildrenByTagName(lazyLoadGroupsElement, "load-group-name"); while(loadGroupNames.hasNext()) { String loadGroupName = MetaData.getElementContent((Element) loadGroupNames.next()); if(!loadGroupName.equals("*") && !loadGroups.containsKey(loadGroupName)) { throw new DeploymentException( "Lazy load group not found: " + "load-group-name=" + loadGroupName ); } lazyLoadGroups.add(loadGroupName); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public List getLoadGroup(String name) throws DeploymentException { List group = (List) loadGroups.get(name); if(group == null) { throw new DeploymentException("Unknown load group: name=" + name); } return group; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public static JDBCTypeMappingMetaData obtainTypeMappingFromLibrary(String dataSourceName) throws DeploymentException { JDBCTypeMappingMetaData typeMapping = null; String datasource; if(dataSourceName.startsWith("java:")) { datasource = dataSourceName.substring("java:".length()); if(datasource.startsWith("/")) { datasource = datasource.substring(1); } } else { datasource = dataSourceName; } final ObjectName metadataService; final String str = "jboss.jdbc:service=metadata,datasource=" + datasource; try { metadataService = new ObjectName(str); } catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); } try { final MBeanServer server = MBeanServerLocator.locateJBoss(); if(server.isRegistered(metadataService)) { typeMapping = (JDBCTypeMappingMetaData)server.getAttribute(metadataService, "TypeMappingMetaData"); } } catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); } /* if(typeMapping == null) { throw new DeploymentException( "type-mapping for datasource " + datasource + " not found in the library. " + "Check the value of metadata/type-mapping in the -ds.xml file." ); } */ return typeMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
private static byte readCheckDirtyAfterGet(Element element, byte defaultValue) throws DeploymentException { byte checkDirtyAfterGet; String dirtyAfterGetStr = MetaData.getOptionalChildContent(element, "check-dirty-after-get"); if(dirtyAfterGetStr == null) { checkDirtyAfterGet = defaultValue; } else { checkDirtyAfterGet = (Boolean.valueOf(dirtyAfterGetStr).booleanValue() ? CHECK_DIRTY_AFTER_GET_TRUE : CHECK_DIRTY_AFTER_GET_FALSE); } return checkDirtyAfterGet; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
public static byte readCheckDirtyAfterGet(Element element) throws DeploymentException { return readCheckDirtyAfterGet(element, CHECK_DIRTY_AFTER_GET_NOT_PRESENT); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
private Class loadFieldType(JDBCEntityMetaData entity, String fieldName) throws DeploymentException { if(entity.isCMP1x()) { // CMP 1.x field Style try { return entity.getEntityClass().getField(fieldName).getType(); } catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); } } else { // CMP 2.x abstract accessor style String baseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getName = "get" + baseName; String setName = "set" + baseName; Method[] methods = entity.getEntityClass().getMethods(); for(int i = 0; i < methods.length; i++) { // is this a public abstract method? if(Modifier.isPublic(methods[i].getModifiers()) && Modifier.isAbstract(methods[i].getModifiers())) { // get accessor if(getName.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 0 && !methods[i].getReturnType().equals(Void.TYPE)) { return methods[i].getReturnType(); } // set accessor if(setName.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 1 && methods[i].getReturnType().equals(Void.TYPE)) { return methods[i].getParameterTypes()[0]; } } } throw new DeploymentException("No abstract accessors for field " + "named '" + fieldName + "' found in entity class " + entity.getEntityClass().getName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
public JDBCApplicationMetaData load() throws DeploymentException { JDBCApplicationMetaData jamd = new JDBCApplicationMetaData( container.getBeanMetaData().getApplicationMetaData(), container.getClassLoader() ); // Load standardjbosscmp-jdbc.xml from the default classLoader // we always load defaults first URL stdJDBCUrl = container.getClassLoader().getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if (debug) log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); // first create the metadata jamd = new JDBCApplicationMetaData(stdJDBCElement, jamd); // Load jbosscmp-jdbc.xml if provided URL jdbcUrl = null; VirtualFile dd = container.getDeploymentUnit().getMetaDataFile("jbosscmp-jdbc.xml"); if(dd != null) { try { jdbcUrl = dd.toURL(); } catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); } } if(jdbcUrl != null) { if (debug) log.debug(jdbcUrl.toString() + " found. Overriding defaults"); Element jdbcElement = XmlFileLoader.getDocument(jdbcUrl, true).getDocumentElement(); jamd = new JDBCApplicationMetaData(jdbcElement, jamd); } return jamd; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
private JDBCCMPFieldMetaData constructLockingField( JDBCEntityMetaData entity, Element element) throws DeploymentException { // field name String fieldName = MetaData.getOptionalChildContent(element, "field-name"); if(fieldName == null || fieldName.trim().length() < 1) fieldName = (lockingStrategy == VERSION_COLUMN_STRATEGY ? "version_lock" : (lockingStrategy == TIMESTAMP_COLUMN_STRATEGY ? "timestamp_lock" : "generated_lock")); // column name String columnName = MetaData.getOptionalChildContent(element, "column-name"); if(columnName == null || columnName.trim().length() < 1) columnName = (lockingStrategy == VERSION_COLUMN_STRATEGY ? "version_lock" : (lockingStrategy == TIMESTAMP_COLUMN_STRATEGY ? "timestamp_lock" : "generated_lock")); // field type Class fieldType = null; if(lockingStrategy == VERSION_COLUMN_STRATEGY) fieldType = java.lang.Long.class; else if(lockingStrategy == TIMESTAMP_COLUMN_STRATEGY) fieldType = java.util.Date.class; String fieldTypeStr = MetaData.getOptionalChildContent(element, "field-type"); if(fieldTypeStr != null) { try { fieldType = GetTCLAction. getContextClassLoader().loadClass(fieldTypeStr); } catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); } } // JDBC/SQL Type int jdbcType; String sqlType; String jdbcTypeName = MetaData.getOptionalChildContent(element, "jdbc-type"); if(jdbcTypeName != null) { jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcTypeName); sqlType = MetaData.getUniqueChildContent(element, "sql-type"); } else { jdbcType = Integer.MIN_VALUE; sqlType = null; } return new JDBCCMPFieldMetaData( entity, fieldName, fieldType, columnName, jdbcType, sqlType ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCMappingMetaData.java
public static int getJdbcTypeFromName(String name) throws DeploymentException { if(name == null) { throw new DeploymentException("jdbc-type cannot be null"); } try { Integer constant = (Integer)Types.class.getField(name).get(null); return constant.intValue(); } catch(Exception e) { log.warn("Unrecognized jdbc-type: " + name + ", using Types.OTHER", e); return Types.OTHER; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
private static JDBCCMPFieldMetaData constructAuditField( JDBCEntityMetaData entity, Element element, String defaultName) throws DeploymentException { // field name String fieldName = MetaData.getOptionalChildContent(element, "field-name"); if (fieldName == null || fieldName.trim().length() < 1) fieldName = defaultName; // column name String columnName = MetaData.getOptionalChildContent(element, "column-name"); if (columnName == null || columnName.trim().length() < 1) columnName = defaultName; // field type Class fieldType; String fieldTypeStr = MetaData.getOptionalChildContent(element, "field-type"); if (fieldTypeStr != null) { try { fieldType = GetTCLAction.getContextClassLoader().loadClass(fieldTypeStr); } catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); } } else { if (defaultName.endsWith("by")) fieldType = String.class; else fieldType = java.util.Date.class; } // JDBC/SQL Type int jdbcType; String sqlType; String jdbcTypeName = MetaData.getOptionalChildContent(element, "jdbc-type"); if (jdbcTypeName != null) { jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcTypeName); sqlType = MetaData.getUniqueChildContent(element, "sql-type"); } else { jdbcType = Integer.MIN_VALUE; sqlType = null; } // Is the field exposed? JDBCCMPFieldMetaData result = entity.getCMPFieldByName(fieldName); if (result == null) result = new JDBCCMPFieldMetaData(entity, fieldName, fieldType, columnName, jdbcType, sqlType); return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
private void initFromString(String sql) throws DeploymentException { ArrayList chunkList = new ArrayList(); ArrayList parameterList = new ArrayList(); // add a dummy chunk so we can be assured that the sql started with chunk before a number if(sql.charAt(0) == '?') { chunkList.add(""); } // break the sql into chunks and parameters StringBuffer chunk = new StringBuffer(); StringReader reader = new StringReader(sql); try { for(int c = reader.read(); c >= 0; c = reader.read()) { if(c != '?') { chunk.append((char)c); } else { chunkList.add(chunk.toString()); chunk = new StringBuffer(); // read the number StringBuffer number = new StringBuffer(); for(int digit = reader.read(); digit >= 0; digit = reader.read()) { if(Character.isDigit((char)digit)) { number.append((char)digit); } else { if(digit >= 0) { chunk.append((char)digit); } break; } } if(number.length() == 0) { throw new DeploymentException("Invalid parameter in function-sql: " + sql); } Integer parameter; try { parameter = new Integer(number.toString()); } catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); } parameterList.add(parameter); } } } catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); } chunkList.add(chunk.toString()); // save out the chunks sqlChunks = new String[chunkList.size()]; chunkList.toArray(sqlChunks); // save out the parameter order parameters = new int[parameterList.size()]; for(int i = 0; i < parameters.length; i++) { parameters[i] = ((Integer)parameterList.get(i)).intValue() - 1; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
public Map createJDBCQueryMetaData(QueryMetaData queryData) throws DeploymentException { Method[] methods = getQueryMethods(queryData); Map queries = new HashMap(methods.length); for(int i = 0; i < methods.length; i++) { queries.put( methods[i], new JDBCQlQueryMetaData(queryData, methods[i], entity.getQLCompiler(), false) ); } return queries; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
public Map createJDBCQueryMetaData(Element queryElement, Map defaultValues, JDBCReadAheadMetaData readAhead) throws DeploymentException { // get the query methods Method[] methods = getQueryMethods(queryElement); // read-ahead Element readAheadElement = MetaData.getOptionalChild(queryElement, "read-ahead"); if(readAheadElement != null) { readAhead = new JDBCReadAheadMetaData(readAheadElement, readAhead); } Map queries = new HashMap(methods.length); for(int i = 0; i < methods.length; i++) { JDBCQueryMetaData defaultValue = (JDBCQueryMetaData) defaultValues.get(methods[i]); if(defaultValue == null && !entity.isCMP1x() && !methods[i].getName().equals("findByPrimaryKey")) { //throw new DeploymentException("Unknown query method : " + methods[i]); log.warn("The query method is not defined in ejb-jar.xml: " + methods[i]); } JDBCQueryMetaData jdbcQueryData = createJDBCQueryMetaData( defaultValue, queryElement, methods[i], readAhead ); queries.put(methods[i], jdbcQueryData); } return queries; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
public static JDBCQueryMetaData createJDBCQueryMetaData(JDBCQueryMetaData jdbcQueryMetaData, JDBCReadAheadMetaData readAhead, Class qlCompiler) throws DeploymentException { // RAW-SQL if(jdbcQueryMetaData instanceof JDBCRawSqlQueryMetaData) { return new JDBCRawSqlQueryMetaData(jdbcQueryMetaData.getMethod(), qlCompiler, false); } // JBOSS-QL if(jdbcQueryMetaData instanceof JDBCJBossQLQueryMetaData) { return new JDBCJBossQLQueryMetaData( (JDBCJBossQLQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // DYNAMIC-SQL if(jdbcQueryMetaData instanceof JDBCDynamicQLQueryMetaData) { return new JDBCDynamicQLQueryMetaData( (JDBCDynamicQLQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // DECLARED-SQL if(jdbcQueryMetaData instanceof JDBCDeclaredQueryMetaData) { return new JDBCDeclaredQueryMetaData( (JDBCDeclaredQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // EJB-QL: default if(jdbcQueryMetaData instanceof JDBCQlQueryMetaData) { return new JDBCQlQueryMetaData( (JDBCQlQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } throw new DeploymentException( "Error in query specification for method " + jdbcQueryMetaData.getMethod().getName() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private JDBCQueryMetaData createJDBCQueryMetaData(JDBCQueryMetaData jdbcQueryMetaData, Element queryElement, Method method, JDBCReadAheadMetaData readAhead) throws DeploymentException { final Class qlCompiler = JDBCQueryManager.getQLCompiler(queryElement, entity); final boolean isResultTypeMappingLocal = (jdbcQueryMetaData == null ? false : jdbcQueryMetaData.isResultTypeMappingLocal()); final boolean lazyResultSetLoading = Collection.class.isAssignableFrom(method.getReturnType()) && MetaData.getOptionalChildBooleanContent(queryElement, "lazy-resultset-loading"); // RAW-SQL Element rawSql = MetaData.getOptionalChild(queryElement, "raw-sql"); if(rawSql != null) { return new JDBCRawSqlQueryMetaData(method, qlCompiler, lazyResultSetLoading); } // JBOSS-QL Element jbossQL = MetaData.getOptionalChild(queryElement, "jboss-ql"); if(jbossQL != null) { return new JDBCJBossQLQueryMetaData( isResultTypeMappingLocal, jbossQL, method, readAhead, qlCompiler, lazyResultSetLoading ); } // DYNAMIC-SQL Element dynamicQL = MetaData.getOptionalChild(queryElement, "dynamic-ql"); if(dynamicQL != null) { return new JDBCDynamicQLQueryMetaData(isResultTypeMappingLocal, method, readAhead, qlCompiler, lazyResultSetLoading); } // DECLARED-SQL Element delcaredSql = MetaData.getOptionalChild(queryElement, "declared-sql"); if(delcaredSql != null) { return new JDBCDeclaredQueryMetaData( isResultTypeMappingLocal, delcaredSql, method, readAhead, qlCompiler, lazyResultSetLoading ); } // EJB-QL: default if(jdbcQueryMetaData instanceof JDBCQlQueryMetaData) { return new JDBCQlQueryMetaData( (JDBCQlQueryMetaData) jdbcQueryMetaData, method, readAhead ); } throw new DeploymentException("Error in query specification for method " + method.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(Element queryElement) throws DeploymentException { // query-method sub-element Element queryMethod = MetaData.getUniqueChild(queryElement, "query-method"); // method name String methodName = MetaData.getUniqueChildContent(queryMethod, "method-name"); // method params ArrayList methodParams = new ArrayList(); Element methodParamsElement = MetaData.getUniqueChild(queryMethod, "method-params"); Iterator iterator = MetaData.getChildrenByTagName(methodParamsElement, "method-param"); while(iterator.hasNext()) { methodParams.add(MetaData.getElementContent((Element) iterator.next())); } try { Class[] parameters = Classes.convertToJavaClasses(methodParams.iterator(), entity.getClassLoader()); return getQueryMethods(methodName, parameters); } catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(QueryMetaData queryData) throws DeploymentException { String methodName = queryData.getMethodName(); try { Class[] parameters = Classes.convertToJavaClasses(queryData.getMethodParams(), entity.getClassLoader()); return getQueryMethods(methodName, parameters); } catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(String methodName, Class parameters[]) throws DeploymentException { // find the query and load the xml ArrayList methods = new ArrayList(2); if(methodName.startsWith("ejbSelect")) { // bean method Method method = getQueryMethod(methodName, parameters, entity.getEntityClass()); if(method != null) { methods.add(method); } } else { // remote home Class homeClass = entity.getHomeClass(); if(homeClass != null) { Method method = getQueryMethod(methodName, parameters, homeClass); if(method != null) { methods.add(method); } } // local home Class localHomeClass = entity.getLocalHomeClass(); if(localHomeClass != null) { Method method = getQueryMethod(methodName, parameters, localHomeClass); if(method != null) { methods.add(method); } } } if(methods.size() == 0) { StringBuffer sb = new StringBuffer(300); sb.append("Query method not found: ") .append(methodName).append('('); for(int i = 0; i < parameters.length; i++) { if(i > 0) { sb.append(','); } sb.append(parameters[i].getName()); } sb.append(')'); throw new DeploymentException(sb.toString()); } return (Method[]) methods.toArray(new Method[methods.size()]); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); // if no exception processor is defined, we will perform a existance // check before trying the insert to report duplicate key if(exceptionProcessor == null) { initExistsSQL(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected void setSelectEntity(JDBCEntityBridge selectEntity) throws DeploymentException { if(queryMetaData.getMethod().getName().startsWith("find") && this.selectEntity != null && this.selectEntity != selectEntity) { throw new DeploymentException("Finder " + queryMetaData.getMethod().getName() + " defined on " + this.selectEntity.getEntityName() + " should return only instances of " + this.selectEntity.getEntityName() + " but the query results in instances of " + selectEntity.getEntityName()); } this.selectField = null; this.selectFunction = null; this.selectEntity = selectEntity; this.selectManager = (JDBCStoreManager) selectEntity.getManager(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected String parseParameters(String sql) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); ArrayList params = new ArrayList(); // Replace placeholders {0} with ? if(sql != null) { sql = sql.trim(); StringTokenizer tokens = new StringTokenizer(sql, "{}", true); while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); if(token.equals("{")) { token = tokens.nextToken(); if(Character.isDigit(token.charAt(0))) { QueryParameter parameter = new QueryParameter(selectManager, queryMetaData.getMethod(), token); // of if we are here we can assume that we have // a parameter and not a function sqlBuf.append("?"); params.add(parameter); if(!tokens.nextToken().equals("}")) { throw new DeploymentException("Invalid parameter - missing closing '}' : " + sql); } } else { // ok we don't have a parameter, we have a function // push the tokens on the buffer and continue sqlBuf.append("{").append(token); } } else { // not parameter... just append it sqlBuf.append(token); } } } parameters = params; return sqlBuf.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public static List getLeftJoinCMRNodes(JDBCEntityBridge entity, String path, Iterator leftJoinIter, Set declaredPaths) throws DeploymentException { List leftJoinCMRNodes; if(leftJoinIter.hasNext()) { leftJoinCMRNodes = new ArrayList(); while(leftJoinIter.hasNext()) { JDBCLeftJoinMetaData leftJoin = (JDBCLeftJoinMetaData) leftJoinIter.next(); JDBCCMRFieldBridge cmrField = entity.getCMRFieldByName(leftJoin.getCmrField()); if(cmrField == null) { throw new DeploymentException("cmr-field in left-join was not found: cmr-field=" + leftJoin.getCmrField() + ", entity=" + entity.getEntityName()); } List subNodes; JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity(); String childPath = path + '.' + cmrField.getFieldName(); if(declaredPaths != null) { declaredPaths.add(childPath); } subNodes = getLeftJoinCMRNodes(relatedEntity, childPath, leftJoin.getLeftJoins(), declaredPaths); boolean[] mask = relatedEntity.getLoadGroupMask(leftJoin.getEagerLoadGroup()); LeftJoinCMRNode node = new LeftJoinCMRNode(childPath, cmrField, mask, subNodes); leftJoinCMRNodes.add(node); } } else { leftJoinCMRNodes = Collections.EMPTY_LIST; } return leftJoinCMRNodes; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public static final CMPFieldStateFactory getCMPFieldStateFactory(JDBCTypeFactory factory, String implClassName, Class clazz) throws DeploymentException { CMPFieldStateFactory stateFactory; // if the state factory is not provided on the field level use the one from the user type mapping if any if(implClassName == null) { JDBCUserTypeMappingMetaData userMapping = (JDBCUserTypeMappingMetaData)factory.userTypeMappings.get(clazz.getName()); if(userMapping != null) { implClassName = userMapping.getStateFactory(); } } if(implClassName != null) { try { Class implClass = TCLAction.UTIL.getContextClassLoader().loadClass(implClassName); stateFactory = (CMPFieldStateFactory)implClass.newInstance(); } catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); } catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); } } else if(Map.class.isAssignableFrom(clazz)) { stateFactory = MAP; } else if(List.class.isAssignableFrom(clazz)) { stateFactory = LIST; } else if(Set.class.isAssignableFrom(clazz)) { stateFactory = SET; } else if(clazz.isArray()) { stateFactory = ARRAY; } else if(usedWithEqualsStateFactory(clazz)) { stateFactory = EQUALS; } else { stateFactory = INVALID_UNLESS_NULL; } return stateFactory; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public JDBCType getJDBCType(JDBCCMPFieldMetaData cmpField) throws DeploymentException { JDBCType fieldJDBCType; final Class fieldType = cmpField.getFieldType(); if(complexTypes.containsKey(fieldType)) { fieldJDBCType = createTypeComplex(cmpField); } else { fieldJDBCType = createTypeSimple(cmpField); } return fieldJDBCType; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private JDBCTypeSimple createTypeSimple(JDBCCMPFieldMetaData cmpField) throws DeploymentException { String columnName = cmpField.getColumnName(); Class javaType = cmpField.getFieldType(); JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType); String paramSetter = typeMappingMD.getParamSetter(); String resultReader = typeMappingMD.getResultReader(); int jdbcType; String sqlType = cmpField.getSQLType(); if(sqlType != null) { jdbcType = cmpField.getJDBCType(); } else { // get jdbcType and sqlType from typeMapping sqlType = typeMappingMD.getSqlType(); jdbcType = typeMappingMD.getJdbcType(); } boolean notNull = cmpField.isNotNull(); boolean autoIncrement = cmpField.isAutoIncrement(); Mapper mapper = null; JDBCUserTypeMappingMetaData userTypeMapping = (JDBCUserTypeMappingMetaData)userTypeMappings.get(javaType.getName()); if(userTypeMapping != null) { String mappedTypeStr = userTypeMapping.getMappedType(); try { final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader(); Class mapperClass = contextClassLoader.loadClass(userTypeMapping.getMapper()); mapper = (Mapper)mapperClass.newInstance(); javaType = contextClassLoader.loadClass(mappedTypeStr); if(cmpField.getSQLType() == null) { JDBCMappingMetaData mappingMD = typeMapping.getTypeMappingMetaData(javaType); sqlType = mappingMD.getSqlType(); jdbcType = mappingMD.getJdbcType(); paramSetter = mappingMD.getParamSetter(); resultReader = mappingMD.getResultReader(); } } catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); } catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); } } JDBCParameterSetter paramSetterImpl; if(paramSetter == null) { paramSetterImpl = JDBCUtil.getParameterSetter(jdbcType, javaType); } else { paramSetterImpl = (JDBCParameterSetter)newInstance(paramSetter); } JDBCResultSetReader resultReaderImpl; if(resultReader == null) { resultReaderImpl = JDBCUtil.getResultSetReader(jdbcType, javaType); } else { resultReaderImpl = (JDBCResultSetReader)newInstance(resultReader); } return new JDBCTypeSimple( columnName, javaType, jdbcType, sqlType, notNull, autoIncrement, mapper, paramSetterImpl, resultReaderImpl ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private Object newInstance(String className) throws DeploymentException { Class clazz = loadClass(className); try { return clazz.newInstance(); } catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private Class loadClass(String className) throws DeploymentException { try { final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader(); return contextClassLoader.loadClass(className); } catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCreateBeanClassInstanceCommand.java
private Map createFieldMap() throws DeploymentException { Map abstractAccessors = getAbstractAccessors(); List fields = entityBridge.getFields(); Map map = new HashMap(fields.size() * 2); for(int i = 0; i < fields.size(); i++) { FieldBridge field = (FieldBridge) fields.get(i); // get the names String fieldName = field.getFieldName(); String fieldBaseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getterName = "get" + fieldBaseName; String setterName = "set" + fieldBaseName; // get the accessor methods Method getterMethod = (Method) abstractAccessors.get(getterName); Method setterMethod = (Method) abstractAccessors.get(setterName); // getters and setters must come in pairs if(getterMethod != null && setterMethod == null) { throw new DeploymentException("Getter was found but no setter was found for field " + fieldName + " in entity " + entityBridge.getEntityName()); } else if(getterMethod == null && setterMethod != null) { throw new DeploymentException("Setter was found but no getter was found for field " + fieldName + " in entity " + entityBridge.getEntityName()); } else if(getterMethod != null && setterMethod != null) { // add methods map.put(getterMethod.getName(), new EntityBridgeInvocationHandler.FieldGetInvoker(field)); map.put(setterMethod.getName(), new EntityBridgeInvocationHandler.FieldSetInvoker(field)); // remove the accessors (they have been used) abstractAccessors.remove(getterName); abstractAccessors.remove(setterName); } } return Collections.unmodifiableMap(map); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
public void execute() throws DeploymentException { Set existedTables = getExistedTables(manager); boolean tableExisted = SQLUtil.tableExists(entity.getQualifiedTableName(), entity.getDataSource()); if(tableExisted) { existedTables.add(entity.getEntityName()); } if(tableExisted) { if(entityMetaData.getAlterTable()) { SQLUtil.OldColumns oldColumns = SQLUtil.getOldColumns(entity.getQualifiedTableName(), entity.getDataSource()); ArrayList oldNames = oldColumns.getColumnNames(); ArrayList oldTypes = oldColumns.getTypeNames(); ArrayList oldSizes = oldColumns.getColumnSizes(); SQLUtil.OldIndexes oldIndexes = null; ArrayList newNames = new ArrayList(); JDBCFieldBridge fields[] = entity.getTableFields(); String tableName = entity.getQualifiedTableName(); for(int i = 0; i < fields.length; i++) { JDBCFieldBridge field = fields[i]; JDBCType jdbcType = field.getJDBCType(); String[] columnNames = jdbcType.getColumnNames(); String[] sqlTypes = jdbcType.getSQLTypes(); boolean[] notNull = jdbcType.getNotNull(); for(int j = 0; j < columnNames.length; j++) { String name = columnNames[j]; String ucName = name.toUpperCase(); newNames.add( ucName ); int oldIndex = oldNames.indexOf( ucName ); if(oldIndex == -1) { // add new column StringBuffer buf = new StringBuffer( sqlTypes[j] ); if( notNull[j] ) { buf.append(SQLUtil.NOT).append(SQLUtil.NULL); } alterTable(entity.getDataSource(), entityMetaData.getTypeMapping().getAddColumnTemplate(), tableName, name, buf.toString()); } else { // alter existing columns // only CHAR and VARCHAR fields are altered, and only when they are longer then before String type = (String) oldTypes.get(oldIndex); if(type.equals("CHAR") || type.equals("VARCHAR")) { try { // get new length String l = sqlTypes[j]; l = l.substring(l.indexOf('(') + 1, l.length() - 1); Integer oldLength = (Integer) oldSizes.get(oldIndex); if(Integer.parseInt(l) > oldLength.intValue()) { alterTable(entity.getDataSource(), entityMetaData.getTypeMapping().getAlterColumnTemplate(), tableName, name, sqlTypes[j] ); } } catch(Exception e) { log.warn("EXCEPTION ALTER :" + e.toString()); } } } } // see if we have to add an index for the field JDBCCMPFieldMetaData fieldMD = entity.getMetaData().getCMPFieldByName(field.getFieldName()); if(fieldMD != null && fieldMD.isIndexed()) { if(oldIndexes == null) { oldIndexes = SQLUtil.getOldIndexes(entity.getQualifiedTableName(), entity.getDataSource()); idxCount = oldIndexes.getIndexNames().size(); } if(!hasIndex(oldIndexes, field)) { createCMPIndex( entity.getDataSource(), field, oldIndexes.getIndexNames() ); } } } // for int i; // delete old columns Iterator it = oldNames.iterator(); while(it.hasNext()) { String name = (String) (it.next()); if(!newNames.contains(name)) { alterTable(entity.getDataSource(), entityMetaData.getTypeMapping().getDropColumnTemplate(), tableName, name, ""); } } } } // Create table if necessary Set createdTables = getCreatedTables(manager); if(entityMetaData.getCreateTable() && !createdTables.contains(entity.getEntityName())) { DataSource dataSource = entity.getDataSource(); createTable(dataSource, entity.getQualifiedTableName(), getEntityCreateTableSQL(dataSource)); // create indices only if table did not yet exist. if(!tableExisted) { createCMPIndices( dataSource, SQLUtil.getOldIndexes( entity.getQualifiedTableName(), entity.getDataSource() ).getIndexNames() ); } else { if(log.isDebugEnabled()) { log.debug("Indices for table " + entity.getQualifiedTableName() + "not created as table existed"); } } // issue extra (user-defined) sql for table if(!tableExisted) { issuePostCreateSQL(dataSource, entity.getMetaData().getDefaultTablePostCreateCmd(), entity.getQualifiedTableName()); } createdTables.add(entity.getEntityName()); } else { log.debug("Table not create as requested: " + entity.getQualifiedTableName()); } // create relation tables JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCAbstractCMRFieldBridge cmrField = cmrFields[i]; JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData(); DataSource dataSource = relationMetaData.getDataSource(); // if the table for the related entity has been created final EntityBridge relatedEntity = cmrField.getRelatedEntity(); if(relationMetaData.isTableMappingStyle() && createdTables.contains(relatedEntity.getEntityName())) { boolean relTableExisted = SQLUtil.tableExists(cmrField.getQualifiedTableName(), entity.getDataSource()); if(relTableExisted) { if(relationMetaData.getAlterTable()) { ArrayList oldNames = SQLUtil.getOldColumns(cmrField.getQualifiedTableName(), dataSource).getColumnNames(); ArrayList newNames = new ArrayList(); JDBCFieldBridge[] leftKeys = cmrField.getTableKeyFields(); JDBCFieldBridge[] rightKeys = cmrField.getRelatedCMRField().getTableKeyFields(); JDBCFieldBridge[] fields = new JDBCFieldBridge[leftKeys.length + rightKeys.length]; System.arraycopy(leftKeys, 0, fields, 0, leftKeys.length); System.arraycopy(rightKeys, 0, fields, leftKeys.length, rightKeys.length); // have to append field names to leftKeys, rightKeys... boolean different = false; for(int j = 0; j < fields.length; j++) { JDBCFieldBridge field = fields[j]; String name = field.getJDBCType().getColumnNames()[0].toUpperCase(); newNames.add(name); if(!oldNames.contains(name)) { different = true; break; } } // for int j; if(!different) { Iterator it = oldNames.iterator(); while(it.hasNext()) { String name = (String) (it.next()); if(!newNames.contains(name)) { different = true; break; } } } if(different) { // only log, don't drop table is this can cause data loss log.error("CMR table structure is incorrect for " + cmrField.getQualifiedTableName()); //SQLUtil.dropTable(entity.getDataSource(), cmrField.getQualifiedTableName()); } } // if alter-table } // if existed // create the relation table if(relationMetaData.isTableMappingStyle() && !relationMetaData.isTableCreated()) { if(relationMetaData.getCreateTable()) { createTable(dataSource, cmrField.getQualifiedTableName(), getRelationCreateTableSQL(cmrField, dataSource)); } else { log.debug("Relation table not created as requested: " + cmrField.getQualifiedTableName()); } // create Indices if needed createCMRIndex(dataSource, cmrField); if(relationMetaData.getCreateTable()) { issuePostCreateSQL(dataSource, relationMetaData.getDefaultTablePostCreateCmd(), cmrField.getQualifiedTableName()); } } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
public void addForeignKeyConstraints() throws DeploymentException { Set createdTables = getCreatedTables(manager); JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCAbstractCMRFieldBridge cmrField = cmrFields[i]; EntityBridge relatedEntity = cmrField.getRelatedEntity(); JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData(); if(relationMetaData.isForeignKeyMappingStyle() && (createdTables.contains(relatedEntity.getEntityName()))) { createCMRIndex(((JDBCAbstractEntityBridge)relatedEntity).getDataSource(), cmrField); } // Create fk constraint addForeignKeyConstraint(cmrField); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void alterTable(DataSource dataSource, JDBCFunctionMappingMetaData mapping, String tableName, String fieldName, String fieldStructure) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); mapping.getFunctionSql( new String[]{tableName, fieldName, fieldStructure}, sqlBuf ); String sql = sqlBuf.toString(); if(log.isDebugEnabled()) log.debug("Executing: " + sql); // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); } try { Connection con = null; Statement statement = null; try { con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); } } // success if ( log.isDebugEnabled() ) log.debug("Table altered successfully."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createTable(DataSource dataSource, String tableName, String sql) throws DeploymentException { // does this table already exist if(SQLUtil.tableExists(tableName, dataSource)) { log.debug("Table '" + tableName + "' already exists"); return; } // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); } try { Connection con = null; Statement statement = null; try { // execute sql if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } // success Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); createdTables.add(tableName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createIndex(DataSource dataSource, String tableName, String indexName, String sql) throws DeploymentException { // we are only called directly after creating a table // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); } try { Connection con = null; Statement statement = null; try { // execute sql if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void issuePostCreateSQL(DataSource dataSource, List sql, String table) throws DeploymentException { if(sql == null) { // no work to do. log.trace("issuePostCreateSQL: sql is null"); return; } log.debug("issuePostCreateSQL::sql: " + sql.toString() + " on table " + table); TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); } String currentCmd = ""; try { Connection con = null; Statement statement = null; try { con = dataSource.getConnection(); statement = con.createStatement(); // execute sql for(int i = 0; i < sql.size(); i++) { currentCmd = (String) sql.get(i); /* * Replace %%t in the sql command with the current table name */ currentCmd = replaceTable(currentCmd, table); currentCmd = replaceIndexCounter(currentCmd); log.debug("Executing SQL: " + currentCmd); statement.executeUpdate(currentCmd); } } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } } // success log.debug("Issued SQL " + sql + " successfully."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private String getEntityCreateTableSQL(DataSource dataSource) throws DeploymentException { StringBuffer sql = new StringBuffer(); sql.append(SQLUtil.CREATE_TABLE).append(entity.getQualifiedTableName()).append(" ("); // add fields boolean comma = false; JDBCFieldBridge[] fields = entity.getTableFields(); for(int i = 0; i < fields.length; ++i) { JDBCFieldBridge field = fields[i]; JDBCType type = field.getJDBCType(); if(comma) { sql.append(SQLUtil.COMMA); } else { comma = true; } addField(type, sql); } // add a pk constraint if(entityMetaData.hasPrimaryKeyConstraint()) { JDBCFunctionMappingMetaData pkConstraint = manager.getMetaData().getTypeMapping().getPkConstraintTemplate(); if(pkConstraint == null) { throw new IllegalStateException("Primary key constraint is " + "not allowed for this type of data source"); } String defTableName = entity.getManager().getMetaData().getDefaultTableName(); String name = "pk_" + SQLUtil.unquote(defTableName, dataSource); name = SQLUtil.fixConstraintName(name, dataSource); String[] args = new String[]{ name, SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), new StringBuffer(100)).toString() }; sql.append(SQLUtil.COMMA); pkConstraint.getFunctionSql(args, sql); } return sql.append(')').toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createCMPIndices(DataSource dataSource, ArrayList indexNames) throws DeploymentException { // Only create indices on CMP fields JDBCFieldBridge[] cmpFields = entity.getTableFields(); for(int i = 0; i < cmpFields.length; ++i) { JDBCFieldBridge field = cmpFields[i]; JDBCCMPFieldMetaData fieldMD = entity.getMetaData().getCMPFieldByName(field.getFieldName()); if(fieldMD != null && fieldMD.isIndexed()) { createCMPIndex(dataSource, field, indexNames); } } final JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); if(cmrFields != null) { for(int i = 0; i < cmrFields.length; ++i) { JDBCAbstractCMRFieldBridge cmrField = cmrFields[i]; if(cmrField.getRelatedCMRField().getMetaData().isIndexed()) { final JDBCFieldBridge[] fkFields = cmrField.getForeignKeyFields(); if(fkFields != null) { for(int fkInd = 0; fkInd < fkFields.length; ++fkInd) { createCMPIndex(dataSource, fkFields[fkInd], indexNames); } } } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createCMPIndex(DataSource dataSource, JDBCFieldBridge field, ArrayList indexNames) throws DeploymentException { StringBuffer sql; log.debug("Creating index for field " + field.getFieldName()); sql = new StringBuffer(); sql.append(SQLUtil.CREATE_INDEX); String indexName; boolean indexExists; do { indexName = entity.getQualifiedTableName() + IDX_POSTFIX + idxCount; idxCount++; indexExists = false; if ( indexNames != null ) { for ( int i = 0 ; i < indexNames.size() && !indexExists ; i++ ) { indexExists = indexName.equalsIgnoreCase( ( (String) indexNames.get( i ) ) ); } } } while ( indexExists ); sql.append( indexName ); sql.append(SQLUtil.ON); sql.append(entity.getQualifiedTableName() + " ("); SQLUtil.getColumnNamesClause(field, sql); sql.append(")"); createIndex(dataSource, entity.getQualifiedTableName(), indexName, sql.toString()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createCMRIndex(DataSource dataSource, JDBCAbstractCMRFieldBridge field) throws DeploymentException { JDBCRelationMetaData rmd; String tableName; rmd = field.getMetaData().getRelationMetaData(); if(rmd.isTableMappingStyle()) { tableName = rmd.getDefaultTableName(); createFKIndex(rmd.getLeftRelationshipRole(), dataSource, tableName); createFKIndex(rmd.getRightRelationshipRole(), dataSource, tableName); } else if(field.hasForeignKey()) { tableName = field.getEntity().getQualifiedTableName(); createFKIndex(field.getRelatedCMRField().getMetaData(), dataSource, tableName); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createFKIndex(JDBCRelationshipRoleMetaData metadata, DataSource dataSource, String tableName) throws DeploymentException { Collection kfl = metadata.getKeyFields(); Iterator it = kfl.iterator(); while(it.hasNext()) { JDBCCMPFieldMetaData fi = (JDBCCMPFieldMetaData) it.next(); if(metadata.isIndexed()) { createIndex(dataSource, tableName, fi.getFieldName(), createIndexSQL(fi, tableName)); idxCount++; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addField(JDBCType type, StringBuffer sqlBuffer) throws DeploymentException { // apply auto-increment template if(type.getAutoIncrement()[0]) { String columnClause = SQLUtil.getCreateTableColumnsClause(type); JDBCFunctionMappingMetaData autoIncrement = manager.getMetaData().getTypeMapping().getAutoIncrementTemplate(); if(autoIncrement == null) { throw new IllegalStateException("auto-increment template not found"); } String[] args = new String[]{columnClause}; autoIncrement.getFunctionSql(args, sqlBuffer); } else { sqlBuffer.append(SQLUtil.getCreateTableColumnsClause(type)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private String getRelationCreateTableSQL(JDBCAbstractCMRFieldBridge cmrField, DataSource dataSource) throws DeploymentException { JDBCFieldBridge[] leftKeys = cmrField.getTableKeyFields(); JDBCFieldBridge[] rightKeys = cmrField.getRelatedCMRField().getTableKeyFields(); JDBCFieldBridge[] fieldsArr = new JDBCFieldBridge[leftKeys.length + rightKeys.length]; System.arraycopy(leftKeys, 0, fieldsArr, 0, leftKeys.length); System.arraycopy(rightKeys, 0, fieldsArr, leftKeys.length, rightKeys.length); StringBuffer sql = new StringBuffer(); sql.append(SQLUtil.CREATE_TABLE).append(cmrField.getQualifiedTableName()) .append(" (") // add field declaration .append(SQLUtil.getCreateTableColumnsClause(fieldsArr)); // add a pk constraint final JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData(); if(relationMetaData.hasPrimaryKeyConstraint()) { JDBCFunctionMappingMetaData pkConstraint = manager.getMetaData().getTypeMapping().getPkConstraintTemplate(); if(pkConstraint == null) { throw new IllegalStateException("Primary key constraint is not allowed for this type of data store"); } String name = "pk_" + relationMetaData.getDefaultTableName(); name = SQLUtil.fixConstraintName(name, dataSource); String[] args = new String[]{ name, SQLUtil.getColumnNamesClause(fieldsArr, new StringBuffer(100).toString(), new StringBuffer()).toString() }; sql.append(SQLUtil.COMMA); pkConstraint.getFunctionSql(args, sql); } sql.append(')'); return sql.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addForeignKeyConstraint(JDBCAbstractCMRFieldBridge cmrField) throws DeploymentException { JDBCRelationshipRoleMetaData metaData = cmrField.getMetaData(); if(metaData.hasForeignKeyConstraint()) { if(metaData.getRelationMetaData().isTableMappingStyle()) { addForeignKeyConstraint(metaData.getRelationMetaData().getDataSource(), cmrField.getQualifiedTableName(), cmrField.getFieldName(), cmrField.getTableKeyFields(), cmrField.getEntity().getQualifiedTableName(), cmrField.getEntity().getPrimaryKeyFields()); } else if(cmrField.hasForeignKey()) { JDBCAbstractEntityBridge relatedEntity = (JDBCAbstractEntityBridge) cmrField.getRelatedEntity(); addForeignKeyConstraint(cmrField.getEntity().getDataSource(), cmrField.getEntity().getQualifiedTableName(), cmrField.getFieldName(), cmrField.getForeignKeyFields(), relatedEntity.getQualifiedTableName(), relatedEntity.getPrimaryKeyFields()); } } else { log.debug("Foreign key constraint not added as requested: relationshipRolename=" + metaData.getRelationshipRoleName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addForeignKeyConstraint(DataSource dataSource, String tableName, String cmrFieldName, JDBCFieldBridge[] fields, String referencesTableName, JDBCFieldBridge[] referencesFields) throws DeploymentException { // can only alter tables we created Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); if(!createdTables.contains(tableName)) { return; } JDBCFunctionMappingMetaData fkConstraint = manager.getMetaData().getTypeMapping().getFkConstraintTemplate(); if(fkConstraint == null) { throw new IllegalStateException("Foreign key constraint is not allowed for this type of datastore"); } String a = SQLUtil.getColumnNamesClause(fields, new StringBuffer(50)).toString(); String b = SQLUtil.getColumnNamesClause(referencesFields, new StringBuffer(50)).toString(); String[] args = new String[]{ tableName, SQLUtil.fixConstraintName("fk_" + tableName + "_" + cmrFieldName, dataSource), a, referencesTableName, b}; String sql = fkConstraint.getFunctionSql(args, new StringBuffer(100)).toString(); // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); } try { Connection con = null; Statement statement = null; try { if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private JDBCEntityMetaData loadJDBCEntityMetaData() throws DeploymentException { ApplicationMetaData amd = container.getBeanMetaData().getApplicationMetaData(); // Get JDBC MetaData JDBCApplicationMetaData jamd = (JDBCApplicationMetaData)amd.getPluginData(CMP_JDBC); if(jamd == null) { // we are the first cmp entity to need jbosscmp-jdbc. // Load jbosscmp-jdbc.xml for the whole application JDBCXmlFileLoader jfl = new JDBCXmlFileLoader(container, log); jamd = jfl.load(); amd.addPluginData(CMP_JDBC, jamd); } // Get JDBC Bean MetaData String ejbName = container.getBeanMetaData().getEjbName(); JDBCEntityMetaData metadata = jamd.getBeanByEjbName(ejbName); if(metadata == null) { throw new DeploymentException("No metadata found for bean " + ejbName); } return metadata; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeclaredSQLQuery.java
private void initSelectObject(JDBCStoreManager manager) throws DeploymentException { String entityName = metadata.getEJBName(); // if no name is specified we are done if(entityName == null) { return; } Catalog catalog = manager.getCatalog(); JDBCEntityBridge entity = (JDBCEntityBridge)catalog.getEntityByEJBName(entityName); if(entity == null) { throw new DeploymentException("Unknown entity: " + entityName); } String fieldName = metadata.getFieldName(); if(fieldName == null) { setSelectEntity(entity); } else { JDBCCMPFieldBridge field = entity.getCMPFieldByName(fieldName); if(field == null) { throw new DeploymentException("Unknown cmp field: " + fieldName); } setSelectField(field); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
protected void initGeneratedFields() throws DeploymentException { super.initGeneratedFields(); pkField = getGeneratedPKField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createFindByPrimaryKeyQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCFindByPrimaryKeyQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createFindAllQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCFindAllQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createDeclaredSQLQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCDeclaredSQLQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createEJBQLQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCEJBQLQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createDynamicQLQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCDynamicQLQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createJBossQLQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCJBossQLQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createFindByQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCFindByQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCCreateCommand createCreateEntityCommand() throws DeploymentException { JDBCCreateCommand cec; try { cec = (JDBCCreateCommand)manager.getMetaData(). getEntityCommand().getCommandClass().newInstance(); cec.init(manager); } catch(DeploymentException de) { throw de; } catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); } if(log.isDebugEnabled()) log.debug("entity-command: " + manager.getMetaData().getEntityCommand()); return cec; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCRemoveEntityCommand createRemoveEntityCommand() throws DeploymentException { return new JDBCRemoveEntityCommand(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCLoadEntityCommand createLoadEntityCommand() throws DeploymentException { return new JDBCLoadEntityCommand(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public static final Class getQLCompiler(Element query, JDBCEntityMetaData entity) throws DeploymentException { String compiler = MetaData.getOptionalChildContent(query, "ql-compiler"); Class impl; if(compiler == null || compiler.trim().length() == 0) { impl = entity.getQLCompiler(); } else { try { impl = TCLAction.UTIL.getContextClassLoader().loadClass(compiler); } catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); } } return impl; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public static final QLCompiler getInstance(Class impl, Catalog catalog) throws DeploymentException { if(impl == null) { throw new DeploymentException("ql-compiler is not specified."); } final Constructor constructor; try { constructor = impl.getConstructor(new Class[]{Catalog.class}); } catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); } try { return (QLCompiler)constructor.newInstance(new Object[]{catalog}); } catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public void start() throws DeploymentException { Logger log = Logger.getLogger( this.getClass().getName() + "." + manager.getMetaData().getName()); JDBCCommandFactory factory = manager.getCommandFactory(); Class homeClass = manager.getContainer().getHomeClass(); Class localHomeClass = manager.getContainer().getLocalHomeClass(); // // findByPrimaryKey // JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge(); if(homeClass != null) { try { // try to get the finder method on the home interface Method method = homeClass.getMethod(FIND_BY_PK, new Class[]{entity.getPrimaryKeyClass()}); JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method); JDBCReadAheadMetaData readAhead = (findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead()); // got it add it to known finders JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData( method, readAhead, entity.getMetaData().getQLCompiler(), false ); knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q)); if(log.isDebugEnabled()) log.debug("Added findByPrimaryKey query command for home interface"); } catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); } } if(localHomeClass != null) { Method method; try { // try to get the finder method on the local home interface method = localHomeClass.getMethod(FIND_BY_PK, new Class[] { entity.getPrimaryKeyClass() }); } catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } // got it add it to known finders JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method); JDBCReadAheadMetaData readAhead = (findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead()); JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false); knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q)); if(log.isDebugEnabled()) log.debug("Added findByPrimaryKey query command for local home interface"); } // // Custom finders - Overrides defined and automatic finders. // Class ejbClass = manager.getMetaData().getEntityClass(); Method[] customMethods = ejbClass.getMethods(); for (int i = 0; i < customMethods.length; i++) { Method m = customMethods[i]; String methodName = m.getName(); if(methodName.startsWith(EJB_FIND)) { String interfaceName = 'f' + methodName.substring(4); if(homeClass != null) { try { // try to get the finder method on the home interface Method interfaceMethod = homeClass.getMethod( interfaceName, m.getParameterTypes()); // got it add it to known finders knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m)); if(log.isDebugEnabled()) log.debug("Added custom finder " + methodName + " on home interface"); } catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface } } if(localHomeClass != null) { try { // try to get the finder method on the local home interface Method interfaceMethod = localHomeClass.getMethod( interfaceName, m.getParameterTypes()); // got it add it to known finders knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m)); if(log.isDebugEnabled()) log.debug("Added custom finder " + methodName + " on local home interface"); } catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface } } } } // // Defined finders - Overrides automatic finders. // Iterator definedFinders = manager.getMetaData().getQueries().iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData q = (JDBCQueryMetaData)definedFinders.next(); if(!knownQueries.containsKey(q.getMethod()) ) { if(q instanceof JDBCJBossQLQueryMetaData) { knownQueries.put(q.getMethod(), factory.createJBossQLQuery(q)); } else if(q instanceof JDBCDynamicQLQueryMetaData) { knownQueries.put(q.getMethod(), factory.createDynamicQLQuery(q)); } else if(q instanceof JDBCDeclaredQueryMetaData) { knownQueries.put(q.getMethod(), factory.createDeclaredSQLQuery(q)); } else if(q instanceof JDBCQlQueryMetaData) { knownQueries.put(q.getMethod(), factory.createEJBQLQuery(q)); } } } // // Automatic finders - The last resort // if(homeClass != null) { addAutomaticFinders(manager, homeClass.getMethods(), log); } if(localHomeClass != null) { addAutomaticFinders(manager, localHomeClass.getMethods(), log); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
private void addAutomaticFinders( JDBCStoreManager manager, Method[] homeMethods, Logger log) throws DeploymentException { JDBCCommandFactory factory = manager.getCommandFactory(); JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge(); for (int i = 0; i < homeMethods.length; i++) { Method method = homeMethods[i]; if(!knownQueries.containsKey(method)) { String name = method.getName(); if(name.equals(FIND_ALL)) { JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData( method, entity.getMetaData().getReadAhead(), entity.getMetaData().getQLCompiler(), false ); knownQueries.put(method, factory.createFindAllQuery(q)); } else if(name.startsWith(FIND_BY) && !name.equals(FIND_BY_PK)) { try { JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData( method, entity.getMetaData().getReadAhead(), entity.getMetaData().getQLCompiler(), false); knownQueries.put(method, factory.createFindByQuery(q)); } catch (IllegalArgumentException e) { log.debug("Could not create the finder " + name + ", because no matching CMP field was found."); } } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String fixTableName(String tableName, DataSource dataSource) throws DeploymentException { // don't fix the quited table name char firstChar = tableName.charAt(0); if(firstChar == '"' || firstChar == '\'') { return tableName; } // Separate schema name and table name String strSchema = ""; int iIndex; if((iIndex = tableName.indexOf('.')) != -1) { strSchema = tableName.substring(0, iIndex); tableName = tableName.substring(iIndex + 1); } // check for SQL reserved word and escape it with prepending a "X" // IMHO one should reject reserved words and throw a // DeploymentException - pilhuhn if(rwords != null) { for(int i = 0; i < rwords.size(); i++) { if(((String)rwords.elementAt(i)).equalsIgnoreCase(tableName)) { tableName = "X" + tableName; break; } } } Connection con = null; try { con = dataSource.getConnection(); DatabaseMetaData dmd = con.getMetaData(); // fix length int maxLength = dmd.getMaxTableNameLength(); if(maxLength > 0 && tableName.length() > maxLength) { CRC32 crc = new CRC32(); crc.update(tableName.getBytes()); String nameCRC = Long.toString(crc.getValue(), 36); tableName = tableName.substring( 0, maxLength - nameCRC.length() - 2); tableName += "_" + nameCRC; } // fix case if(dmd.storesLowerCaseIdentifiers()) { tableName = tableName.toLowerCase(); } else if(dmd.storesUpperCaseIdentifiers()) { tableName = tableName.toUpperCase(); } // now put the schema name back on the table name if(strSchema.length() > 0) { tableName = strSchema + "." + tableName; } return tableName; } catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); } finally { JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String fixConstraintName(String name, DataSource dataSource) throws DeploymentException { return fixTableName(name, dataSource).replace('.', '_'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static boolean tableExists(String tableName, DataSource dataSource) throws DeploymentException { Connection con = null; ResultSet rs = null; try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; String quote = dmd.getIdentifierQuoteString(); if(tableName.startsWith(quote)) { if(tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); if(dmd.storesLowerCaseQuotedIdentifiers()) tableName = tableName.toLowerCase(); else if(dmd.storesUpperCaseQuotedIdentifiers()) tableName = tableName.toUpperCase(); } else { if(dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if(dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); } // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getTables(catalog, schema, tableName, null); return rs.next(); } catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static OldColumns getOldColumns(String tableName, DataSource dataSource) throws DeploymentException { Connection con = null; ResultSet rs = null; ArrayList columnNames = new ArrayList(); ArrayList typeNames = new ArrayList(); ArrayList columnSizes = new ArrayList(); try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; String quote = dmd.getIdentifierQuoteString(); if (tableName.startsWith(quote)) { if (tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); if (dmd.storesLowerCaseQuotedIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseQuotedIdentifiers()) tableName = tableName.toUpperCase(); } else { if (dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); } // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getColumns(catalog, schema, tableName, null); while (rs.next()) { String columnName = rs.getString("COLUMN_NAME"); columnNames.add(columnName == null ? null : columnName.toUpperCase()); typeNames.add(rs.getString("TYPE_NAME")); columnSizes.add(new Integer(rs.getInt("COLUMN_SIZE"))); } return new OldColumns(columnNames, typeNames, columnSizes); } catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static OldIndexes getOldIndexes(String tableName, DataSource dataSource) throws DeploymentException { tableName = unquote(tableName, dataSource); Connection con = null; ResultSet rs = null; ArrayList indexNames = new ArrayList(); ArrayList columnNames = new ArrayList(); ArrayList ascDesc = new ArrayList(); try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; if (dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getIndexInfo(catalog, schema, tableName, false, false); while (rs.next()) { indexNames.add(rs.getString("INDEX_NAME")); columnNames.add(rs.getString("COLUMN_NAME")); ascDesc.add(rs.getString("ASC_OR_DESC")); } return new OldIndexes(indexNames, columnNames, ascDesc); } catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String unquote(String tableName, DataSource ds) throws DeploymentException { Connection con = null; try { con = ds.getConnection(); String quote = con.getMetaData().getIdentifierQuoteString(); if (tableName.startsWith(quote)) { if (tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); } } catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); } finally { JDBCUtil.safeClose(con); } return tableName; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static void dropTable(DataSource dataSource, String tableName) throws DeploymentException { Logger log = Logger.getLogger("CLEANER"); String sql = "DROP TABLE " + tableName; try { Connection con = null; Statement statement = null; try { // execute sql con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); } log.info("Dropped table "+tableName+" succesfuly"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void init() throws DeploymentException { try { InitialContext ic = new InitialContext(); dataSource = (DataSource)ic.lookup(metadata.getDataSourceName()); } catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); } qualifiedTableName = SQLUtil.fixTableName(metadata.getDefaultTableName(), dataSource); int dotIndex = qualifiedTableName.indexOf('.'); tableName = dotIndex == -1 ? qualifiedTableName : qualifiedTableName.substring(dotIndex + 1); // CMP fields loadCMPFields(metadata); // CMR fields loadCMRFields(metadata); // create locking field JDBCOptimisticLockingMetaData lockMetaData = metadata.getOptimisticLocking(); if(lockMetaData != null && lockMetaData.getLockingField() != null) { Integer strategy = lockMetaData.getLockingStrategy(); JDBCCMPFieldMetaData versionMD = lockMetaData.getLockingField(); versionField = getCMPFieldByName(versionMD.getFieldName()); boolean hidden = versionField == null; if(strategy == JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCLongVersionFieldBridge(manager, versionMD); else versionField = new JDBCLongVersionFieldBridge((JDBCCMP2xFieldBridge)versionField); } else if(strategy == JDBCOptimisticLockingMetaData.TIMESTAMP_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCTimestampVersionFieldBridge(manager, versionMD); else versionField = new JDBCTimestampVersionFieldBridge((JDBCCMP2xFieldBridge)versionField); } else if(strategy == JDBCOptimisticLockingMetaData.KEYGENERATOR_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCKeyGenVersionFieldBridge( manager, versionMD, lockMetaData.getKeyGeneratorFactory()); else versionField = new JDBCKeyGenVersionFieldBridge( (JDBCCMP2xFieldBridge)versionField, lockMetaData.getKeyGeneratorFactory()); } if(hidden) addCMPField(versionField); else tableFields[versionField.getTableIndex()] = versionField; } // audit fields JDBCAuditMetaData auditMetaData = metadata.getAudit(); if(auditMetaData != null) { JDBCCMPFieldMetaData auditField = auditMetaData.getCreatedPrincipalField(); if(auditField != null) { createdPrincipalField = getCMPFieldByName(auditField.getFieldName()); if(createdPrincipalField == null) { createdPrincipalField = new JDBCCMP2xFieldBridge(manager, auditField); addCMPField(createdPrincipalField); } } else { createdPrincipalField = null; } auditField = auditMetaData.getCreatedTimeField(); if(auditField != null) { createdTimeField = getCMPFieldByName(auditField.getFieldName()); if(createdTimeField == null) { createdTimeField = new JDBCCMP2xFieldBridge(manager, auditField, JDBCTypeFactory.EQUALS, false); addCMPField(createdTimeField); } else { // just to override state factory and check-dirty-after-get createdTimeField = new JDBCCMP2xFieldBridge( (JDBCCMP2xFieldBridge)createdTimeField, JDBCTypeFactory.EQUALS, false); tableFields[createdTimeField.getTableIndex()] = createdTimeField; } } else { createdTimeField = null; } auditField = auditMetaData.getUpdatedPrincipalField(); if(auditField != null) { updatedPrincipalField = getCMPFieldByName(auditField.getFieldName()); if(updatedPrincipalField == null) { updatedPrincipalField = new JDBCCMP2xUpdatedPrincipalFieldBridge(manager, auditField); addCMPField(updatedPrincipalField); } else { updatedPrincipalField = new JDBCCMP2xUpdatedPrincipalFieldBridge( (JDBCCMP2xFieldBridge)updatedPrincipalField); tableFields[updatedPrincipalField.getTableIndex()] = updatedPrincipalField; } } else { updatedPrincipalField = null; } auditField = auditMetaData.getUpdatedTimeField(); if(auditField != null) { updatedTimeField = getCMPFieldByName(auditField.getFieldName()); if(updatedTimeField == null) { updatedTimeField = new JDBCCMP2xUpdatedTimeFieldBridge(manager, auditField); addCMPField(updatedTimeField); } else { updatedTimeField = new JDBCCMP2xUpdatedTimeFieldBridge((JDBCCMP2xFieldBridge)updatedTimeField); tableFields[updatedTimeField.getTableIndex()] = updatedTimeField; } } else { updatedTimeField = null; } } // ejbSelect methods loadSelectors(metadata); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void resolveRelationships() throws DeploymentException { for(int i = 0; i < cmrFields.length; ++i) cmrFields[i].resolveRelationship(); // load groups: cannot be created until relationships have // been resolved because loadgroups must check for foreign keys loadLoadGroups(metadata); loadEagerLoadGroup(metadata); loadLazyLoadGroups(metadata); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void start() throws DeploymentException { for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].start(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private void loadCMPFields(JDBCEntityMetaData metadata) throws DeploymentException { // only non pk fields are stored here at first and then later // the pk fields are added to the front (makes sql easier to read) List cmpFieldsMD = metadata.getCMPFields(); List cmpFieldsList = new ArrayList(cmpFieldsMD.size()); // primary key cmp fields List pkFieldsList = new ArrayList(cmpFieldsMD.size()); // create pk fields for(int i = 0; i < cmpFieldsMD.size(); ++i) { JDBCCMPFieldMetaData fieldMD = (JDBCCMPFieldMetaData)cmpFieldsMD.get(i); if(fieldMD.isPrimaryKeyMember()) { JDBCCMPFieldBridge cmpField = createCMPField(metadata, fieldMD); pkFieldsList.add(cmpField); } } // create non-pk cmp fields for(int i = 0; i < cmpFieldsMD.size(); ++i) { JDBCCMPFieldMetaData fieldMD = (JDBCCMPFieldMetaData)cmpFieldsMD.get(i); if(!fieldMD.isPrimaryKeyMember()) { JDBCCMPFieldBridge cmpField = createCMPField(metadata, fieldMD); cmpFieldsList.add(cmpField); } } // save the pk fields in the pk field array primaryKeyFields = new JDBCCMPFieldBridge[pkFieldsList.size()]; for(int i = 0; i < pkFieldsList.size(); ++i) primaryKeyFields[i] = (JDBCCMPFieldBridge)pkFieldsList.get(i); // add the pk fields to the front of the cmp list, per guarantee above cmpFields = new JDBCCMPFieldBridge[cmpFieldsMD.size() - primaryKeyFields.length]; int cmpFieldIndex = 0; for(int i = 0; i < cmpFieldsList.size(); ++i) cmpFields[cmpFieldIndex++] = (JDBCCMPFieldBridge)cmpFieldsList.get(i); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private void loadCMRFields(JDBCEntityMetaData metadata) throws DeploymentException { cmrFields = new JDBCCMRFieldBridge[metadata.getRelationshipRoles().size()]; // create each field int cmrFieldIndex = 0; for(Iterator iter = metadata.getRelationshipRoles().iterator(); iter.hasNext();) { JDBCRelationshipRoleMetaData relationshipRole = (JDBCRelationshipRoleMetaData)iter.next(); JDBCCMRFieldBridge cmrField = new JDBCCMRFieldBridge(this, manager, relationshipRole); cmrFields[cmrFieldIndex++] = cmrField; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private void loadLoadGroups(JDBCEntityMetaData metadata) throws DeploymentException { loadGroupMasks = new HashMap(); // load optimistic locking mask and add it to all the load group masks JDBCOptimisticLockingMetaData olMD = metadata.getOptimisticLocking(); if(olMD != null) { if(versionField != null) { defaultLockGroupMask = new boolean[tableFields.length]; defaultLockGroupMask[versionField.getTableIndex()] = true; versionField.setLockingStrategy(LockingStrategy.VERSION); } else if(olMD.getGroupName() != null) { defaultLockGroupMask = loadGroupMask(olMD.getGroupName(), null); for(int i = 0; i < tableFields.length; ++i) { if(defaultLockGroupMask[i]) { JDBCCMPFieldBridge tableField = tableFields[i]; tableField.setLockingStrategy(LockingStrategy.GROUP); tableField.addDefaultFlag(ADD_TO_WHERE_ON_UPDATE); } } } else // read or modified strategy { LockingStrategy strategy = (olMD.getLockingStrategy() == JDBCOptimisticLockingMetaData.READ_STRATEGY ? LockingStrategy.READ : LockingStrategy.MODIFIED ); for(int i = 0; i < tableFields.length; ++i) { JDBCCMPFieldBridge field = tableFields[i]; if(!field.isPrimaryKeyMember()) field.setLockingStrategy(strategy); } } } // add the * load group boolean[] defaultLoadGroup = new boolean[tableFields.length]; Arrays.fill(defaultLoadGroup, true); for(int i = 0; i < primaryKeyFields.length; ++i) { int tableIndex = primaryKeyFields[i].getTableIndex(); defaultLoadGroup[tableIndex] = false; } loadGroupMasks.put(DEFAULT_LOADGROUP_NAME, defaultLoadGroup); // put each group in the load groups map by group name Iterator groupNames = metadata.getLoadGroups().keySet().iterator(); while(groupNames.hasNext()) { // get the group name String groupName = (String)groupNames.next(); boolean[] loadGroup = loadGroupMask(groupName, defaultLockGroupMask); loadGroupMasks.put(groupName, loadGroup); } loadGroupMasks = Collections.unmodifiableMap(loadGroupMasks); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private boolean[] loadGroupMask(String groupName, boolean[] defaultGroup) throws DeploymentException { List fieldNames = metadata.getLoadGroup(groupName); boolean[] group = new boolean[tableFields.length]; if(defaultGroup != null) System.arraycopy(defaultGroup, 0, group, 0, group.length); for(Iterator iter = fieldNames.iterator(); iter.hasNext();) { String fieldName = (String)iter.next(); JDBCFieldBridge field = (JDBCFieldBridge)getFieldByName(fieldName); if(field == null) throw new DeploymentException( "Field " + fieldName + " not found for entity " + getEntityName()); if(field instanceof JDBCCMRFieldBridge) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)field; if(cmrField.hasForeignKey()) { JDBCCMPFieldBridge[] fkFields = (JDBCCMPFieldBridge[]) cmrField.getForeignKeyFields(); for(int i = 0; i < fkFields.length; ++i) { group[fkFields[i].getTableIndex()] = true; } } else { throw new DeploymentException("Only CMR fields that have " + "a foreign-key may be a member of a load group: " + "fieldName=" + fieldName); } } else { group[((JDBCCMPFieldBridge)field).getTableIndex()] = true; } } return group; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private JDBCCMPFieldBridge createCMPField(JDBCEntityMetaData metadata, JDBCCMPFieldMetaData cmpFieldMetaData) throws DeploymentException { JDBCCMPFieldBridge cmpField; if(metadata.isCMP1x()) cmpField = new JDBCCMP1xFieldBridge(manager, cmpFieldMetaData); else cmpField = new JDBCCMP2xFieldBridge(manager, cmpFieldMetaData); return cmpField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void resolveRelationship() throws DeploymentException { // // Set handles to the related entity's container, cache, // manager, and invoker // // Related Entity Name String relatedEntityName = metadata.getRelatedRole().getEntity().getName(); // Related Entity Catalog catalog = (Catalog) manager.getApplicationData("CATALOG"); relatedEntity = (JDBCEntityBridge) catalog.getEntityByEJBName(relatedEntityName); if(relatedEntity == null) { throw new DeploymentException("Related entity not found: " + "entity=" + entity.getEntityName() + ", " + "cmrField=" + getFieldName() + ", " + "relatedEntity=" + relatedEntityName); } // Related CMR Field JDBCCMRFieldBridge[] cmrFields = (JDBCCMRFieldBridge[]) relatedEntity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge cmrField = cmrFields[i]; if(metadata.getRelatedRole() == cmrField.getMetaData()) { relatedCMRField = cmrField; break; } } // if we didn't find the related CMR field throw an exception // with a detailed message if(relatedCMRField == null) { String message = "Related CMR field not found in " + relatedEntity.getEntityName() + " for relationship from"; message += entity.getEntityName() + "."; if(getFieldName() != null) { message += getFieldName(); } else { message += "<no-field>"; } message += " to "; message += relatedEntityName + "."; if(metadata.getRelatedRole().getCMRFieldName() != null) { message += metadata.getRelatedRole().getCMRFieldName(); } else { message += "<no-field>"; } throw new DeploymentException(message); } // Related Manager relatedManager = (JDBCStoreManager) relatedEntity.getManager(); // Related Container EntityContainer relatedContainer = relatedManager.getContainer(); this.relatedContainerRef = new WeakReference(relatedContainer); // related findByPrimaryKey Class homeClass = (relatedContainer.getLocalHomeClass() != null ? relatedContainer.getLocalHomeClass() : relatedContainer.getHomeClass()); try { relatedFindByPrimaryKey = homeClass.getMethod("findByPrimaryKey", new Class[]{relatedEntity.getPrimaryKeyClass()}); } catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); } // // Initialize the key fields // if(metadata.getRelationMetaData().isTableMappingStyle()) { // initialize relation table key fields Collection tableKeys = metadata.getKeyFields(); List keyFieldsList = new ArrayList(tableKeys.size()); // first phase is to create fk fields Map pkFieldsToFKFields = new HashMap(tableKeys.size()); for(Iterator i = tableKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData) i.next(); FieldBridge pkField = entity.getFieldByName(cmpFieldMetaData.getFieldName()); if(pkField == null) { throw new DeploymentException("Primary key not found for key-field " + cmpFieldMetaData.getFieldName()); } pkFieldsToFKFields.put(pkField, new JDBCCMP2xFieldBridge(manager, cmpFieldMetaData)); } // second step is to order fk fields to match the order of pk fields JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { Object fkField = pkFieldsToFKFields.get(pkFields[i]); if(fkField == null) { throw new DeploymentException("Primary key " + pkFields[i].getFieldName() + " is not mapped."); } keyFieldsList.add(fkField); } tableKeyFields = (JDBCCMP2xFieldBridge[]) keyFieldsList.toArray( new JDBCCMP2xFieldBridge[keyFieldsList.size()]); dataSource = metadata.getRelationMetaData().getDataSource(); } else { initializeForeignKeyFields(); dataSource = hasForeignKey() ? entity.getDataSource() : relatedEntity.getDataSource(); } // Fix table name // // This code doesn't work here... The problem each side will generate // the table name and this will only work for simple generation. qualifiedTableName = SQLUtil.fixTableName(metadata.getRelationMetaData().getDefaultTableName(), dataSource); tableName = SQLUtil.getTableNameWithoutSchema(qualifiedTableName); relationManager = relatedCMRField.initRelationManager(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void start() throws DeploymentException { cascadeDeleteStrategy = CascadeDeleteStrategy.getCascadeDeleteStrategy(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void initializeForeignKeyFields() throws DeploymentException { Collection foreignKeys = metadata.getRelatedRole().getKeyFields(); // temporary map used later to write fk fields in special order Map fkFieldsByRelatedPKFields = new HashMap(); for(Iterator i = foreignKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData fkFieldMetaData = (JDBCCMPFieldMetaData) i.next(); JDBCCMP2xFieldBridge relatedPKField = (JDBCCMP2xFieldBridge) relatedEntity.getFieldByName(fkFieldMetaData.getFieldName()); // now determine whether the fk is mapped to a pk column String fkColumnName = fkFieldMetaData.getColumnName(); JDBCCMP2xFieldBridge fkField = null; // look among the CMP fields for the field with the same column name JDBCFieldBridge[] tableFields = entity.getTableFields(); for(int tableInd = 0; tableInd < tableFields.length && fkField == null; ++tableInd) { JDBCCMP2xFieldBridge cmpField = (JDBCCMP2xFieldBridge) tableFields[tableInd]; if(fkColumnName.equals(cmpField.getColumnName())) { hasFKFieldsMappedToCMPFields = true; // construct the foreign key field fkField = new JDBCCMP2xFieldBridge((JDBCStoreManager) cmpField.getManager(), // this cmpField's manager relatedPKField.getFieldName(), relatedPKField.getFieldType(), cmpField.getJDBCType(), // this cmpField's jdbc type relatedPKField.isReadOnly(), relatedPKField.getReadTimeOut(), relatedPKField.getPrimaryKeyClass(), relatedPKField.getPrimaryKeyField(), cmpField, // CMP field I am mapped to this, fkColumnName); if(cmpField.isPrimaryKeyMember()) { relatedPKFieldsByMyPKFields.put(cmpField, relatedPKField); } } } // if the fk is not a part of pk then create a new field if(fkField == null) { fkField = new JDBCCMP2xFieldBridge(manager, fkFieldMetaData, manager.getJDBCTypeFactory().getJDBCType(fkFieldMetaData)); } fkFieldsByRelatedPKFields.put(relatedPKField, fkField); // temporary map relatedPKFieldsByMyFKFields.put(fkField, relatedPKField); } // Note: this important to order the foreign key fields so that their order matches // the order of related entity's pk fields in case of complex primary keys. // The order is important in fk-constraint generation and in SELECT when loading if(fkFieldsByRelatedPKFields.size() > 0) { JDBCFieldBridge[] relatedPKFields = relatedEntity.getPrimaryKeyFields(); List fkList = new ArrayList(relatedPKFields.length); for(int i = 0; i < relatedPKFields.length; ++i) { JDBCCMPFieldBridge fkField = (JDBCCMPFieldBridge) fkFieldsByRelatedPKFields.remove(relatedPKFields[i]); fkList.add(fkField); } foreignKeyFields = (JDBCCMP2xFieldBridge[]) fkList.toArray(new JDBCCMP2xFieldBridge[fkList.size()]); } else { foreignKeyFields = null; } // are all FK fields mapped to PK fields? allFKFieldsMappedToPKFields = relatedPKFieldsByMyPKFields.size() > 0 && relatedPKFieldsByMyPKFields.size() == foreignKeyFields.length; if(foreignKeyFields != null) { jdbcType = new CMRJDBCType(Arrays.asList(foreignKeyFields)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
private KeyGenerator initKeyGenerator(String keygenFactoryName) throws DeploymentException { try { InitialContext ctx = new InitialContext(); KeyGeneratorFactory keygenFactory = (KeyGeneratorFactory)ctx.lookup(keygenFactoryName); return keygenFactory.getKeyGenerator(); } catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); } catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
private String getSQL(JDBCCMRFieldBridge cmrField, boolean[] preloadMask, int keyCount) throws DeploymentException { JDBCCMPFieldBridge[] myKeyFields = getMyKeyFields(cmrField); JDBCCMPFieldBridge[] relatedKeyFields = getRelatedKeyFields(cmrField); String relationTable = getQualifiedRelationTable(cmrField); JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity(); String relatedTable = relatedEntity.getQualifiedTableName(); // do we need to join the relation table and the related table boolean join = ((preloadMask != null) || cmrField.allFkFieldsMappedToPkFields()) && (relatedKeyFields != relatedEntity.getPrimaryKeyFields()); // aliases for the tables, only required if we are joining the tables String relationTableAlias; String relatedTableAlias; if(join) { relationTableAlias = getRelationTable(cmrField); relatedTableAlias = ( relatedTable.equals(relationTable) ? getRelationTable(cmrField) + '_' + cmrField.getFieldName() : relatedEntity.getTableName() ); } else { relationTableAlias = ""; relatedTableAlias = ""; } JDBCFunctionMappingMetaData selectTemplate = getSelectTemplate(cmrField); return selectTemplate == null ? getPlainSQL( keyCount, myKeyFields, relationTableAlias, relatedKeyFields, preloadMask, cmrField, relatedTableAlias, relationTable, join, relatedTable) : getSQLByTemplate( keyCount, myKeyFields, relationTableAlias, relatedKeyFields, preloadMask, cmrField, relatedTableAlias, relationTable, join, relatedTable, selectTemplate); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
private JDBCFunctionMappingMetaData getSelectTemplate(JDBCCMRFieldBridge cmrField) throws DeploymentException { JDBCFunctionMappingMetaData selectTemplate = null; if(cmrField.getRelationMetaData().isTableMappingStyle()) { // relation table if(cmrField.getRelationMetaData().hasRowLocking()) { selectTemplate = cmrField.getRelationMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } else if(cmrField.getRelatedCMRField().hasForeignKey()) { // related has foreign key if(cmrField.getRelatedJDBCEntity().getMetaData().hasRowLocking()) { selectTemplate = cmrField.getRelatedJDBCEntity().getMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } else { // i have foreign key if(entity.getMetaData().hasRowLocking()) { selectTemplate = entity.getMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } return selectTemplate; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { pkSQL = "SELECT SCOPE_IDENTITY()"; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); ClassLoader loader = GetTCLAction.getContextClassLoader(); try { Class psClass = loader.loadClass(className); method = psClass.getMethod(methodName, null); } catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); } catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); } try { Class wrapperClass = loader.loadClass("org.jboss.resource.adapter.jdbc.StatementAccess"); getUnderlyingStatement = wrapperClass.getMethod("getUnderlyingStatement", null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); } catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); className = entityCommand.getAttribute(NAME); if(className == null) { className = DEFAULT_CLASS; } methodName = entityCommand.getAttribute(METHOD); if(methodName == null) { methodName = DEFAULT_METHOD; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { if (CONNECTION_PREPARE == null) { throw new DeploymentException("Create command requires JDBC 3.0 (JDK1.4+)"); } super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); pkField = getGeneratedPKField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); String factoryName = entityCommand.getAttribute("key-generator-factory"); if(factoryName == null) { throw new DeploymentException("key-generator-factory attribute must be set for entity " + entity.getEntityName()); } try { KeyGeneratorFactory keyGeneratorFactory = (KeyGeneratorFactory) new InitialContext().lookup(factoryName); keyGenerator = keyGeneratorFactory.getKeyGenerator(); } catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); } catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); pkField = getGeneratedPKField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { throw new DeploymentException("pk-sql attribute must be set for entity " + entity.getEntityName()); } if(debug) { log.debug("Generate PK sql is: " + pkSQL); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); ClassLoader loader = GetTCLAction.getContextClassLoader(); try { Class psClass = loader.loadClass(className); method = psClass.getMethod(methodName, null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); } catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); } try { Class wrapperClass = loader.loadClass("org.jboss.resource.adapter.jdbc.StatementAccess"); getUnderlyingStatement = wrapperClass.getMethod("getUnderlyingStatement", null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); } catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); className = entityCommand.getAttribute("class-name"); if (className == null) { className = "com.mysql.jdbc.PreparedStatement"; } methodName = entityCommand.getAttribute("method"); if (methodName == null) { methodName = "getGeneratedKeys"; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence = entityCommand.getAttribute("sequence"); if (sequence == null) { sequence = entity.getQualifiedTableName() + '_' + SQLUtil.getColumnNamesClause(pkField, new StringBuffer(20)) + "_seq"; } sequenceSQL = "SELECT currval('"+sequence+"')"; if (debug) { log.debug("SEQUENCE SQL is :"+sequenceSQL); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence = entityCommand.getAttribute("sequence"); if (sequence == null) { throw new DeploymentException("Sequence must be specified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSybaseCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { pkSQL = "SELECT @@IDENTITY"; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence_name = entityCommand.getAttribute("sequence_name"); if (sequence_name == null) { throw new DeploymentException("sequence_name attribute must be specified inside <entity-command>"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCHsqldbCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { pkSQL = "CALL IDENTITY()"; } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
public void importXml(Element element) throws DeploymentException { String maximumSize = MetaData.getElementContent(MetaData.getUniqueChild(element, "MaximumSize")); try { this.maxSize = Integer.parseInt(maximumSize); } catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); } // Get whether the pool will block when MaximumSize instances are active String strictValue = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictMaximumSize")); this.isStrict = Boolean.valueOf(strictValue); String delay = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictTimeout")); try { if( delay != null ) this.strictTimeout = Long.parseLong(delay); } catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); } }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
public void importXml(Element element) throws DeploymentException { super.importXml(element); String rp = MetaData.getElementContent(MetaData.getOptionalChild(element, "remover-period")); String ml = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-bean-life")); try { if (rp != null) { int p = Integer.parseInt(rp); if (p <= 0) { throw new DeploymentException("Remover period can't be <= 0"); } m_removerPeriod = p * 1000; } if (ml != null) { int a = Integer.parseInt(ml); if (a <= 0) { throw new DeploymentException("Max bean life can't be <= 0"); } m_maxBeanLife = a * 1000; } } catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); } }
// in src/main/java/org/jboss/web/deployers/WarSecurityDeployer.java
Override public void deploy(DeploymentUnit unit) throws DeploymentException { ClassLoader oldCL = null; // Set the TCL try { //JBAS-6607: JBossXACML needs the tcl to locate the xacml policies //The TCL would be the CL for VFS for the security deployer beans //Deployment Unit CL would be the war CL. Hence pick the DU CL as TCL. oldCL = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(unit.getClassLoader()); super.deploy(unit); } finally { SecurityActions.setContextClassLoader(oldCL); } }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { synchronized (this) { if ((sharedWebMetaData == null && webXml != null) || (sharedJBossWebMetaData == null && jbossWebXml != null)) { UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); SchemaBindingResolver resolver = SingletonSchemaResolverFactory .getInstance().getSchemaBindingResolver(); if (webXml != null) { try { sharedWebMetaData = (WebMetaData) unmarshaller.unmarshal(webXml, resolver); } catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); } } if (jbossWebXml != null) { try { sharedJBossWebMetaData = (JBossWebMetaData) unmarshaller.unmarshal(jbossWebXml, resolver); } catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); } } } } if (sharedWebMetaData != null || sharedJBossWebMetaData != null) { JBossWebMetaData clone = new JBoss60WebMetaData(); clone.merge(sharedJBossWebMetaData, sharedWebMetaData); unit.addAttachment(SHARED_JBOSSWEB_ATTACHMENT_NAME, clone); } }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public synchronized void stopModule() throws DeploymentException { String warURL = unit.getName(); try { WebApplication webApp = container.removeDeployedApp(warURL); if (deployment != null && webApp != null) { deployment.stop(unit, webApp); } else { log.debug("Failed to find deployer/deployment for war: " + warURL); } } catch (Exception e) { throw new DeploymentException("Error during stop", e); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
Override public void deploy(DeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException { log.debug("Begin deploy, " + metaData); // Merge any settings from the ear level JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class); if (earMetaData != null) { String path = unit.getRelativePath(); ModuleMetaData webModule = earMetaData.getModule(path); if (webModule != null) { // Check for a context-root setting String contextRoot = metaData.getContextRoot(); if (contextRoot == null) { WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue(); contextRoot = wmodule.getContextRoot(); metaData.setContextRoot(contextRoot); } // Add any alt-dd setting metaData.setAlternativeDD(webModule.getAlternativeDD()); } // Merge security domain/roles if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null) metaData.setSecurityDomain(earMetaData.getSecurityDomain()); // TODO metaData.mergeSecurityRoles(earMetaData.getSecurityRoles()); } try { /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since * the vfs deals with the distinction between a true directory, the only way we can tell from * this level of the api is to look for a url that ends in '/'. Here we assume that the name is * the root url. */ String warName = unit.getName(); /** * Ignore the jacc policy service bean */ if (warName.startsWith("jboss:") && warName.contains("id=")) return; if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit; VirtualFile root = vfsUnit.getRoot(); final URL expandedWarURL = root.getPhysicalFile().toURI().toURL(); // Map String warPathName = root.getPathName(); if (warPathName.endsWith("/") == false) warPathName += "/"; List<VirtualFile> classpathVFs = vfsUnit.getClassPath(); if (classpathVFs != null) { List<URL> classpath = new ArrayList<URL>(); for (VirtualFile vf : classpathVFs) { try { String path = vf.getPathName(); if (path.startsWith(warPathName)) { path = path.substring(warPathName.length()); URL pathURL = new URL(expandedWarURL, path); classpath.add(pathURL); } else { log.debug("Ignoring path element: " + vf); } } catch (Exception e) { log.debug("Ignoring path element: " + vf, e); } } unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath); } // Indicate that an expanded URL exists unit.addAttachment("org.jboss.web.expandedWarURL", expandedWarURL, URL.class); // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file String altDDPath = metaData.getAlternativeDD(); if (altDDPath != null) { // First see if this is already a war local dd VirtualFile altDD = vfsUnit.getMetaDataFile(altDDPath); if (altDD == null) { // Pass absolute paths through File file = new File(altDDPath); if (!file.exists() || !file.isAbsolute()) { // Should be an relative to the top deployment VFSDeploymentUnit topUnit = vfsUnit.getTopLevel(); if (topUnit == unit) throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path"); altDD = topUnit.getFile(altDDPath); if (altDD == null) throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path"); VirtualFile altDDFile = root.getChild("WEB-INF/" + altDD.getName()); log.debug("Copying the altDD to: " + altDDFile); VFSUtils.writeFile(altDDFile, altDD.openStream()); metaData.setAlternativeDD(altDDFile.getPathName()); } } } } ClassLoadingMetaData classLoading = metaData.getClassLoading(); if (classLoading == null) classLoading = new ClassLoadingMetaData(); // pass in the java2ClassLoadingCompliance if it was not set at the war level if (classLoading.wasJava2ClassLoadingComplianceSet() == false) classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance); metaData.setClassLoading(classLoading); // Build the context root if its not been set or is specified at the ear String webContext = metaData.getContextRoot(); webContext = buildWebContext(webContext, warName, metaData, unit); metaData.setContextRoot(webContext); AbstractWarDeployment deployment = getDeployment(unit, metaData); deployment.setMainDeployer(mainDeployer); // TODO: until deployment is a MC bean deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver); deployWebModule(unit, metaData, deployment); } catch (Exception e) { throw new DeploymentException("Failed to create web module", e); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
public void build(DeploymentUnit unit, Set<String> outputs, Map<String, ManagedObject> managedObjects) throws DeploymentException { JBossWebMetaData meta = unit.getAttachment(JBossWebMetaData.class); if (meta == null) return; ManagedObject mo = ManagedObjectFactory.getInstance().createManagedObject(ContextMO.class); if (mo == null) throw new DeploymentException("could not create managed object"); mo.getProperty("contextRoot").setValue(SimpleValueSupport.wrap(meta.getContextRoot())); managedObjects.put("ContextMO", mo); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (unit instanceof VFSDeploymentUnit == false) return; VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; deploy(vfsDeploymentUnit); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
protected void deploy(VFSDeploymentUnit unit) throws DeploymentException { if (!unit.getSimpleName().endsWith(".war")) { return; } VirtualFile root = unit.getRoot(); if(root.isFile()) return; List<VirtualFile> classpath = unit.getClassPath(); if(classpath == null || classpath.isEmpty()) return; if (log.isTraceEnabled()) log.trace("Deploying annotations for unit: " + unit + ", classpath: " + classpath); try { processMetaData(unit, classpath); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); } }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataHackDeployer.java
Override public void deploy(DeploymentUnit unit) throws DeploymentException { // let the MergedJBossWebMetaDataDeployer do all its usual work super.deploy(unit); // if we don't have any DataSource references in our ENC, then nothing to hack! JBossWebMetaData mergedJBossWebMetaData = unit.getAttachment(JBossWebMetaData.class); if (mergedJBossWebMetaData == null || !this.hasDataSources(mergedJBossWebMetaData)) { return; } // we only hack if this web unit contains EJB deployments (i.e. Java EE6 shared ENC) if (!this.isSharedENC(unit)) { return; } JBossMetaData jbossMetaData = unit.getAttachment(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME, JBossMetaData.class); JBossEnterpriseBeansMetaData enterpriseBeans = jbossMetaData.getEnterpriseBeans(); if (enterpriseBeans == null || enterpriseBeans.isEmpty()) { // no beans, no hack! return; } // process each EJB for (JBossEnterpriseBeanMetaData enterpriseBean : enterpriseBeans) { this.removeCommonDataResourceReference(mergedJBossWebMetaData, enterpriseBean); } // attach the updated merged JBossWebMetaData to the unit unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, mergedJBossWebMetaData); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
public void deploy(final DeploymentUnit unit) throws DeploymentException { // we require a VFSDeploymentUnit, to be able to pick up context relative // config files if (unit instanceof VFSDeploymentUnit == false) { return; } final VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; // get hold of the parsed web.xml metadata WebMetaData webMetaData = unit.getAttachment(WebMetaData.class); // shouldn't really happen, because we have set WebMetaData as a required input. if (webMetaData == null) { return; } List<ParamValueMetaData> contextParams = webMetaData.getContextParams(); if (contextParams == null || contextParams.isEmpty()) { return; } JSFDeployment jsfDeployment = vfsDeploymentUnit.getAttachment(JSFDeployment.class); if (jsfDeployment == null) { // create and attach jsfDeployment = new JSFDeployment(); vfsDeploymentUnit.addAttachment(JSFDeployment.class, jsfDeployment); } for (ParamValueMetaData contextParam : contextParams) { if (contextParam == null) { continue; } if (JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME.equals(contextParam.getParamName())) { try { logger.debug("Found " + JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME + " param with values: " + contextParam.getParamValue() + " in unit " + vfsDeploymentUnit); // process each of the paths specified in the context param value this.processConfigFilesContextParamValue(vfsDeploymentUnit, jsfDeployment, contextParam.getParamValue()); } catch (Exception e) { throw new DeploymentException(e); } } } }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (!unit.getSimpleName().endsWith(".war")) { return; } synchronized (this) { if (sharedTldMetaData == null && tldJars != null) { UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); SchemaBindingResolver resolver = SingletonSchemaResolverFactory .getInstance().getSchemaBindingResolver(); // Parse shared JARs for TLDs sharedTldMetaData = new ArrayList<TldMetaData>(); if (tldJars != null) { VirtualFileFilter tldFilter = new SuffixMatchFilter(".tld", VisitorAttributes.DEFAULT); for (URL tldJar : tldJars) { try { VirtualFile virtualFile = VFS.getChild(tldJar); VirtualFile metaInf = virtualFile.getChild("META-INF"); if (metaInf != null) { List<VirtualFile> tlds = metaInf.getChildren(tldFilter); for (VirtualFile tld : tlds) { TldMetaData tldMetaData = (TldMetaData) unmarshaller.unmarshal(tld.toURL().toString(), resolver); sharedTldMetaData.add(tldMetaData); } } } catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); } } } } } if (sharedTldMetaData != null) { List<TldMetaData> clone = new ArrayList<TldMetaData>(); clone.addAll(sharedTldMetaData); unit.addAttachment(SHARED_TLDS_ATTACHMENT_NAME, clone); } }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { WebMetaData specMetaData = unit.getAttachment(WebMetaData.class); JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); if(specMetaData == null && metaData == null) return; // Check metadata-complete (see AnnotationMetaDataDeployer) boolean isComplete = this.isMetaDataCompleteIsDefault(); if(specMetaData != null) { if (specMetaData instanceof Web25MetaData) { isComplete |= ((Web25MetaData)specMetaData).isMetadataComplete(); } else if (specMetaData instanceof Web30MetaData) { isComplete |= ((Web30MetaData)specMetaData).isMetadataComplete(); } else { // Any web.xml 2.4 or earlier deployment is metadata complete isComplete = true; } } // Find all fragments that have been processed by deployers, and place them in a map keyed by location LinkedList<String> order = new LinkedList<String>(); List<WebOrdering> orderings = new ArrayList<WebOrdering>(); HashSet<String> jarsSet = new HashSet<String>(); Set<VirtualFile> overlays = new HashSet<VirtualFile>(); Map<String, VirtualFile> scis = new HashMap<String, VirtualFile>(); VirtualFile webInfLib = null; boolean fragmentFound = false; HashMap<String, WebFragmentMetaData> webFragments = new HashMap<String, WebFragmentMetaData>(); if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit; webInfLib = vfsUnit.getFile("WEB-INF/lib"); if (webInfLib != null) { List<VirtualFile> jars = webInfLib.getChildren(); for (VirtualFile jar : jars) { jarsSet.add(jar.getName()); // Find overlays VirtualFile overlay = jar.getChild("META-INF/resources"); if (overlay.exists()) { overlays.add(overlay); } // Find ServletContainerInitializer services VirtualFile sci = jar.getChild("META-INF/services/javax.servlet.ServletContainerInitializer"); if (sci.exists()) { scis.put(jar.getName(), sci); } } } if (!isComplete) { String base = unit.getName(); int pos = base.indexOf(':'); if (pos > 0) { base = base.substring(pos); } Iterator<String> attachementNames = unit.getAttachments().keySet().iterator(); HashSet<String> jarsWithoutFragmentsSet = new HashSet<String>(); jarsWithoutFragmentsSet.addAll(jarsSet); while (attachementNames.hasNext()) { String location = attachementNames.next(); Object attachement = unit.getAttachment(location); if (attachement != null && attachement instanceof WebFragmentMetaData) { if (!location.startsWith(WebFragmentMetaData.class.getName() + ":")) { // If there is only one fragment, it will also get mapped as this attachement continue; } String relativeLocation = "/" + location.substring(WebFragmentMetaData.class.getName().length() + 1); String jarName = null; if (relativeLocation.startsWith("/WEB-INF/lib/")) { jarName = relativeLocation.substring("/WEB-INF/lib/".length()); pos = jarName.indexOf('/'); if (pos > 0) jarName = jarName.substring(0, pos); } if (jarName == null) { continue; } fragmentFound = true; WebFragmentMetaData fragmentMetaData = (WebFragmentMetaData) attachement; webFragments.put(jarName, fragmentMetaData); WebOrdering webOrdering = new WebOrdering(); webOrdering.setName(fragmentMetaData.getName()); webOrdering.setJar(jarName); jarsWithoutFragmentsSet.remove(jarName); if (fragmentMetaData.getOrdering() != null) { if (fragmentMetaData.getOrdering().getAfter() != null) { for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getAfter().getOrdering()) { if (orderingElementMetaData.isOthers()) { webOrdering.setAfterOthers(true); } else { webOrdering.addAfter(orderingElementMetaData.getName()); } } } if (fragmentMetaData.getOrdering().getBefore() != null) { for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getBefore().getOrdering()) { if (orderingElementMetaData.isOthers()) { webOrdering.setBeforeOthers(true); } else { webOrdering.addBefore(orderingElementMetaData.getName()); } } } } orderings.add(webOrdering); } } // If there is no fragment, still consider it for ordering as a // fragment specifying no name and no order for (String jarName : jarsWithoutFragmentsSet) { WebOrdering ordering = new WebOrdering(); ordering.setJar(jarName); orderings.add(ordering); } } } if (!fragmentFound) { // Drop the order as there is no fragment in the webapp orderings.clear(); } // Generate web fragments parsing order AbsoluteOrderingMetaData absoluteOrderingMetaData = null; if (!isComplete && specMetaData instanceof Web30MetaData) { absoluteOrderingMetaData = ((Web30MetaData) specMetaData).getAbsoluteOrdering(); } if (absoluteOrderingMetaData != null) { // Absolute ordering from web.xml, any relative fragment ordering is ignored int otherPos = -1; int i = 0; for (OrderingElementMetaData orderingElementMetaData : absoluteOrderingMetaData.getOrdering()) { if (orderingElementMetaData.isOthers()) { if (otherPos >= 0) { throw new DeploymentException("Duplicate others in absolute ordering"); } otherPos = i; } else { for (WebOrdering ordering : orderings) { if (orderingElementMetaData.getName().equals(ordering.getName())) { order.add(ordering.getJar()); jarsSet.remove(ordering.getJar()); break; } } } i++; } if (otherPos >= 0) { order.addAll(otherPos, jarsSet); jarsSet.clear(); } } else if (orderings.size() > 0) { // Resolve relative ordering try { resolveOrder(orderings, order); } catch (IllegalStateException e) { DeploymentException.rethrowAsDeploymentException("Invalid ordering", e); } jarsSet.clear(); } else { // No order specified order.addAll(jarsSet); jarsSet.clear(); unit.addAttachment(WEB_NOORDER_ATTACHMENT_NAME, Boolean.TRUE); } if (log.isDebugEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("Resolved order: [ "); for (String jar : order) { builder.append(jar).append(' '); } builder.append(']'); log.debug(builder.toString()); } unit.addAttachment(WEB_ORDER_ATTACHMENT_NAME, order); unit.addAttachment(WEB_OVERLAYS_ATTACHMENT_NAME, overlays); unit.addAttachment(WEB_SCIS_ATTACHMENT_NAME, scis); // The fragments and corresponding annotations will need to be merged in order // For each JAR in the order: // - Merge the annotation metadata into the fragment meta data // (unless the fragment exists and is meta data complete) // - Merge the fragment metadata into merged fragment meta data WebCommonMetaData mergedFragmentMetaData = new WebCommonMetaData(); if (specMetaData == null) { // If there is no web.xml, it has to be considered to be the latest version specMetaData = new Web30MetaData(); specMetaData.setVersion("3.0"); } String key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":classes"; // Augment with meta data from annotations in /WEB-INF/classes WebMetaData classesAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if (classesAnnotatedMetaData != null) { if (isComplete) { // Discard @WebFilter, @WebListener and @WebServlet classesAnnotatedMetaData.setFilters(null); classesAnnotatedMetaData.setFilterMappings(null); classesAnnotatedMetaData.setListeners(null); classesAnnotatedMetaData.setServlets(null); classesAnnotatedMetaData.setServletMappings(null); } specMetaData.augment(classesAnnotatedMetaData, null, true); } // Augment with meta data from fragments and annotations from the corresponding JAR for (String jar : order) { WebFragmentMetaData webFragmentMetaData = webFragments.get(jar); if (webFragmentMetaData == null) { webFragmentMetaData = new WebFragmentMetaData(); // Add non overriding default distributable flag webFragmentMetaData.setDistributable(new EmptyMetaData()); } key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":" + jar; WebMetaData jarAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if ((isComplete || webFragmentMetaData.isMetadataComplete()) && jarAnnotatedMetaData != null) { // Discard @WebFilter, @WebListener and @WebServlet jarAnnotatedMetaData.setFilters(null); jarAnnotatedMetaData.setFilterMappings(null); jarAnnotatedMetaData.setListeners(null); jarAnnotatedMetaData.setServlets(null); jarAnnotatedMetaData.setServletMappings(null); } if (jarAnnotatedMetaData != null) { // Merge annotations corresponding to the JAR webFragmentMetaData.augment(jarAnnotatedMetaData, null, true); } // Merge fragment meta data according to the conflict rules try { mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); } } // Augment with meta data from annotations from JARs excluded from the order for (String jar : jarsSet) { WebFragmentMetaData webFragmentMetaData = new WebFragmentMetaData(); // Add non overriding default distributable flag webFragmentMetaData.setDistributable(new EmptyMetaData()); key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":" + jar; WebMetaData jarAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if (jarAnnotatedMetaData != null) { // Discard @WebFilter, @WebListener and @WebServlet jarAnnotatedMetaData.setFilters(null); jarAnnotatedMetaData.setFilterMappings(null); jarAnnotatedMetaData.setListeners(null); jarAnnotatedMetaData.setServlets(null); jarAnnotatedMetaData.setServletMappings(null); } if (jarAnnotatedMetaData != null) { // Merge annotations corresponding to the JAR webFragmentMetaData.augment(jarAnnotatedMetaData, null, true); } // Merge fragment meta data according to the conflict rules try { mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); } } specMetaData.augment(mergedFragmentMetaData, null, true); // Override with meta data (JBossWebMetaData) // Create a merged view JBossWebMetaData mergedMetaData = new JBossWebMetaData(); mergedMetaData.merge(metaData, specMetaData); // Incorporate any ear level overrides DeploymentUnit topUnit = unit.getTopLevel(); if(topUnit != null && topUnit.getAttachment(JBossAppMetaData.class) != null) { JBossAppMetaData earMetaData = topUnit.getAttachment(JBossAppMetaData.class); // Security domain String securityDomain = earMetaData.getSecurityDomain(); if(securityDomain != null && mergedMetaData.getSecurityDomain() == null) mergedMetaData.setSecurityDomain(securityDomain); //Security Roles SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles(); if(earSecurityRolesMetaData != null) { SecurityRolesMetaData mergedSecurityRolesMetaData = mergedMetaData.getSecurityRoles(); if(mergedSecurityRolesMetaData == null) mergedMetaData.setSecurityRoles(earSecurityRolesMetaData); //perform a merge to rebuild the principalVersusRolesMap if(mergedSecurityRolesMetaData != null ) { mergedSecurityRolesMetaData.merge(mergedSecurityRolesMetaData, earSecurityRolesMetaData); } } } // Output the merged JBossWebMetaData unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, mergedMetaData); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException { ContextInfo context = null; VirtualFile file = structureContext.getFile(); try { boolean trace = log.isTraceEnabled(); // the WEB-INF VirtualFile webinf; // We require either a WEB-INF or the name ends in .war if (hasValidSuffix(file.getName()) == false) { webinf = file.getChild("WEB-INF"); if (webinf.exists()) { if (trace) log.trace("... ok - directory has a WEB-INF subdirectory"); } else { if (trace) log.trace("... no - doesn't look like a war and no WEB-INF subdirectory."); return false; } } else if (trace) { log.trace("... ok - name ends in .war."); } // Check for a META-INF for metadata // FIXME: This is not spec legal, descriptors could be loaded from this location String[] metaDataLocations = new String[]{"WEB-INF", "WEB-INF/classes/META-INF"}; // Create a context for this war file and all its metadata locations context = createContext(structureContext, metaDataLocations); // Add all children as locations for TLDs (except classes and lib), recursively webinf = file.getChild("WEB-INF"); boolean webinfExists = webinf.exists(); if (webinfExists) { List<VirtualFile> children = webinf.getChildren(); for (VirtualFile child : children) { if (!isLeaf(child) && (!"lib".equals(child.getName())) && (!"classes".equals(child.getName()))) { addMetaDataPath(structureContext, context, "WEB-INF/" + child.getName(), MetaDataType.ALTERNATIVE); addPathsRecursively(structureContext, context, child, "WEB-INF/" + child.getName()); } } } // Check for jars in WEB-INF/lib List<VirtualFile> archives = null; try { VirtualFile webinfLib = file.getChild("WEB-INF/lib"); if (webinfLib.exists()) { archives = webinfLib.getChildren(webInfLibFilter); // Add the jars' META-INF for metadata for (VirtualFile jar : archives) { Automounter.mount(file, jar); // either same as plain lib filter, null or accepts the jar if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar)) { VirtualFile metaInf = jar.getChild("META-INF"); if (metaInf.exists() && !isLeaf(metaInf)) { addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF", MetaDataType.ALTERNATIVE); List<VirtualFile> children = metaInf.getChildren(); for (VirtualFile child : children) { if (!isLeaf(child) && (!"resources".equals(child.getName()))) { addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName(), MetaDataType.ALTERNATIVE); addPathsRecursively(structureContext, context, child, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName()); } } } } } } } catch (IOException e) { log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e); } // Add the war manifest classpath entries addClassPath(structureContext, file, false, true, context); // Check for WEB-INF/classes VirtualFile classes = file.getChild("WEB-INF/classes"); // Add WEB-INF/classes if present if (classes.exists()) addClassPath(structureContext, classes, true, false, context); else if (trace) log.trace("No WEB-INF/classes for: " + file.getPathName()); // and the top level jars in WEB-INF/lib if (archives != null) { for (VirtualFile jar : archives) addClassPath(structureContext, jar, true, true, context); } else if (trace) { log.trace("No WEB-INF/lib for: " + file.getPathName()); } // do we include WEB-INF in classpath if (includeWebInfInClasspath && webinfExists) { addClassPath(structureContext, webinf, true, false, context); } // There are no subdeployments for wars return true; } catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); } }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
private ServletContainerInitializer loadSci(DeploymentUnit unit, VirtualFile sci, String jar, boolean error) throws DeploymentException { ServletContainerInitializer service = null; InputStream is = null; try { // Get the ServletContainerInitializer class name is = sci.openStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String servletContainerInitializerClassName = reader.readLine(); int pos = servletContainerInitializerClassName.indexOf('#'); if (pos > 0) { servletContainerInitializerClassName = servletContainerInitializerClassName.substring(0, pos); } servletContainerInitializerClassName = servletContainerInitializerClassName.trim(); // Instantiate the ServletContainerInitializer service = (ServletContainerInitializer) unit.getClassLoader() .loadClass(servletContainerInitializerClassName).newInstance(); } catch (Exception e) { if (error) { DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jar, e); } else { log.info("Skipped SCI for JAR: " + jar, e); } } finally { try { if (is != null) is.close(); } catch (IOException e) { ; } } return service; }
(Lib) IllegalStateException 231
              
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
public Method getMethod() { if (this.method != null) return this.method; // Try the hash, the methodMap should be set this.method = (Method) methodMap.get(new Long(methodHash)); // Keep it in the payload if (this.method == null) { throw new IllegalStateException("Failed to find method for hash:" + methodHash + " available=" + methodMap); } return this.method; }
// in src/main/java/org/jboss/jmx/connector/invoker/MBeanProxyRemote.java
protected void startService() throws Exception { if (MBeanProxyExt.remote != null) throw new IllegalStateException("Remote MBeanServerConnection is already set " + MBeanProxyExt.remote); Object o = server.getAttribute(mbeanServerConnection, "Proxy"); if (o instanceof MBeanServerConnection == false) throw new DeploymentException(mbeanServerConnection + " does not define an MBeanServerConnection"); MBeanProxyExt.remote = (MBeanServerConnection) o; }
// in src/main/java/org/jboss/jms/jndi/AbstractJMSProviderAdapter.java
public String getFactoryRef() { if (factoryRef == null) throw new IllegalStateException("Combined ConnectionFactory 'FactoryRef' not configured."); return factoryRef; }
// in src/main/java/org/jboss/jms/jndi/AbstractJMSProviderAdapter.java
public String getQueueFactoryRef() { if (queueFactoryRef == null) throw new IllegalStateException("Queue ConnectionFactory 'QueueFactoryRef' not configured."); return queueFactoryRef; }
// in src/main/java/org/jboss/jms/jndi/AbstractJMSProviderAdapter.java
public String getTopicFactoryRef() { if (topicFactoryRef == null) throw new IllegalStateException("Topic ConnectionFactory 'TopicFactoryRef' not configured."); return topicFactoryRef; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected XAConnectionFactory getConnectionFactory() throws Exception { // Get the JMS Provider Adapter if (providerName == null) throw new IllegalArgumentException("Null provider name"); String providerAdapterJNDI = providerName; if (providerAdapterJNDI.startsWith("java:") == false) providerAdapterJNDI = "java:" + providerAdapterJNDI; Context ctx = new InitialContext(); JMSProviderAdapter adapter = (JMSProviderAdapter) Util.lookup(providerAdapterJNDI, JMSProviderAdapter.class); // Determine the XAConnectionFactory name String connectionFactoryRef = adapter.getFactoryRef(); if (connectionFactoryRef == null) throw new IllegalStateException("Provider '" + providerName + "' has no FactoryRef"); // Lookup the connection factory ctx = adapter.getInitialContext(); try { return (XAConnectionFactory) Util.lookup(ctx, connectionFactoryRef, XAConnectionFactory.class); } finally { ctx.close(); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolve(DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, JBossEnterpriseBeansMetaData beans, DeploymentEndpointResolver resolver, List<String> unresolvedPaths) throws Exception { if(beans == null || beans.size() == 0) return; String vfsPath = unit.getRelativePath(); for(JBossEnterpriseBeanMetaData bean : beans) { // Find the container dependency metadata String ejbCompID = "ejb/" + vfsPath + "#" + bean.getEjbName(); ContainerDependencyMetaData cdmd = endpointMap.get(ejbCompID); if(cdmd == null) throw new IllegalStateException("Failed to find ContainerDependencyMetaData for: "+ejbCompID); Environment env = bean.getJndiEnvironmentRefsGroup(); resolve(cdmd, unit, endpointMap, env, resolver, unresolvedPaths); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected ContainerDependencyMetaData resolveEjbInterface(String iface, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, DeploymentEndpointResolver resolver) throws Exception { ClassLoader loader = unit.getClassLoader(); Class<?> ifaceClass = loader.loadClass(iface); String vfsContext = unit.getRelativePath(); EndpointInfo info = resolver.getEndpointInfo(ifaceClass, EndpointType.EJB, vfsContext); if(info == null) throw new IllegalStateException("Failed to find ContainerDependencyMetaData for interface: "+ iface); ContainerDependencyMetaData cdmd = endpointMap.get(info.getComponentKey()); return cdmd; }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { PolicyConfiguration pc = unit.getAttachment(PolicyConfiguration.class); if (pc == null) return; DeploymentUnit parent = unit.getParent(); if (parent == null) throw new IllegalStateException("Unit has not parent: " + unit); PolicyConfiguration parentPc = parent.getAttachment(PolicyConfiguration.class); try { if (parentPc != null && pc != parentPc) { parentPc.linkConfiguration(pc); } pc.commit(); } catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); } }
// in src/main/java/org/jboss/deployment/AppParsingDeployer.java
protected EarMetaData parse(VFSDeploymentUnit unit, VirtualFile file, EarMetaData root) throws Exception { EarMetaData ear = super.parse(unit,file, root); List<DeploymentUnit> children = unit.getChildren(); ModulesMetaData modules = ear.getModules(); if(children != null && modules != null) { for(DeploymentUnit child : children) { String moduleName = child.getSimpleName(); ModuleMetaData module = modules.get(moduleName); if(module != null && module.getAlternativeDD() != null) { VirtualFile altDDFile = unit.getRoot().getChild(module.getAlternativeDD()); if(altDDFile == null) throw new IllegalStateException("Failed to locate alternative DD '" + module.getAlternativeDD() + "' in " + unit.getRoot().getPathName()); String attachmentName; if(module.getType() == ModuleMetaData.ModuleType.Ejb) attachmentName = EjbJarMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Web) attachmentName = WebMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Client) attachmentName = ApplicationClientMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Connector) attachmentName = "org.jboss.resource.metadata.ConnectorMetaData"; else throw new IllegalStateException("Expected module types in an EAR are ejb, web, java and connector but got " + module.getType() + " for " + child.getName() + " in " + unit.getName()); child.addAttachment(attachmentName + ".altDD", altDDFile); if(log.isTraceEnabled()) log.trace("attached alt-dd " + altDDFile + " for module " + child.getSimpleName()); } } } return ear; }
// in src/main/java/org/jboss/deployment/security/JaccPolicyUtil.java
public static void createPermissions(PolicyConfiguration policyConfiguration, Object metadata) throws PolicyContextException { if(metadata == null) throw new IllegalArgumentException("Meta Data is null"); if(policyConfiguration == null) throw new IllegalArgumentException("Policy Configuration is null"); if(metadata instanceof JBossWebMetaData) { JBossWebMetaData wmd = (JBossWebMetaData)metadata; WebPermissionMapping.createPermissions(wmd, policyConfiguration); } else if(metadata instanceof JBossEnterpriseBeanMetaData) { JBossEnterpriseBeanMetaData bmd = (JBossEnterpriseBeanMetaData)metadata; EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } else if(metadata instanceof JBossMetaData) { JBossMetaData jmd = (JBossMetaData)metadata; JBossEnterpriseBeansMetaData beans = jmd.getEnterpriseBeans(); for(JBossEnterpriseBeanMetaData bmd : beans) { EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } } else throw new IllegalStateException("Unknown metadata"); }
// in src/main/java/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java
public EndpointInfo getEndpointInfo(String ref, String type, String vfsContext) { String prefix = type; // Parse the ref to obtain the path and endpoint name String unitPath = vfsContext; String endpointName = ref; if (ref.indexOf('#') != -1) { // <ejb-link> is of the form relative-path/file.jar#Bean String path = ref.substring(0, ref.indexOf('#')); // resolve any ../* prefix if(path.startsWith("../")) { String[] deploymentPaths = unitPath.split("/"); int count = 0; while(path.startsWith("../")) { path = path.substring(3); count ++; } // build the relative path from the root String rootPath = ""; for(int n = 0; n < (deploymentPaths.length - count); n ++) rootPath += deploymentPaths + "/"; unitPath = rootPath + path; } else { unitPath = path; } // // Get the endpoint name endpointName = ref.substring(ref.indexOf('#') + 1); } EndpointInfo info = null; String key = prefix + "/" + unitPath +"#" + endpointName; ContainerDependencyMetaData cdmd = endpointMap.get(key); if(cdmd != null) { info = new EndpointInfo(unitPath, endpointName, type); return info; } // It could not be found in the unit itself, let's search globally if(ref.indexOf('#') == -1) { // See MappedReferenceMetaDataResolverDeployer.mapEjbs if(type.equals(EndpointType.EJB)) { key = "ejb/" + ref; } else if(type.equals(EndpointType.MessageDestination)) { key = "message-destination/" + ref; } String ejbCompID = endpointAlternateMap.get(key); if(ejbCompID != null) { cdmd = endpointMap.get(ejbCompID); if(cdmd == null) throw new IllegalStateException("endpoint mapping is corrupt, can't find '" + ejbCompID + "' in " + endpointMap); info = new EndpointInfo(cdmd.getDeploymentPath(), cdmd.getComponentName(), type); return info; } } else { log.debug("Failed to find mapping for ref: "+ref+" path: "+vfsContext); if(log.isTraceEnabled()) log.trace("Available keys: "+endpointMap.keySet()); } return info; }
// in src/main/java/org/jboss/naming/NamingAlias.java
protected void startService() throws Exception { if( fromName == null ) throw new IllegalStateException("fromName is null"); if( toName == null ) throw new IllegalStateException("toName is null"); createLinkRef(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void setRollbackOnly(Object tpc) throws RemoteException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); tx.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSourceName) throws SQLException { this.server = server; this.dataSourceName = dataSourceName; // Get the DataSource from JNDI try { String dsJndiTx = (String)server.getAttribute(dataSourceName, "BindName"); ds = (DataSource)new InitialContext().lookup(dsJndiTx); } catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); } // Get the DataSource meta data String dsName = dataSourceName.getKeyProperty("name"); metaDataName = ObjectNameFactory.create("jboss.jdbc:datasource=" + dsName + ",service=metadata"); if (this.server.isRegistered(metaDataName) == false) throw new IllegalStateException("Cannot find datasource meta data: " + metaDataName); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void createTableIfNotExists() throws SQLException { Connection con = null; Statement st = null; try { JDBCTypeMappingMetaData typeMapping = (JDBCTypeMappingMetaData)server.getAttribute(metaDataName, "TypeMappingMetaData"); if (typeMapping == null) throw new IllegalStateException("Cannot obtain type mapping from: " + metaDataName); JDBCMappingMetaData objectMetaData = typeMapping.getTypeMappingMetaData(Object.class); binarySqlType = objectMetaData.getJdbcType(); if (!SQLUtil.tableExists(getTableName(), ds)) { con = ds.getConnection(); String dateType = typeMapping.getTypeMappingMetaData(Timestamp.class).getSqlType(); String longType = typeMapping.getTypeMappingMetaData(Long.class).getSqlType(); String objectType = objectMetaData.getSqlType(); // The create table DDL StringBuffer createTableDDL = new StringBuffer("create table " + getTableName() + " (" + " " + getColumnTimerID() + " varchar(80) not null," + " " + getColumnTargetID() + " varchar(250) not null," + " " + getColumnInitialDate() + " " + dateType + " not null," + " " + getColumnTimerInterval() + " " + longType + "," + " " + getColumnInstancePK() + " " + objectType + "," + " " + getColumnInfo() + " " + objectType + ", "); // Add the primary key constraint using the pk-constraint-template JDBCFunctionMappingMetaData pkConstraint = typeMapping.getPkConstraintTemplate(); String name = SQLUtil.unquote(getTableName(), ds) + "_PK"; name = SQLUtil.fixConstraintName(name, ds); String[] templateParams = new String[] { name, getColumnTimerID() + ", " + getColumnTargetID() }; pkConstraint.getFunctionSql(templateParams, createTableDDL); // Complete the statement createTableDDL.append(" )"); log.debug("Executing DDL: " + createTableDDL); st = con.createStatement(); st.executeUpdate(createTableDDL.toString()); } } catch (SQLException e) { throw e; } catch (Exception e) { log.error("Cannot create timer table", e); } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); return sc.getOutgoingRunAs(); //return SecurityAssociation.peekRunAsIdentity(); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public Object run() { //return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public Object run() { //SecurityAssociation.pushRunAsIdentity(id); SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setOutgoingRunAs(id); return null; }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public RunAs peek() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); return sc.getOutgoingRunAs(); //return SecurityAssociation.peekRunAsIdentity(); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public void push(RunAs id) { //SecurityAssociation.pushRunAsIdentity(id); SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setOutgoingRunAs(id); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public RunAs pop() { //return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBHome getEJBHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return (EJBHome) ci.getEJBHome(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public boolean isIdentical(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.isIdentical(this, mi); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBMetaData getEJBMetaDataHome() throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.getEJBMetaData(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public HomeHandle getHomeHandleHome() throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } EJBHome home = (EJBHome) ci.getEJBHome(); return home.getHomeHandle(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBLocalObject createLocalHome() throws CreateException { if (localProxyFactory == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; return localProxyFactory.getStatelessSessionEJBLocalObject(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBObject createHome() throws RemoteException, CreateException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; Object obj = ci.getStatelessSessionEJBObject(); return (EJBObject) obj; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public EJBObject getEJBObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBObject", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); if (((StatelessSessionContainer)con).getProxyFactory()==null) throw new IllegalStateException( "No remote interface defined." ); if (ejbObject == null) { EJBProxyFactory proxyFactory = con.getProxyFactory(); if(proxyFactory == null) { String defaultInvokerName = con.getBeanMetaData(). getContainerConfiguration().getDefaultInvokerName(); proxyFactory = con.lookupProxyFactory(defaultInvokerName); } ejbObject = (EJBObject) proxyFactory.getStatelessSessionEJBObject(); } return ejbObject; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public EJBLocalObject getEJBLocalObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBLocalObject", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); if (con.getLocalHomeClass()==null) throw new IllegalStateException( "No local interface for bean." ); if (ejbLocalObject == null) { ejbLocalObject = ((StatelessSessionContainer)con).getLocalProxyFactory().getStatelessSessionEJBLocalObject(); } return ejbLocalObject; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { // All we need is an EJBObject for this Id, the first argument is the Id EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Object id = mi.getArguments()[0]; if (id == null) throw new IllegalStateException("Cannot get a session interface with a null id"); // Does the session still exist? InstanceCache cache = getInstanceCache(); BeanLock lock = getLockManager().getLock(id); lock.sync(); try { if (cache.get(id) == null) throw new RemoteException("Session no longer exists: " + id); } finally { lock.releaseSync(); getLockManager().removeLockRef(id); } // Ok lets create the proxy return (EJBObject) ci.getStatefulSessionEJBObject(id); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public EJBHome getEJBHome() { throw new IllegalStateException("getEJBHome should not be access from a message driven bean"); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public EJBLocalHome getEJBLocalHome() { throw new IllegalStateException("getEJBHome should not be access from a message driven bean"); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public boolean isCallerInRole(String id) { throw new IllegalStateException("isCallerInRole should not be access from a message driven bean"); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public UserTransaction getUserTransaction() { if (isContainerManagedTx()) throw new IllegalStateException("getUserTransaction should not be access for container managed Tx"); AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); return super.getUserTransaction(); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public boolean getRollbackOnly() { if (isUserManagedTx()) throw new IllegalStateException("getRollbackOnly should not be access for user managed Tx"); AllowedOperationsAssociation.assertAllowedIn("getRollbackOnly", IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); // // jason: I think this is lame... but the spec says this is how it is. // I think it would be better to silently ignore... or not so silently // but still continue. // if (!isTxRequired()) { throw new IllegalStateException ("getRollbackOnly must only be called in the context of a transaction (EJB 2.0 - 15.5.1)"); } return super.getRollbackOnly(); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public void setRollbackOnly() { if (isUserManagedTx()) throw new IllegalStateException("setRollbackOnly should not be access for user managed Tx"); AllowedOperationsAssociation.assertAllowedIn("getRollbackOnly", IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); if (!isTxRequired()) { throw new IllegalStateException ("setRollbackOnly must only be called in the context of a transaction (EJB 2.0 - 15.5.1)"); } super.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/Container.java
public ObjectName getJmxName() { if (jmxName == null) { BeanMetaData beanMetaData = getBeanMetaData(); if (beanMetaData == null) { throw new IllegalStateException("Container metaData is null"); } String jndiName = beanMetaData.getContainerObjectNameJndiName(); if (jndiName == null) { throw new IllegalStateException("Container jndiName is null"); } // The name must be escaped since the jndiName may be arbitrary String name = BASE_EJB_CONTAINER_NAME + ",jndiName=" + jndiName; try { jmxName = ObjectNameConverter.convert(name); } catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); } } return jmxName; }
// in src/main/java/org/jboss/ejb/Container.java
public TimerService getTimerService(Object pKey) throws IllegalStateException { if (this instanceof StatefulSessionContainer) throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService"); // Validate that the bean implements the TimedObject interface if (TimedObject.class.isAssignableFrom(beanClass) == false) { // jbcts-381 return EJBTimerServiceImpl.FOR_NON_TIMED_OBJECT; } TimerService timerService = null; try { timerService = this.timerService.createTimerService(getJmxName(), pKey, this); } catch (Exception e) { throw new EJBException("Could not create timer service", e); } return timerService; }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public EJBObject getEJBObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBObject", IN_EJB_POST_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_EJB_LOAD | IN_EJB_STORE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); if(((EntityContainer)con).getRemoteClass() == null) { throw new IllegalStateException( "No remote interface defined." ); } if (ejbObject == null) { // Create a new CacheKey Object cacheKey = ((EntityCache)((EntityContainer)con).getInstanceCache()).createCacheKey(id); EJBProxyFactory proxyFactory = con.getProxyFactory(); if(proxyFactory == null) { String defaultInvokerName = con.getBeanMetaData(). getContainerConfiguration().getDefaultInvokerName(); proxyFactory = con.lookupProxyFactory(defaultInvokerName); } ejbObject = (EJBObject)proxyFactory.getEntityEJBObject(cacheKey); } return ejbObject; }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public EJBLocalObject getEJBLocalObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBLocalObject", IN_EJB_POST_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_EJB_LOAD | IN_EJB_STORE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); if (con.getLocalHomeClass()==null) throw new IllegalStateException( "No local interface for bean." ); if (ejbLocalObject == null) { Object cacheKey = ((EntityCache)((EntityContainer)con).getInstanceCache()).createCacheKey(id); ejbLocalObject = ((EntityContainer)con).getLocalProxyFactory().getEntityEJBLocalObject(cacheKey); } return ejbLocalObject; }
// in src/main/java/org/jboss/ejb/deployers/CreateDestination.java
public void create() { if (matcher == null) throw new IllegalStateException("No matcher has been set"); if (factory == null) throw new IllegalStateException("No factory has been set"); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public boolean canPassivate(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to passivate with a null object"); HashMap mapInUse = getHashMap(id); synchronized (mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock == null) throw new IllegalStateException("Attempt to passivate without a lock"); return (lock.getRefs() <= 1); } }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public EJBObject getEJBObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBObject", IN_EJB_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_BUSINESS_METHOD | IN_AFTER_BEGIN | IN_BEFORE_COMPLETION | IN_AFTER_COMPLETION); if (((StatefulSessionContainer)con).getRemoteClass()==null) throw new IllegalStateException( "No remote interface defined." ); if (ejbObject == null) { EJBProxyFactory proxyFactory = con.getProxyFactory(); if(proxyFactory == null) { String defaultInvokerName = con.getBeanMetaData(). getContainerConfiguration().getDefaultInvokerName(); proxyFactory = con.lookupProxyFactory(defaultInvokerName); } ejbObject = (EJBObject) proxyFactory.getStatefulSessionEJBObject(id); } return ejbObject; }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public EJBLocalObject getEJBLocalObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBLocalObject", IN_EJB_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_BUSINESS_METHOD | IN_AFTER_BEGIN | IN_BEFORE_COMPLETION | IN_AFTER_COMPLETION); if (con.getLocalHomeClass()==null) throw new IllegalStateException( "No local interface for bean." ); if (ejbLocalObject == null) { ejbLocalObject = ((StatefulSessionContainer)con).getLocalProxyFactory().getStatefulSessionEJBLocalObject(id); } return ejbLocalObject; }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { throw new IllegalStateException("getTimerService should not be access from a stateful session bean"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
Principal getCallerPrincipalInternal() { if( beanPrincipal == null ) { RealmMapping rm = con.getRealmMapping(); SecurityContext sc = SecurityActions.getSecurityContext(); Principal caller = null; try { caller = SecurityHelperFactory.getEJBAuthorizationHelper(sc).getCallerPrincipal(); } catch (Exception e) { log.error("Error getting callerPrincipal for " + con.getBeanClass(),e); } /* Apply any domain caller mapping. This should really only be done for non-run-as callers. */ if (rm != null) caller = rm.getPrincipal(caller); if( caller == null ) { /* Try the incoming request principal. This is needed if a client clears the current caller association and and an interceptor calls getCallerPrincipal as the call stack unwinds. */ if( principal != null ) { if( rm != null ) caller = rm.getPrincipal(principal); else caller = principal; } // Check for an unauthenticated principal value else { ApplicationMetaData appMetaData = con.getBeanMetaData().getApplicationMetaData(); String name = appMetaData.getUnauthenticatedPrincipal(); if (name != null) caller = new SimplePrincipal(name); } } if( caller == null ) { throw new IllegalStateException("No valid security context for the caller identity"); } /* Save caller as the beanPrincipal for reuse if getCallerPrincipal is called as the stack unwinds. An example of where this would occur is the cmp2 audit layer. */ beanPrincipal = caller; } return beanPrincipal; }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public EJBHome getEJBHome() { EJBProxyFactory proxyFactory = con.getProxyFactory(); if (proxyFactory == null) throw new IllegalStateException("No remote home defined."); return (EJBHome) proxyFactory.getEJBHome(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public EJBLocalHome getEJBLocalHome() { if (con.getLocalHomeClass() == null) throw new IllegalStateException("No local home defined."); if (con instanceof EntityContainer) return ((EntityContainer) con).getLocalProxyFactory().getEJBLocalHome(); else if (con instanceof StatelessSessionContainer) return ((StatelessSessionContainer) con).getLocalProxyFactory().getEJBLocalHome(); else if (con instanceof StatefulSessionContainer) return ((StatefulSessionContainer) con).getLocalProxyFactory().getEJBLocalHome(); // Should never get here throw new EJBException("No EJBLocalHome available (BUG!)"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public boolean getRollbackOnly() { // EJB1.1 11.6.1: Must throw IllegalStateException if BMT if (con.getBeanMetaData().isBeanManagedTx()) throw new IllegalStateException("getRollbackOnly() not allowed for BMT beans."); try { TransactionManager tm = con.getTransactionManager(); // The getRollbackOnly and setRollBackOnly method of the SessionContext interface should be used // only in the session bean methods that execute in the context of a transaction. if (tm.getTransaction() == null) throw new IllegalStateException("getRollbackOnly() not allowed without a transaction."); // JBAS-3847, consider an asynchronous rollback due to timeout int status = tm.getStatus(); return TxUtils.isRollback(status); } catch (SystemException e) { log.warn("failed to get tx manager status; ignoring", e); return true; } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void setRollbackOnly() { // EJB1.1 11.6.1: Must throw IllegalStateException if BMT if (con.getBeanMetaData().isBeanManagedTx()) throw new IllegalStateException("setRollbackOnly() not allowed for BMT beans."); try { TransactionManager tm = con.getTransactionManager(); // The getRollbackOnly and setRollBackOnly method of the SessionContext interface should be used // only in the session bean methods that execute in the context of a transaction. if (tm.getTransaction() == null) throw new IllegalStateException("setRollbackOnly() not allowed without a transaction."); tm.setRollbackOnly(); } catch (SystemException e) { log.warn("failed to set rollback only; ignoring", e); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public UserTransaction getUserTransaction() { if (userTransaction == null) { if (isContainerManagedTx()) { throw new IllegalStateException ("CMT beans are not allowed to get a UserTransaction"); } userTransaction = new UserTransactionImpl(); } return userTransaction; }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void startDelivery() throws Exception { if (getState() != STARTED) throw new IllegalStateException("The MDB is not started"); if (deliveryActive.getAndSet(true)) return; activate(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void stopDelivery(boolean asynch) throws Exception { if (getState() != STARTED) throw new IllegalStateException("The MDB is not started"); if (deliveryActive.getAndSet(false) == false) return; if (asynch) { new Thread("StopDelivery: " + getServiceName()) { public void run() { deactivate(); } }.start(); } else { deactivate(); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
public Object invoke(Invocation mi) throws Throwable { // Are we still useable? if (released.get()) throw new IllegalStateException("This message endpoint + " + getProxyString(mi) + " has been released"); // Concurrent invocation? synchronized (this) { Thread currentThread = Thread.currentThread(); if (inUseThread != null && inUseThread.equals(currentThread) == false) throw new IllegalStateException("This message endpoint + " + getProxyString(mi) + " is already in use by another thread " + inUseThread); inUseThread = currentThread; } String method = mi.getMethod().getName(); if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " in use by " + method + " " + inUseThread); // Which operation? if (method.equals("release")) { release(mi); return null; } else if (method.equals("beforeDelivery")) { before(mi); return null; } else if (method.equals("afterDelivery")) { after(mi); return null; } else return delivery(mi); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void before(Invocation mi) throws Throwable { // Called out of sequence if (getBeforeDeliveryInvoke()) throw new IllegalStateException("Missing afterDelivery from the previous beforeDelivery for message endpoint " + getProxyString(mi)); // Set the classloader MessageDrivenContainer container = getContainer(mi); synchronized (this) { oldClassLoader = GetTCLAction.getContextClassLoader(inUseThread); SetTCLAction.setContextClassLoader(inUseThread, container.getClassLoader()); } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " set context classloader to " + container.getClassLoader()); // start any transaction try { startTransaction("beforeDelivery", mi, container); setBeforeDeliveryInvoke(true); } catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void after(Invocation mi) throws Throwable { // Called out of sequence if(!getBeforeDeliveryInvoke()) { throw new IllegalStateException("afterDelivery without a previous beforeDelivery for message endpoint " + getProxyString(mi)); } // Finish this delivery committing if we can try { finish("afterDelivery", mi, true); } catch (Throwable t) { throw new ResourceException(t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected Object delivery(Invocation mi) throws Throwable { // Have we already delivered a message? if (delivered.get()) throw new IllegalStateException("Multiple message delivery between before and after delivery is not allowed for message endpoint " + getProxyString(mi)); if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivering"); // Mark delivery if beforeDelivery was invoked if (getOldClassLoader() != null) delivered.set(true); MessageDrivenContainer container = getContainer(mi); boolean commit = true; try { // Check for starting a transaction if (getOldClassLoader() == null) startTransaction("delivery", mi, container); return getNext().invoke(mi); } catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; } finally { // No before/after delivery, end any transaction and release the lock if (getOldClassLoader() == null) { try { // Finish any transaction we started endTransaction(mi, commit); } finally { releaseThreadLock(mi); } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected JBossMessageEndpointFactory getMessageEndpointFactory(Invocation mi) { if (endpointFactory == null) endpointFactory = (JBossMessageEndpointFactory) mi.getInvocationContext().getValue(MESSAGE_ENDPOINT_FACTORY); if (endpointFactory == null) throw new IllegalStateException("No message endpoint factory in " + mi.getInvocationContext().context); return endpointFactory; }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected MessageDrivenContainer getContainer(Invocation mi) { JBossMessageEndpointFactory messageEndpointFactory = getMessageEndpointFactory(mi); MessageDrivenContainer container = messageEndpointFactory.getContainer(); if (container == null) throw new IllegalStateException("No container associated with message endpoint factory: " + messageEndpointFactory.getServiceName()); return container; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private Object readResolve() throws ObjectStreamException { server = MBeanServerLocator.locateJBoss(); tm = TransactionManagerLocator.getInstance().locate(); try { ds = lookupDataSource(dataSource); } catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); } return this; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
public synchronized Object generateKey() { if(lo < hi) { ++lo; } else { Transaction curTx = null; try { curTx = tm.suspend(); } catch(SystemException e) { throw new IllegalStateException("Failed to suspend current transaction."); } try { tm.begin(); } catch(Exception e) { throw new IllegalStateException("Failed to begin a new transaction."); } try { doGenerate(); tm.commit(); } catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); } catch(Exception e) { log.error("Failed to commit.", e); } finally { if(curTx != null) { try { tm.resume(curTx); } catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); } } } } return new Long(lo); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private long selectHi() throws SQLException { Connection con = null; PreparedStatement selectHiSt = null; ResultSet rs = null; if(log.isTraceEnabled()) { log.trace("Executing SQL: " + selectHiSql); } try { con = ds.getConnection(); selectHiSt = con.prepareStatement(selectHiSql); rs = selectHiSt.executeQuery(); if(!rs.next()) { throw new IllegalStateException("The sequence has not been initialized in the service start phase!"); } return rs.getLong(1); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(selectHiSt); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invoke(mi); } finally { } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { Method getEJBObject = Handle.class.getMethod("getEJBObject", new Class[0]); //Invocation on the handle, we don't need a bean instance if (getEJBObject.equals(mi.getMethod())) return getNext().invokeHome(mi); EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invokeHome(mi); } finally { } }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private void endTransaction(final Invocation invocation, final Transaction tx, final Transaction oldTx, final int oldTimeout) throws TransactionRolledbackException, SystemException { // Assert the correct transaction association Transaction current = tm.getTransaction(); if ((tx == null && current != null) || tx.equals(current) == false) throw new IllegalStateException("Wrong transaction association: expected " + tx + " was " + current); try { // Marked rollback if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) { tx.rollback(); } else { // Commit tx // This will happen if // a) everything goes well // b) app. exception was thrown tx.commit(); } } catch (RollbackException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicMixedException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicRollbackException e) { throwJBossException(e, invocation.getType()); } catch (SystemException e) { throwJBossException(e, invocation.getType()); } catch (IllegalStateException e) { throwJBossException(e, invocation.getType()); } finally { // reassociate the oldTransaction with the Invocation (even null) invocation.setTransaction(oldTx); // Always drop thread association even if committing or // rolling back the newTransaction because not all TMs // will drop thread associations when commit() or rollback() // are called through tx itself (see JTA spec that seems to // indicate that thread assoc is required to be dropped only // when commit() and rollback() are called through TransactionManager // interface) //tx has committed, so we can't throw txRolledbackException. tm.suspend(); // Reset the transaction timeout (unless we didn't set it) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { //return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { //SecurityAssociation.pushRunAsIdentity((RunAsIdentity)id); SecurityContext sa = SecurityContextAssociation.getSecurityContext(); if(sa == null) throw new IllegalStateException("Security Context is null to push runas"); sa.setOutgoingRunAs(id); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public void push(RunAs id) { //SecurityAssociation.pushRunAsIdentity(id); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null to push runas"); sc.setOutgoingRunAs(id); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public RunAs pop() { //Pop the RAI // return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = null; ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.getUtil().createSubjectInfo(p, cred, s); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); Principal p = sc.getUtil().getUserPrincipal(); Object cred = sc.getUtil().getCredential(); sc.getUtil().createSubjectInfo(p,cred,null); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(ra); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(null); return null; }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void releaseReadLock(Transaction transaction) { if(trace) trace(transaction, "READ (UL)"); if(!readers.remove(transaction)) throw new IllegalStateException("ReadWriteEJBLock: Read lock released when it wasn't taken"); notifyWaiters(); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void releaseWriteLock(Transaction transaction) { if(trace) trace(transaction, "WRITE (UL)"); if (synched == null) throw new IllegalStateException("ReadWriteEJBLock: Do not call nextTransaction while not synched!"); if(writer != null && !writer.equals(transaction)) throw new IllegalStateException("ReadWriteEJBLock: can't unlock a write lock with a different transaction"); writer = null; notifyWaiters(); }
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
public void release(boolean nonReentrant) { synchronized(lock) { held--; if(held < 0) { throw new IllegalStateException("Released lock too many times"); } else if(held == 0) { lockHolder = null; holdingTx = null; lock.notify(); } if(nonReentrant) { inNonReentrant = false; } } }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected void nextTransaction() { if (synched == null) { throw new IllegalStateException("do not call nextTransaction while not synched!"); } setTransaction(null); // is there a waiting list? if (!txWaitQueue.isEmpty()) { TxLock thelock = (TxLock) txWaitQueue.removeFirst(); txLocks.remove(thelock); thelock.isQueued = false; // The new transaction is the next one, important to set it up to avoid race with // new incoming calls setTransaction(thelock.waitingTx); // log.debug(Thread.currentThread()+" handing off to "+lock.threadName); if( deadlockDetection == true ) DeadlockDetector.singleton.removeWaiting(thelock.deadlocker); synchronized (thelock) { // notify All threads waiting on this transaction. // They will enter the methodLock wait loop. thelock.notifyAll(); } } else { // log.debug(Thread.currentThread()+" handing off to empty queue"); } }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
public void removeRef() { refs--; if (refs == 0 && txWaitQueue.size() > 0) { log.error("removing bean lock and it has tx's in QUEUE! " + toString()); throw new IllegalStateException("removing bean lock and it has tx's in QUEUE!"); } else if (refs == 0 && getTransaction() != null) { log.error("removing bean lock and it has tx set! " + toString()); throw new IllegalStateException("removing bean lock and it has tx set!"); } else if (refs < 0) { log.error("negative lock reference count should never happen !"); throw new IllegalStateException("negative lock reference count !"); } }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void insert(Object key, Object ctx) { if (ctx == null) { throw new IllegalArgumentException("Cannot insert a null object in the cache"); } if (key == null) { throw new IllegalArgumentException("Cannot insert an object in the cache with null key"); } synchronized (m_map) { Object obj = m_map.get(key); if (obj == null) { m_map.put(key, ctx); } else { throw new IllegalStateException("Attempt to put in the cache an object that is already there"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
private void delete(View view) throws SQLException { if(view.deleted == null) { if(log.isTraceEnabled()) { log.trace("no rows to delete"); } return; } Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + deleteSql); } con = ds.getConnection(); ps = con.prepareStatement(deleteSql); int batchCount = 0; while(view.deleted != null) { RelationKeys keys = view.deleted; int paramInd = 1; JDBCCMPFieldBridge2[] keyFields = (JDBCCMPFieldBridge2[])leftField.getTableKeyFields(); for(int pkInd = 0; pkInd < keyFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = keyFields[pkInd]; Object fieldValue = pkField.getPrimaryKeyValue(keys.leftKey); paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } keyFields = (JDBCCMPFieldBridge2[])rightField.getTableKeyFields(); for(int pkInd = 0; pkInd < keyFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = keyFields[pkInd]; Object fieldValue = pkField.getPrimaryKeyValue(keys.rightKey); paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } ps.addBatch(); ++batchCount; keys.dereference(); } ps.executeBatch(); if(view.deleted != null) { throw new IllegalStateException("There are still rows to delete!"); } if(log.isTraceEnabled()) { log.trace("deleted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
private Views getViews() { Transaction tx = txLocal.getTransaction(); GlobalTxSynchronization globalSync; try { globalSync = txLocal.getGlobalSynchronization(tx); } catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); } catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); } if(globalSync == null) throw new IllegalStateException("Global transaction synchronization is not available for transaction " + tx); Views views = (Views) globalSync.getTxLocal(viewsTxLocalKey); if(views == null) { views = new Views(tx); globalSync.putTxLocal(viewsTxLocalKey, views); globalSync.addSynchronization(new SchemaSynchronization(views)); } return views; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void delete(View view) throws SQLException { JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + deleteSql); } con = dataSource.getConnection(); ps = con.prepareStatement(deleteSql); int batchCount = 0; while(view.deleted != null) { Row row = view.deleted; int paramInd = 1; for(int pkInd = 0; pkInd < pkFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = pkFields[pkInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } deleteStrategy.executeUpdate(ps); ++batchCount; row.flushStatus(); } deleteStrategy.executeBatch(ps); if(view.deleted != null) { throw new IllegalStateException("There are still rows to delete!"); } if(log.isTraceEnabled()) { log.trace("deleted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public Row getRowByPk(Object pk, boolean required) { /* Row cursor = clean; while(cursor != null) { if(pk.equals(cursor.pk)) { return cursor; } cursor = cursor.next; } cursor = dirty; while(cursor != null) { if(pk.equals(cursor.pk)) { return cursor; } cursor = cursor.next; } cursor = created; while(cursor != null) { if(pk.equals(cursor.pk)) { return cursor; } cursor = cursor.next; } */ Row row = (Row) rowByPk.get(pk); if(row == null) { Object[] fields; Object[] relations = null; try { cache.lock(pk); fields = cache.getFields(pk); if(fields != null && relationsTotal > 0) { relations = cache.getRelations(pk); if(relations == null) { relations = new Object[relationsTotal]; } } } finally { cache.unlock(pk); } if(fields != null) { row = createCleanRow(pk, fields, relations); } } if(row == null && required) { throw new IllegalStateException("row not found: pk=" + pk); } return row; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void committed() { if(cacheUpdates != null) { Row cursor = cacheUpdates; while(cursor != null) { //if(cursor.lockedForUpdate) //{ cache.lock(cursor.pk); try { switch(cursor.state) { case CLEAN: cache.put(tx, cursor.pk, cursor.fields, cursor.relations); break; case DELETED: try { cache.remove(tx, cursor.pk); } catch(Cache.RemoveException e) { log.trace(e.getMessage()); } break; default: throw new IllegalStateException("Unexpected row state: table=" + entity.getQualifiedTableName() + ", pk=" + cursor.pk + ", state=" + cursor.state); } } finally { cache.unlock(cursor.pk); } //cursor.lockedForUpdate = false; //} cursor = cursor.nextCacheUpdate; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void delete() { if(state == CLEAN || state == DIRTY || state == DIRTY_RELATIONS) { updateState(DELETED); } else if(state == CREATED) { dereference(); state = DELETED; view.rowByPk.remove(pk); } else if(state == DELETED) { throw new IllegalStateException("The row is already deleted: pk=" + pk); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void updateState(byte state) { dereference(); if(state == CLEAN) { if(view.clean != null) { next = view.clean; view.clean.prev = this; } view.clean = this; } else if(state == DIRTY) { if(view.dirty != null) { next = view.dirty; view.dirty.prev = this; } view.dirty = this; } else if(state == CREATED) { if(view.created != null) { next = view.created; view.created.prev = this; } view.created = this; } else if(state == DELETED) { if(view.deleted != null) { next = view.deleted; view.deleted.prev = this; } view.deleted = this; } else if(state == DIRTY_RELATIONS) { if(view.dirtyRelations != null) { next = view.dirtyRelations; view.dirtyRelations.prev = this; } view.dirtyRelations = this; } else { throw new IllegalStateException("Can't update to state: " + state); } this.state = state; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
public void isInvalid(Serializable key) { Transaction tx = null; try { tx = tm.getTransaction(); } catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); } if(log.isTraceEnabled()) { log.trace("invalidating key=" + key); } cache.lock(key); try { cache.remove(tx, key); } catch(Cache.RemoveException e) { if(log.isTraceEnabled()) { log.trace(e.getMessage()); } } finally { cache.unlock(key); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
public void areInvalid(Serializable[] keys) { Transaction tx = null; try { tx = tm.getTransaction(); } catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); } boolean trace = log.isTraceEnabled(); for(int i = 0; i < keys.length; ++i) { if(trace) { log.trace("invalidating key[" + i + "]=" + keys[i]); } cache.lock(keys[i]); try { cache.remove(tx, keys[i]); } catch(Cache.RemoveException e) { if(trace) { log.trace(e.getMessage()); } } finally { cache.unlock(keys[i]); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public synchronized void unlock() { if(!locked) { throw new IllegalStateException("The instance is not locked!"); } locked = false; notify(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public void setValueInternal(EntityEnterpriseContext ctx, Object value, boolean makeDirty) { PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); // todo this is weird if(cmpFieldIAmMappedTo != null && cmpFieldIAmMappedTo.isPrimaryKeyMember) { Object curValue = pctx.getFieldValue(rowIndex); if(value != null && !value.equals(curValue)) { throw new IllegalStateException( "Attempt to modify a primary key field through a foreign key field mapped to it: " + entity.getEntityName() + "." + cmpFieldIAmMappedTo.getFieldName() + " -> " + entity.getQualifiedTableName() + "." + cmpFieldIAmMappedTo.getColumnName() + ", current value=" + curValue + ", new value=" + value ); } makeDirty = false; } else { pctx.setFieldValue(rowIndex, value); } if(makeDirty) { pctx.setDirty(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object loadArgumentResults(ResultSet rs, int parameterIndex) throws IllegalArgumentException { try { // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); if(javaTypes.length > 1) { throw new IllegalStateException("Complex types are not supported yet."); } JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); Object columnValue = null; for(int i = 0; i < javaTypes.length; i++) { columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); columnValue = jdbcType.setColumnValue(i, null, columnValue); } // retrun the updated parameterIndex return columnValue; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void addLoadedPk(Object pk) { if(loaded) { throw new IllegalStateException(entity.getEntityName() + "." + getFieldName() + " single-valued CMR field is already loaded. Check the database for consistancy. " + " current value=" + value + ", loaded value=" + pk ); } changeValue(pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void addLoadedPk(Object pk) { if(loaded) { throw new IllegalStateException(entity.getEntityName() + "." + getFieldName() + " collection-valued CMR field is already loaded. Check the database for consistancy. " + " current value=" + value + ", loaded value=" + pk ); } if(pk != null) { value.add(pk); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void remove() { try { idIter.remove(); } catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); } removeById(curId); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean hasNext() { try { return idIter.hasNext(); } catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public Object next() { try { curId = idIter.next(); } catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); } return relatedContainer.getLocalProxyFactory().getEntityEJBLocalObject(curId); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/EJBSelectBridge.java
public Object execute(Object[] args) throws FinderException { JDBCStoreManager2 manager = command.getStoreManager(); GenericEntityObjectFactory factory = (metadata.isResultTypeMappingLocal() ? (GenericEntityObjectFactory)manager.getContainer().getLocalProxyFactory() : manager.getContainer().getProxyFactory()); Object result; switch(returnType) { case SINGLE: result = command.fetchOne(schema, factory, args); if(result == null && getMethod().getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + getMethod().getReturnType().getName() ); } break; case COLLECTION: result = command.fetchCollection(schema, factory, args); break; default: throw new IllegalStateException("Unexpected return type: " + returnType); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public FieldBridge getFieldByName(String fieldName) { FieldBridge field; for(int i = 0; i < pkFields.length; ++i) { field = pkFields[i]; if(field.getFieldName().equals(fieldName)) { return field; } } for(int i = 0; i < cmpFields.length; ++i) { field = cmpFields[i]; if(field.getFieldName().equals(fieldName)) { return field; } } for(int i = 0; i < cmrFields.length; ++i) { field = cmrFields[i]; if(field.getFieldName().equals(fieldName)) { return field; } } throw new IllegalStateException("Field " + fieldName + " not found in entity " + getEntityName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
public JDBCFunctionMappingMetaData getFunctionMapping(String name) { JDBCFunctionMappingMetaData funcMapping = (JDBCFunctionMappingMetaData)functionMappings.get(name.toLowerCase()); if(funcMapping == null) throw new IllegalStateException("Function " + name + " is not defined for " + this.name); return funcMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
public JDBCApplicationMetaData load() throws DeploymentException { JDBCApplicationMetaData jamd = new JDBCApplicationMetaData( container.getBeanMetaData().getApplicationMetaData(), container.getClassLoader() ); // Load standardjbosscmp-jdbc.xml from the default classLoader // we always load defaults first URL stdJDBCUrl = container.getClassLoader().getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if (debug) log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); // first create the metadata jamd = new JDBCApplicationMetaData(stdJDBCElement, jamd); // Load jbosscmp-jdbc.xml if provided URL jdbcUrl = null; VirtualFile dd = container.getDeploymentUnit().getMetaDataFile("jbosscmp-jdbc.xml"); if(dd != null) { try { jdbcUrl = dd.toURL(); } catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); } } if(jdbcUrl != null) { if (debug) log.debug(jdbcUrl.toString() + " found. Overriding defaults"); Element jdbcElement = XmlFileLoader.getDocument(jdbcUrl, true).getDocumentElement(); jamd = new JDBCApplicationMetaData(jdbcElement, jamd); } return jamd; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public boolean add(Object o) { if(firstIterator == null) { return results.add(o); } throw new IllegalStateException("Can't modify collection while the first iterator is not exhausted."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public boolean remove(Object o) { if(firstIterator == null) { return results.remove(o); } throw new IllegalStateException("Can't modify collection while the first iterator is not exhausted."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private static Object cloneValue(Object fieldValue, Class argType) { if(fieldValue == null) { return null; } Class valueType = fieldValue.getClass(); Constructor ctor; try { ctor = valueType.getConstructor(new Class[]{argType}); } catch(NoSuchMethodException e) { throw new IllegalStateException( "Failed to find a ctor in " + valueType + " that takes an instance of " + argType + " as an argument." ); } try { return ctor.newInstance(new Object[]{fieldValue}); } catch(Exception e) { throw new IllegalStateException( "Failed to create an instance of " + valueType + " with the " + fieldValue + " as a ctor argument" ); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public JDBCType getJDBCType(Class javaType) { if(complexTypes.containsKey(javaType)) { return (JDBCTypeComplex)complexTypes.get(javaType); } else { JDBCTypeSimple type = (JDBCTypeSimple)mappedSimpleTypes.get(javaType); if(type == null) { JDBCUserTypeMappingMetaData userTypeMapping = (JDBCUserTypeMappingMetaData)userTypeMappings.get(javaType.getName()); Mapper mapper = null; if(userTypeMapping != null) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { javaType = cl.loadClass(userTypeMapping.getMappedType()); } catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); } try { mapper = (Mapper)newInstance(userTypeMapping.getMapper()); } catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); } } JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType); String sqlType = typeMappingMD.getSqlType(); int jdbcType = typeMappingMD.getJdbcType(); boolean notNull = javaType.isPrimitive(); boolean autoIncrement = false; JDBCParameterSetter paramSetter; if(typeMappingMD.getParamSetter() != null) { try { paramSetter = (JDBCParameterSetter)newInstance(typeMappingMD.getParamSetter()); } catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); } } else { paramSetter = JDBCUtil.getParameterSetter(jdbcType, javaType); } JDBCResultSetReader resultReader; if(typeMappingMD.getResultReader() != null) { try { resultReader = (JDBCResultSetReader)newInstance(typeMappingMD.getResultReader()); } catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); } } else { resultReader = JDBCUtil.getResultSetReader(jdbcType, javaType); } type = new JDBCTypeSimple( null, javaType, jdbcType, sqlType, notNull, autoIncrement, mapper, paramSetter, resultReader ); } return type; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTEJBQL node, Object data) { Node selectNode = node.jjtGetChild(0); Node fromNode = node.jjtGetChild(1); // compile selectNode StringBuffer selectClause = new StringBuffer(50); selectNode.jjtAccept(this, selectClause); StringBuffer whereClause = null; StringBuffer orderByClause = null; for(int i = 2; i < node.jjtGetNumChildren(); ++i) { Node childNode = node.jjtGetChild(i); if(childNode instanceof ASTWhere) { whereClause = new StringBuffer(20); childNode.jjtAccept(this, whereClause); } else if(childNode instanceof ASTOrderBy) { orderByClause = new StringBuffer(); childNode.jjtAccept(this, orderByClause); } else if(childNode instanceof ASTLimitOffset) { childNode.jjtAccept(this, null); } } // compile fromNode StringBuffer fromClause = new StringBuffer(30); fromNode.jjtAccept(this, fromClause); // left-join for(Iterator iter = identifierToTable.entrySet().iterator(); iter.hasNext();) { final Map.Entry entry = (Map.Entry) iter.next(); final String identifier = (String) entry.getKey(); final String table = (String) entry.getValue(); final String alias = aliasManager.getAlias(identifier); fromClause.append(table).append(' ').append(alias); join(alias, fromClause); if(iter.hasNext()) { fromClause.append(SQLUtil.COMMA); } } selectDistinct = ((ASTSelect) selectNode).distinct || returnType == Set.class || forceDistinct; // assemble sql StringBuffer sql = (StringBuffer) data; if(selectManager.getMetaData().hasRowLocking() && !(selectObject instanceof SelectFunction)) { JDBCFunctionMappingMetaData rowLockingTemplate = typeMapping.getRowLockingTemplate(); if(rowLockingTemplate == null) { throw new IllegalStateException("Row locking template is not defined for given mapping: " + typeMapping.getName()); } boolean distinct = selectDistinct; Object args[] = new Object[]{ distinct ? SQLUtil.DISTINCT + selectClause : selectClause.toString(), fromClause, whereClause == null || whereClause.length() == 0 ? null : whereClause, orderByClause == null || orderByClause.length() == 0 ? null : orderByClause }; rowLockingTemplate.getFunctionSql(args, sql); } else { sql.append(SQLUtil.SELECT); if(selectDistinct) { sql.append(SQLUtil.DISTINCT); } sql.append(selectClause) .append(SQLUtil.FROM) .append(fromClause); if(whereClause != null && whereClause.length() > 0) { sql.append(SQLUtil.WHERE).append(whereClause); } if(orderByClause != null && orderByClause.length() > 0) { sql.append(SQLUtil.ORDERBY).append(orderByClause); } } if(countCompositePk) { sql.insert(0, "SELECT COUNT(*) FROM (").append(") t_count"); } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTLimitOffset node, Object data) { int child = 0; if(node.hasOffset) { Node offsetNode = node.jjtGetChild(child++); if(offsetNode instanceof ASTParameter) { ASTParameter param = (ASTParameter) offsetNode; Class parameterType = getParameterType(param.number); if(int.class != parameterType && Integer.class != parameterType) { throw new IllegalStateException("OFFSET parameter must be an int"); } offsetParam = param.number; } else { ASTExactNumericLiteral param = (ASTExactNumericLiteral) offsetNode; offsetValue = (int) param.value; } } if(node.hasLimit) { Node limitNode = node.jjtGetChild(child); if(limitNode instanceof ASTParameter) { ASTParameter param = (ASTParameter) limitNode; Class parameterType = getParameterType(param.number); if(int.class != parameterType && Integer.class != parameterType) { throw new IllegalStateException("LIMIT parameter must be an int"); } limitParam = param.number; } else { ASTExactNumericLiteral param = (ASTExactNumericLiteral) limitNode; limitValue = (int) param.value; } } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTSelect select, Object data) { StringBuffer sql = (StringBuffer) data; final Node child0 = select.jjtGetChild(0); final ASTPath path; if(child0 instanceof ASTPath) { path = (ASTPath) child0; if(path.isCMPField()) { // set the select object JDBCFieldBridge selectField = (JDBCFieldBridge) path.getCMPField(); selectManager = selectField.getManager(); selectObject = selectField; setTypeFactory(selectManager.getJDBCTypeFactory()); // todo inner or left? //addLeftJoinPath(path); addInnerJoinPath(path); String alias = aliasManager.getAlias(path.getPath(path.size() - 2)); SQLUtil.getColumnNamesClause(selectField, alias, sql); } else { JDBCAbstractEntityBridge selectEntity = (JDBCAbstractEntityBridge) path.getEntity(); selectManager = selectEntity.getManager(); selectObject = selectEntity; setTypeFactory(selectEntity.getManager().getJDBCTypeFactory()); final String alias = aliasManager.getAlias(path.getPath()); if(select.distinct) { SQLUtil.getSearchableColumnNamesClause(selectEntity.getTableFields(), alias, sql); } else { SQLUtil.getColumnNamesClause(selectEntity.getTableFields(), alias, sql); } /* if(readAhead.isOnFind()) { String eagerLoadGroupName = readAhead.getEagerLoadGroup(); boolean[] loadGroupMask = selectEntity.getLoadGroupMask(eagerLoadGroupName); SQLUtil.appendColumnNamesClause( selectEntity.getTableFields(), loadGroupMask, alias, sql ); } */ addLeftJoinPath(path); } } else { // the function should take a path expresion as a parameter path = getPathFromChildren(child0); if(path == null) { throw new IllegalStateException("The function in SELECT clause does not contain a path expression."); } if(path.isCMPField()) { JDBCFieldBridge selectField = (JDBCFieldBridge) path.getCMPField(); selectManager = selectField.getManager(); setTypeFactory(selectManager.getJDBCTypeFactory()); if(selectField.getJDBCType().hasMapper()) this.functionJDBCType = selectField.getJDBCType(); } else if(path.isCMRField()) { JDBCFieldBridge cmrField = (JDBCFieldBridge) path.getCMRField(); selectManager = cmrField.getManager(); setTypeFactory(selectManager.getJDBCTypeFactory()); addLeftJoinPath(path); } else { final JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge) path.getEntity(); selectManager = entity.getManager(); setTypeFactory(selectManager.getJDBCTypeFactory()); addLeftJoinPath(path); } selectObject = child0; child0.jjtAccept(this, data); } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTNullComparison node, Object data) { StringBuffer sql = (StringBuffer) data; final Node child0 = node.jjtGetChild(0); if(child0 instanceof ASTPath) { ASTPath path = (ASTPath) child0; addLeftJoinPath(path); JDBCFieldBridge field = (JDBCFieldBridge) path.getField(); if(field instanceof JDBCAbstractCMRFieldBridge) { JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge)field; final String alias; final JDBCFieldBridge[] keyFields; if(cmrField.hasForeignKey()) { alias = aliasManager.getAlias(path.getPath(path.size() - 2)); keyFields = cmrField.getForeignKeyFields(); } else { alias = aliasManager.getAlias(path.getPath()); if(cmrField.getMetaData().getRelationMetaData().isTableMappingStyle()) { keyFields = cmrField.getRelatedCMRField().getEntity().getPrimaryKeyFields(); } else { keyFields = cmrField.getRelatedCMRField().getForeignKeyFields(); } } SQLUtil.getIsNullClause(node.not, keyFields, alias, sql); } else { String alias = aliasManager.getAlias(path.getPath(path.size() - 2)); SQLUtil.getIsNullClause(node.not, field, alias, sql); } } else if(child0 instanceof ASTParameter) { ASTParameter param = (ASTParameter) child0; Class type = getParameterType(param.number); QueryParameter queryParam = new QueryParameter(param.number - 1, typeFactory.getJDBCType(type)); inputParameters.add(queryParam); sql.append("? IS "); if(node.not) { sql.append(SQLUtil.NOT); } sql.append(SQLUtil.NULL); } else { throw new IllegalStateException("Unexpected node in IS NULL clause: " + node); } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTIsEmpty node, Object data) { ASTPath path = (ASTPath) node.jjtGetChild(0); if(!path.isCMRField()) { throw new IllegalStateException("IS EMPTY can be applied only to collection valued CMR field."); } addLeftJoinPath(path); StringBuffer sql = (StringBuffer) data; JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge) path.getCMRField(); JDBCAbstractEntityBridge relatedEntity = (JDBCAbstractEntityBridge) cmrField.getRelatedEntity(); String alias = aliasManager.getAlias(path.getPath()); SQLUtil.getIsNullClause(node.not, relatedEntity.getPrimaryKeyFields(), alias, sql); return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTMemberOf node, Object data) { Node member = node.jjtGetChild(0); ASTPath colPath = (ASTPath) node.jjtGetChild(1); JDBCAbstractEntityBridge colEntity = (JDBCAbstractEntityBridge) colPath.getEntity(); StringBuffer sql = (StringBuffer) data; if(node.not) { sql.append(SQLUtil.NOT); } sql.append(SQLUtil.EXISTS).append('(').append(SQLUtil.SELECT); if(member instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) member; verifyParameterEntityType(toParam.number, colEntity); inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, colEntity)); String parentAlias = aliasManager.getAlias(colPath.getPath(0)); String localParentAlias = aliasManager.getAlias(colPath.getPath(0) + "_local"); JDBCAbstractEntityBridge parentEntity = (JDBCAbstractEntityBridge) colPath.getEntity(0); SQLUtil.getColumnNamesClause(parentEntity.getPrimaryKeyFields(), localParentAlias, sql); sql.append(SQLUtil.FROM) .append(parentEntity.getQualifiedTableName()).append(' ').append(localParentAlias); innerJoinPath(colPath, sql); sql.append(SQLUtil.WHERE); JDBCAbstractEntityBridge col0 = (JDBCAbstractEntityBridge)colPath.getEntity(0); SQLUtil.getSelfCompareWhereClause(col0.getPrimaryKeyFields(), parentAlias, localParentAlias, sql); sql.append(SQLUtil.AND); String localColAlias = aliasManager.getAlias(colPath.getPath() + "_local"); SQLUtil.getWhereClause(colEntity.getPrimaryKeyFields(), localColAlias, sql); } else { ASTPath memberPath = (ASTPath) member; JDBCAbstractEntityBridge memberEntity = (JDBCAbstractEntityBridge) memberPath.getEntity(); if(!memberEntity.equals(colEntity)) { throw new IllegalStateException("Member must be if the same type as the collection, got: member=" + memberEntity.getEntityName() + ", collection=" + colEntity.getEntityName()); } String memberAlias = aliasManager.getAlias(memberPath.getPath()); if(memberPath.size() > 1) { String parentAlias = aliasManager.getAlias(memberPath.getPath(0) + "_local"); JDBCAbstractEntityBridge parentEntity = (JDBCAbstractEntityBridge) memberPath.getEntity(0); SQLUtil.getColumnNamesClause(parentEntity.getPrimaryKeyFields(), parentAlias, sql); sql.append(SQLUtil.FROM) .append(parentEntity.getQualifiedTableName()).append(' ').append(parentAlias); innerJoinPath(memberPath, sql); innerJoinPath(colPath, sql); } else if(colPath.size() > 1) { String parentAlias = aliasManager.getAlias(colPath.getPath(0) + "_local"); JDBCAbstractEntityBridge parentEntity = (JDBCAbstractEntityBridge) colPath.getEntity(0); SQLUtil.getColumnNamesClause(parentEntity.getPrimaryKeyFields(), parentAlias, sql); sql.append(SQLUtil.FROM) .append(parentEntity.getQualifiedTableName()).append(' ').append(parentAlias); innerJoinPath(colPath, sql); } else { throw new IllegalStateException( "There should be collection valued path expression, not identification variable."); } sql.append(SQLUtil.WHERE); JDBCAbstractEntityBridge member0 = (JDBCAbstractEntityBridge)memberPath.getEntity(0); String colAliasLocal = aliasManager.getAlias(colPath.getPath() + "_local"); if(memberPath.size() > 1) { String memberAliasLocal = aliasManager.getAlias(memberPath.getPath() + "_local"); SQLUtil.getSelfCompareWhereClause(colEntity.getPrimaryKeyFields(), memberAliasLocal, colAliasLocal, sql); sql.append(SQLUtil.AND); String member0Alias = aliasManager.getAlias(memberPath.getPath(0)); String member0AliasLocal = aliasManager.getAlias(memberPath.getPath(0) + "_local"); SQLUtil.getSelfCompareWhereClause(member0.getPrimaryKeyFields(), member0Alias, member0AliasLocal, sql); } else { SQLUtil.getSelfCompareWhereClause(member0.getPrimaryKeyFields(), memberAlias, colAliasLocal, sql); sql.append(SQLUtil.AND); String col0Alias = aliasManager.getAlias(colPath.getPath(0)); String col0AliasLocal = aliasManager.getAlias(colPath.getPath(0) + "_local"); SQLUtil.getSelfCompareWhereClause(colEntity.getPrimaryKeyFields(), col0Alias, col0AliasLocal, sql); } } sql.append(')'); return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTValueClassComparison node, Object data) { StringBuffer buf = (StringBuffer) data; boolean not = (node.opp.equals(SQLUtil.NOT_EQUAL)); String comparison = node.opp; buf.append('('); if(not) { buf.append(SQLUtil.NOT).append('('); comparison = "="; } // setup the from path ASTPath fromPath = (ASTPath) node.jjtGetChild(0); addInnerJoinPath(fromPath); String fromAlias = aliasManager.getAlias(fromPath.getPath(fromPath.size() - 2)); CMPFieldBridge fromCMPField = (CMPFieldBridge) fromPath.getCMPField(); Node toNode = node.jjtGetChild(1); if(toNode instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) toNode; // can only compare like kind entities Class parameterType = getParameterType(toParam.number); if(!(fromCMPField.getFieldType().equals(parameterType))) { throw new IllegalStateException("Only like types can be " + "compared: from CMP field=" + fromCMPField.getFieldType() + " to parameter=" + parameterType); } inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromCMPField)); SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, comparison, buf); } else { ASTPath toPath = (ASTPath) toNode; addInnerJoinPath(toPath); String toAlias = aliasManager.getAlias(toPath.getPath(toPath.size() - 2)); JDBCCMPFieldBridge toCMPField = (JDBCCMPFieldBridge) toPath.getCMPField(); // can only compare like kind entities if(!(fromCMPField.getFieldType().equals(toCMPField.getFieldType()))) { throw new IllegalStateException("Only like types can be " + "compared: from CMP field=" + fromCMPField.getFieldType() + " to CMP field=" + toCMPField.getFieldType()); } SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, comparison, buf); } return (not ? buf.append(')') : buf).append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTPath node, Object data) { StringBuffer buf = (StringBuffer) data; if(!node.isCMPField()) { throw new IllegalStateException("Can only visit cmp valued path node. " + "Should have been handled at a higher level."); } JDBCFieldBridge cmpField = (JDBCFieldBridge) node.getCMPField(); // make sure this is mapped to a single column switch(node.type) { case EJBQLTypes.ENTITY_TYPE: case EJBQLTypes.VALUE_CLASS_TYPE: if(cmpField.getJDBCType().hasMapper() || cmpField.getJDBCType().getParameterSetter() != null) { break; } case EJBQLTypes.UNKNOWN_TYPE: throw new IllegalStateException("Can not visit multi-column path " + "node. Should have been handled at a higher level."); } addLeftJoinPath(node); String alias = aliasManager.getAlias(node.getPath(node.size() - 2)); SQLUtil.getColumnNamesClause(cmpField, alias, buf); return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTAbstractSchema node, Object data) { throw new IllegalStateException("Can not visit abstract schema node. " + " Should have been handled at a higher level."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTParameter node, Object data) { StringBuffer buf = (StringBuffer) data; Class type = getParameterType(node.number); // make sure this is mapped to a single column int ejbqlType = EJBQLTypes.getEJBQLType(type); if(ejbqlType == EJBQLTypes.ENTITY_TYPE || ejbqlType == EJBQLTypes.VALUE_CLASS_TYPE || ejbqlType == EJBQLTypes.UNKNOWN_TYPE) { throw new IllegalStateException("Can not visit multi-column " + "parameter node. Should have been handled at a higher level."); } QueryParameter param = new QueryParameter(node.number - 1, typeFactory.getJDBCType(type)); inputParameters.add(param); buf.append('?'); return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
private void compareEntity(boolean not, Node fromNode, Node toNode, StringBuffer buf) { buf.append('('); if(not) { buf.append(SQLUtil.NOT).append('('); } ASTPath fromPath = (ASTPath) fromNode; addLeftJoinPath(fromPath); String fromAlias = aliasManager.getAlias(fromPath.getPath()); JDBCAbstractEntityBridge fromEntity = (JDBCAbstractEntityBridge) fromPath.getEntity(); if(toNode instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) toNode; // can only compare like kind entities verifyParameterEntityType(toParam.number, fromEntity); inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromEntity)); SQLUtil.getWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, buf); } else { ASTPath toPath = (ASTPath) toNode; addLeftJoinPath(toPath); String toAlias = aliasManager.getAlias(toPath.getPath()); JDBCAbstractEntityBridge toEntity = (JDBCAbstractEntityBridge) toPath.getEntity(); // can only compare like kind entities if(!fromEntity.equals(toEntity)) { throw new IllegalStateException("Only like types can be " + "compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toEntity.getEntityName()); } SQLUtil.getSelfCompareWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, toAlias, buf); } if(not) { buf.append(')'); } buf.append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
private void verifyParameterEntityType(int number, JDBCAbstractEntityBridge entity) { Class parameterType = getParameterType(number); Class remoteClass = entity.getRemoteInterface(); Class localClass = entity.getLocalInterface(); if((localClass == null || !localClass.isAssignableFrom(parameterType)) && (remoteClass == null || !remoteClass.isAssignableFrom(parameterType))) { throw new IllegalStateException("Only like types can be compared: from entity=" + entity.getEntityName() + " to parameter type=" + parameterType); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
public void execute(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { if(entity.isRemoved(ctx)) { throw new IllegalStateException("Instance was already removed: id=" + ctx.getId()); } entity.setIsBeingRemoved(ctx); // remove entity from all relations Object[] oldRelationsRef = new Object[1]; boolean needsSync = entity.removeFromRelations(ctx, oldRelationsRef); // update the related entities (stores the removal from relationships) // if one of the store fails an EJBException will be thrown if(!syncOnCommitOnly && needsSync) { EntityContainer.synchronizeEntitiesWithinTransaction(ctx.getTransaction()); } if(!batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.trace("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } // cascate-delete to old relations, if relation uses cascade. if(oldRelationsRef[0] != null) { Map oldRelations = (Map)oldRelationsRef[0]; entity.cascadeDelete(ctx, oldRelations); } if(batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.debug("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } entity.setRemoved(ctx); manager.getReadAheadCache().removeCachedData(ctx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private String getEntityCreateTableSQL(DataSource dataSource) throws DeploymentException { StringBuffer sql = new StringBuffer(); sql.append(SQLUtil.CREATE_TABLE).append(entity.getQualifiedTableName()).append(" ("); // add fields boolean comma = false; JDBCFieldBridge[] fields = entity.getTableFields(); for(int i = 0; i < fields.length; ++i) { JDBCFieldBridge field = fields[i]; JDBCType type = field.getJDBCType(); if(comma) { sql.append(SQLUtil.COMMA); } else { comma = true; } addField(type, sql); } // add a pk constraint if(entityMetaData.hasPrimaryKeyConstraint()) { JDBCFunctionMappingMetaData pkConstraint = manager.getMetaData().getTypeMapping().getPkConstraintTemplate(); if(pkConstraint == null) { throw new IllegalStateException("Primary key constraint is " + "not allowed for this type of data source"); } String defTableName = entity.getManager().getMetaData().getDefaultTableName(); String name = "pk_" + SQLUtil.unquote(defTableName, dataSource); name = SQLUtil.fixConstraintName(name, dataSource); String[] args = new String[]{ name, SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), new StringBuffer(100)).toString() }; sql.append(SQLUtil.COMMA); pkConstraint.getFunctionSql(args, sql); } return sql.append(')').toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addField(JDBCType type, StringBuffer sqlBuffer) throws DeploymentException { // apply auto-increment template if(type.getAutoIncrement()[0]) { String columnClause = SQLUtil.getCreateTableColumnsClause(type); JDBCFunctionMappingMetaData autoIncrement = manager.getMetaData().getTypeMapping().getAutoIncrementTemplate(); if(autoIncrement == null) { throw new IllegalStateException("auto-increment template not found"); } String[] args = new String[]{columnClause}; autoIncrement.getFunctionSql(args, sqlBuffer); } else { sqlBuffer.append(SQLUtil.getCreateTableColumnsClause(type)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private String getRelationCreateTableSQL(JDBCAbstractCMRFieldBridge cmrField, DataSource dataSource) throws DeploymentException { JDBCFieldBridge[] leftKeys = cmrField.getTableKeyFields(); JDBCFieldBridge[] rightKeys = cmrField.getRelatedCMRField().getTableKeyFields(); JDBCFieldBridge[] fieldsArr = new JDBCFieldBridge[leftKeys.length + rightKeys.length]; System.arraycopy(leftKeys, 0, fieldsArr, 0, leftKeys.length); System.arraycopy(rightKeys, 0, fieldsArr, leftKeys.length, rightKeys.length); StringBuffer sql = new StringBuffer(); sql.append(SQLUtil.CREATE_TABLE).append(cmrField.getQualifiedTableName()) .append(" (") // add field declaration .append(SQLUtil.getCreateTableColumnsClause(fieldsArr)); // add a pk constraint final JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData(); if(relationMetaData.hasPrimaryKeyConstraint()) { JDBCFunctionMappingMetaData pkConstraint = manager.getMetaData().getTypeMapping().getPkConstraintTemplate(); if(pkConstraint == null) { throw new IllegalStateException("Primary key constraint is not allowed for this type of data store"); } String name = "pk_" + relationMetaData.getDefaultTableName(); name = SQLUtil.fixConstraintName(name, dataSource); String[] args = new String[]{ name, SQLUtil.getColumnNamesClause(fieldsArr, new StringBuffer(100).toString(), new StringBuffer()).toString() }; sql.append(SQLUtil.COMMA); pkConstraint.getFunctionSql(args, sql); } sql.append(')'); return sql.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addForeignKeyConstraint(DataSource dataSource, String tableName, String cmrFieldName, JDBCFieldBridge[] fields, String referencesTableName, JDBCFieldBridge[] referencesFields) throws DeploymentException { // can only alter tables we created Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); if(!createdTables.contains(tableName)) { return; } JDBCFunctionMappingMetaData fkConstraint = manager.getMetaData().getTypeMapping().getFkConstraintTemplate(); if(fkConstraint == null) { throw new IllegalStateException("Foreign key constraint is not allowed for this type of datastore"); } String a = SQLUtil.getColumnNamesClause(fields, new StringBuffer(50)).toString(); String b = SQLUtil.getColumnNamesClause(referencesFields, new StringBuffer(50)).toString(); String[] args = new String[]{ tableName, SQLUtil.fixConstraintName("fk_" + tableName + "_" + cmrFieldName, dataSource), a, referencesTableName, b}; String sql = fkConstraint.getFunctionSql(args, new StringBuffer(100)).toString(); // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); } try { Connection con = null; Statement statement = null; try { if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
private static Object coerceToJavaType( Object value, Class destination) throws SQLException { try { // // null // if(value == null) { return null; } // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // // Primitive wrapper classes // // We have a primitive wrapper and we want a real primitive // just return the wrapper and the vm will convert it at the proxy if(destination.isPrimitive()) { if(value == null) throw new IllegalStateException("Loaded NULL value for a field of a primitive type."); if((destination.equals(Byte.TYPE) && value instanceof Byte) || (destination.equals(Short.TYPE) && value instanceof Short) || (destination.equals(Character.TYPE) && value instanceof Character) || (destination.equals(Boolean.TYPE) && value instanceof Boolean) || (destination.equals(Integer.TYPE) && value instanceof Integer) || (destination.equals(Long.TYPE) && value instanceof Long) || (destination.equals(Float.TYPE) && value instanceof Float) || (destination.equals(Double.TYPE) && value instanceof Double) ) { return value; } } // // java.util.Date // // make new copy as sub types have problems in comparions if(destination == java.util.Date.class && value instanceof java.util.Date) { // handle timestamp special becauses it hoses the milisecond values if(value instanceof java.sql.Timestamp) { java.sql.Timestamp ts = (java.sql.Timestamp)value; // Timestamp returns whole seconds from getTime and partial // seconds are retrieved from getNanos() // Adrian Brock: Not in 1.4 it doesn't long temp = ts.getTime(); if(temp % 1000 == 0) temp += ts.getNanos() / 1000000; return new java.util.Date(temp); } else { return new java.util.Date(((java.util.Date)value).getTime()); } } // // java.sql.Time // // make a new copy object; you never know what a driver will return if(destination == java.sql.Time.class && value instanceof java.sql.Time) { return new java.sql.Time(((java.sql.Time)value).getTime()); } // // java.sql.Date // // make a new copy object; you never know what a driver will return if(destination == java.sql.Date.class && value instanceof java.sql.Date) { return new java.sql.Date(((java.sql.Date)value).getTime()); } // // java.sql.Timestamp // // make a new copy object; you never know what a driver will return if(destination == java.sql.Timestamp.class && value instanceof java.sql.Timestamp) { // make a new Timestamp object; you never know // what a driver will return java.sql.Timestamp orignal = (java.sql.Timestamp)value; java.sql.Timestamp copy = new java.sql.Timestamp(orignal.getTime()); copy.setNanos(orignal.getNanos()); return copy; } // // java.lang.String --> java.lang.Character or char // // just grab first character if(value instanceof String && (destination == Character.class || destination == Character.TYPE)) { return new Character(((String)value).charAt(0)); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do throw new SQLException("Got a " + value.getClass().getName() + "[cl=" + System.identityHashCode(value.getClass().getClassLoader()) + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + System.identityHashCode(destination) + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object createBeanClassInstance() throws Exception { if(createBeanClassInstanceCommand == null) throw new IllegalStateException("createBeanClassInstanceCommand == null"); return createBeanClassInstanceCommand.execute(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
protected SQLException processException(Throwable t) { if (t instanceof InvocationTargetException) { t = ((InvocationTargetException) t).getTargetException(); } if (t instanceof SQLException) { return (SQLException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Error) { throw (Error) t; } log.error(t); throw new IllegalStateException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
public Transaction getTransaction() { try { return transactionManager.getTransaction(); } catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
public boolean load(EntityEnterpriseContext ctx) { if(log.isTraceEnabled()) { log.trace("load data:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId()); } // get the preload data map Map preloadDataMap = getPreloadDataMap(ctx.getId(), false); if(preloadDataMap == null || preloadDataMap.isEmpty()) { // no preloaded data for this entity if(log.isTraceEnabled()) { log.trace("No preload data found:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId()); } return false; } boolean cleanReadAhead = manager.getMetaData().isCleanReadAheadOnLoad(); boolean loaded = false; JDBCCMRFieldBridge onlyOneSingleValuedCMR = null; // iterate over the keys in the preloaded map Iterator iter = preloadDataMap.entrySet().iterator(); while(iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); Object field = entry.getKey(); // get the value that was preloaded for this field Object value = entry.getValue(); // if we didn't get a value something is seriously hosed if(value == null) { throw new IllegalStateException("Preloaded value not found"); } if(cleanReadAhead) { // remove this value from the preload cache as it is about to be loaded iter.remove(); } // check for null value standin if(value == NULL_VALUE) { value = null; } if(field instanceof JDBCCMPFieldBridge) { JDBCCMPFieldBridge cmpField = (JDBCCMPFieldBridge) field; if(!cmpField.isLoaded(ctx)) { if(log.isTraceEnabled()) { log.trace("Preloading data:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId() + " cmpField=" + cmpField.getFieldName()); } // set the value cmpField.setInstanceValue(ctx, value); // mark this field clean as it's value was just loaded cmpField.setClean(ctx); loaded = true; } else { if(log.isTraceEnabled()) { log.trace("CMPField already loaded:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId() + " cmpField=" + cmpField.getFieldName()); } } } else if(field instanceof JDBCCMRFieldBridge) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) field; if(!cmrField.isLoaded(ctx)) { if(log.isTraceEnabled()) { log.trace("Preloading data:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId() + " cmrField=" + cmrField.getFieldName()); } // set the value cmrField.load(ctx, (List) value); // add the loaded list to the related entity's readahead cache JDBCStoreManager relatedManager = (JDBCStoreManager) cmrField.getRelatedCMRField().getManager(); ReadAheadCache relatedReadAheadCache = relatedManager.getReadAheadCache(); relatedReadAheadCache.addFinderResults( (List) value, cmrField.getReadAhead()); if(!loaded) { // this is a hack to fix on-load read-ahead for 1:m relationships if(cmrField.isSingleValued() && onlyOneSingleValuedCMR == null) { onlyOneSingleValuedCMR = cmrField; } else { loaded = true; } } } else { if(log.isTraceEnabled()) { log.trace("CMRField already loaded:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId() + " cmrField=" + cmrField.getFieldName()); } } } } if(cleanReadAhead) { // remove all preload data map as all of the data has been loaded manager.removeEntityTxData(new PreloadKey(ctx.getId())); } return loaded; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
public Transaction getTransaction() { try { return transactionManager.getTransaction(); } catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
private void verifyParameterEntityType(int number, JDBCEntityBridge entity) { Class parameterType = getParameterType(number); Class remoteClass = entity.getMetaData().getRemoteClass(); Class localClass = entity.getMetaData().getLocalClass(); if(( localClass == null || !localClass.isAssignableFrom(parameterType) ) && ( remoteClass == null || !remoteClass.isAssignableFrom(parameterType) )) { throw new IllegalStateException("Only like types can be " + "compared: from entity=" + entity.getEntityName() + " to parameter type=" + parameterType); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
private void compareEntity(boolean not, Node fromNode, Node toNode, StringBuffer buf) { buf.append('('); if(not) { buf.append(SQLUtil.NOT).append('('); } String fromAlias; JDBCEntityBridge fromEntity; ASTPath fromPath = (ASTPath) fromNode; addJoinPath(fromPath); fromAlias = aliasManager.getAlias(fromPath.getPath()); fromEntity = (JDBCEntityBridge) fromPath.getEntity(); if(toNode instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) toNode; // can only compare like kind entities verifyParameterEntityType(toParam.number, fromEntity); inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromEntity)); SQLUtil.getWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, buf); } else { String toAlias; JDBCEntityBridge toEntity; ASTPath toPath = (ASTPath) toNode; addJoinPath(toPath); toAlias = aliasManager.getAlias(toPath.getPath()); toEntity = (JDBCEntityBridge) toPath.getEntity(); // can only compare like kind entities if(!fromEntity.equals(toEntity)) { throw new IllegalStateException("Only like types can be " + "compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toEntity.getEntityName()); } SQLUtil.getSelfCompareWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, toAlias, buf); } if(not) { buf.append(')'); } buf.append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTSelect node, Object data) { StringBuffer buf = (StringBuffer) data; Node child0 = node.jjtGetChild(0); ASTPath path; if(child0 instanceof ASTPath) { path = (ASTPath) child0; if(path.isCMPField()) { // set the select object JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge) path.getCMPField(); selectManager = (JDBCStoreManager) selectField.getManager(); selectObject = selectField; setTypeFactory(selectManager.getJDBCTypeFactory()); addJoinPath(path); selectAlias = aliasManager.getAlias(path.getPath(path.size() - 2)); SQLUtil.getColumnNamesClause(selectField, selectAlias, buf); } else { // set the select object JDBCEntityBridge selectEntity = (JDBCEntityBridge) path.getEntity(); selectManager = (JDBCStoreManager) selectEntity.getManager(); selectObject = selectEntity; setTypeFactory(selectManager.getJDBCTypeFactory()); selectEntity(path, node.distinct, buf); } } else { // the function should take a path expresion as a parameter path = getPathFromChildren(child0); if(path == null) { throw new IllegalStateException("The function in SELECT clause does not contain a path expression."); } if(path.isCMPField()) { JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge) path.getCMPField(); selectManager = (JDBCStoreManager) selectField.getManager(); if(selectField.getJDBCType().hasMapper()) this.functionJDBCType = selectField.getJDBCType(); } else if(path.isCMRField()) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) path.getCMRField(); selectManager = (JDBCStoreManager) cmrField.getEntity().getManager(); addJoinPath(path); } else { final JDBCEntityBridge entity = (JDBCEntityBridge) path.getEntity(); selectManager = (JDBCStoreManager) entity.getManager(); addJoinPath(path); } setTypeFactory(selectManager.getJDBCTypeFactory()); selectObject = child0; child0.jjtAccept(this, buf); } return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTNullComparison node, Object data) { StringBuffer buf = (StringBuffer) data; final Node child0 = node.jjtGetChild(0); if(child0 instanceof ASTPath) { ASTPath path = (ASTPath) child0; if(path.isCMRField()) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) path.getCMRField(); if(cmrField.getRelationMetaData().isTableMappingStyle()) { existsClause(path, buf, !node.not); return buf; } } String alias = aliasManager.getAlias(path.getPath(path.size() - 2)); JDBCFieldBridge field = (JDBCFieldBridge) path.getField(); // if jdbc type is null then it should be a cmr field in // a one-to-one mapping that isn't a foreign key. // handle it the way the IS EMPTY on the one side of one-to-many // relationship is handled if(field.getJDBCType() == null) { existsClause(path, buf, !node.not); return buf; } // check the path for cmr fields and add them to join paths if(path.fieldList.size() > 2) { for(int i = 0; i < path.fieldList.size(); ++i) { Object pathEl = path.fieldList.get(i); if(pathEl instanceof JDBCCMRFieldBridge) { addJoinPath(path); break; } } } buf = SQLUtil.getIsNullClause(node.not, field, alias, buf); } else if(child0 instanceof ASTParameter) { ASTParameter param = (ASTParameter) child0; Class type = getParameterType(param.number); QueryParameter queryParam = new QueryParameter(param.number - 1, typeFactory.getJDBCType(type)); inputParameters.add(queryParam); buf.append("? IS "); if(node.not) { buf.append(SQLUtil.NOT); } buf.append(SQLUtil.NULL); } else { throw new IllegalStateException("Unexpected node in IS NULL clause: " + node); } return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTMemberOf node, Object data) { StringBuffer buf = (StringBuffer) data; // setup compare to vars first, so we can compre types in from vars ASTPath toPath = (ASTPath) node.jjtGetChild(1); JDBCCMRFieldBridge toCMRField = (JDBCCMRFieldBridge) toPath.getCMRField(); JDBCEntityBridge toChildEntity = (JDBCEntityBridge) toPath.getEntity(); String pathStr = toPath.getPath(toPath.size() - 2); String toParentAlias = aliasManager.getAlias(pathStr); String toChildAlias = aliasManager.getAlias(toPath.getPath()); String relationTableAlias = null; if(toCMRField.getRelationMetaData().isTableMappingStyle()) { relationTableAlias = aliasManager.getRelationTableAlias(toPath.getPath()); } // setup from variables String fromAlias = null; int fromParamNumber = -1; if(node.jjtGetChild(0) instanceof ASTParameter) { ASTParameter fromParam = (ASTParameter) node.jjtGetChild(0); // can only compare like kind entities verifyParameterEntityType(fromParam.number, toChildEntity); fromParamNumber = fromParam.number; } else { ASTPath fromPath = (ASTPath) node.jjtGetChild(0); addJoinPath(fromPath); JDBCEntityBridge fromEntity = (JDBCEntityBridge) fromPath.getEntity(); fromAlias = aliasManager.getAlias(fromPath.getPath()); // can only compare like kind entities if(!fromEntity.equals(toChildEntity)) { throw new IllegalStateException("Only like types can be " + "compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toChildEntity.getEntityName()); } } // add the path to the list of paths to left join addLeftJoinPath(pathStr, toPath); // first part makes toChild not in toParent.child if(!subquerySupported) { addJoinPath(toPath); // subquery not supported; use a left join and is not null if(node.not) { buf.append(SQLUtil.NOT); } buf.append('('); if(relationTableAlias == null) { SQLUtil.getIsNullClause(true, toChildEntity.getPrimaryKeyFields(), toChildAlias, buf); } else { SQLUtil.getIsNullClause(true, toCMRField.getTableKeyFields(), relationTableAlias, buf); } } else { // subquery supported; use exists subquery if(node.not) { buf.append(SQLUtil.NOT); } buf.append(SQLUtil.EXISTS).append('('); if(relationTableAlias == null) { buf.append(SQLUtil.SELECT); SQLUtil.getColumnNamesClause(toChildEntity.getPrimaryKeyFields(), toChildAlias, buf) .append(SQLUtil.FROM) .append(toChildEntity.getQualifiedTableName()) .append(' ') .append(toChildAlias) .append(SQLUtil.WHERE); SQLUtil.getJoinClause(toCMRField, toParentAlias, toChildAlias, buf); } else { buf.append(SQLUtil.SELECT); SQLUtil.getColumnNamesClause(toCMRField.getRelatedCMRField().getTableKeyFields(), relationTableAlias, buf) .append(SQLUtil.FROM) .append(toCMRField.getQualifiedTableName()) .append(' ') .append(relationTableAlias) .append(SQLUtil.WHERE); SQLUtil.getRelationTableJoinClause(toCMRField, toParentAlias, relationTableAlias, buf); } } buf.append(SQLUtil.AND); // second part makes fromNode equal toChild if(fromAlias != null) { // compre pk to pk if(relationTableAlias == null) { SQLUtil.getSelfCompareWhereClause(toChildEntity.getPrimaryKeyFields(), toChildAlias, fromAlias, buf); } else { SQLUtil.getRelationTableJoinClause(toCMRField.getRelatedCMRField(), fromAlias, relationTableAlias, buf); } } else { // add the parameters inputParameters.addAll(QueryParameter.createParameters(fromParamNumber - 1, toChildEntity)); // compare pk to parameter if(relationTableAlias == null) { SQLUtil.getWhereClause(toChildEntity.getPrimaryKeyFields(), toChildAlias, buf); } else { SQLUtil.getWhereClause(toCMRField.getRelatedCMRField().getTableKeyFields(), relationTableAlias, buf); } } buf.append(')'); return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTValueClassComparison node, Object data) { StringBuffer buf = (StringBuffer) data; boolean not = (node.opp.equals(SQLUtil.NOT_EQUAL)); String comparison = node.opp; buf.append('('); if(not) { buf.append(SQLUtil.NOT).append('('); comparison = "="; } // setup the from path ASTPath fromPath = (ASTPath) node.jjtGetChild(0); addJoinPath(fromPath); String fromAlias = aliasManager.getAlias(fromPath.getPath(fromPath.size() - 2)); JDBCCMPFieldBridge fromCMPField = (JDBCCMPFieldBridge) fromPath.getCMPField(); Node toNode = node.jjtGetChild(1); if(toNode instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) toNode; // can only compare like kind entities Class parameterType = getParameterType(toParam.number); if(!(fromCMPField.getFieldType().equals(parameterType))) { throw new IllegalStateException("Only like types can be " + "compared: from CMP field=" + fromCMPField.getFieldType() + " to parameter=" + parameterType); } inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromCMPField)); SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, comparison, buf); } else { ASTPath toPath = (ASTPath) toNode; addJoinPath(toPath); String toAlias = aliasManager.getAlias(toPath.getPath(toPath.size() - 2)); JDBCCMPFieldBridge toCMPField = (JDBCCMPFieldBridge) toPath.getCMPField(); // can only compare like kind entities if(!(fromCMPField.getFieldType().equals(toCMPField.getFieldType()))) { throw new IllegalStateException("Only like types can be " + "compared: from CMP field=" + fromCMPField.getFieldType() + " to CMP field=" + toCMPField.getFieldType()); } SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, comparison, buf); } return (not ? buf.append(')') : buf).append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTPath node, Object data) { StringBuffer buf = (StringBuffer) data; if(!node.isCMPField()) { throw new IllegalStateException("Can only visit cmp valued path " + "node. Should have been handled at a higher level."); } JDBCCMPFieldBridge cmpField = (JDBCCMPFieldBridge) node.getCMPField(); // make sure this is mapped to a single column switch(node.type) { case EJBQLTypes.ENTITY_TYPE: case EJBQLTypes.VALUE_CLASS_TYPE: if(cmpField.getJDBCType().hasMapper() || cmpField.getJDBCType().getParameterSetter() != null) { break; } case EJBQLTypes.UNKNOWN_TYPE: throw new IllegalStateException("Can not visit multi-column path " + "node. Should have been handled at a higher level."); } addJoinPath(node); String alias = aliasManager.getAlias(node.getPath(node.size() - 2)); SQLUtil.getColumnNamesClause(cmpField, alias, buf); return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTAbstractSchema node, Object data) { throw new IllegalStateException("Can not visit abstract schema node. " + "Should have been handled at a higher level."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTParameter node, Object data) { StringBuffer buf = (StringBuffer) data; Class type = getParameterType(node.number); // make sure this is mapped to a single column int ejbqlType = EJBQLTypes.getEJBQLType(type); if(ejbqlType == EJBQLTypes.ENTITY_TYPE || ejbqlType == EJBQLTypes.VALUE_CLASS_TYPE || ejbqlType == EJBQLTypes.UNKNOWN_TYPE) { throw new IllegalStateException("Can not visit multi-column " + "parameter node. Should have been handled at a higher level."); } QueryParameter param = new QueryParameter(node.number - 1, typeFactory.getJDBCType(type)); inputParameters.add(param); buf.append('?'); return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
private void selectEntity(ASTPath path, boolean distinct, StringBuffer buf) { JDBCEntityBridge selectEntity = (JDBCEntityBridge) path.getEntity(); StringBuffer columnNamesClause = new StringBuffer(200); addJoinPath(path); selectAlias = aliasManager.getAlias(path.getPath()); // get a list of all fields to be loaded // get the identifier for this field SQLUtil.getColumnNamesClause(selectEntity.getPrimaryKeyFields(), selectAlias, columnNamesClause); if(readAhead.isOnFind()) { String eagerLoadGroupName = readAhead.getEagerLoadGroup(); boolean[] loadGroupMask = selectEntity.getLoadGroupMask(eagerLoadGroupName); if(distinct) SQLUtil.appendSearchableColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, selectAlias, columnNamesClause); else SQLUtil.appendColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, selectAlias, columnNamesClause); try { leftJoinCMRList = JDBCAbstractQueryCommand.getLeftJoinCMRNodes( selectEntity, path.getPath(), readAhead.getLeftJoins(), declaredPaths); } catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); } if(!leftJoinCMRList.isEmpty()) { onFindCMRJoin = new StringBuffer(100); JDBCAbstractQueryCommand.leftJoinCMRNodes(selectAlias, leftJoinCMRList, aliasManager, onFindCMRJoin); JDBCAbstractQueryCommand.appendLeftJoinCMRColumnNames(leftJoinCMRList, aliasManager, columnNamesClause); } } buf.append(columnNamesClause); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public boolean[] getLoadGroupMask(String name) { boolean[] mask = (boolean[])loadGroupMasks.get(name); if(mask == null) { throw new IllegalStateException( "Load group '" + name + "' is not defined. Defined load groups: " + loadGroupMasks.keySet() ); } return mask; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private static EntityState getEntityState(EntityEnterpriseContext ctx) { JDBCContext jdbcCtx = (JDBCContext)ctx.getPersistenceContext(); EntityState entityState = jdbcCtx.getEntityState(); if(entityState == null) throw new IllegalStateException("Entity state is null."); return entityState; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP2xFieldBridge.java
public void setInstanceValue(EntityEnterpriseContext ctx, Object value) { FieldState fieldState = getFieldState(ctx); // update current value if(cmpFieldIAmMappedTo != null && cmpFieldIAmMappedTo.isPrimaryKeyMember()) { // if this field shares the column with the primary key field and new value // changes the primary key then we are in an illegal state. if(value != null) { if(fieldState.isLoaded() && fieldState.isValueChanged(value)) { throw new IllegalStateException( "New value [" + value + "] of a foreign key field " + getFieldName() + " changed the value of a primary key field " + cmpFieldIAmMappedTo.getFieldName() + "[" + fieldState.value + "]" ); } else { fieldState.setValue(value); } } } else { if(cmrChainLink != null && JDBCEntityBridge.isEjbCreateDone(ctx) && fieldState.isLoaded() && fieldState.isValueChanged(value)) { cmrChainLink.execute(ctx, fieldState, value); } fieldState.setValue(value); } // we are loading the field right now so it isLoaded fieldState.setLoaded(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMR field cannot be set " + "in ejbCreate; this should be done in the ejbPostCreate " + "method instead [EJB 2.0 Spec. 10.5.2]."); } if(isCollectionValued() && value == null) { throw new IllegalArgumentException("null cannot be assigned to a " + "collection-valued cmr-field [EJB 2.0 Spec. 10.3.8]."); } /* if(allFKFieldsMappedToPKFields) { throw new IllegalStateException( "Can't modify relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]."); } */ setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void checkSetForeignKey(EntityEnterpriseContext myCtx, Object newValue) throws IllegalStateException { JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCCMP2xFieldBridge pkField = (JDBCCMP2xFieldBridge) pkFields[i]; JDBCCMP2xFieldBridge relatedPkField = (JDBCCMP2xFieldBridge) relatedPKFieldsByMyPKFields.get(pkField); if(relatedPkField != null) { Object comingValue = relatedPkField.getPrimaryKeyValue(newValue); Object currentValue = pkField.getInstanceValue(myCtx); // they shouldn't be null if(!comingValue.equals(currentValue)) { throw new IllegalStateException("Can't create relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]." + " primary key value is " + currentValue + " overriding value is " + comingValue); } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void addRelation(EntityEnterpriseContext myCtx, Object fk, boolean updateForeignKey) { checkSetForeignKey(myCtx, fk); if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(myCtx)) { throw new IllegalStateException("A CMR field cannot be set or added " + "to a relationship in ejbCreate; this should be done in the " + "ejbPostCreate method instead [EJB 2.0 Spec. 10.5.2]."); } // add to current related set FieldState myState = getFieldState(myCtx); myState.addRelation(fk); // set the foreign key, if we have one. if(hasForeignKey() && updateForeignKey) { setForeignKey(myCtx, fk); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { //return SecurityAssociation.peekRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); return sc.getOutgoingRunAs(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { //return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { //SecurityAssociation.pushRunAsIdentity((RunAsIdentity)id); SecurityContext sa = SecurityContextAssociation.getSecurityContext(); if(sa == null) throw new IllegalStateException("Security Context is null to push runas"); sa.setOutgoingRunAs(id); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public RunAs peek() { //return SecurityAssociation.peekRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); return sc.getOutgoingRunAs(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public void push(RunAs id) { //SecurityAssociation.pushRunAsIdentity(id); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null to push runas"); sc.setOutgoingRunAs(id); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public RunAs pop() { //Pop the RAI // return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = null; ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.getUtil().createSubjectInfo(p, cred, s); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); Principal p = sc.getUtil().getUserPrincipal(); Object cred = sc.getUtil().getCredential(); sc.getUtil().createSubjectInfo(p, cred,null); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(ra); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(null); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
private List getIdList() { if(setHandle[0] == null) { throw new IllegalStateException("A CMR collection may only be used " + "within the transction in which it was created"); } return setHandle[0]; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean hasNext() { verifyIteratorIsValid(); try { return idIterator.hasNext(); } catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public Object next() { verifyIteratorIsValid(); try { currentId = idIterator.next(); return localFactory.getEntityEJBLocalObject(currentId); } catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public void remove() { verifyIteratorIsValid(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); try { idIterator.remove(); cmrField.destroyRelationLinks(ctx, currentId, false); } catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
private void verifyIteratorIsValid() { if(setHandle[0] == null) { throw new IllegalStateException("The iterator of a CMR " + "collection may only be used within the transction in " + "which it was created"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + fieldName); } if(primaryKeyMember && JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMP field that is a member " + "of the primary key can only be set in ejbCreate " + "[EJB 2.0 Spec. 10.3.5]."); } if(ctx.isValid()) { if(!isLoaded(ctx)) { // the field must be loaded for dirty cheking to work properly manager.loadField(this, ctx); } lockingStrategy.changed(this, ctx); } setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
private JDBCFunctionMappingMetaData getSelectTemplate(JDBCCMRFieldBridge cmrField) throws DeploymentException { JDBCFunctionMappingMetaData selectTemplate = null; if(cmrField.getRelationMetaData().isTableMappingStyle()) { // relation table if(cmrField.getRelationMetaData().hasRowLocking()) { selectTemplate = cmrField.getRelationMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } else if(cmrField.getRelatedCMRField().hasForeignKey()) { // related has foreign key if(cmrField.getRelatedJDBCEntity().getMetaData().hasRowLocking()) { selectTemplate = cmrField.getRelatedJDBCEntity().getMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } else { // i have foreign key if(entity.getMetaData().hasRowLocking()) { selectTemplate = entity.getMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } return selectTemplate; }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private Object process(Invocation mi, boolean isInvoke) throws Exception { if (this.shouldBypassSecurity(mi)) { if (log.isTraceEnabled()) log.trace("Bypass security for invoke or invokeHome"); if (isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } SecurityContext sc = SecurityActions.getSecurityContext(); if (sc == null) throw new IllegalStateException("Security Context is null"); RunAs callerRunAsIdentity = sc.getIncomingRunAs(); if (log.isTraceEnabled()) log.trace("Caller RunAs=" + callerRunAsIdentity + ": useCallerIdentity=" + this.isUseCallerIdentity); // Authenticate the subject and apply any declarative security checks try { checkSecurityContext(mi, callerRunAsIdentity); } catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; } RunAs runAsIdentityToPush = runAsIdentity; /** * Special case: if <use-caller-identity> configured and * the caller is arriving with a run-as, we need to push that run-as */ if (callerRunAsIdentity != null && this.isUseCallerIdentity) runAsIdentityToPush = callerRunAsIdentity; /* If a run-as role was specified, push it so that any calls made by this bean will have the runAsRole available for declarative security checks. */ SecurityActions.pushRunAsIdentity(runAsIdentityToPush); try { if (isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } finally { SecurityActions.popRunAsIdentity(); SecurityActions.popSubjectContext(); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private void checkSecurityContext(Invocation mi, RunAs callerRunAsIdentity) throws Exception { Principal principal = mi.getPrincipal(); Object credential = mi.getCredential(); boolean trace = log.isTraceEnabled(); // If there is not a security manager then there is no authentication required Method m = mi.getMethod(); boolean containerMethod = m == null || m.equals(ejbTimeout); if (containerMethod == true || securityManager == null || container == null) { // Allow for the propagation of caller info to other beans SecurityActions.pushSubjectContext(principal, credential, null); return; } if (realmMapping == null) { throw new SecurityException("Role mapping manager has not been set"); } SecurityContext sc = SecurityActions.getSecurityContext(); EJBAuthenticationHelper helper = SecurityHelperFactory.getEJBAuthenticationHelper(sc); boolean isTrusted = containsTrustableRunAs(sc) || helper.isTrusted(); if (!isTrusted) { // Check the security info from the method invocation Subject subject = new Subject(); if (SecurityActions.isValid(helper, subject, m.getName()) == false) { // Notify authentication observer if (authenticationObserver != null) authenticationObserver.authenticationFailed(); // Else throw a generic SecurityException String msg = "Authentication exception, principal=" + principal; throw new SecurityException(msg); } else { SecurityActions.pushSubjectContext(principal, credential, subject); if (trace) { log.trace("Authenticated principal=" + principal + " in security domain=" + sc.getSecurityDomain()); } } } else { // Duplicate the current subject context on the stack since //SecurityActions.dupSubjectContext(); SecurityActions.pushRunAsIdentity(callerRunAsIdentity); } Method ejbMethod = mi.getMethod(); // Ignore internal container calls if (ejbMethod == null) return; // Get the caller Subject caller = SecurityActions.getContextSubject(); if (caller == null) throw new IllegalStateException("Authenticated User. But caller subject is null"); //Establish the deployment rolename-principalset custom mapping(if available) SecurityRolesAssociation.setSecurityRoles(this.deploymentRoles); boolean isAuthorized = false; Set<Principal> methodRoles = container.getMethodPermissions(ejbMethod, mi.getType()); SecurityContext currentSC = SecurityActions.getSecurityContext(); if (SecurityActions.getSecurityManagement(currentSC) == null) SecurityActions.setSecurityManagement(currentSC, securityManagement); AbstractEJBAuthorizationHelper authorizationHelper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); authorizationHelper.setPolicyRegistration(container.getPolicyRegistration()); isAuthorized = SecurityActions.authorize(authorizationHelper, ejbName, ejbMethod, mi.getPrincipal(), mi.getType().toInterfaceString(), ejbCS, caller, callerRunAsIdentity, container.getJaccContextID(), new SimpleRoleGroup(methodRoles)); if (!isAuthorized) { String msg = "Denied: caller with subject=" + caller + " and security context post-mapping roles=" + SecurityActions.getRolesFromSecurityContext(currentSC) + ": ejbMethod=" + ejbMethod; throw new SecurityException(msg); } }
// in src/main/java/org/jboss/ejb/plugins/security/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(ra); return null; }
// in src/main/java/org/jboss/ejb/plugins/security/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(null); return null; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
public void start() { // This is in here so that EntityMultiInstanceInterceptor can avoid doing a lock.sync(). // if (!container.getLockManager().lockClass.equals(org.jboss.ejb.plugins.lock.NoLock.class) && !container.getLockManager().lockClass.equals(org.jboss.ejb.plugins.lock.JDBCOptimisticLock.class) && !container.getLockManager().lockClass.equals(org.jboss.ejb.plugins.lock.MethodOnlyEJBLock.class) ) { throw new IllegalStateException("the <locking-policy> must be org.jboss.ejb.plugins.lock.NoLock, JDBCOptimisticLock, or MethodOnlyEJBLock for Instance Per Transaction:" + container.getLockManager().lockClass.getName()); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
public void afterCompletion(int status) { boolean trace = log.isTraceEnabled(); // This is an independent point of entry. We need to make sure the // thread is associated with the right context class loader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(container.getClassLoader()); container.pushENC(); ctx.hasTxSynchronization(false); ctx.setTransaction(null); try { try { // If rolled back -> invalidate instance if (status != Status.STATUS_ROLLEDBACK) { switch (commitOption) { // Keep instance cached after tx commit case ConfigurationMetaData.A_COMMIT_OPTION: throw new IllegalStateException("Commit option A not allowed with this Interceptor"); // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: break; case ConfigurationMetaData.D_COMMIT_OPTION: throw new IllegalStateException("Commit option D not allowed with this Interceptor"); } } try { if (ctx.getId() != null) container.getPersistenceManager().passivateEntity(ctx); } catch (Exception ignored) { } container.getInstancePool().free(ctx); } finally { if (trace) log.trace("afterCompletion, clear tx for ctx=" + ctx + ", tx=" + tx); } } // synchronized(lock) finally { container.popENC(); SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBHome getEJBHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return (EJBHome) ci.getEJBHome(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public boolean isIdentical(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.isIdentical(this, mi); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object find(Invocation mi) throws Exception { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Method method = mi.getMethod(); Object[] args = mi.getArguments(); EntityEnterpriseContext instance = (EntityEnterpriseContext)mi.getEnterpriseContext(); boolean syncOnCommitOnly = metaData.getContainerConfiguration().getSyncOnCommitOnly(); Transaction tx = mi.getTransaction(); Class returnType = method.getReturnType(); if (Collection.class.isAssignableFrom(returnType) || returnType == Enumeration.class) { // as per the spec 9.6.4, entities must be synchronized with the datastore when an ejbFind<METHOD> is called. if (!syncOnCommitOnly) { synchronizeEntitiesWithinTransaction(tx); } // Iterator finder Collection c = getPersistenceManager().findEntities(method, args, instance, ci); // BMP entity finder methods are allowed to return java.util.Enumeration. // We need a serializable Enumeration, so we can't use Collections.enumeration() if (returnType == Enumeration.class) { return new SerializableEnumeration(c); } else { return c; } } else { return findSingleObject(tx, method, args, instance, ci); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } // All we need is an EJBObject for this Id; return (EJBObject)ci.getEntityEJBObject(((EntityCache) instanceCache).createCacheKey(mi.getId())); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBMetaData getEJBMetaDataHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.getEJBMetaData(); }
// in src/main/java/org/jboss/ejb/AllowedOperationsAssociation.java
public static void assertAllowedIn(String ctxMethod, int flags) { Stack inMethodStack = (Stack)threadLocal.get(); // Strict validation, the caller MUST set the in method flag if (inMethodStack.empty()) { throw new IllegalStateException("Cannot obtain inMethodFlag for: " + ctxMethod); } // The container should push a method flag into the context just before // a call to the instance method if (inMethodStack.empty() == false) { // Check if the given ctxMethod can be called from the ejb instance // this relies on the inMethodFlag being pushed prior to the call to the ejb method Integer inMethodFlag = ((Integer) inMethodStack.peek()); if ((inMethodFlag.intValue() & flags) == 0 && inMethodFlag.intValue() != IN_INTERCEPTOR_METHOD) { String message = ctxMethod + " should not be access from this bean method: " + methodMap.get(inMethodFlag); IllegalStateException ex = new IllegalStateException(message); log.error(message + ", allowed is " + getAllowedMethodList(flags), ex); throw ex; } } }
// in src/main/java/org/jboss/as/naming/javaee/NamingJavaEEComponentInformer.java
public String getComponentName(DeploymentUnit unit) { // FIXME: it's real ugly to analyze the deployment unit at this stage. Better to let the ComponentNamingDeployer be explicitly driven by meta data. JBossEnterpriseBeanMetaData ejb = unit.getAttachment(JBossEnterpriseBeanMetaData.class); JBossServletMetaData servlet = unit.getAttachment(JBossServletMetaData.class); assert ejb != null || servlet != null : "borked deployment unit " + unit; if(ejb != null) return ejb.getEjbName(); if(servlet != null) return servlet.getServletName(); throw new IllegalStateException("Deployment unit " + unit + " has no known component meta data"); }
// in src/main/java/org/jboss/executor/ThreadPoolExecutorFactory.java
private ThreadPoolExecutor createExecutor() { int coreSize = Math.max(calcPoolSize(corePoolSizeBase, corePoolSizePerCpu), 0); if (coreSize == 0) { throw new IllegalStateException("Core size was calculated to 0"); } int maxSize = Math.max(calcPoolSize(maxPoolSizeBase, maxPoolSizePerCpu), 0); if (maxSize == 0) { throw new IllegalStateException("Max size was calculated to 0"); } BlockingQueue<Runnable> queue = workQueue == null ? new LinkedBlockingQueue<Runnable>() : workQueue; ThreadFactory factory = threadFactory == null ? DEFAULT_THREAD_FACTORY : threadFactory; RejectedExecutionHandler handler = rejectedExecutionHandler == null ? DEFAULT_REJECTED_EXECUTION_HANDLER : rejectedExecutionHandler; return new ThreadPoolExecutor(coreSize, maxSize, keepAliveTime, keepAliveTimeUnit, queue, factory, handler); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public String getDefaultSecurityDomain() { if (defaultSecurityDomain == null) throw new IllegalStateException("Default Security Domain is null"); return defaultSecurityDomain; }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public synchronized void startModule() throws Exception { if (this.unit == null || this.container == null || this.deployment == null) throw new IllegalStateException("WebModules cannot be restarted, and must be redeployed"); // Get the war URL JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); WebApplication webApp = deployment.start(unit, metaData); String warURL = unit.getName(); container.addDeployedApp(warURL, webApp); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
protected boolean isBeforeInternal(Ordering ordering, Set<Ordering> checked) { checked.add(this); if (before.contains(ordering)) { return true; } Iterator<Ordering> beforeIterator = before.iterator(); while (beforeIterator.hasNext()) { Ordering check = beforeIterator.next(); if (checked.contains(check)) { //throw new IllegalStateException(sm.getString("ordering.orderConflict", this.ordering.getJar())); throw new IllegalStateException("Ordering conflict with JAR: " + this.ordering.getJar()); } if (check.isBeforeInternal(ordering, checked)) { return false; } } return false; }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
protected boolean isAfterInternal(Ordering ordering, Set<Ordering> checked) { checked.add(this); if (after.contains(ordering)) { return true; } Iterator<Ordering> afterIterator = after.iterator(); while (afterIterator.hasNext()) { Ordering check = afterIterator.next(); if (checked.contains(check)) { //throw new IllegalStateException(sm.getString("ordering.orderConflict", this.ordering.getJar())); throw new IllegalStateException("Ordering conflict with JAR: " + this.ordering.getJar()); } if (check.isAfterInternal(ordering, checked)) { return false; } } return false; }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
public boolean isLastBeforeOthers() { if (!beforeOthers) { throw new IllegalStateException(); } Iterator<Ordering> beforeIterator = before.iterator(); while (beforeIterator.hasNext()) { Ordering check = beforeIterator.next(); if (!check.beforeOthers) { return true; } else if (check.isLastBeforeOthers()) { return true; } } return false; }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
public boolean isFirstAfterOthers() { if (!afterOthers) { throw new IllegalStateException(); } Iterator<Ordering> afterIterator = after.iterator(); while (afterIterator.hasNext()) { Ordering check = afterIterator.next(); if (!check.afterOthers) { return true; } else if (check.isFirstAfterOthers()) { return true; } } return false; }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
protected static void resolveOrder(List<WebOrdering> webOrderings, List<String> order) { List<Ordering> work = new ArrayList<Ordering>(); // Populate the work Ordering list Iterator<WebOrdering> webOrderingsIterator = webOrderings.iterator(); while (webOrderingsIterator.hasNext()) { WebOrdering webOrdering = webOrderingsIterator.next(); Ordering ordering = new Ordering(); ordering.ordering = webOrdering; ordering.afterOthers = webOrdering.isAfterOthers(); ordering.beforeOthers = webOrdering.isBeforeOthers(); if (ordering.afterOthers && ordering.beforeOthers) { // Cannot be both after and before others //throw new IllegalStateException(sm.getString("ordering.afterAndBeforeOthers", webOrdering.getJar())); throw new IllegalStateException("Ordering includes both before and after others in JAR: " + webOrdering.getJar()); } work.add(ordering); } // Create double linked relationships between the orderings, // and resolve names Iterator<Ordering> workIterator = work.iterator(); while (workIterator.hasNext()) { Ordering ordering = workIterator.next(); WebOrdering webOrdering = ordering.ordering; Iterator<String> after = webOrdering.getAfter().iterator(); while (after.hasNext()) { String name = after.next(); Iterator<Ordering> workIterator2 = work.iterator(); boolean found = false; while (workIterator2.hasNext()) { Ordering ordering2 = workIterator2.next(); if (name.equals(ordering2.ordering.getName())) { if (found) { // Duplicate name //throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar())); throw new IllegalStateException("Duplicate name declared in JAR: " + webOrdering.getJar()); } ordering.addAfter(ordering2); ordering2.addBefore(ordering); found = true; } } } Iterator<String> before = webOrdering.getBefore().iterator(); while (before.hasNext()) { String name = before.next(); Iterator<Ordering> workIterator2 = work.iterator(); boolean found = false; while (workIterator2.hasNext()) { Ordering ordering2 = workIterator2.next(); if (name.equals(ordering2.ordering.getName())) { if (found) { // Duplicate name //throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar())); throw new IllegalStateException("Duplicate name declared in JAR: " + webOrdering.getJar()); } ordering.addBefore(ordering2); ordering2.addAfter(ordering); found = true; } } } } // Validate ordering workIterator = work.iterator(); while (workIterator.hasNext()) { workIterator.next().validate(); } // Create three ordered lists that will then be merged List<Ordering> tempOrder = new ArrayList<Ordering>(); // Create the ordered list of fragments which are before others workIterator = work.iterator(); while (workIterator.hasNext()) { Ordering ordering = workIterator.next(); if (ordering.beforeOthers) { // Insert at the first possible position int insertAfter = -1; boolean last = ordering.isLastBeforeOthers(); int lastBeforeOthers = -1; for (int i = 0; i < tempOrder.size(); i++) { if (ordering.isAfter(tempOrder.get(i))) { insertAfter = i; } if (tempOrder.get(i).beforeOthers) { lastBeforeOthers = i; } } int pos = insertAfter; if (last && lastBeforeOthers > insertAfter) { pos = lastBeforeOthers; } tempOrder.add(pos + 1, ordering); } else if (ordering.afterOthers) { // Insert at the last possible element int insertBefore = tempOrder.size(); boolean first = ordering.isFirstAfterOthers(); int firstAfterOthers = tempOrder.size(); for (int i = tempOrder.size() - 1; i >= 0; i--) { if (ordering.isBefore(tempOrder.get(i))) { insertBefore = i; } if (tempOrder.get(i).afterOthers) { firstAfterOthers = i; } } int pos = insertBefore; if (first && firstAfterOthers < insertBefore) { pos = firstAfterOthers; } tempOrder.add(pos, ordering); } else { // Insert according to other already inserted elements int insertAfter = -1; int insertBefore = tempOrder.size(); for (int i = 0; i < tempOrder.size(); i++) { if (ordering.isAfter(tempOrder.get(i)) || tempOrder.get(i).beforeOthers) { insertAfter = i; } if (ordering.isBefore(tempOrder.get(i)) || tempOrder.get(i).afterOthers) { insertBefore = i; } } if (insertAfter > insertBefore) { // Conflicting order (probably caught earlier) //throw new IllegalStateException(sm.getString("ordering.orderConflict", ordering.ordering.getJar())); throw new IllegalStateException("Fragment ordering conflict with JAR: " + ordering.ordering.getJar()); } // Insert somewhere in the range tempOrder.add(insertAfter + 1, ordering); } } // Create the final ordered list Iterator<Ordering> tempOrderIterator = tempOrder.iterator(); while (tempOrderIterator.hasNext()) { Ordering ordering = tempOrderIterator.next(); order.add(ordering.ordering.getJar()); } }
// in src/main/java/org/jboss/corba/ORBFactory.java
public static void setORB(ORB orb) { if (ORBFactory.orb != null) throw new IllegalStateException("ORB has already been set"); ORBFactory.orb = orb; }
26
              
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new IllegalStateException("Cannot create EJBTimerService proxy: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e) { throw new IllegalStateException("Failed to suspend current transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to begin a new transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(NoSuchMethodException e) { throw new IllegalStateException( "Failed to find a ctor in " + valueType + " that takes an instance of " + argType + " as an argument." ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new IllegalStateException( "Failed to create an instance of " + valueType + " with the " + fieldValue + " as a ctor argument" ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); }
92
              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void rollback() throws SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.rollback(" + tpc + ")"); } try { getSession().rollback(tpc); } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void setRollbackOnly() throws IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.setRollbackOnly(" + tpc + ")"); } try { getSession().setRollbackOnly(tpc); } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void setRollbackOnly(Object tpc) throws RemoteException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); tx.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (duration < 0) throw new IllegalArgumentException("duration is negative"); return createTimer(new Date(System.currentTimeMillis() + duration), 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialDuration < 0) throw new IllegalArgumentException("initial duration is negative"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); return createTimer(new Date(System.currentTimeMillis() + initialDuration), intervalDuration, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (expiration == null) throw new IllegalArgumentException("expiration is null"); return createTimer(expiration, 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Collection getTimers() throws IllegalStateException, EJBException { ArrayList activeTimers = new ArrayList(); synchronized (timers) { Iterator it = timers.values().iterator(); while (it.hasNext()) { TimerImpl timer = (TimerImpl)it.next(); if (timer.isActive()) activeTimers.add(timer); } } return activeTimers; }
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
public Timer getTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { EJBTimerService ejbTimerService = EJBTimerServiceLocator.getEjbTimerService(); ObjectName containerId = timedObjectId.getContainerId(); Object instancePk = timedObjectId.getInstancePk(); TimerServiceImpl timerService = (TimerServiceImpl)ejbTimerService.getTimerService(containerId, instancePk); if (timerService == null) throw new NoSuchObjectLocalException("TimerService not available: " + timedObjectId); TimerImpl timer = (TimerImpl)timerService.getTimer(this); if (timer == null || timer.isActive() == false) throw new NoSuchObjectLocalException("Timer not available: " + timedObjectId); return timer; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public void cancel() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.cancel"); registerTimerWithTx(); cancelInTx(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public long getTimeRemaining() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getTimeRemaining"); return nextExpire - System.currentTimeMillis(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Date getNextTimeout() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getNextTimeout"); return new Date(nextExpire); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Serializable getInfo() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getInfo"); return info; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public TimerHandle getHandle() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getHandle"); return new TimerHandleImpl(this); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { return Collections.EMPTY_LIST; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public void removeTimerService(ObjectName containerId, boolean keepState) throws IllegalStateException { // remove all timers with the given containerId synchronized(timerServiceMap) { Iterator<Map.Entry<TimedObjectId, TimerServiceImpl>> it = timerServiceMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<TimedObjectId, TimerServiceImpl> entry = it.next(); TimedObjectId key = entry.getKey(); TimerServiceImpl timerService = entry.getValue(); if (containerId.equals(key.getContainerId())) { log.debug("removeTimerService: " + timerService); timerService.shutdown(keepState); it.remove(); } } } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public void removeTimerService(ObjectName containerId, Object instancePk, boolean keepState) throws IllegalStateException { // remove a single timer service TimedObjectId timedObjectId = new TimedObjectId(containerId, instancePk); if (timedObjectId.getInstancePk() != null) { TimerServiceImpl timerService = (TimerServiceImpl)getTimerService(containerId, instancePk); if (timerService != null) { log.debug("removeTimerService: " + timerService); timerService.shutdown(false); timerServiceMap.remove(timedObjectId); } } // remove all timers with the given containerId else { synchronized(timerServiceMap) { Iterator<Map.Entry<TimedObjectId, TimerServiceImpl>> it = timerServiceMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<TimedObjectId, TimerServiceImpl> entry = it.next(); TimedObjectId key = (TimedObjectId) entry.getKey(); TimerServiceImpl timerService = (TimerServiceImpl) entry.getValue(); if (containerId.equals(key.getContainerId())) { log.debug("removeTimerService: " + timerService); timerService.shutdown(keepState); it.remove(); } } } } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public void restoreTimers(ObjectName containerId, ClassLoader loader) throws IllegalStateException { assert persistencePolicy != null : "persistencePolicy is not set"; // find out all the persisted handles, for the specified container List handles = persistencePolicy.listTimerHandles(containerId, loader); if (handles.isEmpty() == false) { // first remove the persisted handles from the db for (Iterator i = handles.iterator(); i.hasNext(); ) { TimerHandleImpl handle = (TimerHandleImpl)i.next(); persistencePolicy.deleteTimer(handle.getTimerId(), handle.getTimedObjectId()); } // make a second pass to re-create the timers; use the container // itself to retrieve the correct TimerService/ for each handle, // then use the standard ejb timer API to recreate the timer for (Iterator i = handles.iterator(); i.hasNext(); ) { TimerHandleImpl handle = (TimerHandleImpl)i.next(); try { TimedObjectId targetId = handle.getTimedObjectId(); ContainerMBean container = (ContainerMBean)MBeanProxyExt.create(ContainerMBean.class, containerId, server); TimerService timerService = container.getTimerService(targetId.getInstancePk()); timerService.createTimer(handle.getFirstTime(), handle.getPeriode(), handle.getInfo()); } catch (Exception e) { log.warn("Unable to restore timer record: " + handle, e); } } } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public TimerService createTimerService(ObjectName containerId, Object instancePk, Container container) throws IllegalStateException { try { TimerService timerService = mbeanEjbTimerService.createTimerService(containerId, instancePk, container); return timerService; } catch (Exception e) { log.error("Cannot createTimerService", e); return null; } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public TimerService createTimerService(ObjectName containerId, Object instancePk, TimedObjectInvoker invoker) throws IllegalStateException { try { TimerService timerService = mbeanEjbTimerService.createTimerService(containerId, instancePk, invoker); return timerService; } catch (Exception e) { log.error("Cannot createTimerService", e); return null; } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public TimerService getTimerService(ObjectName containerId, Object instancePk) throws IllegalStateException { try { TimerService timerService = mbeanEjbTimerService.getTimerService(containerId, instancePk); return timerService; } catch (Exception e) { log.error("Cannot getTimerService", e); return null; } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public void removeTimerService(ObjectName containerId, Object instancePk) throws IllegalStateException { try { mbeanEjbTimerService.removeTimerService(containerId, instancePk); } catch (Exception e) { log.error("Cannot removeTimerService", e); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public void removeTimerService(ObjectName containerId, boolean keepState) throws IllegalStateException { try { mbeanEjbTimerService.removeTimerService(containerId, keepState); } catch (Exception e) { log.error("Cannot removeTimerService", e); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public void restoreTimers(ObjectName containerId, ClassLoader loader) throws IllegalStateException { try { mbeanEjbTimerService.restoreTimers(containerId, loader); } catch (Exception e) { log.error("Cannot restoreTimer", e); } }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Object getBusinessObject(Class businessInterface) throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Class getInvokedBusinessInterface() throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getTimerService", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); return new TimerServiceWrapper(this, super.getTimerService()); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public MessageContext getMessageContext() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getMessageContext", IN_SERVICE_ENDPOINT_METHOD); return soapMessageContext; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getTimerService", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); return new TimerServiceWrapper(this, super.getTimerService()); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/Container.java
public TimerService getTimerService(Object pKey) throws IllegalStateException { if (this instanceof StatefulSessionContainer) throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService"); // Validate that the bean implements the TimedObject interface if (TimedObject.class.isAssignableFrom(beanClass) == false) { // jbcts-381 return EJBTimerServiceImpl.FOR_NON_TIMED_OBJECT; } TimerService timerService = null; try { timerService = this.timerService.createTimerService(getJmxName(), pKey, this); } catch (Exception e) { throw new EJBException("Could not create timer service", e); } return timerService; }
// in src/main/java/org/jboss/ejb/Container.java
public void removeTimerService(Object pKey) throws IllegalStateException { try { if (pKey != null) { // entity bean->remove() timerService.removeTimerService(getJmxName(), pKey); } else { // container stop, we choose whether active timers // should be persisted (default), or not (legacy) timerService.removeTimerService(getJmxName(), getBeanMetaData().getTimerPersistence()); } } catch (Exception e) { log.error("Could not remove timer service", e); } }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getTimerService", IN_EJB_CREATE | IN_EJB_POST_CREATE | IN_EJB_REMOVE | IN_EJB_HOME | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_EJB_LOAD | IN_EJB_STORE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); return new TimerServiceWrapper(this, getContainer().getTimerService(id)); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public Object getBusinessObject(Class businessInterface) throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public Class getInvokedBusinessInterface() throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { throw new IllegalStateException("getTimerService should not be access from a stateful session bean"); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public MessageContext getMessageContext() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getMessageContext", NOT_ALLOWED); return null; }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { return getContainer().getTimerService(null); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx commit: " + tx); int status = tm.getStatus(); tm.commit(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx rollback: " + tx); tm.rollback(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void setRollbackOnly() throws IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx setRollbackOnly: " + tx); tm.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void checkSetForeignKey(EntityEnterpriseContext myCtx, Object newValue) throws IllegalStateException { JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCCMP2xFieldBridge pkField = (JDBCCMP2xFieldBridge) pkFields[i]; JDBCCMP2xFieldBridge relatedPkField = (JDBCCMP2xFieldBridge) relatedPKFieldsByMyPKFields.get(pkField); if(relatedPkField != null) { Object comingValue = relatedPkField.getPrimaryKeyValue(newValue); Object currentValue = pkField.getInstanceValue(myCtx); // they shouldn't be null if(!comingValue.equals(currentValue)) { throw new IllegalStateException("Can't create relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]." + " primary key value is " + currentValue + " overriding value is " + comingValue); } } } }
(Lib) EJBException 195
              
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } try { return mi.performCall(StatelessSessionContainer.this, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // wire the transaction on the context, this is how the instance remember the tx EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); // Get method and instance to invoke upon Method miMethod = mi.getMethod(); Map map = getBeanMapping(); Method m = (Method) map.get(miMethod); // The Invocation might contain the actual bean method // e.g. For an invocation based on a JSR-181 @WebMethod annotation if (m == null && map.values().contains(miMethod)) { m = miMethod; } if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } //If we have a method that needs to be done by the container (EJBObject methods) if (m.getDeclaringClass().equals(StatelessSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { try { return mi.performCall(StatelessSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else // we have a method that needs to be done by a bean instance { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
private void createSession(final Method m, final Object[] args, final StatefulSessionEnterpriseContext ctx) throws Exception { // Create a new ID and set it Object id = getPersistenceManager().createId(ctx); log.debug("Created new session ID: " + id); ctx.setId(id); // Invoke ejbCreate<METHOD>() try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); // Build the ejbCreate<METHOD> from the home create<METHOD> sig String createName = m.getName(); Object instance = ctx.getInstance(); String ejbCreateName = "ejbC" + createName.substring(1); Method createMethod = instance.getClass().getMethod(ejbCreateName, m.getParameterTypes()); log.debug("Using create method for session: " + createMethod); createMethod.invoke(instance, args); createCount++; } catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); } catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // call back to the PM to let it know that ejbCreate has been called with success getPersistenceManager().createdSession(ctx); // Insert in cache getInstanceCache().insert(ctx); // Create EJBObject if (getProxyFactory() != null) ctx.setEJBObject((EJBObject) getProxyFactory().getStatefulSessionEJBObject(id)); // Create EJBLocalObject if (getLocalHomeClass() != null) ctx.setEJBLocalObject(getLocalProxyFactory().getStatefulSessionEJBLocalObject(id)); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("HOMEMETHOD coming in "); log.trace("" + mi.getMethod()); log.trace("HOMEMETHOD coming in hashcode" + mi.getMethod().hashCode()); log.trace("HOMEMETHOD coming in classloader" + mi.getMethod().getDeclaringClass().getClassLoader().hashCode()); log.trace("CONTAINS " + getHomeMapping().containsKey(mi.getMethod())); } Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // Invoke and handle exceptions if (trace) { log.trace("HOMEMETHOD m " + m); java.util.Iterator iterator = getHomeMapping().keySet().iterator(); while (iterator.hasNext()) { Method me = (Method) iterator.next(); if (me.getName().endsWith("create")) { log.trace(me.toString()); log.trace("" + me.hashCode()); log.trace("" + me.getDeclaringClass().getClassLoader().hashCode()); log.trace("equals " + me.equals(mi.getMethod()) + " " + mi.getMethod().equals(me)); } } } try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) getBeanMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // wire the transaction on the context, this is how the instance remember the tx // Unlike Entity beans we can't do that in the previous interceptors (ordering) EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); else if(ejbObjectRemove.equals(miMethod) || ejbLocalObjectRemove.equals(miMethod)) { throw new RemoveException("An attempt to remove a session " + "object while the object is in a transaction " + "(EJB2.1, 7.6.4 Restrictions for Transactions): ejb-name=" + metaData.getEjbName() + ", method=" + mi.getMethod() + ", tx=" + ctx.getTransaction()); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(StatefulSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { // Invoke and handle exceptions try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/Container.java
public TimerService getTimerService(Object pKey) throws IllegalStateException { if (this instanceof StatefulSessionContainer) throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService"); // Validate that the bean implements the TimedObject interface if (TimedObject.class.isAssignableFrom(beanClass) == false) { // jbcts-381 return EJBTimerServiceImpl.FOR_NON_TIMED_OBJECT; } TimerService timerService = null; try { timerService = this.timerService.createTimerService(getJmxName(), pKey, this); } catch (Exception e) { throw new EJBException("Could not create timer service", e); } return timerService; }
// in src/main/java/org/jboss/ejb/Container.java
public Object invoke(Invocation mi) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); long start = System.currentTimeMillis(); Method m = null; Object type = null; String contextID = getJaccContextID(); try { pushENC(); // JBAS-3732 - Remove classloader.equals optimization SecurityActions.setContextClassLoader(this.classLoader); // Set the JACC context id mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID); contextID = SecurityActions.setContextID(contextID); // Set the standard JACC policy context handler data is not a SEI msg if (mi.getType() != InvocationType.SERVICE_ENDPOINT) { EJBArgsPolicyContextHandler.setArgs(mi.getArguments()); } else { SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE); SOAPMsgPolicyContextHandler.setMessage(msg); } // Set custom JACC policy handlers BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData()); // Check against home, remote, localHome, local, getHome, // getRemote, getLocalHome, getLocal type = mi.getType(); // stat gathering: concurrent calls this.invokeStats.callIn(); if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || // web service calls come in as "ordinary" application invocations type == InvocationType.SERVICE_ENDPOINT) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD REMOTE INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||"); } } m = mi.getMethod(); Object obj = internalInvoke(mi); return obj; } else if (type == InvocationType.HOME || type == InvocationType.LOCALHOME) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD HOME INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||" + mi.getArguments().toString()); } } m = mi.getMethod(); Object obj = internalInvokeHome(mi); return obj; } else { throw new MBeanException(new IllegalArgumentException("Unknown invocation type: " + type)); } } /** * Having to catch this exception here in case can not * unmarshall arguments, values, etc. Then, convert to * UnmarshalException as defined by spec (JBAS-2999) */ catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } } finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); } }
// in src/main/java/org/jboss/ejb/Container.java
protected void rethrow(Exception e) throws Exception { if (e instanceof IllegalAccessException) { // Throw this as a bean exception...(?) throw new EJBException(e); } else if (e instanceof InvocationTargetException) { Throwable t = ((InvocationTargetException)e).getTargetException(); if (t instanceof EJBException) { throw (EJBException)t; } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new NestedError("Unexpected Throwable", t); } } throw e; }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); // wire the transaction on the context, // this is how the instance remember the tx if (ctx.getTransaction() == null) { ctx.setTransaction(mi.getTransaction()); } // Get method and instance to invoke upon Method m = (Method) beanMapping.get(mi.getMethod()); if( m == null ) { // This is a configuration error that should have been caught earlier String msg = MessageDrivenContainer.this.getBeanMetaData().getEjbName() + " Invalid invocation, check your deployment packaging, interfaces, method=" + mi.getMethod(); throw new EJBException(msg); } // we have a method that needs to be done by a bean instance try { messageCount++; return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public Identity getCallerIdentity() { throw new EJBException("Deprecated"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public EJBLocalHome getEJBLocalHome() { if (con.getLocalHomeClass() == null) throw new IllegalStateException("No local home defined."); if (con instanceof EntityContainer) return ((EntityContainer) con).getLocalProxyFactory().getEJBLocalHome(); else if (con instanceof StatelessSessionContainer) return ((StatelessSessionContainer) con).getLocalProxyFactory().getEJBLocalHome(); else if (con instanceof StatefulSessionContainer) return ((StatefulSessionContainer) con).getLocalProxyFactory().getEJBLocalHome(); // Should never get here throw new EJBException("No EJBLocalHome available (BUG!)"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public Properties getEnvironment() { throw new EJBException("Deprecated"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public boolean isCallerInRole(Identity id) { throw new EJBException("Deprecated"); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public void initEntity (EntityEnterpriseContext ctx) { // first get cmp metadata of this entity Object instance = ctx.getInstance (); Class ejbClass = instance.getClass (); Field cmpField; Class cmpFieldType; EntityMetaData metaData = (EntityMetaData)con.getBeanMetaData (); Iterator i= metaData.getCMPFields (); while(i.hasNext ()) { // get the field declaration try { cmpField = ejbClass.getField ((String)i.next ()); cmpFieldType = cmpField.getType (); // find the type of the field and resets it // to the default value if (cmpFieldType.equals (boolean.class)) { cmpField.setBoolean (instance,false); } else if (cmpFieldType.equals (byte.class)) { cmpField.setByte (instance,(byte)0); } else if (cmpFieldType.equals (int.class)) { cmpField.setInt (instance,0); } else if (cmpFieldType.equals (long.class)) { cmpField.setLong (instance,0L); } else if (cmpFieldType.equals (short.class)) { cmpField.setShort (instance,(short)0); } else if (cmpFieldType.equals (char.class)) { cmpField.setChar (instance,'\u0000'); } else if (cmpFieldType.equals (double.class)) { cmpField.setDouble (instance,0d); } else if (cmpFieldType.equals (float.class)) { cmpField.setFloat (instance,0f); } else { cmpField.set (instance,null); } } catch (NoSuchFieldException e) { // will be here with dependant value object's private attributes // should not be a problem } catch (Exception e) { throw new EJBException (e); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public void loadEntity (EntityEnterpriseContext ctx) { try { // Read fields java.io.ObjectInputStream in = new CMPObjectInputStream (new java.io.ByteArrayInputStream ((byte[])this.beans.get (ctx.getId ()))); Object obj = ctx.getInstance (); Field[] f = obj.getClass ().getFields (); for (int i = 0; i < f.length; i++) { f[i].set (obj, in.readObject ()); } in.close (); } catch (Exception e) { throw new EJBException ("Load failed", e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected void storeEntity (Object id, Object obj) { try { // Store fields java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream (); java.io.ObjectOutputStream out = new CMPObjectOutputStream (baos); try { Field[] f = obj.getClass ().getFields (); for (int i = 0; i < f.length; i++) { out.writeObject (f[i].get (obj)); } } finally { out.close(); } this.beans.put (id, baos.toByteArray ()); } catch (Exception e) { throw new EJBException ("Store failed", e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void createEntity( Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { Object id = null; try { // Call ejbCreate<METHOD) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); Method createMethod = (Method)createMethods.get(m); id = createMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } // set the id ctx.setId(id); // Create a new CacheKey Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id ); // Give it to the context ctx.setCacheKey(cacheKey); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void postCreateEntity( Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_POST_CREATE); Method postCreateMethod = (Method)postCreateMethods.get(m); postCreateMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { // call the finder method Object result; try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); result = callFinderMethod(finderMethod, args, ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } if (result == null) { // for EJB 1.0 compliance // if the bean couldn't find any matching entities // it returns null, so we return an empty collection return new ArrayList(); } if (result instanceof java.util.Enumeration) { // to preserve 1.0 spec compatiblity ArrayList array = new ArrayList(); Enumeration e = (Enumeration) result; while (e.hasMoreElements() == true) { // Wrap a cache key around the given object id/primary key final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(e.nextElement()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o); } return array; } else if (result instanceof java.util.Collection) { ArrayList array = new ArrayList(((Collection) result).size()); Iterator i = ((Collection) result).iterator(); while (i.hasNext()) { // Wrap a cache key around the given object id/primary key final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(i.next()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o); } return array; } else { // so we received something that's not valid // throw an exception reporting it throw new EJBException("result of finder method is not a valid " + "return type: " + result.getClass()); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void activateEntity(EntityEnterpriseContext ctx) throws RemoteException { // Create a new CacheKey Object id = ctx.getId(); Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id ); // Give it to the context ctx.setCacheKey(cacheKey); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); ejbActivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void loadEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_LOAD); ejbLoad.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void invokeEjbStore(EntityEnterpriseContext ctx) throws RemoteException { try { if(!isStoreRequired(ctx)) { return; } } catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); } try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE); ejbStore.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void passivateEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); ejbPassivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } ctx.setEJBObject(null); ctx.setEJBLocalObject(null); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); ejbRemove.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
private Object callFinderMethod(Method finderMethod, Object[] args, EntityEnterpriseContext ctx) throws Exception { // get the finder method Method callMethod = (Method)finderMethods.get(finderMethod); if (callMethod == null) { throw new EJBException("couldn't find finder method in bean class. " + finderMethod.toString()); } // invoke the finder method Object result = null; try { result = callMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } return result; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void activateSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to activate; ctx=" + ctx); } Object id = ctx.getId(); // Load state File file = getFile(id); if (trace) { log.trace("Reading session state from: " + file); } try { FileInputStream fis = FISAction.open(file); SessionObjectInputStream in = new SessionObjectInputStream(ctx, new BufferedInputStream(fis)); try { Object obj = in.readObject(); if (trace) { log.trace("Session state: " + obj); } ctx.setInstance(obj); } finally { in.close(); } } catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); } removePassivated(id); try { // Instruct the bean to perform activation logic AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbActivate(); } finally { AllowedOperationsAssociation.popInMethodFlag(); } if (trace) { log.trace("Activation complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void passivateSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to passivate; ctx=" + ctx); } try { // Instruct the bean to perform passivation logic AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbPassivate(); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Store state File file = getFile(ctx.getId()); if (trace) { log.trace("Saving session state to: " + file); } try { FileOutputStream fos = FOSAction.open(file); SessionObjectOutputStream out = new SessionObjectOutputStream( new BufferedOutputStream(fos)); Object obj = ctx.getInstance(); if (trace) { log.trace("Writing session state: " + obj); } try { out.writeObject(obj); } finally { out.close(); } } catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); } if (trace) { log.trace("Passivation complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private Object runWithTransactions(Invocation invocation) throws Exception { // Old transaction is the transaction that comes with the MI Transaction oldTransaction = invocation.getTransaction(); // New transaction is the new transaction this might start Transaction newTransaction = null; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Current transaction in MI is " + oldTransaction); InvocationType type = invocation.getType(); byte transType = container.getBeanMetaData().getTransactionMethod(invocation.getMethod(), type); if ( trace ) printMethod(invocation.getMethod(), transType); // Thread arriving must be clean (jboss doesn't set the thread // previously). However optimized calls come with associated // thread for example. We suspend the thread association here, and // resume in the finally block of the following try. Transaction threadTx = tm.suspend(); if( trace ) log.trace("Thread came in with tx " + threadTx); try { switch (transType) { case MetaData.TX_NOT_SUPPORTED: { // Do not set a transaction on the thread even if in MI, just run try { invocation.setTransaction(null); return invokeNext(invocation, false); } finally { invocation.setTransaction(oldTransaction); } } case MetaData.TX_REQUIRED: { int oldTimeout = 0; Transaction theTransaction = oldTransaction; if (oldTransaction == null) { // No tx running // Create tx oldTimeout = startTransaction(invocation); // get the tx newTransaction = tm.getTransaction(); if( trace ) log.trace("Starting new tx " + newTransaction); // Let the method invocation know invocation.setTransaction(newTransaction); theTransaction = newTransaction; } else { // We have a tx propagated // Associate it with the thread tm.resume(oldTransaction); } // Continue invocation try { Object result = invokeNext(invocation, oldTransaction != null); checkTransactionStatus(theTransaction, type); return result; } finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); } } case MetaData.TX_SUPPORTS: { // Associate old transaction with the thread // Some TMs cannot resume a null transaction and will throw // an exception (e.g. Tyrex), so make sure it is not null if (oldTransaction != null) { tm.resume(oldTransaction); } try { Object result = invokeNext(invocation, oldTransaction != null); if (oldTransaction != null) checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } // Even on error we don't do anything with the tx, // we didn't start it } case MetaData.TX_REQUIRES_NEW: { // Always begin a transaction int oldTimeout = startTransaction(invocation); // get it newTransaction = tm.getTransaction(); // Set it on the method invocation invocation.setTransaction(newTransaction); // Continue invocation try { Object result = invokeNext(invocation, false); checkTransactionStatus(newTransaction, type); return result; } finally { // We started the transaction for sure so we commit or roll back endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); } } case MetaData.TX_MANDATORY: { if (oldTransaction == null) { if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new TransactionRequiredLocalException( "Transaction Required"); } else { throw new TransactionRequiredException( "Transaction Required"); } } // Associate it with the thread tm.resume(oldTransaction); try { Object result = invokeNext(invocation, true); checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } } case MetaData.TX_NEVER: { if (oldTransaction != null) { throw new EJBException("Transaction not allowed"); } return invokeNext(invocation, false); } default: log.error("Unknown TX attribute "+transType+" for method"+invocation.getMethod()); } } finally { // IN case we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } return null; }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void getReadLock(Transaction tx) { boolean done = false; while(!done) { if(tx == null) { done = writer == null; } else if(readers.contains(tx)) { done = true; } else if(writer == null && promotingReader == null && writersWaiting == 0) { try { ReadLockReliever reliever = getReliever(); reliever.setup(this, tx); tx.registerSynchronization(reliever); } catch (Exception e) { throw new EJBException(e); } readers.add(tx); done = true; } else if (writer != null && writer.equals(tx)) { done = true; } if(!done) { if(trace) trace(tx, "READ (WT) writer:" + writer + " writers waiting: " + writersWaiting + " reader count: " + readers.size()); waitAWhile(tx); } } }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void getWriteLock(Transaction tx) { boolean done = false; boolean isReader; if(tx == null) throw new EJBException("Write lock requested without transaction."); isReader = readers.contains(tx); writersWaiting++; while(!done) { if(writer == null && (readers.isEmpty() || (readers.size() == 1 && isReader))) { writersWaiting--; promotingReader = null; writer = tx; done = true; } else if (writer != null && writer.equals(tx)) { writersWaiting--; done = true; } else { if(isReader) { if(promotingReader != null && !promotingReader.equals(tx)) { writersWaiting--; throw new EJBException("Contention on read lock promotion for bean. Exception in second transaction"); } promotingReader = tx; } if(trace) trace(tx, "WRITE (WT) writer:" + writer + " writers waiting: " + writersWaiting + " reader count: " + readers.size()); waitAWhile(tx); } } }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void checkTransaction(Transaction tx) { try { if(TxUtils.isRollback(tx)) throw new EJBException ("Transaction marked for rollback - probably a timeout."); } catch (Exception e) { throw new EJBException(e); } }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context MessageDrivenContainer mdc = (MessageDrivenContainer) container; InstancePool pool = mdc.getInstancePool(); EnterpriseContext ctx = null; try { ctx = pool.get(); } catch (EJBException e) { throw e; } catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Use this context mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); // There is no need for synchronization since the instance is always // fresh also there should never be a tx associated with the instance. try { // Invoke through interceptors Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free((EnterpriseContext) mi.getEnterpriseContext()); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
protected void register(EntityEnterpriseContext ctx, Transaction tx) { boolean trace = log.isTraceEnabled(); if(trace) log.trace("register, ctx=" + ctx + ", tx=" + tx); EntityContainer ctxContainer = null; try { ctxContainer = (EntityContainer)ctx.getContainer(); if(!ctx.hasTxSynchronization()) { // Create a new synchronization Synchronization synch = createSynchronization(tx, ctx); // We want to be notified when the transaction commits tx.registerSynchronization(synch); ctx.hasTxSynchronization(true); } //mark it dirty in global tx entity map if it is not read only if(!ctxContainer.isReadOnly()) { ctx.getTxAssociation().scheduleSync(tx, ctx); } } catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); } catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
private void checkSecurityAssociation(Invocation mi) throws Exception { Principal principal = mi.getPrincipal(); boolean trace = log.isTraceEnabled(); if (realmMapping == null) { throw new EJBException("checkSecurityAssociation", new SecurityException("Role mapping manager has not been set")); } // Get the method permissions InvocationType iface = mi.getType(); Set methodRoles = container.getMethodPermissions(mi.getMethod(), iface); if (methodRoles == null) { String method = mi.getMethod().getName(); String msg = "No method permissions assigned to method=" + method + ", interface=" + iface; log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } else if (trace) { log.trace("method=" + mi.getMethod() + ", interface=" + iface + ", requiredRoles=" + methodRoles); } // Check if the caller is allowed to access the method RunAsIdentity callerRunAsIdentity = SecurityAssociation.peekRunAsIdentity(); if (methodRoles.contains(AnybodyPrincipal.ANYBODY_PRINCIPAL) == false) { // The caller is using a the caller identity if (callerRunAsIdentity == null) { // Now actually check if the current caller has one of the required method roles if (realmMapping.doesUserHaveRole(principal, methodRoles) == false) { Set userRoles = realmMapping.getUserRoles(principal); String method = mi.getMethod().getName(); String msg = "Insufficient method permissions, principal=" + principal + ", method=" + method + ", interface=" + iface + ", requiredRoles=" + methodRoles + ", principalRoles=" + userRoles; log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } } // The caller is using a run-as identity else { // Check that the run-as role is in the set of method roles if (callerRunAsIdentity.doesUserHaveRole(methodRoles) == false) { String method = mi.getMethod().getName(); String msg = "Insufficient method permissions, runAsPrincipal=" + callerRunAsIdentity.getName() + ", method=" + method + ", interface=" + iface + ", requiredRoles=" + methodRoles + ", runAsRoles=" + callerRunAsIdentity.getRunAsRoles(); log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
protected Object invokeNext(Invocation invocation, boolean inheritedTx) throws Exception { InvocationType type = invocation.getType(); try { if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || type == InvocationType.SERVICE_ENDPOINT) { // register the Timer with the transaction if (ejbTimeout.equals(invocation.getMethod())) registerTimer(invocation); return getNext().invoke(invocation); } else { return getNext().invokeHome(invocation); } } catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); boolean nonReentrant = !(reentrant || isReentrantMethod(mi)); // Not a reentrant method like getPrimaryKey NonReentrantLock methodLock = ctx.getMethodLock(); Transaction miTx = ctx.getTransaction(); boolean locked = false; try { while (!locked) { if (methodLock.attempt(5000, miTx, nonReentrant)) { locked = true; } else { if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } } } catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } } try { ctx.lock(); return getNext().invoke(mi); } finally { ctx.unlock(); methodLock.release(nonReentrant); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { // Deligate initialization of bean to persistence store store.initEntity(ctx); // Call ejbCreate on the target bean try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); Method createMethod = (Method) createMethods.get(m); createMethod.invoke(ctx.getInstance(), args); } catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // if insertAfterEjbPostCreate == true, this will INSERT entity // otherwise, primary key is extracted from the context and returned Object id; try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); id = store.createEntity(m, args, ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Set the key on the target context ctx.setId(id); // Create a new CacheKey Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id); // Give it to the context ctx.setCacheKey(cacheKey); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void postCreateEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { // this call should go first as it sets up relationships // for fk fields mapped to pk fields store.postCreateEntity(m, args, ctx); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_POST_CREATE); Method postCreateMethod = (Method) postCreateMethods.get(m); postCreateMethod.invoke(ctx.getInstance(), args); if(insertAfterEjbPostCreate) { store.createEntity(m, args, ctx); } } catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void activateEntity(EntityEnterpriseContext ctx) throws RemoteException { // Create a new CacheKey Object id = ctx.getId(); Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id); // Give it to the context ctx.setCacheKey(cacheKey); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbActivate(); } catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // The implementation of the call can be left absolutely empty, the // propagation of the call is just a notification for stores that would // need to know that an instance is being activated store.activateEntity(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void throwRemoteException(Exception e) throws RemoteException { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
public synchronized EnterpriseContext get() throws Exception { boolean intr = false; try { // Wait while someone else is using it while(inUse && isSynchronized) { try { this.wait(); } catch (InterruptedException e) { intr = true; } } // Create if not already created (or it has been discarded) if (ctx == null) { try { ctx = create(getContainer().createBeanClassInstance()); } catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); } catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); } } else { } // Lock and return instance inUse = true; return ctx; } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context InstancePool pool = container.getInstancePool(); StatelessSessionEnterpriseContext ctx = null; try { ctx = (StatelessSessionEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Use this context mi.setEnterpriseContext(ctx); // JAXRPC/JAXWS message context Object msgContext = mi.getValue(InvocationKey.SOAP_MESSAGE_CONTEXT); // Timer invocation if (ejbTimeout.equals(mi.getMethod())) { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); } // Service Endpoint invocation else if (msgContext != null) { if (msgContext instanceof javax.xml.rpc.handler.MessageContext) ctx.setMessageContext((javax.xml.rpc.handler.MessageContext)msgContext); AllowedOperationsAssociation.pushInMethodFlag(IN_SERVICE_ENDPOINT_METHOD); } // Business Method Invocation else { AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); } // There is no need for synchronization since the instance is always fresh also there should // never be a tx associated with the instance. try { Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public void initEntity(final EntityEnterpriseContext ctx) { // first get cmp metadata of this entity Object instance = ctx.getInstance(); Class ejbClass = instance.getClass(); Field cmpField; Class cmpFieldType; EntityMetaData metaData = (EntityMetaData)con.getBeanMetaData(); Iterator i = metaData.getCMPFields(); while (i.hasNext()) { // get the field declaration try { cmpField = ejbClass.getField((String)i.next()); cmpFieldType = cmpField.getType(); // find the type of the field and reset it // to the default value if (cmpFieldType.equals(boolean.class)) { cmpField.setBoolean(instance,false); } else if (cmpFieldType.equals(byte.class)) { cmpField.setByte(instance,(byte)0); } else if (cmpFieldType.equals(int.class)) { cmpField.setInt(instance,0); } else if (cmpFieldType.equals(long.class)) { cmpField.setLong(instance,0L); } else if (cmpFieldType.equals(short.class)) { cmpField.setShort(instance,(short)0); } else if (cmpFieldType.equals(char.class)) { cmpField.setChar(instance,'\u0000'); } else if (cmpFieldType.equals(double.class)) { cmpField.setDouble(instance,0d); } else if (cmpFieldType.equals(float.class)) { cmpField.setFloat(instance,0f); } else { cmpField.set(instance,null); } } catch (NoSuchFieldException e) { // will be here with dependant value object's private attributes // should not be a problem } catch (Exception e) { throw new EJBException(e); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public void loadEntity(final EntityEnterpriseContext ctx) { try { Object obj = ctx.getInstance(); // Read fields ObjectInputStream in = new CMPObjectInputStream (new BufferedInputStream(new FileInputStream(getFile(ctx.getId())))); try { Field[] f = obj.getClass().getFields(); for (int i = 0; i < f.length; i++) { f[i].set(obj, in.readObject()); } } finally { in.close(); } } catch (Exception e) { throw new EJBException("Load failed", e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
private void storeEntity(Object id, Object obj) { try { // Store fields ObjectOutputStream out = new CMPObjectOutputStream (new BufferedOutputStream(new FileOutputStream(getFile(id)))); try { Field[] f = obj.getClass().getFields(); for (int i = 0; i < f.length; i++) { out.writeObject(f[i].get(obj)); } } finally { out.close(); } } catch (Exception e) { throw new EJBException("Store failed", e); } }
// in src/main/java/org/jboss/ejb/plugins/local/StatefulSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { if (args == null) args = EMPTY_ARGS; // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (m.equals(GET_PRIMARY_KEY)) { if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } Object retValue = super.invoke( proxy, m, args ); if (retValue == null) { // If not taken care of, go on and call the container retValue = factory.invoke(id, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/local/StatelessSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { Object retValue = null; if (args == null) args = EMPTY_ARGS; // Implement local methods if (m.equals(TO_STRING)) { retValue = jndiName + ":Stateless"; } else if (m.equals(EQUALS)) { retValue = invoke(proxy, IS_IDENTICAL, args); } else if (m.equals(HASH_CODE)) { // We base the stateless hash on the hash of the proxy... // MF XXX: it could be that we want to return the hash of the name? retValue = new Integer(this.hashCode()); } else if (m.equals(GET_PRIMARY_KEY)) { // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } else if (m.equals(GET_EJB_HOME)) { InitialContext ctx = new InitialContext(); return ctx.lookup(jndiName); } else if (m.equals(IS_IDENTICAL)) { // All stateless beans are identical within a home, // if the names are equal we are equal retValue = isIdentical(args[0], jndiName + ":Stateless"); } // If not taken care of, go on and call the container else { retValue = factory.invoke(jndiName, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/RelationInterceptor.java
public Object invoke(Invocation mi) throws Exception { if(!(mi instanceof CMRInvocation)) { return getNext().invoke(mi); } org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage msg = ((CMRInvocation)mi).getCmrMessage(); // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); JDBCCMRFieldBridge2 cmrField = (JDBCCMRFieldBridge2)mi.getArguments()[0]; if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.ADD_RELATION == msg) { Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Add relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.addRelatedId(ctx, relatedId); } else if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.REMOVE_RELATION == msg) { // call removeRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Remove relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.removeRelatedId(ctx, relatedId); } else { // this should not be possible we are using a type safe enum throw new EJBException("Unknown cmp2.0-relationship-message=" + msg); } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
public void flush() { Views views = getViews(); Table.View[] relationViews = views.relationViews; if(relationViews != null) { for(int i = 0; i < relationViews.length; ++i) { final Table.View view = relationViews[i]; if(view != null) { try { view.flushDeleted(views); } catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); } } } } final Table.View[] entityViews = views.entityViews; for(int i = 0; i < entityViews.length; ++i) { Table.View view = entityViews[i]; if(view != null) { try { view.flushDeleted(views); } catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); } } } for(int i = 0; i < entityViews.length; ++i) { Table.View view = entityViews[i]; if(view != null) { try { view.flushCreated(views); } catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); } } } for(int i = 0; i < entityViews.length; ++i) { Table.View view = entityViews[i]; if(view != null) { try { view.flushUpdated(); } catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); } } } if(relationViews != null) { for(int i = 0; i < relationViews.length; ++i) { final Table.View view = relationViews[i]; if(view != null) { try { view.flushCreated(views); } catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); } } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
private Views getViews() { Transaction tx = txLocal.getTransaction(); GlobalTxSynchronization globalSync; try { globalSync = txLocal.getGlobalSynchronization(tx); } catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); } catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); } if(globalSync == null) throw new IllegalStateException("Global transaction synchronization is not available for transaction " + tx); Views views = (Views) globalSync.getTxLocal(viewsTxLocalKey); if(views == null) { views = new Views(tx); globalSync.putTxLocal(viewsTxLocalKey, views); globalSync.addSynchronization(new SchemaSynchronization(views)); } return views; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void nullifyForeignKeys() throws SQLException { if(log.isTraceEnabled()) { log.trace("nullifying foreign keys"); } Connection con = null; PreparedStatement[] ps = new PreparedStatement[fkConstraints.length]; try { final JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); con = dataSource.getConnection(); for(int i = 0; i < rowsWithNullFks.size(); ++i) { final Row row = (Row) rowsWithNullFks.get(i); final ForeignKeyConstraint[] cons = row.fkUpdates; for (int c = 0; c < fkConstraints.length; ++c) { if (cons[c] == null || row.state == DELETED && !cons[c].selfReference) continue; PreparedStatement s = ps[c]; if (s == null) { if (log.isDebugEnabled()) { log.debug("nullifying fk: " + cons[c].nullFkSql); } s = con.prepareStatement(cons[c].nullFkSql); ps[c] = s; } int paramInd = 1; for (int fInd = 0; fInd < pkFields.length; ++fInd) { JDBCCMPFieldBridge2 pkField = pkFields[fInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(s, paramInd, fieldValue); } final int affected = s.executeUpdate(); if (affected != 1) { throw new EJBException("Affected " + affected + " rows while expected just one"); } } } } finally { for(int i = 0; i < ps.length; ++i) { JDBCUtil.safeClose(ps[i]); } JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private Object loadField(int i) { JDBCCMPFieldBridge2 field = (JDBCCMPFieldBridge2)entity.getFields().get(i); StringBuffer query = new StringBuffer(); query.append("select ") .append(field.getColumnName()) .append(" from ") .append(tableName) .append(" where "); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[])entity.getPrimaryKeyFields(); for(int pkI = 0; pkI < pkFields.length; ++pkI) { if(pkI > 0) { query.append(" and "); } query.append(pkFields[pkI].getColumnName()).append("=?"); } if(log.isDebugEnabled()) { log.debug("executing: " + query.toString()); } Object value = null; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = dataSource.getConnection(); ps = con.prepareStatement(query.toString()); for(int pkI = 0; pkI < pkFields.length; ++pkI) { JDBCCMPFieldBridge2 pkField = pkFields[pkI]; Object fieldValue = fields[pkField.getRowIndex()]; pkField.setArgumentParameters(ps, pkI + 1, fieldValue); } rs = ps.executeQuery(); if(!rs.next()) { throw new NoSuchEntityException("Row not found: " + pk); } value = field.loadArgumentResults(rs, 1); } catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } fields[field.getRowIndex()] = value; return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeBatch(PreparedStatement ps) throws SQLException { int[] updates = ps.executeBatch(); for(int i = 0; i < updates.length; ++i) { int status = updates[i]; if(status != 1 && status != -2 /* java.sql.Statement.SUCCESS_NO_INFO since jdk1.4*/) { String msg = (status == -3 /* java.sql.Statement.EXECUTE_FAILED since jdk1.4 */ ? "One of the commands in the batch failed to execute" : "Each command in the batch should update exactly 1 row but " + "one of the commands updated " + updates[i] + " rows."); throw new EJBException(msg); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeUpdate(PreparedStatement ps) throws SQLException { int rows = ps.executeUpdate(); if(rows != 1) { throw new EJBException("Expected one updated row but got: " + rows); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public void loadEntity(EntityEnterpriseContext ctx) { try { EntityTable.Row row = entityBridge.getTable().loadRow(ctx.getId()); PersistentContext pctx = new PersistentContext(entityBridge, row); ctx.setPersistenceContext(pctx); } catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; } catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object setPrimaryKeyValue(Object primaryKey, Object value) throws IllegalArgumentException { try { if(pkField != null) { // if we are trying to set a null value into a null pk, we are already done. if(value == null && primaryKey == null) { return null; } // if we don't have a pk object yet create one if(primaryKey == null) { primaryKey = pkClass.newInstance(); } // Set this field's value into the primary key object. pkField.set(primaryKey, value); return primaryKey; } else { // This field is the primary key, so no extraction is necessary. return value; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public int setArgumentParameters(PreparedStatement ps, int parameterIndex, Object arg) { try { int[] jdbcTypes = jdbcType.getJDBCTypes(); for(int i = 0; i < jdbcTypes.length; i++) { Object columnValue = jdbcType.getColumnValue(i, arg); jdbcType.getParameterSetter()[i].set(ps, parameterIndex++, jdbcTypes[i], columnValue, log); //JDBCUtil.setParameter(log, ps, parameterIndex++, jdbcTypes[i], columnValue); } return parameterIndex; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object loadArgumentResults(ResultSet rs, int parameterIndex) throws IllegalArgumentException { try { // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); if(javaTypes.length > 1) { throw new IllegalStateException("Complex types are not supported yet."); } JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); Object columnValue = null; for(int i = 0; i < javaTypes.length; i++) { columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); columnValue = jdbcType.setColumnValue(i, null, columnValue); } // retrun the updated parameterIndex return columnValue; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object getPrimaryKeyValue(Object primaryKey) throws IllegalArgumentException { try { if(pkField != null) { if(primaryKey == null) { return null; } return pkField.get(primaryKey); } else { return primaryKey; } } catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private void invokeRemoveRelatedId(Object myId, Object relatedId) { try { Transaction tx = getTransaction(); EntityCache instanceCache = (EntityCache)manager.getContainer().getInstanceCache(); /* RelationInterceptor.RelationInvocation invocation = new RelationInterceptor.RelationInvocation(RelationInterceptor.CMRMessage.REMOVE_RELATED_ID); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(SecurityAssociation.getPrincipal()); invocation.setCredential(SecurityAssociation.getCredential()); invocation.setType(InvocationType.LOCAL); */ SecurityActions actions = SecurityActions.UTIL.getSecurityActions(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.REMOVE_RELATION); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(actions.getPrincipal()); invocation.setCredential(actions.getCredential()); invocation.setType(InvocationType.LOCAL); manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in invokeRemoveRelatedId()", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private void invokeAddRelatedId(Object myId, Object relatedId) { try { Transaction tx = getTransaction(); EntityCache instanceCache = (EntityCache)manager.getContainer().getInstanceCache(); /* RelationInterceptor.RelationInvocation invocation = new RelationInterceptor.RelationInvocation(RelationInterceptor.CMRMessage.ADD_RELATED_ID); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(SecurityAssociation.getPrincipal()); invocation.setCredential(SecurityAssociation.getCredential()); invocation.setType(InvocationType.LOCAL); */ SecurityActions actions = SecurityActions.UTIL.getSecurityActions(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.ADD_RELATION); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(actions.getPrincipal()); invocation.setCredential(actions.getCredential()); invocation.setType(InvocationType.LOCAL); manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in invokeAddRelatedId()", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private void loadOnlyFromCache(EntityEnterpriseContext ctx) { PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext(); if(pctx == null) { throw new EJBException("Persistence context is not available! Make sure the CMR collection is accessed in the transaction it was obtained."); } pctx.loadCachedRelations(cmrIndex, this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void load(EntityEnterpriseContext ctx, FieldState state) { Object value; EntityTable relatedTable = relatedEntity.getTable(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing: " + loadSql); } con = relatedTable.getDataSource().getConnection(); ps = con.prepareStatement(loadSql); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[])entity.getPrimaryKeyFields(); Object myPk = ctx.getId(); int paramInd = 1; for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object fieldValue = pkField.getPrimaryKeyValue(myPk); JDBCCMPFieldBridge2 relatedFkField = tableKeyFields[i]; relatedFkField.setArgumentParameters(ps, paramInd++, fieldValue); } rs = ps.executeQuery(); while(rs.next()) { value = relatedTable.loadRow(rs, false); state.addLoadedPk(value); } } catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void load(EntityEnterpriseContext ctx, FieldState state) { Object value; EntityTable relatedTable = relatedEntity.getTable(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing: " + loadSql); } con = relatedTable.getDataSource().getConnection(); ps = con.prepareStatement(loadSql); JDBCCMPFieldBridge2[] relatedFkFields = relatedCMRField.foreignKeyFields; JDBCCMPFieldBridge2[] myPkFields = relatedCMRField.relatedPKFields; Object myPk = ctx.getId(); int paramInd = 1; for(int i = 0; i < relatedFkFields.length; ++i) { JDBCCMPFieldBridge2 myPkField = myPkFields[i]; Object fieldValue = myPkField.getPrimaryKeyValue(myPk); JDBCCMPFieldBridge2 relatedFkField = relatedFkFields[i]; relatedFkField.setArgumentParameters(ps, paramInd++, fieldValue); } rs = ps.executeQuery(); while(rs.next()) { value = relatedTable.loadRow(rs, false); state.addLoadedPk(value); } } catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public Object extractPrimaryKeyFromInstance(EntityEnterpriseContext ctx) { try { Object pk = null; for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object fieldValue = pkField.getValue(ctx); pk = pkField.setPrimaryKeyValue(pk, fieldValue); } return pk; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Internal error extracting primary key from instance", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public void setContext(EntityEnterpriseContext ctx) { if(ctx != null && !beanClass.isInstance(ctx.getInstance())) { throw new EJBException("Instance must be an instance of beanClass"); } this.ctx = ctx; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public Object invoke(Object proxy, Method method, Object[] args) throws FinderException { // todo find a better workaround // CMP/CMR field bridges are mapped to its abstract method names because of the bug // in reflection introduced in Sun's 1.4 JVM, i.e. when an abstract class C1 extends a super class C2 // and implements interface I and C2 and I both declare method with the same signature M, // C1.getMethods() will contain M twice. // ejbSelect methods are mapped to Method objects instead. Because ejbSelect methods having the same name // might have different signatures. Hopefully, the probability of an ejbSelect method to appear in an interface // is lower. String methodName = method.getName(); BridgeInvoker invoker = (BridgeInvoker) fieldMap.get(methodName); if(invoker == null) { //invoker = (BridgeInvoker) selectorMap.get(methodName); invoker = (BridgeInvoker) selectorMap.get(method); if(invoker == null) { throw new EJBException("Method is not a known CMP field " + "accessor, CMR field accessor, or ejbSelect method: " + "methodName=" + methodName); } } try { return invoker.invoke(ctx, method, args); } catch(RuntimeException e) { throw e; } catch(FinderException e) { throw e; } catch(Exception e) { throw new EJBException("Internal error", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public Object invoke(EntityEnterpriseContext ctx, Method method, Object[] args) { // In the case of ejbHome methods there is no context, but ejb home // methods are only allowed to call selectors. if(ctx == null) { throw new EJBException("EJB home methods are not allowed to " + "access CMP or CMR fields: methodName=" + method.getName()); } return field.getValue(ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public Object invoke(EntityEnterpriseContext ctx, Method method, Object[] args) { // In the case of ejbHome methods there is no context, but ejb home // methods are only allowed to call selectors. if(ctx == null) { throw new EJBException("EJB home methods are not allowed to " + "access CMP or CMR fields: methodName=" + method.getName()); } field.setValue(ctx, args[0]); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRelationInterceptor.java
public Object invoke(Invocation mi) throws Exception { if(!(mi instanceof CMRInvocation)) return getNext().invoke(mi); CMRMessage relationshipMessage = ((CMRInvocation)mi).getCmrMessage(); if(relationshipMessage == null) { // Not a relationship message. Invoke down the chain return getNext().invoke(mi); } // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)mi.getArguments()[0]; if(CMRMessage.GET_RELATED_ID == relationshipMessage) { // call getRelateId if(log.isTraceEnabled()) { log.trace("Getting related id: field=" + cmrField.getFieldName() + " id=" + ctx.getId()); } return cmrField.getRelatedId(ctx); } else if(CMRMessage.ADD_RELATION == relationshipMessage) { // call addRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Add relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.addRelation(ctx, relatedId); return null; } else if(CMRMessage.REMOVE_RELATION == relationshipMessage) { // call removeRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Remove relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.removeRelation(ctx, relatedId); return null; } else if(CMRMessage.SCHEDULE_FOR_CASCADE_DELETE == relationshipMessage) { JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity(); entity.scheduleForCascadeDelete(ctx); return null; } else if(CMRMessage.SCHEDULE_FOR_BATCH_CASCADE_DELETE == relationshipMessage) { JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity(); entity.scheduleForBatchCascadeDelete(ctx); return null; } else { // this should not be possible we are using a type safe enum throw new EJBException("Unknown cmp2.0-relationship-message=" + relationshipMessage); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
public void execute(EntityEnterpriseContext ctx) { // scheduled for batch cascade-delete instance should not be updated // because foreign key fields could be updated to null and cascade-delete will fail. JDBCEntityBridge.FieldIterator dirtyIterator = entity.getDirtyIterator(ctx); if(!dirtyIterator.hasNext() || entity.isBeingRemoved(ctx) || entity.isScheduledForBatchCascadeDelete(ctx)) { if(log.isTraceEnabled()) { log.trace("Store command NOT executed. Entity is not dirty " + ", is being removed or scheduled for *batch* cascade delete: pk=" + ctx.getId()); } return; } // generate sql StringBuffer sql = new StringBuffer(200); sql.append(SQLUtil.UPDATE) .append(entity.getQualifiedTableName()) .append(SQLUtil.SET); SQLUtil.getSetClause(dirtyIterator, sql) .append(SQLUtil.WHERE); SQLUtil.getWhereClause(primaryKeyFields, sql); boolean hasLockedFields = entity.hasLockedFields(ctx); JDBCEntityBridge.FieldIterator lockedIterator = null; if(hasLockedFields) { lockedIterator = entity.getLockedIterator(ctx); while(lockedIterator.hasNext()) { sql.append(SQLUtil.AND); JDBCCMPFieldBridge field = lockedIterator.next(); if(field.getLockedValue(ctx) == null) { SQLUtil.getIsNullClause(false, field, "", sql); lockedIterator.remove(); } else { SQLUtil.getWhereClause(field, sql); } } } Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { // create the statement if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql.toString()); // SET: set the dirty fields parameters int index = 1; dirtyIterator.reset(); while(dirtyIterator.hasNext()) { index = dirtyIterator.next().setInstanceParameters(ps, index, ctx); } // WHERE: set primary key fields index = entity.setPrimaryKeyParameters(ps, index, ctx.getId()); // WHERE: set optimistically locked field values if(hasLockedFields) { lockedIterator.reset(); while(lockedIterator.hasNext()) { JDBCCMPFieldBridge field = lockedIterator.next(); Object value = field.getLockedValue(ctx); index = field.setArgumentParameters(ps, index, value); } } // execute statement rowsAffected = ps.executeUpdate(); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Store failed", e); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected != 1) { throw new EJBException("Update failed. Expected one affected row: rowsAffected=" + rowsAffected + ", id=" + ctx.getId()); } // Mark the updated fields as clean. dirtyIterator.reset(); while(dirtyIterator.hasNext()) { dirtyIterator.next().setClean(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
public synchronized DataSource getDataSource() { if (dataSource == null) { try { InitialContext context = new InitialContext(); dataSource = (DataSource) context.lookup(dataSourceName); } catch (NamingException e) { throw new EJBException("Data source for relationship named " + relationName + " not found " + dataSourceName); } } return dataSource; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
private boolean hasNextResult() { try { boolean has = (limit == 0 || count-- > 0) && rs.next(); if(!has) { if(log.isTraceEnabled()) { log.trace("first iterator exhausted!"); } firstIterator = null; closeResources(); } return has; } catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
private Object readNext() { try { if(selectEntity != null) { ReadAheadCache selectReadAheadCache = selectManager.getReadAheadCache(); // first one is size int index = 2; // get the pk index = selectEntity.loadPrimaryKeyResults(rs, index, ref); curPk = ref[0]; boolean addPk = (loadOnFindCmr ? !curPk.equals(prevPk) : true); if(addPk) { prevPk = curPk; currentResult = factory.getEntityEJBObject(curPk); } // read the preload fields if(eagerLoadMask != null) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < eagerLoadMask.length; i++) { if(eagerLoadMask[i]) { JDBCFieldBridge field = tableFields[i]; ref[0] = null; // read the value and store it in the readahead cache index = field.loadArgumentResults(rs, index, ref); if(addPk) { selectReadAheadCache.addPreloadData(curPk, field, ref[0]); } } } if(!onFindCMRList.isEmpty()) { index = loadOnFindCMRFields(curPk, onFindCMRList, rs, index, log); } } } else if(selectField != null) { // load the field selectField.loadArgumentResults(rs, 2, ref); currentResult = ref[0]; } else { currentResult = selectFunction.readResult(rs); } if(log.isTraceEnabled() && limit != 0 && count == 0) { log.trace("Query result was limited to " + limit + " row(s)"); } return currentResult; } catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private JDBCTypeComplex createTypeComplex(JDBCCMPFieldMetaData cmpField) { // get the default properties for a field of its type JDBCTypeComplex type = (JDBCTypeComplex)complexTypes.get(cmpField.getFieldType()); JDBCTypeComplexProperty[] defaultProperties = type.getProperties(); // create a map of the overrides based on flat property name HashMap overrides = new HashMap(); for(int i = 0; i < cmpField.getPropertyOverrides().size(); ++i) { JDBCCMPFieldPropertyMetaData p = (JDBCCMPFieldPropertyMetaData)cmpField.getPropertyOverrides().get(i); overrides.put(p.getPropertyName(), p); } // array that will hold the final properites after overrides JDBCTypeComplexProperty[] finalProperties = new JDBCTypeComplexProperty[defaultProperties.length]; // override property default values for(int i = 0; i < defaultProperties.length; i++) { // pop off the override, if present JDBCCMPFieldPropertyMetaData override; override = (JDBCCMPFieldPropertyMetaData)overrides.remove(defaultProperties[i].getPropertyName()); if(override == null) { finalProperties[i] = defaultProperties[i]; finalProperties[i] = new JDBCTypeComplexProperty( defaultProperties[i], cmpField.getColumnName() + "_" + defaultProperties[i].getColumnName(), defaultProperties[i].getJDBCType(), defaultProperties[i].getSQLType(), cmpField.isNotNull() || defaultProperties[i].isNotNull()); } else { // columnName String columnName = override.getColumnName(); if(columnName == null) { columnName = cmpField.getColumnName() + "_" + defaultProperties[i].getColumnName(); } // sql and jdbc type String sqlType = override.getSQLType(); int jdbcType; if(sqlType != null) { jdbcType = override.getJDBCType(); } else { sqlType = defaultProperties[i].getSQLType(); jdbcType = defaultProperties[i].getJDBCType(); } boolean notNull = cmpField.isNotNull() || override.isNotNull() || defaultProperties[i].isNotNull(); finalProperties[i] = new JDBCTypeComplexProperty( defaultProperties[i], columnName, jdbcType, sqlType, notNull); } } // did we find all overriden properties if(overrides.size() > 0) { String propertyName = (String)overrides.keySet().iterator().next(); throw new EJBException("Property " + propertyName + " in field " + cmpField.getFieldName() + " is not a property of value object " + cmpField.getFieldType().getName()); } // return the new complex type return new JDBCTypeComplex(finalProperties, cmpField.getFieldType()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public final void pushPropertyMetaData( JDBCValuePropertyMetaData propertyMetaData) { propertyNames.add(propertyMetaData.getPropertyName()); columnNames.add(propertyMetaData.getColumnName()); notNulls.add(new Boolean(propertyMetaData.isNotNull())); getters.add(propertyMetaData.getGetter()); setters.add(propertyMetaData.getSetter()); if(properties.contains(propertyMetaData)) { throw new EJBException("Circular reference discoverd at " + "property: " + getPropertyName()); } properties.add(propertyMetaData); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private Map getApplicationTxDataMap() { try { Transaction tx = tm.getTransaction(); if(tx == null) { return null; } // get the txDataMap from the txMap Map txMap = (Map)txDataMap.get(tx); // do we have an existing map if(txMap == null) { int status = tx.getStatus(); if(status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARING) { // create and add the new map txMap = new HashMap(); txDataMap.set(tx, txMap); } } return txMap; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error getting application tx data map.", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
public void execute(RelationData relationData) { if(relationData.addedRelations.size() == 0) { return; } Connection con = null; PreparedStatement ps = null; JDBCCMRFieldBridge cmrField = relationData.getLeftCMRField(); try { // get the sql String sql = getSQL(relationData); boolean debug = log.isDebugEnabled(); if(debug) log.debug("Executing SQL: " + sql); // get the connection DataSource dataSource = cmrField.getDataSource(); con = dataSource.getConnection(); // get a prepared statement ps = con.prepareStatement(sql); Iterator pairs = relationData.addedRelations.iterator(); while(pairs.hasNext()) { RelationPair pair = (RelationPair)pairs.next(); // set the parameters setParameters(ps, relationData, pair); int rowsAffected = ps.executeUpdate(); } } catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); Connection c; Statement s = null; ResultSet rs = null; try { c = ps.getConnection(); s = c.createStatement(); rs = s.executeQuery(pkSQL); if (!rs.next()) { throw new EJBException("ResultSet was empty"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
public void execute(RelationData relationData) { if(relationData.removedRelations.size() == 0) { return; } Iterator pairs = relationData.removedRelations.iterator(); int i = 0; while(i < relationData.removedRelations.size()) { String sql = getSQL(relationData, relationData.removedRelations.size() - i); Connection con = null; PreparedStatement ps = null; JDBCCMRFieldBridge cmrField = relationData.getLeftCMRField(); try { // create the statement if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } // get the connection DataSource dataSource = cmrField.getDataSource(); con = dataSource.getConnection(); ps = con.prepareStatement(sql); // set the parameters setParameters(ps, relationData, pairs); // execute statement int rowsAffected = ps.executeUpdate(); if(log.isDebugEnabled()) { log.debug("Rows affected = " + rowsAffected); } i += (maxKeysInDelete > 0 ? maxKeysInDelete : relationData.removedRelations.size()); } catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
private boolean execute(JDBCCMPFieldBridge requiredField, EntityEnterpriseContext ctx, boolean failIfNotFound) { // load the instance primary key fields into the context Object id = ctx.getId(); // TODO: when exactly do I need to do the following? entity.injectPrimaryKeyIntoInstance(ctx, id); // get the read ahead cache ReadAheadCache readAheadCache = manager.getReadAheadCache(); // load any preloaded fields into the context if(readAheadCache.load(ctx)) { if(requiredField == null || (requiredField != null && requiredField.isLoaded(ctx))) { return true; } } // get the finder results associated with this context, if it exists ReadAheadCache.EntityReadAheadInfo info = readAheadCache.getEntityReadAheadInfo(id); // determine the fields to load JDBCEntityBridge.FieldIterator loadIter = entity.getLoadIterator(requiredField, info.getReadAhead(), ctx); if(!loadIter.hasNext()) return true; // get the keys to load List loadKeys = info.getLoadKeys(); // generate the sql String sql = (rowLockingTemplate != null ? getRawLockingSQL(loadIter, loadKeys.size()) : getSQL(loadIter, loadKeys.size())); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { // create the statement if (log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql); // Set the fetch size of the statement if (entity.getFetchSize() > 0) { ps.setFetchSize(entity.getFetchSize()); } // set the parameters int paramIndex = 1; for (int i = 0; i < loadKeys.size(); i++) { paramIndex = entity.setPrimaryKeyParameters(ps, paramIndex, loadKeys.get(i)); } // execute statement rs = ps.executeQuery(); // load results boolean mainEntityLoaded = false; Object[] ref = new Object[1]; while (rs.next()) { // reset the column index for this row int index = 1; // ref must be reset to null before load ref[0] = null; // if we are loading more then one entity, load the pk from the row Object pk = null; if (loadKeys.size() > 1) { // load the pk index = entity.loadPrimaryKeyResults(rs, index, ref); pk = ref[0]; } // is this the main entity or a preload entity if (loadKeys.size() == 1 || pk.equals(id)) { // main entity; load the values into the context loadIter.reset(); while(loadIter.hasNext()) { JDBCCMPFieldBridge field = loadIter.next(); index = field.loadInstanceResults(rs, index, ctx); field.setClean(ctx); } mainEntityLoaded = true; } else { // preload entity; load the values into the read ahead cahce loadIter.reset(); while(loadIter.hasNext()) { JDBCCMPFieldBridge field = loadIter.next(); // ref must be reset to null before load ref[0] = null; // load the result of the field index = field.loadArgumentResults(rs, index, ref); // cache the field value readAheadCache.addPreloadData(pk, field, ref[0]); } } } // clear LOAD_REQUIRED flag loadIter.removeAll(); // did we load the main results if (!mainEntityLoaded) { if (failIfNotFound) throw new NoSuchEntityException("Entity not found: primaryKey=" + ctx.getId()); else return false; } else return true; } catch (EJBException e) { throw e; } catch (Exception e) { throw new EJBException("Load failed", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
public JDBCTypeComplexProperty getProperty(String propertyName) { JDBCTypeComplexProperty prop = (JDBCTypeComplexProperty)propertiesByName.get(propertyName); if(prop == null) { throw new EJBException(fieldType.getName() + " does not have a property named " + propertyName); } return prop; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
private static Object getColumnValue(JDBCTypeComplexProperty property, Object value) { try { return property.getColumnValue(value); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error getting column value", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
private Object setColumnValue( JDBCTypeComplexProperty property, Object value, Object columnValue) { if(value==null && columnValue==null) { // nothing to do return null; } try { if(value == null) { value = fieldType.newInstance(); } return property.setColumnValue(value, columnValue); } catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/RelationData.java
private RelationPair createRelationPair(JDBCCMRFieldBridge leftCMRField, Object leftId, JDBCCMRFieldBridge rightCMRField, Object rightId) { if(this.leftCMRField == leftCMRField && this.rightCMRField == rightCMRField) { return new RelationPair(leftCMRField, leftId, rightCMRField, rightId); } if(this.leftCMRField == rightCMRField && this.rightCMRField == leftCMRField) { return new RelationPair(rightCMRField, rightId, leftCMRField, leftId); } throw new EJBException("Error: cmrFields are of wrong type"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public Object createPrimaryKeyInstance() { if(primaryKeyFieldName == null) { try { return primaryKeyClass.newInstance(); } catch(Exception e) { throw new EJBException("Error creating primary key instance: ", e); } } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public Object extractPrimaryKeyFromInstance(EntityEnterpriseContext ctx) { try { Object pk = null; for(int i = 0; i < primaryKeyFields.length; ++i) { JDBCCMPFieldBridge pkField = primaryKeyFields[i]; Object fieldValue = pkField.getInstanceValue(ctx); // updated pk object with return form set primary key value to // handle single valued non-composit pks and more complicated behivors. pk = pkField.setPrimaryKeyValue(pk, fieldValue); } return pk; } catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error extracting primary key from " + "instance", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP2xFieldBridge.java
private FieldState getLoadedState(EntityEnterpriseContext ctx) { FieldState fieldState = getFieldState(ctx); if(!fieldState.isLoaded()) { manager.loadField(this, ctx); if(!fieldState.isLoaded()) throw new EJBException("Could not load field value: " + getFieldName()); } return fieldState; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMR field cannot be set " + "in ejbCreate; this should be done in the ejbPostCreate " + "method instead [EJB 2.0 Spec. 10.5.2]."); } if(isCollectionValued() && value == null) { throw new IllegalArgumentException("null cannot be assigned to a " + "collection-valued cmr-field [EJB 2.0 Spec. 10.3.8]."); } /* if(allFKFieldsMappedToPKFields) { throw new IllegalStateException( "Can't modify relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]."); } */ setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Object getInstanceValue(EntityEnterpriseContext myCtx) { load(myCtx); FieldState fieldState = getFieldState(myCtx); if(isCollectionValued()) { return fieldState.getRelationSet(); } // only return one try { List value = fieldState.getValue(); if(!value.isEmpty()) { Object fk = value.get(0); return getRelatedEntityByFK(fk); } else if(foreignKeyFields != null) { // for those completely mapped to CMP fields and created in this current tx !!! Object relatedId = getRelatedIdFromContext(myCtx); if(relatedId != null) { return getRelatedEntityByFK(relatedId); } } return null; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException(e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setInstanceValue(EntityEnterpriseContext myCtx, Object newValue) { // validate new value first List newPks; if(newValue instanceof Collection) { Collection col = (Collection) newValue; if(!col.isEmpty()) { newPks = new ArrayList(col.size()); for(Iterator iter = col.iterator(); iter.hasNext();) { Object localObject = iter.next(); if(localObject != null) { Object relatedId = getRelatedPrimaryKey(localObject); // check whether new value modifies the primary key if there are FK fields mapped to PK fields if(relatedPKFieldsByMyPKFields.size() > 0) { checkSetForeignKey(myCtx, relatedId); } newPks.add(relatedId); } } } else { newPks = Collections.EMPTY_LIST; } } else { if(newValue != null) { newPks = Collections.singletonList(getRelatedPrimaryKey(newValue)); } else { newPks = Collections.EMPTY_LIST; } } // load the current value load(myCtx); FieldState fieldState = getFieldState(myCtx); // is this just setting our own relation set back if(newValue == fieldState.getRelationSet()) { return; } try { // Remove old value(s) List value = fieldState.getValue(); if(!value.isEmpty()) { Object[] curPks = value.toArray(new Object[value.size()]); for(int i = 0; i < curPks.length; ++i) { destroyRelationLinks(myCtx, curPks[i]); } } // Add new value(s) for(int i = 0; i < newPks.size(); ++i) { createRelationLinks(myCtx, newPks.get(i)); } } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new EJBException(e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void createRelationLinks(EntityEnterpriseContext myCtx, Object relatedId, boolean updateForeignKey) { if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } // If my multiplicity is one, then we need to free the new related context // from its old relationship. Transaction tx = getTransaction(); if(metadata.isMultiplicityOne()) { Object oldRelatedId = relatedCMRField.invokeGetRelatedId(tx, relatedId); if(oldRelatedId != null) { invokeRemoveRelation(tx, oldRelatedId, relatedId); relatedCMRField.invokeRemoveRelation(tx, relatedId, oldRelatedId); } } addRelation(myCtx, relatedId, updateForeignKey); relatedCMRField.invokeAddRelation(tx, relatedId, myCtx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void destroyRelationLinks(EntityEnterpriseContext myCtx, Object relatedId, boolean updateValueCollection, boolean updateForeignKey) { if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } removeRelation(myCtx, relatedId, updateValueCollection, updateForeignKey); relatedCMRField.invokeRemoveRelation(getTransaction(), relatedId, myCtx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Object invokeScheduleForCascadeDelete(Transaction tx, Object myId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.SCHEDULE_FOR_CASCADE_DELETE); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); return manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Object invokeScheduleForBatchCascadeDelete(Transaction tx, Object myId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.SCHEDULE_FOR_BATCH_CASCADE_DELETE); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); return manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Object invokeGetRelatedId(Transaction tx, Object myId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.GET_RELATED_ID); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); return manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in getRelatedId", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void invokeAddRelation(Transaction tx, Object myId, Object relatedId) { try { SecurityContext sc = SecurityActions.getSecurityContext(); EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.ADD_RELATION); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in addRelation", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void invokeRemoveRelation(Transaction tx, Object myId, Object relatedId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.REMOVE_RELATION); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in removeRelation", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Object getRelatedId(EntityEnterpriseContext myCtx) { if(isCollectionValued()) { throw new EJBException("getRelatedId may only be called on a cmr-field with a multiplicity of one."); } load(myCtx); List value = getFieldState(myCtx).getValue(); return value.isEmpty() ? null : value.get(0); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void addRelation(EntityEnterpriseContext myCtx, Object fk, boolean updateForeignKey) { checkSetForeignKey(myCtx, fk); if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(myCtx)) { throw new IllegalStateException("A CMR field cannot be set or added " + "to a relationship in ejbCreate; this should be done in the " + "ejbPostCreate method instead [EJB 2.0 Spec. 10.5.2]."); } // add to current related set FieldState myState = getFieldState(myCtx); myState.addRelation(fk); // set the foreign key, if we have one. if(hasForeignKey() && updateForeignKey) { setForeignKey(myCtx, fk); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void removeRelation(EntityEnterpriseContext myCtx, Object fk, boolean updateValueCollection, boolean updateForeignKey) { if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } // remove from current related set if(updateValueCollection) { FieldState myState = getFieldState(myCtx); myState.removeRelation(fk); } // set the foreign key to null, if we have one. if(hasForeignKey() && updateForeignKey) { setForeignKey(myCtx, null); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void load(EntityEnterpriseContext myCtx, Collection values) { // did we get more then one value for a single valued field if(isSingleValued() && values.size() > 1) { throw new EJBException("Data contains multiple values, but this cmr field is single valued: " + values); } // add the new values FieldState fieldState = getFieldState(myCtx); fieldState.loadRelations(values); // set the foreign key, if we have one. if(hasForeignKey()) { // update the states and locked values of FK fields if(!values.isEmpty()) { Object loadedValue = values.iterator().next(); for(int i = 0; i < foreignKeyFields.length; ++i) { JDBCCMP2xFieldBridge fkField = foreignKeyFields[i]; Object fieldValue = fkField.getPrimaryKeyValue(loadedValue); fkField.updateState(myCtx, fieldValue); } } // set the real FK value List realValue = fieldState.getValue(); Object fk = realValue.isEmpty() ? null : realValue.get(0); setForeignKey(myCtx, fk); } JDBCEntityBridge.setCreated(myCtx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setForeignKey(EntityEnterpriseContext myCtx, Object fk) { if(!hasForeignKey()) { throw new EJBException(getFieldName() + " CMR field does not have a foreign key to set."); } for(int i = 0; i < foreignKeyFields.length; ++i) { JDBCCMP2xFieldBridge fkField = foreignKeyFields[i]; Object fieldValue = fkField.getPrimaryKeyValue(fk); fkField.setInstanceValue(myCtx, fieldValue); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] fkRef) { if(foreignKeyFields == null) { return parameterIndex; } boolean fkIsNull = false; // value of this field, will be filled in below Object[] argumentRef = new Object[1]; for(int i = 0; i < foreignKeyFields.length; ++i) { JDBCCMPFieldBridge field = foreignKeyFields[i]; parameterIndex = field.loadArgumentResults(rs, parameterIndex, argumentRef); if(fkIsNull) { continue; } if(field.getPrimaryKeyField() != null) { // if there is a null field among FK fields, the whole FK field is considered null. // NOTE: don't throw exception in this case, it's ok if FK is partly mapped to a PK // NOTE2: we still need to iterate through foreign key fields and 'load' them to // return correct parameterIndex. if(argumentRef[0] == null) { fkRef[0] = null; fkIsNull = true; } else { // if we don't have a pk object yet create one if(fkRef[0] == null) { fkRef[0] = relatedEntity.createPrimaryKeyInstance(); } try { // Set this field's value into the primary key object. field.getPrimaryKeyField().set(fkRef[0], argumentRef[0]); } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); } } } else { // This field is the primary key, so no extraction is necessary. fkRef[0] = argumentRef[0]; } } return parameterIndex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Transaction getTransaction() { try { EntityContainer container = getJDBCStoreManager().getContainer(); TransactionManager tm = container.getTransactionManager(); return tm.getTransaction(); } catch(SystemException e) { throw new EJBException("Error getting transaction from the transaction manager", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public List getValue() { if(!isLoaded) { throw new EJBException("CMR field value not loaded yet"); } return Collections.unmodifiableList(setHandle[0]); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void loadRelations(Collection values) { // check if we are aleready loaded if(isLoaded) { throw new EJBException("CMR field value is already loaded"); } // just in the case where there are lingering values setHandle[0].clear(); // add the new values setHandle[0].addAll(values); if(removedRelations != null) { // remove the already removed values setHandle[0].removeAll(removedRelations); removedRelations = null; } if(addedRelations != null) { // add the already added values // but remove FKs we are going to add to avoid duplication setHandle[0].removeAll(addedRelations); setHandle[0].addAll(addedRelations); addedRelations = null; } // mark the field loaded isLoaded = true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Set getRelationSet() { if(!isLoaded) { throw new EJBException("CMR field value not loaded yet"); } if(ctx.isReadOnly()) { // we are in a read-only invocation, so return a snapshot set return new RelationSet(JDBCCMRFieldBridge.this, ctx, new List[]{new ArrayList(setHandle[0])}, true); } // if we already have a relationset use it if(relationSet != null) { return relationSet; } // construct a new relationshet try { // get the curent transaction EntityContainer container = getJDBCStoreManager().getContainer(); TransactionManager tm = container.getTransactionManager(); Transaction tx = tm.getTransaction(); // if whe have a valid transaction... if(tx != null && (tx.getStatus() == Status.STATUS_ACTIVE || tx.getStatus() == Status.STATUS_PREPARING)) { // crete the relation set and register for a tx callback relationSet = new RelationSet(JDBCCMRFieldBridge.this, ctx, setHandle, false); TxSynchronization sync = new TxSynchronization(FieldState.this); tx.registerSynchronization(sync); } else { // if there is no transaction create a pre-failed list relationSet = new RelationSet(JDBCCMRFieldBridge.this, ctx, new List[1], false); } return relationSet; } catch(SystemException e) { throw new EJBException("Error while creating RelationSet", e); } catch(RollbackException e) { throw new EJBException("Error while creating RelationSet", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
public Object getInstanceValue(EntityEnterpriseContext ctx) { FieldState fieldState = getFieldState(ctx); if(!fieldState.isLoaded()) { throw new EJBException("CMP 1.1 field not loaded: " + getFieldName()); } try { return field.get(ctx.getInstance()); } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
public void setInstanceValue(EntityEnterpriseContext ctx, Object value) { try { field.set(ctx.getInstance(), value); FieldState fieldState = getFieldState(ctx); fieldState.setLoaded(); fieldState.setCheckDirty(); } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean add(Object o) { if(o == null) { throw new IllegalArgumentException("Null cannot be added to a CMR " + "relationship collection"); } checkForPKChange(); List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } if(!relatedLocalInterface.isInstance(o)) { String msg = "Object must be an instance of " + relatedLocalInterface.getName() + ", but is an isntance of ["; Class[] classes = o.getClass().getInterfaces(); for(int i = 0; i < classes.length; i++) { if(i > 0) msg += ", "; msg += classes[i].getName(); } msg += "]"; throw new IllegalArgumentException(msg); } Object id = getPrimaryKey((EJBLocalObject) o); if(idList.contains(id)) { return false; } cmrField.createRelationLinks(ctx, id); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean addAll(Collection c) { if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } if(c == null) { return false; } boolean isModified = false; Iterator iterator = (new HashSet(c)).iterator(); while(iterator.hasNext()) { isModified = add(iterator.next()) || isModified; } return isModified; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean remove(Object o) { List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); if(!relatedLocalInterface.isInstance(o)) { throw new IllegalArgumentException("Object must be an instance of " + relatedLocalInterface.getName()); } Object id = getPrimaryKey((EJBLocalObject) o); if(!idList.contains(id)) { return false; } cmrField.destroyRelationLinks(ctx, id); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean removeAll(Collection c) { if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } if(c == null) { return false; } boolean isModified = false; Iterator iterator = (new HashSet(c)).iterator(); while(iterator.hasNext()) { isModified = remove(iterator.next()) || isModified; } return isModified; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public void clear() { checkForPKChange(); List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } Iterator iterator = (new ArrayList(idList)).iterator(); while(iterator.hasNext()) { cmrField.destroyRelationLinks(ctx, iterator.next()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean retainAll(Collection c) { List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); if(c == null) { if(idList.size() == 0) { return false; } clear(); return true; } // get a set of the argument collection's ids List argIds = new ArrayList(); Iterator iterator = c.iterator(); while(iterator.hasNext()) { EJBLocalObject localObject = (EJBLocalObject) iterator.next(); Object relatedId = getPrimaryKey(localObject); argIds.add(relatedId); } boolean isModified = false; iterator = (new ArrayList(idList)).iterator(); while(iterator.hasNext()) { Object id = iterator.next(); if(!argIds.contains(id)) { cmrField.destroyRelationLinks(ctx, id); isModified = true; } } return isModified; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public void remove() { verifyIteratorIsValid(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); try { idIterator.remove(); cmrField.destroyRelationLinks(ctx, currentId, false); } catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + fieldName); } if(primaryKeyMember && JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMP field that is a member " + "of the primary key can only be set in ejbCreate " + "[EJB 2.0 Spec. 10.3.5]."); } if(ctx.isValid()) { if(!isLoaded(ctx)) { // the field must be loaded for dirty cheking to work properly manager.loadField(this, ctx); } lockingStrategy.changed(this, ctx); } setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public Object getPrimaryKeyValue(Object primaryKey) throws IllegalArgumentException { try { if(primaryKeyField != null) { if(primaryKey == null) { return null; } // Extract this field's value from the primary key. return primaryKeyField.get(primaryKey); } else { // This field is the primary key, so no extraction is necessary. return primaryKey; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public Object setPrimaryKeyValue(Object primaryKey, Object value) throws IllegalArgumentException { try { if(primaryKeyField != null) { // if we are tring to set a null value // into a null pk, we are already done. if(value == null && primaryKey == null) { return null; } // if we don't have a pk object yet create one if(primaryKey == null) { primaryKey = primaryKeyClass.newInstance(); } // Set this field's value into the primary key object. primaryKeyField.set(primaryKey, value); return primaryKey; } else { // This field is the primary key, so no extraction is necessary. return value; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int setArgumentParameters(PreparedStatement ps, int parameterIndex, Object arg) { try { int[] jdbcTypes = jdbcType.getJDBCTypes(); for(int i = 0; i < jdbcTypes.length; i++) { Object columnValue = jdbcType.getColumnValue(i, arg); jdbcType.getParameterSetter()[i].set(ps, parameterIndex++, jdbcTypes[i], columnValue, log); //JDBCUtil.setParameter(log, ps, parameterIndex++, jdbcTypes[i], columnValue); } return parameterIndex; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int loadInstanceResults(ResultSet rs, int parameterIndex, EntityEnterpriseContext ctx) { try { // value of this field, will be filled in below Object[] argumentRef = new Object[1]; // load the cmp field value from the result set parameterIndex = loadArgumentResults(rs, parameterIndex, argumentRef); // set the value into the context setInstanceValue(ctx, argumentRef[0]); lockingStrategy.loaded(this, ctx); return parameterIndex; } catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
private int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef, boolean nullColumnNullifiesResult) throws IllegalArgumentException { try { // value of this field, will be filled in below // set the value of this field into the pk argumentRef[0] = null; // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); for(int i = 0; i < javaTypes.length; i++) { Object columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); if(nullColumnNullifiesResult && columnValue == null) { argumentRef[0] = null; parameterIndex += javaTypes.length - i - 1; break; } argumentRef[0] = jdbcType.setColumnValue(i, argumentRef[0], columnValue); } // retrun the updated parameterIndex return parameterIndex; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object execute(Object[] args) throws FinderException { Collection retVal; Method method = getMethod(); try { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(method); EntityContainer selectedContainer = query.getSelectManager().getContainer(); GenericEntityObjectFactory factory; if(queryMetaData.isResultTypeMappingLocal() && selectedContainer.getLocalHomeClass() != null) { factory = selectedContainer.getLocalProxyFactory(); } else { factory = selectedContainer.getProxyFactory(); } retVal = query.execute(method, args, null, factory); } catch(FinderException e) { throw e; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); } if(!Collection.class.isAssignableFrom(getReturnType())) { // single object if(retVal.size() == 0) { throw new ObjectNotFoundException(); } if(retVal.size() > 1) { throw new FinderException(getSelectorName() + " returned " + retVal.size() + " objects"); } Object o = retVal.iterator().next(); if(o == null && method.getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + method.getReturnType().getName() ); } return o; } else { // collection or set if(Set.class.isAssignableFrom(getReturnType())) { return new HashSet(retVal); } else { return retVal; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
public Collection execute(JDBCCMRFieldBridge cmrField, Object pk) { JDBCCMRFieldBridge relatedCMRField = (JDBCCMRFieldBridge) cmrField.getRelatedCMRField(); // get the read ahead cahces ReadAheadCache readAheadCache = manager.getReadAheadCache(); ReadAheadCache relatedReadAheadCache = cmrField.getRelatedManager().getReadAheadCache(); // get the finder results associated with this context, if it exists ReadAheadCache.EntityReadAheadInfo info = readAheadCache.getEntityReadAheadInfo(pk); List loadKeys = info.getLoadKeys(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { // generate the sql boolean[] preloadMask = getPreloadMask(cmrField); String sql = getSQL(cmrField, preloadMask, loadKeys.size()); // create the statement if(log.isDebugEnabled()) log.debug("load relation SQL: " + sql); // get the connection con = cmrField.getDataSource().getConnection(); ps = con.prepareStatement(sql.toString()); // Set the fetch size of the statement if(entity.getFetchSize() > 0) { ps.setFetchSize(entity.getFetchSize()); } // get the load fields JDBCCMPFieldBridge[] myKeyFields = getMyKeyFields(cmrField); JDBCCMPFieldBridge[] relatedKeyFields = getRelatedKeyFields(cmrField); // set the parameters int paramIndex = 1; for(int i = 0; i < loadKeys.size(); i++) { Object key = loadKeys.get(i); for(int j = 0; j < myKeyFields.length; ++j) paramIndex = myKeyFields[j].setPrimaryKeyParameters(ps, paramIndex, key); } // execute statement rs = ps.executeQuery(); // initialize the results map Map resultsMap = new HashMap(loadKeys.size()); for(int i = 0; i < loadKeys.size(); ++i) { resultsMap.put(loadKeys.get(i), new ArrayList()); } // load the results Object[] ref = new Object[1]; while(rs.next()) { // reset the column index for this row int index = 1; // ref must be reset to null before each load ref[0] = null; // if we are loading more then one entity, load the pk from the row Object loadedPk = pk; if(loadKeys.size() > 1) { // load the pk for(int i = 0; i < myKeyFields.length; ++i) { index = myKeyFields[i].loadPrimaryKeyResults(rs, index, ref); if(ref[0] == null) { break; } } loadedPk = ref[0]; } // load the fk ref[0] = null; for(int i = 0; i < relatedKeyFields.length; ++i) { index = relatedKeyFields[i].loadPrimaryKeyResults(rs, index, ref); if(ref[0] == null) { break; } } Object loadedFk = ref[0]; if(loadedFk != null) { // add this value to the list for loadedPk List results = (List)resultsMap.get(loadedPk); results.add(loadedFk); // if the related cmr field is single valued we can pre-load // the reverse relationship if(relatedCMRField.isSingleValued()) { relatedReadAheadCache.addPreloadData( loadedFk, relatedCMRField, Collections.singletonList(loadedPk)); } // read the preload fields if(preloadMask != null) { JDBCFieldBridge[] relatedFields = cmrField.getRelatedJDBCEntity().getTableFields(); for(int i = 0; i < relatedFields.length; ++i) { if(preloadMask[i]) { JDBCFieldBridge field = relatedFields[i]; ref[0] = null; // read the value and store it in the readahead cache index = field.loadArgumentResults(rs, index, ref); relatedReadAheadCache.addPreloadData(loadedFk, field, ref[0]); } } } } } // set all of the preloaded values JDBCReadAheadMetaData readAhead = relatedCMRField.getReadAhead(); for(Iterator iter = resultsMap.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); // get the results for this key List results = (List)resultsMap.get(key); // store the results list for readahead on-load relatedReadAheadCache.addFinderResults(results, readAhead); // store the preloaded relationship (unless this is the realts we // are actually after) if(!key.equals(pk)) { readAheadCache.addPreloadData(key, cmrField, results); } } // success, return the results return (List)resultsMap.get(pk); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Load relation failed", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
protected int executeInsert(int index, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { ps.execute(); ResultSet rs = null; try { int rows = ps.getUpdateCount(); if(rows != 1) { throw new EJBException("Expected updateCount of 1, got " + rows); } if(ps.getMoreResults() == false) { throw new EJBException("Expected ResultSet but got an updateCount. Is NOCOUNT set for all triggers?"); } rs = ps.getResultSet(); if(!rs.next()) { throw new EJBException("ResultSet was empty"); } pkField.loadInstanceResults(rs, 1, ctx); return rows; } catch(RuntimeException e) { throw e; } catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); // remove any JCA wrappers Statement stmt = ps; do { try { Object[] args = {}; stmt = (Statement) getUnderlyingStatement.invoke(stmt, args); } catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } } while (stmt != null && method.getDeclaringClass().isInstance(stmt) == false); try { Number pk = (Number)method.invoke(stmt, null); pkField.setInstanceValue(ctx, pk); return rows; } catch(RuntimeException e) { throw e; } catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); ResultSet rs = null; try { rs = (ResultSet) GET_GENERATED_KEYS.invoke(ps, null); if (!rs.next()) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("getGeneratedKeys returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); // remove any JCA wrappers Statement stmt = ps; do { try { Object[] args = {}; stmt = (Statement) getUnderlyingStatement.invoke(stmt, args); } catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } } while (stmt != null && method.getDeclaringClass().isInstance(stmt) == false); ResultSet rs = null; try { rs = (ResultSet) method.invoke(stmt, null); if (!rs.next()) { throw new EJBException("getGeneratedKeys returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx ) throws SQLException { int rows = ps.executeUpdate(); ResultSet results = null; try { Connection conn = ps.getConnection(); results = conn.prepareStatement( SQL ).executeQuery(); if( !results.next() ) { throw new EJBException( "identity_val_local() returned an empty ResultSet" ); } pkField.loadInstanceResults( results, 1, ctx ); } catch( RuntimeException e ) { throw e; } catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); } finally { JDBCUtil.safeClose( results ); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
protected int executeInsert(int index, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); Statement s = null; ResultSet rs = null; try { if (trace) { log.trace("Executing SQL :"+sequenceSQL); } Connection c = ps.getConnection(); s = c.createStatement(); rs = s.executeQuery(sequenceSQL); if (!rs.next()) { throw new EJBException("sequence sql returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
public EnterpriseContext get() throws Exception { boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Get instance "+this+"#"+pool.size()+"#"+getContainer().getBeanClass()); if( strictMaxSize != null ) { // Block until an instance is available boolean acquired = strictMaxSize.attempt(strictTimeout); if( trace ) log.trace("Acquired("+acquired+") strictMaxSize semaphore, remaining="+strictMaxSize.permits()); if( acquired == false ) throw new EJBException("Failed to acquire the pool semaphore, strictTimeout="+strictTimeout); } synchronized (pool) { if ( pool.isEmpty() == false ) { return (EnterpriseContext) pool.removeFirst(); } } // Pool is empty, create an instance try { Object instance = container.createBeanClassInstance(); return create(instance); } catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // The key Object key = mi.getId(); EntityEnterpriseContext ctx = null; EntityContainer ec = (EntityContainer) container; if (mi.getTransaction() != null) { //ctx = ec.getTxEntityMap().getCtx(mi.getTransaction(), key); } if (ctx == null) { InstancePool pool = ec.getInstancePool(); try { ctx = (EntityEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } ctx.setCacheKey(key); ctx.setId(key); EntityPersistenceManager pm = ec.getPersistenceManager(); pm.activateEntity(ctx); } boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Begin invoke, key="+key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); try { Object ret = getNext().invoke(mi); return ret; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenTxInterceptorBMT.java
public Object invokeHome(Invocation mi) { throw new EJBException("No home methods for message beans."); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
protected void register(EnterpriseContext ctx, Transaction tx, BeanLock lock) { // Create a new synchronization InstanceSynchronization synch = new InstanceSynchronization(ctx, lock); try { // OSH: An extra check to avoid warning. // Can go when we are sure that we no longer get // the JTA violation warning. if (TxUtils.isRollback(tx.getStatus())) { return; } // We want to be notified when the transaction commits try { tx.registerSynchronization(synch); } catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; } // EJB 1.1, 6.5.3 synch.afterBegin(); } catch (RollbackException e) { } catch (Exception e) { throw new EJBException(e); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { InstanceCache cache = container.getInstanceCache(); InstancePool pool = container.getInstancePool(); Object methodID = mi.getId(); EnterpriseContext ctx = null; BeanLock lock = container.getLockManager().getLock(methodID); boolean callerRunAsIdentityPresent = SecurityActions.peekRunAsIdentity() != null; boolean pushSecurityContext = SecurityActions.getSecurityContext() == null; try { /* The security context must be established before the cache lookup because the activation of a session should have the caller's security context as ejbActivate is allowed to call other secured resources. Since the pm makes the ejbActivate call, we need to set the caller's security context. The only reason this shows up for stateful session is that we moved the SecurityInterceptor to after the instance interceptor to allow security exceptions to result in invalidation of the session. This may be too literal an interpretation of the ejb spec requirement that runtime exceptions should invalidate the session. */ if(!callerRunAsIdentityPresent && pushSecurityContext) { AuthenticationManager am = container.getSecurityManager(); String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(am != null) securityDomain = am.getSecurityDomain(); SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain , null); //SecurityActions.pushSubjectContext(mi.getPrincipal(), mi.getCredential(), null); } lock.sync(); try { // Get context try { ctx = cache.get(methodID); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } // Associate it with the method invocation mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // BMT beans will lock and replace tx no matter what, CMT do work on transaction boolean isBMT = ((SessionMetaData)container.getBeanMetaData()).isBeanManagedTx(); if (isBMT == false) { // Do we have a running transaction with the context if (ctx.getTransaction() != null && // And are we trying to enter with another transaction !ctx.getTransaction().equals(mi.getTransaction())) { // Calls must be in the same transaction StringBuffer msg = new StringBuffer("Application Error: " + "tried to enter Stateful bean with different tx context"); msg.append(", contextTx: " + ctx.getTransaction()); msg.append(", methodTx: " + mi.getTransaction()); throw new EJBException(msg.toString()); } //If the instance will participate in a new transaction we register a sync for it if (ctx.getTransaction() == null && mi.getTransaction() != null) { register(ctx, mi.getTransaction(), lock); } } if (!ctx.isLocked()) { //take it! ctx.lock(); } else { if (!isCallAllowed(mi)) { // Concurent calls are not allowed throw new EJBException("Application Error: no concurrent " + "calls on stateful beans"); } else { ctx.lock(); } } } finally { lock.releaseSync(); } // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); boolean validContext = true; try { // Invoke through interceptors Object ret = getNext().invoke(mi); return ret; } catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } } } finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
protected void setProxyFactory(String invokerBinding, Invocation mi) throws Exception { // if (BeanMetaData.LOCAL_INVOKER_PROXY_BINDING.equals(invokerBinding)) return; if (invokerBinding == null) { log.trace("invokerBInding is null in ProxyFactoryFinder"); return; } /* if (invokerBinding == null) { log.error("***************** invokerBinding is null ********"); log.error("Method name: " + mi.getMethod().getName()); log.error("jmx name: " + container.getJmxName().toString()); new Throwable().printStackTrace(); log.error("*************************"); throw new EJBException("Couldn't insert proxy factory, " + "invokerBinding was null"); } */ Object proxyFactory = container.lookupProxyFactory(invokerBinding); if (proxyFactory == null) { String methodName; if(mi.getMethod() != null) { methodName = mi.getMethod().getName(); } else { methodName ="<no method>"; } log.error("***************** proxyFactory is null ********"); log.error("Method name: " + methodName); log.error("jmx name: " + container.getJmxName().toString()); log.error("invokerBinding: " + invokerBinding); log.error("Stack trace", new Throwable()); log.error("*************************"); throw new EJBException("Couldn't find proxy factory"); } container.setProxyFactory(proxyFactory); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { EntityContainer container = (EntityContainer)instance.getContainer(); if(container.getPersistenceManager().isStoreRequired(instance)) { throw new EJBException("The instance of " + container.getBeanMetaData().getEjbName() + " with pk=" + instance.getId() + " was not stored to prevent potential inconsistency of data in the database:" + " the instance was evicted from the cache during the transaction" + " and the database was possibly updated by another process."); } }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize() { if(synchronizing || instances.isEmpty()) { return; } synchronizing = true; // This is an independent point of entry. We need to make sure the // thread is associated with the right context class loader Thread currentThread = Thread.currentThread(); ClassLoader oldCl = SecurityActions.getContextClassLoader(); EntityEnterpriseContext instance = null; try { for(int i = 0; i < instances.size(); i++) { // any one can mark the tx rollback at any time so check // before continuing to the next store if(TxUtils.isRollback(tx)) { return; } instance = (EntityEnterpriseContext) instances.get(i); instance.getTxAssociation().invokeEjbStore(currentThread, instance); } for(int i = 0; i < instances.size(); i++) { // any one can mark the tx rollback at any time so check // before continuing to the next store if(TxUtils.isRollback(tx)) { return; } // read-only instances will never get into this list. instance = (EntityEnterpriseContext) instances.get(i); instance.getTxAssociation().synchronize(currentThread, tx, instance); } } catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); } finally { SecurityActions.setContextClassLoader(oldCl); synchronizing = false; } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke and handle exceptions Method miMethod = mi.getMethod(); Method m = (Method) homeMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } if (m.getDeclaringClass().equals(EntityContainer.class)) { try { return mi.performCall(EntityContainer.this, m, new Object[] { mi }); } catch (Exception e) { rethrow(e); } } else // Home method { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); try { AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_EJB_HOME); return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } finally{ AllowedOperationsAssociation.popInMethodFlag(); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) beanMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(EntityContainer.class)) { // Invoke container try { return mi.performCall(EntityContainer.this, m, new Object[]{ mi }); } catch (Exception e) { rethrow(e); } } else { // Invoke bean instance try { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); Object instance = ctx.getInstance(); return mi.performCall(instance, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
public EJBHome getEJBHome() { try { return homeHandle.getEJBHome(); } catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); } }
113
              
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { throw new EJBException("Failed to create timer", e); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
catch (InvocationTargetException e) { Throwable ex = e.getTargetException(); if (ex instanceof EJBException) throw (Exception)ex; else if (ex instanceof RuntimeException) throw new EJBException((Exception)ex); // Transform runtime exception into what a bean *should* have thrown else if (ex instanceof Exception) throw (Exception)ex; else throw (Error)ex; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { throw new EJBException("Could not create timer service", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException (e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeRemoveRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeAddRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(Exception e) { throw new EJBException("Internal error extracting primary key from instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(Exception e) { throw new EJBException("Internal error", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NamingException e) { throw new EJBException("Data source for relationship named " + relationName + " not found " + dataSourceName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(SQLException e) { throw new EJBException("Failed to read ResultSet.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { throw new EJBException("Failed to obtain current transaction", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(Exception e) { throw new EJBException("Error getting application tx data map.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { throw new EJBException("Error getting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { throw new EJBException("Error creating primary key instance: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error extracting primary key from " + "instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in getRelatedId", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in addRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in removeRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error getting transaction from the transaction manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error while creating RelationSet", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RollbackException e) { throw new EJBException("Error while creating RelationSet", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(Exception e) { throw new EJBException("Load relation failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); }
57
              
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (duration < 0) throw new IllegalArgumentException("duration is negative"); return createTimer(new Date(System.currentTimeMillis() + duration), 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialDuration < 0) throw new IllegalArgumentException("initial duration is negative"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); return createTimer(new Date(System.currentTimeMillis() + initialDuration), intervalDuration, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (expiration == null) throw new IllegalArgumentException("expiration is null"); return createTimer(expiration, 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Collection getTimers() throws IllegalStateException, EJBException { ArrayList activeTimers = new ArrayList(); synchronized (timers) { Iterator it = timers.values().iterator(); while (it.hasNext()) { TimerImpl timer = (TimerImpl)it.next(); if (timer.isActive()) activeTimers.add(timer); } } return activeTimers; }
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
public Timer getTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { EJBTimerService ejbTimerService = EJBTimerServiceLocator.getEjbTimerService(); ObjectName containerId = timedObjectId.getContainerId(); Object instancePk = timedObjectId.getInstancePk(); TimerServiceImpl timerService = (TimerServiceImpl)ejbTimerService.getTimerService(containerId, instancePk); if (timerService == null) throw new NoSuchObjectLocalException("TimerService not available: " + timedObjectId); TimerImpl timer = (TimerImpl)timerService.getTimer(this); if (timer == null || timer.isActive() == false) throw new NoSuchObjectLocalException("Timer not available: " + timedObjectId); return timer; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public void cancel() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.cancel"); registerTimerWithTx(); cancelInTx(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public long getTimeRemaining() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getTimeRemaining"); return nextExpire - System.currentTimeMillis(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Date getNextTimeout() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getNextTimeout"); return new Date(nextExpire); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Serializable getInfo() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getInfo"); return info; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public TimerHandle getHandle() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getHandle"); return new TimerHandleImpl(this); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { return Collections.EMPTY_LIST; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
(Lib) IllegalArgumentException 142
              
// in src/main/java/org/jboss/invocation/Invocation.java
public void setValue(Object key, Object value, PayloadKey type) { if(type == PayloadKey.TRANSIENT) { getTransientPayload().put(key,value); } else if(type == PayloadKey.AS_IS) { getAsIsPayload().put(key,value); } else if(type == PayloadKey.PAYLOAD) { getPayload().put(key,value); } else { throw new IllegalArgumentException("Unknown PayloadKey: " + type); } }
// in src/main/java/org/jboss/client/AppClientMain.java
public static void main(String[] args) throws Exception { log.debug("System Properties"); Properties sysprops = System.getProperties(); for (Object key : sysprops.keySet()) log.debug(" " + key + "=" + sysprops.getProperty((String) key)); // read the client class from args String clientClass = null; String clientName = null; ArrayList<String> newArgs = new ArrayList<String>(); String[] launchers = DEFAULT_LAUNCHERS; for (int i = 0; i < args.length; i++) { String arg = args[i]; log.debug("arg=" + arg); if( arg.equals(JBOSS_CLIENT_PARAM) ) { clientClass = args[i+1]; i ++; } else if( arg.equals(J2EE_CLIENT_PARAM) ) { /* Set the j2ee.client system property so the AppContextFactory sees what name the client app JNDI enc is bound under */ clientName = args[i+1]; System.setProperty(javaURLContextFactory.J2EE_CLIENT_NAME_PROP, clientName); log.info(javaURLContextFactory.J2EE_CLIENT_NAME_PROP + "=" + clientName); i ++; } else if( arg.equals(LAUNCHERS_PARAM) ) { launchers = args[i+1].split(","); log.info(LAUNCHERS_PARAM + "=" + args[i+1]); i ++; } else { newArgs.add(args[i]); } } ClassLoader loader = Thread.currentThread().getContextClassLoader(); if( loader == null ) loader = AppClientMain.class.getClassLoader(); // Look for a manifest Main-Class if (clientClass == null) { clientClass = getMainClassName(loader); throw new IllegalArgumentException("Neither a Main-Class was found in the manifest, " +"nor was a " + JBOSS_CLIENT_PARAM + " specified"); } // If J2EE_CLIENT_NAME_PROP was not specified, look in the jar descriptors if (clientName == null) { clientName = getClientName(loader); } String[] mainArgs = new String [newArgs.size()]; newArgs.toArray(mainArgs); // Try each launcher in the order specified for(String launcherName : launchers) { try { Class<AppClientLauncher> launcherClass = (Class<AppClientLauncher>) loader.loadClass(launcherName); AppClientLauncher launcher = launcherClass.newInstance(); launcher.launch(clientClass, clientName, mainArgs); break; } catch(Throwable t) { log.warn("Failed to launch using: "+launcherName, t); } } }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static Connection createConnection(final Object factory, final String username, final String password) throws JMSException { if (factory == null) throw new IllegalArgumentException("factory is null"); log.debug("using connection factory: " + factory); log.debug("using username/password: " + String.valueOf(username) + "/-- not shown --"); Connection connection; if (factory instanceof XAConnectionFactory) { XAConnectionFactory qFactory = (XAConnectionFactory) factory; if (username != null) connection = qFactory.createXAConnection(username, password); else connection = qFactory.createXAConnection(); log.debug("created XAConnection: " + connection); } else if (factory instanceof ConnectionFactory) { ConnectionFactory qFactory = (ConnectionFactory) factory; if (username != null) connection = qFactory.createConnection(username, password); else connection = qFactory.createConnection(); log.debug("created Connection: " + connection); } else { throw new IllegalArgumentException("factory is invalid"); } return connection; }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static QueueConnection createQueueConnection(final Object factory, final String username, final String password) throws JMSException { if (factory == null) throw new IllegalArgumentException("factory is null"); log.debug("using connection factory: " + factory); log.debug("using username/password: " + String.valueOf(username) + "/-- not shown --"); QueueConnection connection; if (factory instanceof XAQueueConnectionFactory) { XAQueueConnectionFactory qFactory = (XAQueueConnectionFactory) factory; if (username != null) connection = qFactory.createXAQueueConnection(username, password); else connection = qFactory.createXAQueueConnection(); log.debug("created XAQueueConnection: " + connection); } else if (factory instanceof QueueConnectionFactory) { QueueConnectionFactory qFactory = (QueueConnectionFactory) factory; if (username != null) connection = qFactory.createQueueConnection(username, password); else connection = qFactory.createQueueConnection(); log.debug("created QueueConnection: " + connection); } else throw new IllegalArgumentException("factory is invalid"); return connection; }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static TopicConnection createTopicConnection(final Object factory, final String username, final String password) throws JMSException { if (factory == null) throw new IllegalArgumentException("factory is null"); log.debug("using connection factory: " + factory); log.debug("using username/password: " + String.valueOf(username) + "/-- not shown --"); TopicConnection connection; if (factory instanceof XATopicConnectionFactory) { XATopicConnectionFactory tFactory = (XATopicConnectionFactory) factory; if (username != null) connection = tFactory.createXATopicConnection(username, password); else connection = tFactory.createXATopicConnection(); log.debug("created XATopicConnection: " + connection); } else if (factory instanceof TopicConnectionFactory) { TopicConnectionFactory tFactory = (TopicConnectionFactory) factory; if (username != null) connection = tFactory.createTopicConnection(username, password); else connection = tFactory.createTopicConnection(); log.debug("created TopicConnection: " + connection); } else throw new IllegalArgumentException("factory is invalid"); return connection; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected XAConnectionFactory getConnectionFactory() throws Exception { // Get the JMS Provider Adapter if (providerName == null) throw new IllegalArgumentException("Null provider name"); String providerAdapterJNDI = providerName; if (providerAdapterJNDI.startsWith("java:") == false) providerAdapterJNDI = "java:" + providerAdapterJNDI; Context ctx = new InitialContext(); JMSProviderAdapter adapter = (JMSProviderAdapter) Util.lookup(providerAdapterJNDI, JMSProviderAdapter.class); // Determine the XAConnectionFactory name String connectionFactoryRef = adapter.getFactoryRef(); if (connectionFactoryRef == null) throw new IllegalStateException("Provider '" + providerName + "' has no FactoryRef"); // Lookup the connection factory ctx = adapter.getInitialContext(); try { return (XAConnectionFactory) Util.lookup(ctx, connectionFactoryRef, XAConnectionFactory.class); } finally { ctx.close(); } }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (unit == null) throw new IllegalArgumentException("Null unit"); ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class); if (clmd != null) return clmd; clmd = create(unit.getName(), loaderMetaData, parentDelegation); if (clmd != null) unit.addAttachment(ClassLoadingMetaData.class, clmd); return clmd; }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (deploymentName == null) throw new IllegalArgumentException("Null deployment name"); if (loaderMetaData == null) throw new IllegalArgumentException("Null loader repository metadata"); LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig(); repositoryConfig.repositoryClassName = loaderMetaData.getLoaderRepositoryClass(); if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0) repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS; // Get the object name of the repository String name = loaderMetaData.getName(); if (name != null) { try { repositoryConfig.repositoryName = new ObjectName(name.trim()); } catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); } } StringBuilder configData = new StringBuilder(); Set<LoaderRepositoryConfigMetaData> children = loaderMetaData.getLoaderRepositoryConfig(); if (children != null) { for (LoaderRepositoryConfigMetaData child : children) { // This looks stupid? Why inside a loop? String parserClassName = child.getConfigParserClass(); if (parserClassName == null || parserClassName.length() == 0) repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS; else repositoryConfig.configParserClassName = parserClassName; // Append all config String childConfig = child.getConfig(); if (childConfig != null) configData.append(childConfig); } } repositoryConfig.repositoryConfig = configData.toString().trim(); return LoaderRepositoryConfigHelper.create(name, repositoryConfig, parentDelegation); }
// in src/main/java/org/jboss/deployment/EARStructure.java
public void setEarLibFilter(VirtualFileFilter earLibFilter) { if (earLibFilter == null) throw new IllegalArgumentException("Null filter"); this.earLibFilter = earLibFilter; }
// in src/main/java/org/jboss/deployment/ListDeploymentUnitFilter.java
public void start() { if (filters == null || filters.isEmpty()) throw new IllegalArgumentException("Null or empty filters list."); }
// in src/main/java/org/jboss/deployment/TldParsingDeployer.java
protected TldMetaData parse(VirtualFile file) throws Exception { if (file == null) throw new IllegalArgumentException("Null file"); // Implicit TLDs are reserved as the "implicit.tld" name if (file.getName().equals("implicit.tld")) { return new TldMetaData(); } else { return super.parse(file); } }
// in src/main/java/org/jboss/deployment/JSFDeployment.java
public void addManagedBean(String managedBeanClass) { if (managedBeanClass == null || managedBeanClass.trim().isEmpty()) { throw new IllegalArgumentException("Managed bean class cannot be null or empty string"); } this.managedBeans.add(managedBeanClass); }
// in src/main/java/org/jboss/deployment/security/JaccPolicyUtil.java
public static void createPermissions(PolicyConfiguration policyConfiguration, Object metadata) throws PolicyContextException { if(metadata == null) throw new IllegalArgumentException("Meta Data is null"); if(policyConfiguration == null) throw new IllegalArgumentException("Policy Configuration is null"); if(metadata instanceof JBossWebMetaData) { JBossWebMetaData wmd = (JBossWebMetaData)metadata; WebPermissionMapping.createPermissions(wmd, policyConfiguration); } else if(metadata instanceof JBossEnterpriseBeanMetaData) { JBossEnterpriseBeanMetaData bmd = (JBossEnterpriseBeanMetaData)metadata; EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } else if(metadata instanceof JBossMetaData) { JBossMetaData jmd = (JBossMetaData)metadata; JBossEnterpriseBeansMetaData beans = jmd.getEnterpriseBeans(); for(JBossEnterpriseBeanMetaData bmd : beans) { EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } } else throw new IllegalStateException("Unknown metadata"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (duration < 0) throw new IllegalArgumentException("duration is negative"); return createTimer(new Date(System.currentTimeMillis() + duration), 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialDuration < 0) throw new IllegalArgumentException("initial duration is negative"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); return createTimer(new Date(System.currentTimeMillis() + initialDuration), intervalDuration, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (expiration == null) throw new IllegalArgumentException("expiration is null"); return createTimer(expiration, 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSource, String tableName) throws SQLException { if (tableName == null) throw new IllegalArgumentException("Timers tableName is null"); if (tableName.length() == 0) throw new IllegalArgumentException("Timers tableName is empty"); this.tableName = tableName; init(server, dataSource); }
// in src/main/java/org/jboss/ejb/txtimer/TimedObjectId.java
public static TimedObjectId parse(String externalForm) { if (externalForm.startsWith("[") == false || externalForm.endsWith("]") == false) throw new IllegalArgumentException("Square brackets expected arround: " + externalForm); // take first and last char off String inStr = externalForm.substring(1, externalForm.length() - 1); if (inStr.startsWith("target=") == false) throw new IllegalArgumentException("Cannot parse: " + externalForm); String jmxStr = inStr.substring(7); String pkStr = null; int pkIndex = jmxStr.indexOf(",pk="); if (pkIndex > 0) { pkStr = jmxStr.substring(pkIndex + 4); jmxStr = jmxStr.substring(0, pkIndex); } ObjectName contatinerId = ObjectNameFactory.create(jmxStr); return new TimedObjectId(contatinerId, pkStr); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public void setInstancePool(InstancePool ip) { if (ip == null) throw new IllegalArgumentException("Null pool"); this.instancePool = ip; }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
public void addCreateDestination(CreateDestination factory) { if (factory == null) throw new IllegalArgumentException("Null factory"); factories.add(factory); addOutput(factory.getOutput()); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
public void removeCreateDestination(CreateDestination factory) { if (factory == null) throw new IllegalArgumentException("Null factory"); factories.add(factory); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public BeanLock getLock(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to get lock ref with a null object"); HashMap mapInUse = getHashMap(id); synchronized (mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock!=null) { lock.addRef(); return lock; } } try { BeanLock lock2 = (BeanLock)createLock(id); synchronized(mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); // in case of bad luck, this might happen if (lock != null) { lock.addRef(); return lock; } mapInUse.put(id, lock2); lock2.addRef(); return lock2; } } catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); } }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public void removeLockRef(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to remove lock ref with a null object"); HashMap mapInUse = getHashMap(id); synchronized(mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock != null) { try { lock.removeRef(); if( trace ) log.trace("Remove ref lock:"+lock); } finally { // schrouf: ALLWAYS ensure proper map lock removal even in case // of exception within lock.removeRef ! There seems to be a bug // in the ref counting of QueuedPessimisticEJBLock under certain // conditions ( lock.ref < 0 should never happen !!! ) if (lock.getRefs() <= 0) { Object mapLock = mapInUse.remove(lock.getId()); if( trace ) log.trace("Lock no longer referenced, lock: "+lock); } } } } }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public boolean canPassivate(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to passivate with a null object"); HashMap mapInUse = getHashMap(id); synchronized (mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock == null) throw new IllegalStateException("Attempt to passivate without a lock"); return (lock.getRefs() <= 1); } }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
protected void ageOut(LRUCacheEntry entry) { if( m_cache == null ) return; if (entry == null) { throw new IllegalArgumentException ("Cannot remove a null cache entry"); } if( log.isTraceEnabled() ) { m_buffer.setLength(0); m_buffer.append("Aging out from cache bean "); m_buffer.append(m_cache.getContainer().getBeanMetaData().getEjbName()); m_buffer.append("with id = "); m_buffer.append(entry.m_key); m_buffer.append("; cache size = "); m_buffer.append(getList().m_count); log.trace(m_buffer.toString()); } // This will schedule the passivation m_cache.release((EnterpriseContext)entry.m_object); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if (id == null) throw new IllegalArgumentException("Can't get an object with a null key"); EnterpriseContext ctx; synchronized (getCacheLock()) { CachePolicy cache = getCache(); ctx = (EnterpriseContext)cache.get(id); if (ctx == null) { try { ctx = acquireContext(); setKey(id, ctx); if (doActivate(ctx) == false) // This is a recursive activation return ctx; logActivation(id); // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here cache.insert(id, ctx); } catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void insert(EnterpriseContext ctx) { if (ctx == null) throw new IllegalArgumentException("Can't insert a null object in the cache"); Object key = getKey(ctx); synchronized (getCacheLock()) { // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here getCache().insert(key, ctx); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void release(EnterpriseContext ctx) { if (ctx == null) throw new IllegalArgumentException("Can't release a null object"); // Here I remove the bean; call to remove(id) is wrong // cause will remove also the cache lock that is needed // by the passivation, that eventually will remove it. /* the removal should only be done if the instance is not in use. this is taken care of in tryToPassivate Object id = getKey(ctx); synchronized (getCacheLock()) { if (getCache().peek(id) != null) getCache().remove(id); } */ tryToPassivate(ctx, true); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void remove(Object id) { if (id == null) throw new IllegalArgumentException("Can't remove an object using a null key"); synchronized (getCacheLock()) { if (getCache().peek(id) != null) { getCache().remove(id); } }
// in src/main/java/org/jboss/ejb/plugins/CallValidationInterceptor.java
protected void validateArguments(Invocation mi) { if (mi.getType() == InvocationType.REMOTE) { Object[] params = mi.getArguments(); for (int i = 0; i < params.length; i++) { Object obj = params[i]; if (obj instanceof TimerHandle) throw new IllegalArgumentException("Cannot pass TimerHandle through remote interface"); } } }
// in src/main/java/org/jboss/ejb/plugins/CallValidationInterceptor.java
protected Object validateReturnValue(Invocation mi, Object retValue) { if (mi.getType() == InvocationType.REMOTE) { if (retValue instanceof TimerHandle) throw new IllegalArgumentException("Cannot return TimerHandle from remote interface"); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public Object get(Object key) { if (key == null) { throw new IllegalArgumentException("Requesting an object using a null key"); } EnterpriseContext ctx = null; synchronized (m_map) { ctx = (EnterpriseContext) m_map.get(key); } return ctx; }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void insert(Object key, Object ctx) { if (ctx == null) { throw new IllegalArgumentException("Cannot insert a null object in the cache"); } if (key == null) { throw new IllegalArgumentException("Cannot insert an object in the cache with null key"); } synchronized (m_map) { Object obj = m_map.get(key); if (obj == null) { m_map.put(key, ctx); } else { throw new IllegalStateException("Attempt to put in the cache an object that is already there"); } } }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void remove(Object key) { if (key == null) { throw new IllegalArgumentException("Removing an object using a null key"); } synchronized (m_map) { Object value = m_map.get(key); if (value != null) { m_map.remove(key); } else { throw new IllegalArgumentException("Cannot remove an object that isn't in the cache"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/IdentifierManager.java
public void declareCollectionMember( String identifier, String path) { List fieldList = (List)fieldLists.get(path); Object field = fieldList.get(fieldList.size()-1); if(!(field instanceof CMRFieldBridge)) { throw new IllegalArgumentException("Path is collection valued: "+path); } CMRFieldBridge cmrField = (CMRFieldBridge)field; if(cmrField.isSingleValued()) { throw new IllegalArgumentException("Path is collection valued: "+path); } identifiers.put(identifier, cmrField.getRelatedEntity()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/IdentifierManager.java
public void registerPath( String path, List pathList, List fieldList) { if(pathList.size() != fieldList.size()) { throw new IllegalArgumentException("Path list and field list must " + "have the same size: pathList.size=" + pathList.size() + " fieldList.size=" + fieldList.size()); } pathLists.put(path, pathList); fieldLists.put(path, fieldList); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PersistentContext.java
public void setPk(Object pk) throws DuplicateKeyException { if(pk == null) { throw new IllegalArgumentException("Primary key is null!"); } row.insert(pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/FindByPrimaryKeyCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { Object pk = args[0]; if(pk == null) { throw new IllegalArgumentException("Null argument for findByPrimaryKey"); } Object instance; boolean cached = entity.getTable().hasRow(pk); if(!cached) { instance = super.executeFetchOne(args, factory); if(instance == null) { throw new ObjectNotFoundException("Instance not find: entity=" + entity.getEntityName() + ", pk=" + pk); } } else { instance = factory.getEntityEJBObject(pk); } return instance; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
protected void setParameters(List p) { if(p.size() > 0) { params = new QueryParameter[p.size()]; for(int i = 0; i < p.size(); i++) { Object pi = p.get(i); if(!(pi instanceof QueryParameter)) { throw new IllegalArgumentException("Element " + i + " of list is not an instance of QueryParameter, but " + p.get(i).getClass().getName()); } params[i] = (QueryParameter) pi; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private Object getPrimaryKey(Object o) { if(o == null) { throw new IllegalArgumentException("This implementation does not support null members."); } if(!relatedEntity.getLocalInterface().isInstance(o)) { throw new IllegalArgumentException("Argument must be of type " + entity.getLocalInterface().getName()); } EJBLocalObject local = (EJBLocalObject)o; try { return local.getPrimaryKey(); } catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(value == null) { throw new IllegalArgumentException("Can't set collection-valued CMR field to null: " + entity.getEntityName() + "." + getFieldName() ); } destroyExistingRelationships(ctx); Collection newValue = (Collection)value; if(!newValue.isEmpty()) { Set copy = new HashSet(newValue); for(Iterator iter = copy.iterator(); iter.hasNext();) { Object relatedId = getPrimaryKey(iter.next()); addRelatedId(ctx, relatedId); relatedCMRField.invokeAddRelatedId(relatedId, ctx.getId()); loader.addRelatedId(ctx, relatedId); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
public JDBCRelationshipRoleMetaData getOtherRelationshipRole(JDBCRelationshipRoleMetaData role) { if (left == role) { return right; } else if (right == role) { return left; } else { throw new IllegalArgumentException("Specified role is not the left " + "or right role. role=" + role); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected void setParameterList(List p) { for(int i = 0; i < p.size(); i++) { if(!(p.get(i) instanceof QueryParameter)) { throw new IllegalArgumentException("Element " + i + " of list " + "is not an instance of QueryParameter, but " + p.get(i).getClass().getName()); } } parameters = new ArrayList(p); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
private void existsClause(ASTPath path, StringBuffer buf, boolean not) { if(!path.isCMRField()) { throw new IllegalArgumentException("path must be a cmr field"); } JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) path.getCMRField(); String pathStr = path.getPath(path.size() - 2); String parentAlias = aliasManager.getAlias(pathStr); // if exists is not supported we use a left join and is null if(!subquerySupported) { // add the path to the list of paths to left join addLeftJoinPath(pathStr, path); forceDistinct = true; addJoinPath(path); if(cmrField.getRelationMetaData().isForeignKeyMappingStyle()) { JDBCEntityBridge childEntity = (JDBCEntityBridge) cmrField.getRelatedEntity(); String childAlias = aliasManager.getAlias(path.getPath()); SQLUtil.getIsNullClause(!not, childEntity.getPrimaryKeyFields(), childAlias, buf); } else { String relationTableAlias = aliasManager.getRelationTableAlias(path.getPath()); SQLUtil.getIsNullClause(!not, cmrField.getTableKeyFields(), relationTableAlias, buf); } return; } if(not) { buf.append(SQLUtil.NOT); } buf.append(SQLUtil.EXISTS).append('('); if(cmrField.getRelationMetaData().isForeignKeyMappingStyle()) { JDBCEntityBridge childEntity = (JDBCEntityBridge) cmrField.getRelatedEntity(); String childAlias = aliasManager.getAlias(path.getPath()); buf.append(SQLUtil.SELECT); SQLUtil.getColumnNamesClause(childEntity.getPrimaryKeyFields(), childAlias, buf) .append(SQLUtil.FROM) .append(childEntity.getQualifiedTableName()).append(' ').append(childAlias) .append(SQLUtil.WHERE); SQLUtil.getJoinClause(cmrField, parentAlias, childAlias, buf); } else { String relationTableAlias = aliasManager.getRelationTableAlias(path.getPath()); buf.append(SQLUtil.SELECT); SQLUtil.getColumnNamesClause(cmrField.getTableKeyFields(), relationTableAlias, buf) .append(SQLUtil.FROM) .append(cmrField.getQualifiedTableName()) .append(' ') .append(relationTableAlias) .append(SQLUtil.WHERE); SQLUtil.getRelationTableJoinClause(cmrField, parentAlias, relationTableAlias, buf); } buf.append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
public void set(Logger log, PreparedStatement ps, int index, Object[] args) throws Exception { Object arg = args[argNum]; JDBCParameterSetter param; if(field != null) { if(!isPrimaryKeyParameter) { if(arg instanceof EJBObject) { arg = ((EJBObject)arg).getPrimaryKey(); } else if(arg instanceof EJBLocalObject) { arg = ((EJBLocalObject)arg).getPrimaryKey(); } else { throw new IllegalArgumentException("Expected an instanc of " + "EJBObject or EJBLocalObject, but got an instance of " + arg.getClass().getName()); } } arg = field.getPrimaryKeyValue(arg); // use mapper final JDBCType jdbcType = field.getJDBCType(); arg = jdbcType.getColumnValue(0, arg); param = jdbcType.getParameterSetter()[0]; } else if(property != null) { arg = property.getColumnValue(arg); param = property.getParameterSetter(); } else { if(type != null) { arg = type.getColumnValue(0, arg); param = type.getParameterSetter()[0]; } else { param = JDBCUtil.getParameterSetter(jdbcType, arg == null ? null : arg.getClass()); } } param.set(ps, index, jdbcType, arg, log); //JDBCUtil.setParameter(log, ps, index, jdbcType, arg); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
private static JDBCFieldBridge getCMPField( JDBCEntityPersistenceStore manager, Class intf, String fieldName) { Catalog catalog = manager.getCatalog(); JDBCAbstractEntityBridge entityBridge = (JDBCAbstractEntityBridge)catalog.getEntityByInterface(intf); if(entityBridge == null) { throw new IllegalArgumentException("Entity not found in application " + "catalog with interface=" + intf.getName()); } JDBCFieldBridge cmpField = (JDBCFieldBridge)entityBridge.getFieldByName(fieldName); if(cmpField == null) { throw new IllegalArgumentException("cmpField not found:" + " cmpFieldName=" + fieldName + " entityName=" + entityBridge.getEntityName()); } return cmpField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static StringBuffer getJoinClause(JDBCFieldBridge[] pkFields, String parent, JDBCFieldBridge[] fkFields, String child, StringBuffer buf) { if(pkFields.length != fkFields.length) { throw new IllegalArgumentException( "Error createing theta join clause:" + " pkField.size()=" + pkFields.length + " fkField.size()=" + fkFields.length); } boolean and = false; for(int i = 0; i < pkFields.length; ++i) { // these types should not be null JDBCType pkType = getJDBCType(pkFields[i]); JDBCType fkType = getJDBCType(fkFields[i]); if(and) buf.append(AND); else and = true; getJoinClause(pkType, parent, fkType, child, buf); } return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
private static StringBuffer getJoinClause(JDBCType pkType, String parent, JDBCType fkType, String child, StringBuffer buf) { if(parent.length() > 0) { parent += '.'; } if(child.length() > 0) { child += '.'; } String[] pkColumnNames = pkType.getColumnNames(); String[] fkColumnNames = fkType.getColumnNames(); if(pkColumnNames.length != fkColumnNames.length) { throw new IllegalArgumentException("PK and FK have different number of columns"); } buf.append(parent).append(pkColumnNames[0]).append('=').append(child).append(fkColumnNames[0]); int i = 1; while(i < pkColumnNames.length) { buf.append(AND) .append(parent) .append(pkColumnNames[i]) .append('=') .append(child) .append(fkColumnNames[i++]); } return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMR field cannot be set " + "in ejbCreate; this should be done in the ejbPostCreate " + "method instead [EJB 2.0 Spec. 10.5.2]."); } if(isCollectionValued() && value == null) { throw new IllegalArgumentException("null cannot be assigned to a " + "collection-valued cmr-field [EJB 2.0 Spec. 10.3.8]."); } /* if(allFKFieldsMappedToPKFields) { throw new IllegalStateException( "Can't modify relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]."); } */ setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Object getRelatedPrimaryKey(Object localObject) { Object relatedId; if(relatedEntity.getLocalInterface().isAssignableFrom(localObject.getClass())) { EJBLocalObject local = (EJBLocalObject) localObject; try { relatedId = local.getPrimaryKey(); } catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); } /* if(relatedManager.wasCascadeDeleted(relatedId)) { throw new IllegalArgumentException("The instance was cascade-deleted: pk=" + relatedId); } */ } else { throw new IllegalArgumentException("The values of this field must be of type " + relatedEntity.getLocalInterface().getName()); } return relatedId; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean add(Object o) { if(o == null) { throw new IllegalArgumentException("Null cannot be added to a CMR " + "relationship collection"); } checkForPKChange(); List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } if(!relatedLocalInterface.isInstance(o)) { String msg = "Object must be an instance of " + relatedLocalInterface.getName() + ", but is an isntance of ["; Class[] classes = o.getClass().getInterfaces(); for(int i = 0; i < classes.length; i++) { if(i > 0) msg += ", "; msg += classes[i].getName(); } msg += "]"; throw new IllegalArgumentException(msg); } Object id = getPrimaryKey((EJBLocalObject) o); if(idList.contains(id)) { return false; } cmrField.createRelationLinks(ctx, id); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean remove(Object o) { List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); if(!relatedLocalInterface.isInstance(o)) { throw new IllegalArgumentException("Object must be an instance of " + relatedLocalInterface.getName()); } Object id = getPrimaryKey((EJBLocalObject) o); if(!idList.contains(id)) { return false; } cmrField.destroyRelationLinks(ctx, id); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean contains(Object o) { List idList = getIdList(); if(!relatedLocalInterface.isInstance(o)) { throw new IllegalArgumentException("Object must be an instance of " + relatedLocalInterface.getName()); } Object id = getPrimaryKey((EJBLocalObject) o); return idList.contains(id); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
private Object getPrimaryKey(EJBLocalObject o) { try { return o.getPrimaryKey(); } catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if(id == null) throw new IllegalArgumentException("Can't get an object with a null key"); Map cache = getLocalCache(); EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id); if(instance == null) { try { // acquire instance = (EntityEnterpriseContext) container.getInstancePool().get(); // set key instance.setId(id); instance.setCacheKey(id); // activate container.getPersistenceManager().activateEntity(instance); // insert cache.put(id, instance); } catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); } } return instance; }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public void insert(EnterpriseContext instance) { if(instance == null) throw new IllegalArgumentException("Can't insert a null object in the cache"); EntityEnterpriseContext entity = (EntityEnterpriseContext) instance; getLocalCache().put(entity.getCacheKey(), instance); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public void release(EnterpriseContext instance) { if(instance == null) throw new IllegalArgumentException("Can't release a null object"); tryToPassivate(instance); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void setInstancePool(InstancePool ip) { if (ip == null) throw new IllegalArgumentException("Null pool"); this.instancePool = ip; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void setInstanceCache(InstanceCache ic) { if (ic == null) throw new IllegalArgumentException("Null cache"); this.instanceCache = ic; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void setPersistenceManager(EntityPersistenceManager pm) { if (pm == null) throw new IllegalArgumentException("Null persistence manager"); persistenceManager = pm; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private Object findSingleObject(Transaction tx, Method method, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if(method.getName().equals("findByPrimaryKey")) { if(args[0] == null) throw new IllegalArgumentException("findByPrimaryKey called with null argument."); if(metaData.getContainerConfiguration().getCommitOption() != ConfigurationMetaData.B_COMMIT_OPTION) { Object key = instance.getCacheKey(); if(key == null) { key = ((EntityCache)instanceCache).createCacheKey(args[0]); } if(instanceCache.isActive(key)) { return factory.getEntityEJBObject(key); } } } else if(!metaData.getContainerConfiguration().getSyncOnCommitOnly()) { EntityContainer.synchronizeEntitiesWithinTransaction(tx); } return getPersistenceManager().findEntity(method, args, instance, factory); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public Object getAttribute (String attribute) throws javax.management.AttributeNotFoundException, javax.management.MBeanException, javax.management.ReflectionException { if (attribute == null || attribute.equals ("")) throw new IllegalArgumentException ("null or empty attribute name"); if (attribute.equals ("AsynchronousInvalidation")) return new Boolean(this.asynchronous); else throw new javax.management.AttributeNotFoundException(attribute + " is not a known attribute"); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public java.lang.Object invoke (java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature) throws javax.management.MBeanException, javax.management.ReflectionException { if ("invalidate".equals (actionName)) { if (params.length == 1) { if (params[0] instanceof Serializable[]) this.invalidate ((Serializable[])params[0]); else if (params[0] instanceof Serializable) this.invalidate ((Serializable)params[0]); else throw new IllegalArgumentException ("First argument must be Serializable (or array of)"); } else if (params.length == 2) { if (params[0] instanceof Serializable[]) this.invalidate ((Serializable[])params[0], ((Boolean)params[1]).booleanValue ()); else if (params[0] instanceof Serializable) this.invalidate ((Serializable)params[0], ((Boolean)params[1]).booleanValue ()); else throw new IllegalArgumentException ("First argument must be Serializable (or array of)"); } else { throw new IllegalArgumentException ("Unknown operation with these parameters: " + actionName); } } else if("invalidateAll".equals(actionName)) { if(params == null || params.length == 0) { this.invalidateAll(); } else if (params.length == 1) { this.invalidateAll (((Boolean)params[1]).booleanValue ()); } else { throw new IllegalArgumentException ("invalidateAll can take zero or one parameter but got " + params.length); } } else { throw new IllegalArgumentException ("Unknown operation: " + actionName); } return null; }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public void setAttribute (javax.management.Attribute attribute) throws javax.management.AttributeNotFoundException, javax.management.InvalidAttributeValueException, javax.management.MBeanException, javax.management.ReflectionException { String attrName = attribute.getName(); if (attrName == null || attrName.equals ("")) throw new IllegalArgumentException ("null or empty attribute name"); if (attrName.equals ("AsynchronousInvalidation")) { Object value = attribute.getValue (); if (value instanceof Boolean) this.asynchronous = ((Boolean)value).booleanValue (); else throw new javax.management.InvalidAttributeValueException("Attribute is of boolean type"); } else throw new javax.management.AttributeNotFoundException(attrName + " is not a known attribute"); }
// in src/main/java/org/jboss/web/WebPermissionMapping.java
public static void createPermissions(JBossWebMetaData metaData, PolicyConfiguration pc) throws PolicyContextException { HashMap<String, PatternInfo> patternMap = qualifyURLPatterns(metaData); log.debug("Qualified url patterns: "+patternMap); List<SecurityConstraintMetaData> constraints = metaData.getSecurityConstraints(); if(constraints != null) { for(SecurityConstraintMetaData sc : constraints) { WebResourceCollectionsMetaData resources = sc.getResourceCollections(); TransportGuaranteeType transport = sc.getTransportGuarantee(); if( sc.isExcluded() || sc.isUnchecked() ) { // Process the permissions for the excluded/unchecked resources if(resources != null) for(WebResourceCollectionMetaData wrc : resources) { List<String> httpMethods = wrc.getHttpMethods(); List<String> urlPatterns = wrc.getUrlPatterns(); int length = urlPatterns != null ? urlPatterns.size() : 0; for(int n = 0; n < length; n ++) { String url = urlPatterns.get(n); PatternInfo info = (PatternInfo) patternMap.get(url); // Add the excluded methods if( sc.isExcluded() ) { info.addExcludedMethods(httpMethods); } } } } else { // Process the permission for the resources x roles if(resources != null) for(WebResourceCollectionMetaData wrc : resources) { List<String> httpMethods = wrc.getHttpMethods(); List<String> urlPatterns = wrc.getUrlPatterns(); int length = urlPatterns != null ? urlPatterns.size() : 0; for(int n = 0; n < length; n ++) { String url = urlPatterns.get(n); // Get the qualified url pattern PatternInfo info = (PatternInfo) patternMap.get(url); HashSet<String> mappedRoles = new HashSet<String>(); if(sc.getRoleNames() != null) for(String role : sc.getRoleNames()) { if( role.equals("*") ) { //JBAS-1824: Allow "*" to provide configurable authorization bypass if(metaData.isJaccAllStoreRole()) mappedRoles.add("*"); else { // The wildcard ref maps to all declared security-role names for(SecurityRoleMetaData srmd : metaData.getSecurityRoles()) { role = srmd.getRoleName(); mappedRoles.add(role); } } } else { mappedRoles.add(role); } } info.addRoles(mappedRoles, httpMethods); // Add the transport to methods info.addTransport(transport.name(), httpMethods); //SECURITY-63: Missing auth-constraint needs unchecked policy if(sc.getAuthConstraint() == null) info.isMissingAuthConstraint = true; } } } } } // Create the permissions for(PatternInfo info : patternMap.values()) { String qurl = info.getQualifiedPattern(); if( info.isOverriden == true ) { log.debug("Dropping overriden pattern: "+info); continue; } // Create the excluded permissions String[] httpMethods = info.getExcludedMethods(); if( httpMethods != null ) { // There were excluded security-constraints WebResourcePermission wrp = new WebResourcePermission(qurl, httpMethods); WebUserDataPermission wudp = new WebUserDataPermission(qurl, httpMethods, null); pc.addToExcludedPolicy(wrp); pc.addToExcludedPolicy(wudp); //!(excluded methods) [JACC 1.1] String excludedString = "!" + getCommaSeparatedString(httpMethods); WebResourcePermission wrp1 = new WebResourcePermission(info.pattern, excludedString); WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern,excludedString); pc.addToUncheckedPolicy(wrp1); pc.addToUncheckedPolicy(wudp1); } // Create the role permissions Iterator<Map.Entry<String, Set<String>>> roles = info.getRoleMethods(); while( roles.hasNext() ) { Map.Entry<String, Set<String>> roleMethods = roles.next(); String role = (String) roleMethods.getKey(); WebResourcePermission wrp; if("*".equals(role)) { //JBAS-1824: <role-name>*</role-name> wrp = new WebResourcePermission(qurl, (String)null); } else { Set<String> methods = roleMethods.getValue(); httpMethods = new String[methods.size()]; methods.toArray(httpMethods); wrp = new WebResourcePermission(qurl, httpMethods); } pc.addToRole(role, wrp); //JACC 1.1: create !(httpmethods) in unchecked perms if(httpMethods != null) { final String pattern = info.pattern; final String methodsAsString = "!" + getCommaSeparatedString(httpMethods); WebResourcePermission wrpUnchecked = null; try { wrpUnchecked = new WebResourcePermission(pattern, methodsAsString); } catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); } pc.addToUncheckedPolicy(wrpUnchecked); } } // Create the unchecked permissions String[] missingHttpMethods = info.getMissingMethods(); if( missingHttpMethods.length > 0 ) { // Create the unchecked permissions WebResourcePermissions WebResourcePermission wrp = new WebResourcePermission(qurl, missingHttpMethods); pc.addToUncheckedPolicy(wrp); } else pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null)); //SECURITY-63: Missing auth-constraint needs unchecked policy if(info.isMissingAuthConstraint) { pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null)); } // Create the unchecked permissions WebUserDataPermissions Iterator<Map.Entry<String, Set<String>>> transportContraints = info.getTransportMethods(); while( transportContraints.hasNext() ) { Map.Entry<String, Set<String>> transportMethods = transportContraints.next(); String transport = transportMethods.getKey(); Set<String> methods = transportMethods.getValue(); httpMethods = new String[methods.size()]; methods.toArray(httpMethods); WebUserDataPermission wudp = new WebUserDataPermission(qurl, httpMethods, transport); pc.addToUncheckedPolicy(wudp); //If the transport is "NONE", then add an exlusive WebUserDataPermission //with the url pattern and null if("NONE".equals(transport)) { WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern, null); pc.addToUncheckedPolicy(wudp1); } else { //JACC 1.1: Transport is CONFIDENTIAL/INTEGRAL, add a !(http methods) if(httpMethods != null) { WebUserDataPermission wudpNonNull = new WebUserDataPermission(info.pattern, "!" + getCommaSeparatedString(httpMethods)); pc.addToUncheckedPolicy(wudpNonNull); } } } } /* Create WebRoleRefPermissions for all servlet/security-role-refs along with all the cross product of servlets and security-role elements that are not referenced via a security-role-ref as described in JACC section 3.1.3.2 */ JBossServletsMetaData servlets = metaData.getServlets(); for(JBossServletMetaData servlet : servlets) { String servletName = servlet.getServletName(); SecurityRoleRefsMetaData roleRefs = servlet.getSecurityRoleRefs(); //Perform the unreferenced roles processing for every servlet name Set<String> unreferencedRoles = metaData.getSecurityRoleNames(); if(roleRefs != null) for(SecurityRoleRefMetaData roleRef : roleRefs) { String roleName = roleRef.getRoleLink(); WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, roleRef.getName()); pc.addToRole(roleName, wrrp); /* A bit of a hack due to how tomcat calls out to its Realm.hasRole() with a role name that has been mapped to the role-link value. We may need to handle this with a custom request wrapper. */ wrrp = new WebRoleRefPermission(servletName, roleName); pc.addToRole(roleRef.getName(), wrrp); // Remove the role from the unreferencedRoles unreferencedRoles.remove(roleName); } //Spec 3.1.3.2: For each servlet element in the deployment descriptor //a WebRoleRefPermission must be added to each security-role of the //application whose name does not appear as the rolename //in a security-role-ref within the servlet element. if(unreferencedRoles != null) for(String unrefRole : unreferencedRoles) { WebRoleRefPermission unrefP = new WebRoleRefPermission(servletName,unrefRole); pc.addToRole(unrefRole, unrefP); } } Set<String> unreferencedRoles = metaData.getSecurityRoleNames(); //JACC 1.1:Spec 3.1.3.2: For each security-role defined in the deployment descriptor, an //additional WebRoleRefPermission must be added to the corresponding role by //calling the addToRole method on the PolicyConfiguration object. The //name of all such permissions must be the empty string, and the actions of each //such permission must be the role-name of the corresponding role. if(unreferencedRoles != null) for(String unreferencedRole : unreferencedRoles) { WebRoleRefPermission wrrep = new WebRoleRefPermission("", unreferencedRole); pc.addToRole(unreferencedRole, wrrep); } // Now build the cross product of the unreferencedRoles and servlets Set<String> servletNames = servlets.keySet(); if(servletNames != null) for(String servletName : servletNames) { if(unreferencedRoles != null) for(String role : unreferencedRoles) { WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, role); pc.addToRole(role, wrrp); } } /** * The programmatic security checks are made from jsps. * JBAS-3054:Use of isCallerInRole from jsp does not work for JACC */ if(unreferencedRoles != null) for(String role : unreferencedRoles) { WebRoleRefPermission wrrp = new WebRoleRefPermission("", role); pc.addToRole(role, wrrp); } }
// in src/main/java/org/jboss/web/WebApplication.java
public void setURL(URL url) { if (url == null) throw new IllegalArgumentException("Null URL"); this.url = url; }
// in src/main/java/org/jboss/web/WebServer.java
public void start() throws Exception { if (executor == null) throw new IllegalArgumentException("Required property 'executor' not specified"); try { server = new ServerSocket(port, backlog, bindAddress); log.debug("Started server: " + server); listen(); } catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); } catch (IOException e) { throw e; } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void processEnc(ClassLoader loader, WebApplication webApp) throws Exception { if (loader == null) throw new IllegalArgumentException("Classloader passed to process ENC refs is null"); log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin"); InitialContext iniCtx = new InitialContext(); Context envCtx = null; Thread currentThread = Thread.currentThread(); ClassLoader currentLoader = currentThread.getContextClassLoader(); JBossWebMetaData metaData = webApp.getMetaData(); try { // Create a java:comp/env environment unique for the web application log.debug("Creating ENC using ClassLoader: " + loader); ClassLoader parent = loader.getParent(); while (parent != null) { log.debug(".." + parent); parent = parent.getParent(); } // TODO: The enc should be an input? currentThread.setContextClassLoader(loader); // webApp.setENCLoader(loader); envCtx = (Context)iniCtx.lookup("java:comp"); // TODO: inject the ORB try { ObjectName ORB_NAME = new ObjectName("jboss:service=CorbaORB"); org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB)server.getAttribute(ORB_NAME, "ORB"); // Bind the orb if (orb != null) { NonSerializableFactory.rebind(envCtx, "ORB", orb); log.debug("Bound java:comp/ORB"); } } catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); } // TODO: injection, Add a link to the global transaction manager envCtx.bind("UserTransaction", new LinkRef("UserTransaction")); log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction"); envCtx = envCtx.createSubcontext("env"); processEncReferences(webApp, envCtx); } finally { currentThread.setContextClassLoader(currentLoader); } String securityDomain = metaData.getSecurityDomain(); log.debug("linkSecurityDomain"); linkSecurityDomain(securityDomain, envCtx); log.debug("AbstractWebContainer.parseWebAppDescriptors, End"); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
public void setWebInfLibFilter(VirtualFileFilter webInfLibFilter) { if (webInfLibFilter == null) throw new IllegalArgumentException("Null filter"); this.webInfLibFilter = webInfLibFilter; }
// in src/main/java/org/jboss/verifier/BeanVerifier.java
protected void setVerifier( String version ) { if( VERSION_1_1.equals(version) ) { verifier = new EJBVerifier11(this); } else if( VERSION_2_0.equals(version) ) { verifier = new EJBVerifier20(this); } else if (VERSION_2_1.equals(version)) { verifier=new EJBVerifier21(this); } else { throw new IllegalArgumentException( UNRECOGNIZED_VERSION + ": " + version); } }
// in src/main/java/org/jboss/verifier/event/VerificationEvent.java
public void setState(String state) { if( WARNING.equalsIgnoreCase(state) ) { isWarning = true; isOk = false; } else if( OK.equalsIgnoreCase(state) ) { isOk = true; isWarning = false; } else { throw new IllegalArgumentException( STATE_NOT_RECOGNIZED + ": " + state); } }
// in src/main/java/org/jboss/verifier/Main.java
public static void main(String[] args) { try { if( args.length < 1 ) { throw new IllegalArgumentException( "Usage: beanverifier mybeans.jar"); } URL url = new File(args[0]).toURL(); URLClassLoader cl = new URLClassLoader( new URL[] {url}, Thread.currentThread().getContextClassLoader()); XmlFileLoader xfl = new XmlFileLoader(); BeanVerifier verifier = new BeanVerifier(); xfl.setClassLoader(cl); verifier.addVerificationListener(new Listener()); verifier.verify(url, xfl.load(null)); } catch (Exception e) { System.err.println("Problem starting the application:"); System.err.println("Exception: " + e); System.err.println("Message: " + e.getMessage()); e.printStackTrace(); System.exit(-1); } System.exit(returnCode); }
// in src/main/java/org/jboss/proxy/compiler/Utility.java
public static String getObjectEquivalentClassName(BasicType t) { switch (t.getType()) { case Constants.T_INT: return "java.lang.Integer"; case Constants.T_SHORT: return "java.lang.Short"; case Constants.T_BOOLEAN: return "java.lang.Boolean"; case Constants.T_CHAR: return "java.lang.Character"; case Constants.T_BYTE: return "java.lang.Byte"; case Constants.T_FLOAT: return "java.lang.Float"; case Constants.T_DOUBLE: return "java.lang.Double"; case Constants.T_LONG: return "java.lang.Long"; default: throw new IllegalArgumentException("Unexpected Type: " + t); } }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
Method[] checkTargetType(Class targetType) { if (targetType.isArray()) { throw new IllegalArgumentException ("cannot subclass an array type: " + targetType.getName()); } if (targetType.isPrimitive()) { throw new IllegalArgumentException ("cannot subclass a primitive type: " + targetType); } int tmod = targetType.getModifiers(); if (Modifier.isFinal(tmod)) { throw new IllegalArgumentException ("cannot subclass a final type: " + targetType); } if (!Modifier.isPublic(tmod)) { throw new IllegalArgumentException ("cannot subclass a non-public type: " + targetType); } // Make sure the subclass will not need a "super" statement. if (!targetType.isInterface()) { if (!targetType.isAssignableFrom(superclass)) { if (superclass.isAssignableFrom(targetType)) { superclass = targetType; } else { throw new IllegalArgumentException ("inconsistent superclass: " + targetType); } } } // Decide what overrideable methods this type supports. Method methodList[] = targetType.getMethods(); int nm = 0; for (int i = 0; i < methodList.length; i++) { Method m = methodList[i]; if (eligibleForInvocationHandler(m)) { methodList[nm++] = m; // (reuse the method array) } } while (nm < methodList.length) { methodList[nm++] = null; // (pad the reused method array) } return methodList; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
void checkSuperclass() { Constructor constructors[] = superclass.getConstructors(); for (int i = 0; i < constructors.length; i++) { Constructor c = constructors[i]; int mod = c.getModifiers(); if (Modifier.isPublic(mod) && c.getParameterTypes().length == 0) { return; // OK } } throw new IllegalArgumentException ("cannot subclass without nullary constructor: " +superclass.getName()); }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
Object invoke(Object target, Member method, Object values[]) throws Throwable { // Note: // // We will not invoke the method unless we are expecting it. // Thus, we cannot blindly call Method.invoke, but must first // check our list of allowed methods. try { Method methods[] = this.methods; // cache // use fast pointer equality (it usually succeeds) for (int i = methods.length; --i >= 0; ) { if (methods[i] == method) { return methods[i].invoke(target, values); } } // special case: allow a null method to select the unique one if (method == null) { if (methods.length == 1) { return methods[0].invoke(target, values); } throw new IllegalArgumentException("non-unique method"); } // try the slower form of equality for (int i = methods.length; --i >= 0; ) { if (methods[i].equals(method)) { return methods[i].invoke(target, values); } } } catch (InvocationTargetException e) { throw e.getTargetException(); } throw new IllegalArgumentException("method unexpected "+method); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public short getMemberIndex(Object cls, String name, Class ptypes[]) { if (cls instanceof Class) { Class c = (Class) cls; Member m; try { if (ptypes == null) { m = c.getField(name); } else if (name.equals("<init>")) { m = c.getConstructor(ptypes); } else { m = c.getMethod(name, ptypes); } } catch (NoSuchMethodException ee) { throw new IllegalArgumentException(ee+" in "+c); } catch (NoSuchFieldException ee) { throw new IllegalArgumentException(ee+" in "+c); } return getIndex(m); } else if (cls instanceof ProxyAssembler) { ProxyAssembler asm = (ProxyAssembler) cls; String sig = getSig(null, ptypes); AMember m = asm.findMember(sig, name); if (m == null) { throw new IllegalArgumentException(sig + " " + name); } return getIndex(m); } else { throw new IllegalArgumentException("not a type: "+cls); } }
9
              
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
catch (ParseException e) { throw new IllegalArgumentException("Cannot parse date/time in: " + externalForm); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
catch(NumberFormatException e) { throw new IllegalArgumentException("The parameter must begin with a number"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/web/WebPermissionMapping.java
catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); }
// in src/main/java/org/jboss/verifier/Section.java
catch ( ParseException e ) { throw new IllegalArgumentException( CONSTRUCTION_ERROR ); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchMethodException ee) { throw new IllegalArgumentException(ee+" in "+c); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchFieldException ee) { throw new IllegalArgumentException(ee+" in "+c); }
57
              
// in src/main/java/org/jboss/invocation/Invocation.java
public Object performCall(Object instance, Method m, Object[] arguments) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Exception { return m.invoke(instance,arguments); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (duration < 0) throw new IllegalArgumentException("duration is negative"); return createTimer(new Date(System.currentTimeMillis() + duration), 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialDuration < 0) throw new IllegalArgumentException("initial duration is negative"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); return createTimer(new Date(System.currentTimeMillis() + initialDuration), intervalDuration, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (expiration == null) throw new IllegalArgumentException("expiration is null"); return createTimer(expiration, 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object setPrimaryKeyValue(Object primaryKey, Object value) throws IllegalArgumentException { try { if(pkField != null) { // if we are trying to set a null value into a null pk, we are already done. if(value == null && primaryKey == null) { return null; } // if we don't have a pk object yet create one if(primaryKey == null) { primaryKey = pkClass.newInstance(); } // Set this field's value into the primary key object. pkField.set(primaryKey, value); return primaryKey; } else { // This field is the primary key, so no extraction is necessary. return value; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object loadArgumentResults(ResultSet rs, int parameterIndex) throws IllegalArgumentException { try { // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); if(javaTypes.length > 1) { throw new IllegalStateException("Complex types are not supported yet."); } JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); Object columnValue = null; for(int i = 0; i < javaTypes.length; i++) { columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); columnValue = jdbcType.setColumnValue(i, null, columnValue); } // retrun the updated parameterIndex return columnValue; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object getPrimaryKeyValue(Object primaryKey) throws IllegalArgumentException { try { if(pkField != null) { if(primaryKey == null) { return null; } return pkField.get(primaryKey); } else { return primaryKey; } } catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public Object getPrimaryKeyValue(Object primaryKey) throws IllegalArgumentException { try { if(primaryKeyField != null) { if(primaryKey == null) { return null; } // Extract this field's value from the primary key. return primaryKeyField.get(primaryKey); } else { // This field is the primary key, so no extraction is necessary. return primaryKey; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public Object setPrimaryKeyValue(Object primaryKey, Object value) throws IllegalArgumentException { try { if(primaryKeyField != null) { // if we are tring to set a null value // into a null pk, we are already done. if(value == null && primaryKey == null) { return null; } // if we don't have a pk object yet create one if(primaryKey == null) { primaryKey = primaryKeyClass.newInstance(); } // Set this field's value into the primary key object. primaryKeyField.set(primaryKey, value); return primaryKey; } else { // This field is the primary key, so no extraction is necessary. return value; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int setPrimaryKeyParameters(PreparedStatement ps, int parameterIndex, Object primaryKey) throws IllegalArgumentException { Object primaryKeyValue = getPrimaryKeyValue(primaryKey); return setArgumentParameters(ps, parameterIndex, primaryKeyValue); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int loadPrimaryKeyResults(ResultSet rs, int parameterIndex, Object[] pkRef) throws IllegalArgumentException { // value of this field, will be filled in below Object[] argumentRef = new Object[1]; parameterIndex = loadArgumentResults(rs, parameterIndex, argumentRef, true); // set the value of this field into the pk pkRef[0] = argumentRef[0] == null ? null : setPrimaryKeyValue(pkRef[0], argumentRef[0]); // retrun the updated parameterIndex return parameterIndex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef) throws IllegalArgumentException { return loadArgumentResults(rs, parameterIndex, argumentRef, false); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
private int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef, boolean nullColumnNullifiesResult) throws IllegalArgumentException { try { // value of this field, will be filled in below // set the value of this field into the pk argumentRef[0] = null; // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); for(int i = 0; i < javaTypes.length; i++) { Object columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); if(nullColumnNullifiesResult && columnValue == null) { argumentRef[0] = null; parameterIndex += javaTypes.length - i - 1; break; } argumentRef[0] = jdbcType.setColumnValue(i, argumentRef[0], columnValue); } // retrun the updated parameterIndex return parameterIndex; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/as/naming/javaee/NamingJavaEEApplicationInformer.java
public String getApplicationName(DeploymentUnit deploymentUnit) throws IllegalArgumentException { if(!isJavaEEApplication(deploymentUnit)) return null; // JBAS-8528 String explicitAppName = this.getExplicitApplicationName(deploymentUnit); if (explicitAppName != null) { return explicitAppName; } String name = deploymentUnit.getSimpleName(); // prevent StringIndexOutOfBoundsException and only cut when there is a typical extension return stripSuffix(name); }
(Lib) UnsupportedOperationException 64
              
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) { throw new UnsupportedOperationException("createCalendarTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) { throw new UnsupportedOperationException("createCalendarTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, Serializable info) { throw new UnsupportedOperationException("createCalendarTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) { throw new UnsupportedOperationException("createIntervalTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) { throw new UnsupportedOperationException("createIntervalTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public ScheduleExpression getSchedule() { throw new UnsupportedOperationException("getSchedule: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public boolean isCalendarTimer() { throw new UnsupportedOperationException("isCalendarTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public boolean isPersistent() { throw new UnsupportedOperationException("isPersistent: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public boolean wasCancelCalled() { throw new UnsupportedOperationException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public long getPassivatedCount() { if (! (instanceCache instanceof StatefulSessionInstanceCache)) throw new UnsupportedOperationException(); return ((StatefulSessionInstanceCache)instanceCache).getPassivatedCount(); }
// in src/main/java/org/jboss/ejb/Container.java
protected InstancePool getInstancePool() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public boolean wasCancelCalled() { throw new UnsupportedOperationException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public Map<String, Object> getContextData() { // TODO: implement throw new UnsupportedOperationException("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public void resetPersistenceContext(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public int setInstanceParameters(PreparedStatement ps, int parameterIndex, EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object getInstanceValue(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public void setInstanceValue(EntityEnterpriseContext ctx, Object value) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public int loadInstanceResults(ResultSet rs, int parameterIndex, EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public boolean isDirty(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public void setClean(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public boolean isReadOnly() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public boolean isReadTimedOut(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public boolean isLoaded(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public String getTableName() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public JDBCType getJDBCType() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean isPrimaryKeyMember() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean isReadOnly() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean isReadTimedOut(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean isLoaded(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void resetPersistenceContext(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public int setInstanceParameters(PreparedStatement ps, int parameterIndex, EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public Object getInstanceValue(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void setInstanceValue(EntityEnterpriseContext ctx, Object value) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public int loadInstanceResults(ResultSet rs, int parameterIndex, EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void setClean(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public boolean[] getLoadGroupMask(String eagerLoadGroupName) { // todo throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTIdentifier node, Object data) { throw new UnsupportedOperationException("Must not visit ASTIdentifier noe."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object getParameter(Logger log, CallableStatement cs, int index, int jdbcType, Class destination) throws SQLException { Object value = null; switch(jdbcType) { // // Large types // case Types.CLOB: case Types.LONGVARCHAR: case Types.BLOB: case Types.LONGVARBINARY: throw new UnsupportedOperationException(); // // Small binary types // case Types.BINARY: case Types.VARBINARY: { byte[] bytes = cs.getBytes(index); if(!cs.wasNull()) { if(destination == byte[].class) value = bytes; else value = convertToObject(bytes); } if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Binary, value=" + value); } } break; // // Specialist types that the // driver should handle // case Types.JAVA_OBJECT: case Types.STRUCT: case Types.ARRAY: case Types.OTHER: { value = cs.getObject(index); if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Object, value=" + value); } } break; // // Non-binary types // default: Method method = (Method)csTypes.get(destination.getName()); if(method != null) { try { value = method.invoke(cs, new Object[]{new Integer(index)}); if(cs.wasNull()) { value = null; } if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Simple, value=" + value); } } catch(IllegalAccessException e) { // Whatever, I guess non-binary will not work for this field. } catch(InvocationTargetException e) { // Whatever, I guess non-binary will not work for this field. } } else { value = cs.getObject(index); if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Object, value=" + value); } } } return coerceToJavaType(value, destination); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public InputStream getBinaryStream(long pos, long length) throws SQLException { throw new UnsupportedOperationException("Unimplemented JDK6 method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public OutputStream setBinaryStream(long pos) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public int setBytes(long pos, byte[] bytes) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public int setBytes(long pos, byte[] bytes, int offset, int length) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public void truncate(long length) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTLimitOffset node, Object data) { int child = 0; if(node.hasOffset) { Node offsetNode = node.jjtGetChild(child++); if(offsetNode instanceof ASTParameter) { ASTParameter param = (ASTParameter) offsetNode; Class parameterType = getParameterType(param.number); if(int.class != parameterType && Integer.class != parameterType) { throw new UnsupportedOperationException("OFFSET parameter must be an int"); } offsetParam = param.number; } else { ASTExactNumericLiteral param = (ASTExactNumericLiteral) offsetNode; offsetValue = (int) param.value; } } if(node.hasLimit) { Node limitNode = node.jjtGetChild(child); if(limitNode instanceof ASTParameter) { ASTParameter param = (ASTParameter) limitNode; Class parameterType = getParameterType(param.number); if(int.class != parameterType && Integer.class != parameterType) { throw new UnsupportedOperationException("LIMIT parameter must be an int"); } limitParam = param.number; } else { ASTExactNumericLiteral param = (ASTExactNumericLiteral) limitNode; limitValue = (int) param.value; } } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void remove() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void removeAll() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setClean(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Object getColumnValue(int index, Object value) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Object setColumnValue(int index, Object value, Object columnValue) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public boolean hasMapper() { throw new UnsupportedOperationException("hasMapper is not implemented."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public boolean isSearchable() { throw new UnsupportedOperationException("isSearchable is not implemented."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public JDBCResultSetReader[] getResultSetReaders() { // foreign key fields has their result set readers throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public JDBCParameterSetter[] getParameterSetter() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public RelationData getRelationData() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMRFieldBridge.java
public Object getPrimaryKeyValue(Object o) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
public Object getLockedValue(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException("Optimistic locking is not supported in CMP1.1."); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void invokeEjbStore(Thread thread, EntityEnterpriseContext instance) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public boolean isIdentical(Container container, Invocation mi) { throw new UnsupportedOperationException("TODO provide a default implementation"); }
0 0
(Lib) RuntimeException 45
              
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
protected void startService() throws Exception { log.debug("Starting unified invoker service."); InvokerLocator locator = null; if(serverInvoker != null) { locator = serverInvoker.getLocator(); if(!serverInvoker.isStarted()) { serverInvoker.start(); } } else if(connector != null) { locator = connector.getLocator(); } else { /** * This will happen in one of two scenarios. One, the unified invoker was not declared in as * service before the connector AND was not specified as the handler within the connector config. * Two, the unified invoker service config did not use the proxy-type attribute within the depends * tag to have the container set the connector upon creating the unified invoker. */ log.error("Error referencing either remoting connector or server invoker to be used. " + "Please check configuration to make sure proper dependancies are set."); throw new RuntimeException("Error getting locator because server invoker is null."); } proxy = new UnifiedInvokerProxy(locator, strictRMIException); jmxBind(); }
// in src/main/java/org/jboss/deployment/EARStructure.java
public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException { ContextInfo context; boolean valid; boolean trace = log.isTraceEnabled(); VirtualFile file = structureContext.getFile(); try { if (hasValidName(file) == false) return false; context = createContext(structureContext, "META-INF"); context.setComparatorClassName(comparatorClassName); VirtualFile applicationXml = getMetaDataFile(file, "META-INF/application.xml"); VirtualFile jbossAppXml = getMetaDataFile(file, "META-INF/jboss-app.xml"); VirtualFile lib; boolean scan = true; Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setValidation(useValidation); EarMetaData specMetaData = null; JBossAppMetaData appMetaData = null; if (applicationXml != null) { InputStream in = applicationXml.openStream(); try { specMetaData = (EarMetaData) unmarshaller.unmarshal(in, resolver); } finally { in.close(); } scan = false; } if (jbossAppXml != null) { InputStream in = jbossAppXml.openStream(); try { appMetaData = (JBossAppMetaData) unmarshaller.unmarshal(in, resolver); } finally { in.close(); } } // Need a metadata instance and there will not be one if there are no descriptors if (appMetaData == null) { appMetaData = new JBossAppMetaData(); } // Create the merged view appMetaData.merge(appMetaData, specMetaData); String libDir = appMetaData.getLibraryDirectory(); if (libDir == null || libDir.length() > 0) { if (libDir == null) libDir = "lib"; // Add the ear lib contents to the classpath if(trace) log.trace("Checking for ear lib directory: "+libDir); try { lib = file.getChild(libDir); if (lib.exists()) { if(trace) log.trace("Found ear lib directory: "+lib); List<VirtualFile> archives = lib.getChildren(earLibFilter); for (VirtualFile archive : archives) { Automounter.mount(file, archive); addClassPath(structureContext, archive, true, true, context); // add any jars with persistence.xml as a deployment VirtualFile child = archive.getChild("META-INF/persistence.xml"); if (child.exists()) { log.trace(archive.getName() + " in ear lib directory has persistence units"); addMetaDataPath(structureContext, context, child.getParent().getPathNameRelativeTo(file), MetaDataType.ALTERNATIVE); } else if (trace) log.trace(archive.getPathName() + " does not contain META-INF/persistence.xml"); } } else if (trace) log.trace("No lib directory in ear archive."); } catch (IOException e) { // TODO - should we throw this fwd? log.warn("Exception while searching for lib dir: " + e); } } else if (trace) { log.trace("Ignoring library directory, got empty library-directory element."); } // Add the ear manifest locations? addClassPath(structureContext, file, includeEarRootInClasspath, true, context); // TODO: need to scan for annotationss if( scan ) { scanEar(file, appMetaData); } // Create subdeployments for the ear modules ModulesMetaData modules = appMetaData.getModules(); if(modules != null) { for (ModuleMetaData mod : modules) { String fileName = mod.getFileName(); if (fileName != null && (fileName = fileName.trim()).length() > 0) { if (log.isTraceEnabled()) log.trace("Checking application.xml module: " + fileName); VirtualFile module = file.getChild(fileName); if (module.exists() == false) { throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + file.toURI()); } // Ask the deployers to analyze this if(structureContext.determineChildStructure(module) == false) { throw new RuntimeException(fileName + " module listed in application.xml is not a recognized deployment, .ear: " + file.getName()); } } } if (appMetaData.getModuleOrderEnum() == ModuleOrder.STRICT || (specMetaData instanceof Ear6xMetaData && ((Ear6xMetaData)specMetaData).getInitializeInOrder())) { context.setComparatorClassName(RelativeDeploymentContextComparator.class.getName()); int i = 0; for (ContextInfo ctx : structureContext.getMetaData().getContexts()) { ctx.setRelativeOrder(i++); } } } valid = true; } catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); } return valid; }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
protected void deploy(VFSDeploymentUnit unit, VirtualFile root, VirtualFile file) { try { JBossAppMetaData j2eeMetaData = new JBoss50AppMetaData(); // TODO: need to scan for annotationss scanEar(unit, file, j2eeMetaData); unit.addAttachment(JBossAppMetaData.class, j2eeMetaData); } catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); } }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { PolicyConfiguration pc = unit.getAttachment(PolicyConfiguration.class); if (pc == null) return; DeploymentUnit parent = unit.getParent(); if (parent == null) throw new IllegalStateException("Unit has not parent: " + unit); PolicyConfiguration parentPc = parent.getAttachment(PolicyConfiguration.class); try { if (parentPc != null && pc != parentPc) { parentPc.linkConfiguration(pc); } pc.commit(); } catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); } }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { boolean accepted = false; for (String accept : acceptedAttachments) { if (unit.isAttachmentPresent(accept)) { accepted = true; break; } } if (accepted == false) return; String contextID = unit.getName(); PolicyConfiguration pc = null; try { PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); pc = pcFactory.getPolicyConfiguration(contextID, true); } catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); } unit.addAttachment(PolicyConfiguration.class, pc); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
public void create() { try { createPolicyConfiguration(); } catch (Exception e) { throw new RuntimeException(e); } if(this.standaloneDeployment == Boolean.TRUE) { try { if (metaData != null) createPermissions(metaData,parentPC); else log.warn("Cannot create permissions with 'null' metaData for id=" + contextID); } catch (PolicyContextException e) { throw new RuntimeException("Cannot create permissions:",e); } } if(trace) log.trace("create():" + this.contextID); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
public void stop() { try { //The linked PCs will delete themselves via the PolicyConfigurationFacade this.parentPC.delete(); } catch (PolicyContextException e) { throw new RuntimeException(e); } if(trace) log.trace("stop():" + this.contextID); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
protected void createPermissions(T metaData, PolicyConfiguration policyConfiguration) throws PolicyContextException { throw new RuntimeException("Need to override"); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { T metaData = unit.getAttachment(getMetaDataClassType()); if (metaData == null) return; String contextId = unit.getSimpleName(); // Is the war the top level deployment? // DeploymentUnit topUnit = unit.getTopLevel(); if (unit.getParent() == null || getParentJaccPolicyBean(unit) == null) { createTopLevelServiceBeanWithMetaData(contextId, unit, metaData); } else { ServiceMetaData subjaccPolicy = getServiceMetaData(); String deploymentName = unit.getSimpleName(); try { subjaccPolicy.setObjectName(new ObjectName(getObjectName(unit))); } catch (Exception e) { throw new RuntimeException(e); } // Provide a constructor for the service bean ServiceConstructorMetaData serviceConstructor = new ServiceConstructorMetaData(); serviceConstructor.setSignature(new String[]{String.class.getName(), getMetaDataClassType().getName()}); serviceConstructor.setParameters(new Object[]{deploymentName, metaData}); subjaccPolicy.setConstructor(serviceConstructor); ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>(); services.add(subjaccPolicy); unit.addAttachment(JACC_ATTACHMENT_NAME, subjaccPolicy, ServiceMetaData.class); // Add a dependence into the parent JaccPolicy ServiceMetaData parentServiceMetaData = this.getParentJaccPolicyBean(unit); if (parentServiceMetaData != null) { ServiceDependencyMetaData serviceDependencyMetaData = new ServiceDependencyMetaData(); serviceDependencyMetaData.setIDependOnObjectName(subjaccPolicy.getObjectName()); parentServiceMetaData.addDependency(serviceDependencyMetaData); // Add an attribute in the parent service ServiceAttributeMetaData serviceAttributeMetaData = new ServiceAttributeMetaData(); serviceAttributeMetaData.setName("PolicyConfigurationFacadeMBean"); ServiceDependencyValueMetaData dependencyValue = new ServiceDependencyValueMetaData(); dependencyValue.setDependency(subjaccPolicy.getObjectName().toString()); dependencyValue.setProxyType("attribute"); serviceAttributeMetaData.setValue(dependencyValue); parentServiceMetaData.addAttribute(serviceAttributeMetaData); } } /** Register XACML/ACL policies if present in the deployment */ if(this.policyRegistration != null) { String xacmlType = PolicyRegistration.XACML; JAXBElement<?> policyConfig = (JAXBElement<?>) unit.getAttachment(XACML_ATTACHMENT_NAME); if(policyConfig != null) this.policyRegistration.registerPolicyConfig(contextId, xacmlType, policyConfig); String aclType = PolicyRegistration.ACL; ACLConfiguration aclConfig = (ACLConfiguration) unit.getAttachment(ACLConfiguration.class.getName()); if(aclConfig != null) this.policyRegistration.registerPolicyConfig(contextId, aclType, aclConfig); } }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
private void createJaccPolicyBean(ServiceConstructorMetaData serviceConstructor, DeploymentUnit unit) { // Create a Service Bean for the JACC Policy ServiceMetaData jaccPolicy = new ServiceMetaData(); jaccPolicy.setCode(getJaccPolicyName()); try { jaccPolicy.setObjectName(new ObjectName(getObjectName(unit))); } catch (Exception e) { throw new RuntimeException(e); } // Provide a constructor for the service bean jaccPolicy.setConstructor(serviceConstructor); ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>(); services.add(jaccPolicy); unit.addAttachment(JACC_ATTACHMENT_NAME, jaccPolicy, ServiceMetaData.class); }
// in src/main/java/org/jboss/naming/NamingService.java
protected void startService() throws Exception { boolean debug = log.isDebugEnabled(); // Read jndi.properties into system properties ClassLoader loader = Thread.currentThread().getContextClassLoader(); InputStream is = loader.getResourceAsStream("jndi.properties"); if (is == null) throw new RuntimeException("Cannot find jndi.properties, it should be at conf/jndi.properties by default."); Properties props = new Properties(); try { props.load(is); } finally { is.close(); } for (Enumeration keys = props.propertyNames(); keys.hasMoreElements(); ) { String key = (String) keys.nextElement(); String value = props.getProperty(key); if (debug) { log.debug("System.setProperty, key="+key+", value="+value); } System.setProperty(key, value); } if( proxyFactory != null ) namingMain.setNamingProxy(proxyFactory.getProxy()); if( startNamingBean ) namingMain.start(); // Build the Naming interface method map HashMap tmpMap = new HashMap(13); Method[] methods = Naming.class.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
private synchronized void createSession() { // Destroy any old session. if (session != null) destroySession(); try { // Get a reference to the UT session factory. UserTransactionSessionFactory factory; Hashtable env = (Hashtable) NamingContextFactory.lastInitialContextEnv.get(); InitialContext ctx = new InitialContext(env); factory = (UserTransactionSessionFactory) ctx.lookup("UserTransactionSessionFactory"); // Call factory to get a UT session. session = factory.newInstance(); } catch (Exception ex) { throw new RuntimeException("UT factory lookup failed", ex); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public static EJBTimerService getEjbTimerService() { try { // First try the MBean server MBeanServer server = MBeanServerLocator.locateJBoss(); if (server != null && server.isRegistered(EJBTimerService.OBJECT_NAME)) ejbTimerService = new MBeanDelegate(server); } catch (Exception ignore) { } // This path can be used for standalone test cases if (ejbTimerService == null) { EJBTimerServiceImpl ejbTimerServiceImpl = new EJBTimerServiceImpl(); ejbTimerService = ejbTimerServiceImpl; try { ejbTimerServiceImpl.create(); ejbTimerServiceImpl.start(); } catch (Exception e) { throw new RuntimeException("Cannot start EJBTimerService", e); } } return ejbTimerService; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Object getBusinessObject(Class businessInterface) throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Class getInvokedBusinessInterface() throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/Container.java
public ObjectName getJmxName() { if (jmxName == null) { BeanMetaData beanMetaData = getBeanMetaData(); if (beanMetaData == null) { throw new IllegalStateException("Container metaData is null"); } String jndiName = beanMetaData.getContainerObjectNameJndiName(); if (jndiName == null) { throw new IllegalStateException("Container jndiName is null"); } // The name must be escaped since the jndiName may be arbitrary String name = BASE_EJB_CONTAINER_NAME + ",jndiName=" + jndiName; try { jmxName = ObjectNameConverter.convert(name); } catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); } } return jmxName; }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public BeanLock getLock(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to get lock ref with a null object"); HashMap mapInUse = getHashMap(id); synchronized (mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock!=null) { lock.addRef(); return lock; } } try { BeanLock lock2 = (BeanLock)createLock(id); synchronized(mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); // in case of bad luck, this might happen if (lock != null) { lock.addRef(); return lock; } mapInUse.put(id, lock2); lock2.addRef(); return lock2; } } catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); } }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public Object getBusinessObject(Class businessInterface) throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public Class getInvokedBusinessInterface() throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
private InitialContext getContext() { if (ctx==null) { try { ctx = new InitialContext(); } catch (NamingException e) { throw new RuntimeException(e); } } return ctx; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public Object invokeHome(Invocation invocation) throws Exception { Transaction oldTransaction = invocation.getTransaction(); for (int i = 0; i < MAX_RETRIES; i++) { try { return runWithTransactions(invocation); } catch (Exception ex) { checkRetryable(i, ex, oldTransaction); } } throw new RuntimeException("Unreachable"); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public Object invoke(Invocation invocation) throws Exception { Transaction oldTransaction = invocation.getTransaction(); for (int i = 0; i < MAX_RETRIES; i++) { try { return runWithTransactions(invocation); } catch (Exception ex) { checkRetryable(i, ex, oldTransaction); } } throw new RuntimeException("Unreachable"); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean doSchedule(Invocation mi) throws Exception { boolean wasThreadScheduled = false; Transaction miTx = mi.getTransaction(); boolean trace = log.isTraceEnabled(); this.sync(); try { if (trace) log.trace("Begin schedule, key=" + mi.getId()); if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } //Next test is independent of whether the context is locked or not, it is purely transactional // Is the instance involved with another transaction? if so we implement pessimistic locking long startWait = System.currentTimeMillis(); try { wasThreadScheduled = waitForTx(miTx, trace); if (wasThreadScheduled && lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } } catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; } } finally { if (miTx == null // non-transactional && wasThreadScheduled) { // if this non-transctional thread was // scheduled in txWaitQueue, we need to call nextTransaction // Otherwise, threads in txWaitQueue will never wake up. nextTransaction(); } this.releaseSync(); } //If we reach here we are properly scheduled to go through so return true return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean waitForTx(Transaction miTx, boolean trace) throws Exception { boolean intr = false; try { boolean wasScheduled = false; // Do we have a running transaction with the context? // We loop here until either until success or until transaction timeout // If we get out of the loop successfully, we can successfully // set the transaction on this puppy. TxLock txLock = null; Object deadlocker = miTx; if (deadlocker == null) deadlocker = Thread.currentThread(); while (getTransaction() != null && // And are we trying to enter with another transaction? !getTransaction().equals(miTx)) { // Check for a deadlock on every cycle try { if( deadlockDetection == true ) DeadlockDetector.singleton.deadlockDetection(deadlocker, this); } catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; } wasScheduled = true; if (lockMonitor != null) lockMonitor.contending(); // That's no good, only one transaction per context // Let's put the thread to sleep the transaction demarcation will wake them up if (trace) log.trace("Transactional contention on context" + id); // Only queue the lock on the first iteration if (txLock == null) txLock = getTxLock(miTx); if (trace) log.trace("Begin wait on Tx=" + getTransaction()); // And lock the threads on the lock corresponding to the Tx in MI synchronized (txLock) { releaseSync(); try { txLock.wait(txTimeout); } catch (InterruptedException ignored) { intr = true; } } // end synchronized(txLock) this.sync(); if (trace) log.trace("End wait on TxLock=" + getTransaction()); if (isTxExpired(miTx)) { log.error(Thread.currentThread() + "Saw rolled back tx=" + miTx + " waiting for txLock" // +" On method: " + mi.getMethod().getName() // +" txWaitQueue size: " + txWaitQueue.size() ); if (txLock.isQueued) { // Remove the TxLock from the queue because this thread is exiting. // Don't worry about notifying other threads that share the same transaction. // They will timeout and throw the below RuntimeException txLocks.remove(txLock); txWaitQueue.remove(txLock); } else if (getTransaction() != null && getTransaction().equals(miTx)) { // We're not qu nextTransaction(); } if (miTx != null) { if( deadlockDetection == true ) DeadlockDetector.singleton.removeWaiting(deadlocker); } throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } // end while(tx!=miTx) // If we get here, this means that we have the txlock if (!wasScheduled) { setTransaction(miTx); } return wasScheduled; } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); boolean nonReentrant = !(reentrant || isReentrantMethod(mi)); // Not a reentrant method like getPrimaryKey NonReentrantLock methodLock = ctx.getMethodLock(); Transaction miTx = ctx.getTransaction(); boolean locked = false; try { while (!locked) { if (methodLock.attempt(5000, miTx, nonReentrant)) { locked = true; } else { if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } } } catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } } try { ctx.lock(); return getNext().invoke(mi); } finally { ctx.unlock(); methodLock.release(nonReentrant); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(SimpleNode node, Object data) { throw new RuntimeException("Internal error: Found unknown node type in " + "EJB-QL abstract syntax tree: node=" + node); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(SimpleNode node, Object data) { throw new RuntimeException("Internal error: Found unknown node type in " + "EJB-QL abstract syntax tree: node=" + node); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
public void setAcknowledgeMode (int ackMode) { if (ackMode > 3 || ackMode < 1) throw new RuntimeException ("Value AcknowledgeMode must be between 1 and 3"); switch (ackMode) { case 1: this.acknowledgeMode = TopicSession.AUTO_ACKNOWLEDGE; break; case 2: this.acknowledgeMode = TopicSession.CLIENT_ACKNOWLEDGE; break; case 3: this.acknowledgeMode = TopicSession.DUPS_OK_ACKNOWLEDGE; break; } }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
public void setPropagationMode (int propMode) { if (propMode > 3 || propMode < 1) throw new RuntimeException ("Value PropagationMode must be between 1 and 3"); this.propagationMode = propMode; }
// in src/main/java/org/jboss/proxy/compiler/ProxyCompiler.java
public byte[] getCode() { boolean trace = log.isTraceEnabled(); final String proxyClassName = getProxyClassName(); final String superClassName = superclass.getName(); int icount = 1; // don't forget ProxyTarget for (int i = 0; i < targetTypes.length; i++) { Class targetType = targetTypes[i]; if (targetType.isInterface()) { icount++; } } String interfaceNames[] = new String[icount]; interfaceNames[0] = Proxies.ProxyTarget.class.getName(); icount = 1; for (int i = 0; i < targetTypes.length; i++) { Class targetType = targetTypes[i]; if (targetType.isInterface()) { interfaceNames[icount++] = targetType.getName(); } else if (!superclass.isAssignableFrom(targetType)) { throw new RuntimeException("unexpected: " + targetType); } } ClassGen cg = new ClassGen(proxyClassName, superClassName, "<generated>", Constants.ACC_PUBLIC | Constants.ACC_FINAL, interfaceNames); ProxyImplementationFactory factory = new ProxyImplementationFactory(superClassName, proxyClassName, cg); cg.addField(factory.createInvocationHandlerField()); cg.addField(factory.createRuntimeField()); cg.addMethod(factory.createConstructor()); // ProxyTarget implementation cg.addMethod(factory.createGetInvocationHandler()); cg.addMethod(factory.createGetTargetTypes()); boolean haveToString = false; if (trace) log.trace("Creating proxy methods..."); // Implement the methods of the target types. for (int i = 0; i < methods.length; i++) { Method m = methods[i]; if (trace) log.trace("Reflected method: " + m); String name = m.getName(); Class rTypeClass = m.getReturnType(); String rTypeName = rTypeClass.getName(); Type rType = Utility.getType(rTypeClass); Type[] pTypes = Utility.getTypes(m.getParameterTypes()); String[] exceptionNames = getNames(m.getExceptionTypes()); if (name.equals("toString") && pTypes.length == 0) { haveToString = true; } org.apache.bcel.classfile.Method proxyMethod = factory.createProxyMethod(name, i, rType, pTypes, exceptionNames); if (trace) log.trace("Created proxy method: " + proxyMethod); cg.addMethod(proxyMethod); } if (!haveToString) { cg.addMethod(factory.createToString()); } JavaClass jclass = cg.getJavaClass(); if (trace) log.trace("Generated Java class: " + jclass); // dump the class if we have been configured todo so if (CLASS_DUMP_PATH != null) { try { String filename = CLASS_DUMP_PATH + java.io.File.separator + proxyClassName + ".class"; log.info("Dumping generated proxy class to " + filename); jclass.dump(filename); } catch (Exception e) { log.error("Failed to dump class file", e); } } return jclass.getBytes(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public short getUtfIndex(String x) { Object n = ut.get(x); if (n == null) { n = new Short(cn++); ut.put(x, n); int xlen = 2 + x.length(); // x.utfLength(), really ByteArrayOutputStream bytes = new ByteArrayOutputStream(xlen); DataOutputStream ds = new DataOutputStream(bytes); try { ds.writeByte(CONSTANT_UTF8); ds.writeUTF(x); } catch (IOException ee) { throw new RuntimeException(ee.toString()); } cv.addElement(bytes.toByteArray()); } return ((Short)n).shortValue(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public void pushConstant(Object x) { int op = opc_ldc_w; if (x instanceof Integer) { declare(Integer.TYPE); int v = ((Integer)x).intValue(); if (v >= -1 && v <= 5) { code.write(opc_iconst_0 + v); return; } else if ((v > -(1 << 7)) && (v < (1 << 7))) { code.write(opc_bipush); code.write(v); return; } else if ((v > -(1 << 15)) && (v < (1 << 15))) { code.write(opc_sipush); codeShort(v); return; } } else if (x instanceof Float) { declare(Float.TYPE); } else if (x instanceof String) { declare(String.class); } else if (x instanceof Long) { declare(Long.TYPE); op = opc_ldc2_w; } else if (x instanceof Double) { declare(Double.TYPE); op = opc_ldc2_w; } else { throw new RuntimeException("unexpected: "+x); } int xi = getIndex(x); if (op == opc_ldc_w && xi < (1 << 8)) { code.write(opc_ldc); code.write(xi); } else { code.write(op); codeShort(xi); } }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public byte[] getCode() { try { return internalGetCode(); } catch (IOException ee) { throw new RuntimeException(ee.toString()); } }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public byte[] internalGetCode() throws IOException { // first, flush out all references to the cpool getIndex(this); getIndex(superClass); for (int i = 0; i < interfaces.length; i++) { getIndex(interfaces[i]); } int nfields = 0; int nmethods = 0; for (int i = 0; i < members.size(); i++) { AMember m = (AMember) members.elementAt(i); if (m.code != null) { byte[] codeAttr = getMethodCode(m, m.code); if (codeAttr != null) { addAttribute(m, "Code", codeAttr); } } for (int j = 0; j < m.attr.size(); j++) { Attr a = (Attr) m.attr.elementAt(j); getUtfIndex(a.name); } if (m.name.length() == 0) { continue; } getUtfIndex(m.name); getUtfIndex(m.sig); if (isMethodSig(m.sig)) { nmethods += 1; } else { nfields += 1; } } // next, deal with internal references in the cpool for (int i = 0; i < cv.size(); i++) { Object x = cv.elementAt(i); if (x == null) { continue; } else if (x instanceof String) { String s = (String)x; short si = getUtfIndex(s); short data[] = { CONSTANT_STRING, si }; x = data; } else if (x instanceof Class) { Class c = (Class)x; short ci = getUtfIndex(c.getName().replace('.', '/')); short data[] = { CONSTANT_CLASS, ci }; x = data; } else if (x instanceof Field) { Field m = (Field)x; short ci = getIndex(m.getDeclaringClass()); short nt = getNTIndex(m.getName(), getSig(m.getType())); short data[] = { CONSTANT_FIELD, ci, nt }; x = data; } else if (x instanceof Constructor) { Constructor m = (Constructor)x; short ci = getIndex(m.getDeclaringClass()); short nt = getNTIndex("<init>", getSig(Void.TYPE, m.getParameterTypes())); short data[] = { CONSTANT_METHOD, ci, nt }; x = data; } else if (x instanceof Method) { Method m = (Method)x; Class c = m.getDeclaringClass(); short kind = c.isInterface() ? CONSTANT_INTERFACEMETHOD : CONSTANT_METHOD; short ci = getIndex(c); short nt = getNTIndex(m.getName(), getSig(m.getReturnType(), m.getParameterTypes())); short data[] = { kind, ci, nt }; x = data; } else if (x instanceof ProxyAssembler) { ProxyAssembler asm = (ProxyAssembler)x; short ci = getUtfIndex(asm.className.replace('.', '/')); short data[] = { CONSTANT_CLASS, ci }; x = data; } else if (x instanceof AMember) { AMember m = (AMember) x; short kind = !isMethodSig(m.sig) ? CONSTANT_FIELD : m.asm.isInterface() ? CONSTANT_INTERFACEMETHOD : CONSTANT_METHOD; short ci = getIndex(m.asm); short nt = getNTIndex(m.name, m.sig); short data[] = { kind, ci, nt }; x = data; } else if (x instanceof NameAndType) { NameAndType nt = (NameAndType) x; short data[] = { CONSTANT_NAMEANDTYPE, nt.name, nt.sig }; x = data; } cv.setElementAt(x, i); // update } ByteArrayOutputStream bytes = new ByteArrayOutputStream(400); DataOutputStream ds = new DataOutputStream(bytes); ds.writeInt(JAVA_MAGIC); ds.writeShort(JAVA_MINOR_VERSION); ds.writeShort(JAVA_VERSION); int cvsize = cv.size(); ds.writeShort(cvsize); for (int i = 0; i < cv.size(); i++) { Object x = cv.elementAt(i); if (x == null) { continue; } else if (x instanceof short[]) { short data[] = (short[])x; ds.writeByte(data[0]); for (int j = 1; j < data.length; j++) { ds.writeShort(data[j]); } } else if (x instanceof byte[]) { ds.write((byte[])x); } else if (x instanceof Integer) { ds.writeByte(CONSTANT_INTEGER); ds.writeInt(((Integer)x).intValue()); // (do other primitive literal types?) } else { throw new RuntimeException("unexpected"); } } ds.writeShort(modifiers); ds.writeShort(getIndex(this)); ds.writeShort(getIndex(superClass)); ds.writeShort(interfaces.length); for (int i = 0; i < interfaces.length; i++) { ds.writeShort(getIndex(interfaces[i])); } for (int pass = 0; pass <= 1; pass++) { boolean methods = (pass > 0); ds.writeShort(methods ? nmethods : nfields); for (int i = 0; i < members.size(); i++) { AMember m = (AMember) members.elementAt(i); if (m.name.length() == 0 || isMethodSig(m.sig) != methods) { continue; } ds.writeShort(m.mods); ds.writeShort(getUtfIndex(m.name)); ds.writeShort(getUtfIndex(m.sig)); writeAttrs(ds, m.attr); } } AMember m0 = (AMember) members.elementAt(0); writeAttrs(ds, (Vector) m0.attr); // sanity check if (cvsize != cv.size()) { throw new RuntimeException("cvsize"); } return bytes.toByteArray(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
private void writeAttrs(DataOutputStream ds, Vector attrs) throws IOException { ds.writeShort(attrs.size()); for (int i = 0; i < attrs.size(); i++) { Attr a = (Attr) attrs.elementAt(i); ds.writeShort(getUtfIndex(a.name)); if (a.data instanceof byte[]) { byte[] xa = (byte[])a.data; ds.writeInt(xa.length); ds.write(xa); } else { throw new RuntimeException("unexpected"); } } }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
public Class getPrimaryKeyClass() { if (session == true) throw new RuntimeException("A session bean does not have a primary key class"); return pkClass; }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public void create() throws Exception { jmxName = container.getJmxName(); jmxNameHash = jmxName.hashCode(); jmxNameHashInteger = new Integer(jmxNameHash); // Create metadata BeanMetaData bmd = container.getBeanMetaData(); boolean isSession = !(bmd instanceof EntityMetaData); boolean isStatelessSession = false; if(isSession) { SessionMetaData smd = (SessionMetaData) bmd; if(bmd.getRemote() == null) { isServiceEndpointOnly = true; // nothing more to do return; } isStatelessSession = smd.isStateless(); } Class pkClass = null; if(!isSession) { EntityMetaData metaData = (EntityMetaData) bmd; String pkClassName = metaData.getPrimaryKeyClass(); try { if(pkClassName != null) { pkClass = container.getClassLoader().loadClass(pkClassName); } else { pkClass = container.getClassLoader() .loadClass(metaData.getEjbClass()) .getField(metaData.getPrimKeyField()) .getClass(); } } catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); } catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); } } ejbMetaData = new EJBMetaDataImpl( ((EJBProxyFactoryContainer) container).getRemoteClass(), ((EJBProxyFactoryContainer) container).getHomeClass(), pkClass, //null if not entity isSession, //Session isStatelessSession, //Stateless new HomeHandleImpl(jndiBinding) ); log.debug("Proxy Factory for " + jndiBinding + " initialized"); initInterceptorClasses(); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void setupInvokers() throws Exception { ObjectName oname = new ObjectName(invokerMetaData.getInvokerMBean()); Invoker invoker = (Invoker) Registry.lookup(oname); if(invoker == null) { throw new RuntimeException("invoker is null: " + oname); } homeInvoker = beanInvoker = invoker; }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
public Object createProxy(Object id, ObjectName targetName, ObjectName invokerName, String jndiName, String proxyBindingName, ArrayList interceptorClasses, ClassLoader loader, Class[] ifaces) { Invoker invoker = (Invoker) Registry.lookup(invokerName); if (invoker == null) throw new RuntimeException("Failed to find invoker for name: " + invokerName); return createProxy(id, targetName, invoker, jndiName, proxyBindingName, interceptorClasses, loader, ifaces, null); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
public Object createProxy(Object id, ObjectName targetName, Invoker invoker, String jndiName, String proxyBindingName, ArrayList interceptorClasses, ClassLoader loader, Class[] ifaces, HashMap ctx) { InvocationContext context; if (ctx != null) context = new InvocationContext(ctx); else context = new InvocationContext(); Integer nameHash = new Integer(targetName.hashCode()); if (log.isTraceEnabled()) { log.trace("Target name " + targetName + " and corresponding hash code" + nameHash); } context.setObjectName(nameHash); context.setCacheId(id); if( jndiName != null ) context.setValue(InvocationKey.JNDI_NAME, jndiName); if( invoker == null ) throw new RuntimeException("Null invoker given for name: " + targetName); context.setInvoker(invoker); if( proxyBindingName != null ) context.setInvokerProxyBinding(proxyBindingName); // If the IClientContainer interceptor was specified, use the ClientContainerEx boolean wantIClientAccess = false; for(int n = 0; wantIClientAccess == false && n < interceptorClasses.size(); n ++) { Class type = (Class) interceptorClasses.get(n); wantIClientAccess = type.isAssignableFrom(IClientContainer.class); } ClientContainer client; if( wantIClientAccess ) { client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } try { loadInterceptorChain(interceptorClasses, client); } catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); } ArrayList tmp = new ArrayList(Arrays.asList(ifaces)); Class[] ifaces2 = new Class[tmp.size()]; tmp.toArray(ifaces2); return Proxy.newProxyInstance( // Classloaders loader, // Interfaces ifaces2, // Client container as invocation handler client); }
18
              
// in src/main/java/org/jboss/deployment/EARStructure.java
catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException("Cannot create permissions:",e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception ex) { throw new RuntimeException("UT factory lookup failed", ex); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new RuntimeException("Cannot start EJBTimerService", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (NamingException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
0
(Lib) Error 21
              
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { throw new Error("invokeHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBObject createHome() throws java.rmi.RemoteException, CreateException { throw new Error("createHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Handle handle) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Object primaryKey) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBMetaData getEJBMetaDataHome() throws java.rmi.RemoteException { // TODO //return null; throw new Error("getEJBMetaDataHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public HomeHandle getHomeHandleHome() throws java.rmi.RemoteException { // TODO //return null; throw new Error("getHomeHandleHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invokeHome(Invocation mi) throws Exception { throw new Error("invokeHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public boolean isIdentical(Container container, Invocation mi) { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Object getEJBHome() { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public EJBMetaData getEJBMetaData() { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Collection getEntityCollection(Collection collection) { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Object getEntityEJBObject(Object id) { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Object getStatefulSessionEJBObject(Object id) { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Object getStatelessSessionEJBObject() { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Handle getHandle(Invocation mi) throws RemoteException { // TODO throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public HomeHandle getHomeHandleHome(Invocation mi) throws RemoteException { // TODO throw new Error("Not yet implemented"); }
0 0
(Lib) CreateException 20
              
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object createEntity (Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get (ctx.getInstance ()); // Check exist if (this.beans.containsKey (id)) throw new javax.ejb.DuplicateKeyException ("Already exists: "+id); // Store to file storeEntity (id, ctx.getInstance ()); return id; } catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object createEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get(ctx.getInstance()); // Check exist if (getFile(id).exists()) throw new DuplicateKeyException("Already exists: "+id); // Store to file storeEntity(id, ctx.getInstance()); return id; } catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { pk = entityBridge.extractPrimaryKeyFromInstance(ctx); if(pk == null) { throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void checkCreateAllowed() throws CreateException { if(!createAllowed) { throw new CreateException("Creation is not allowed because a primary key field is read only."); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void performInsert(EntityEnterpriseContext ctx) throws CreateException { Connection c = null; PreparedStatement ps = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { c = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; } } try { if(debug) log.debug("Executing SQL: " + insertSQL); // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { c = entity.getDataSource().getConnection(); } ps = prepareStatement(c, insertSQL, ctx); // set the parameters int index = 1; for(int fieldInd = 0; fieldInd < insertFields.length; ++fieldInd) { index = insertFields[fieldInd].setInstanceParameters(ps, index, ctx); } // execute statement int rowsAffected = executeInsert(index, ps, ctx); if(rowsAffected != 1) { throw new CreateException("Expected one affected row but update returned" + rowsAffected + " for id=" + ctx.getId()); } } catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } // Mark the inserted fields as clean. for(int fieldInd = 0; fieldInd < insertFields.length; ++fieldInd) { insertFields[fieldInd].setClean(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
protected void beforeInsert(EntityEnterpriseContext ctx) throws CreateException { // are we checking existance by query? if(existsSQL != null) { Connection c = null; PreparedStatement ps = null; ResultSet rs = null; try { if(debug) log.debug("Executing SQL: " + existsSQL); c = entity.getDataSource().getConnection(); ps = c.prepareStatement(existsSQL); // bind PK // @todo add a method to EntityBridge that binds pk fields directly Object pk = entity.extractPrimaryKeyFromInstance(ctx); entity.setPrimaryKeyParameters(ps, 1, pk); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("Error checking if entity with primary pk " + pk + "exists: SQL returned no rows"); } if(rs.getInt(1) > 0) { throw new DuplicateKeyException("Entity with primary key " + pk + " already exists"); } } catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object createEntity(Method createMethod, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk = createEntityCommand.execute(createMethod, args, ctx); if(pk == null) throw new CreateException("Primary key for created instance is null."); return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
protected void generateFields(EntityEnterpriseContext ctx) throws CreateException { super.generateFields(ctx); Connection con = null; Statement s = null; ResultSet rs = null; try { if(debug) { log.debug("Executing SQL: " + pkSQL); } DataSource dataSource = entity.getDataSource(); con = dataSource.getConnection(); s = con.createStatement(); rs = s.executeQuery(pkSQL); if(!rs.next()) { throw new CreateException("Error fetching next primary key value: result set contains no rows"); } pkField.loadInstanceResults(rs, 1, ctx); } catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); JDBCUtil.safeClose(con); } }
10
              
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); }
18
              
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBLocalObject createLocalHome() throws CreateException { if (localProxyFactory == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; return localProxyFactory.getStatelessSessionEJBLocalObject(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBObject createHome() throws RemoteException, CreateException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; Object obj = ci.getStatelessSessionEJBObject(); return (EJBObject) obj; }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBObject createHome() throws java.rmi.RemoteException, CreateException { throw new Error("createHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Object createEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { /* Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { pk = entityBridge.extractPrimaryKeyFromInstance(ctx); if(pk == null) { throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; */ return createCmd.execute(m, args, ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Object postCreateEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { pk = entityBridge.extractPrimaryKeyFromInstance(ctx); if(pk == null) { throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { // TODO: implement this logic nicer if(insertAfterEjbPostCreate) { if(!JDBCEntityBridge.isEjbCreateDone(ctx)) { checkCreateAllowed(); generateFields(ctx); JDBCEntityBridge.setEjbCreateDone(ctx); } else { beforeInsert(ctx); performInsert(ctx); afterInsert(ctx); JDBCEntityBridge.setCreated(ctx); } } else { checkCreateAllowed(); generateFields(ctx); beforeInsert(ctx); performInsert(ctx); afterInsert(ctx); JDBCEntityBridge.setCreated(ctx); } return getPrimaryKey(ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void checkCreateAllowed() throws CreateException { if(!createAllowed) { throw new CreateException("Creation is not allowed because a primary key field is read only."); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void generateFields(EntityEnterpriseContext ctx) throws CreateException { // Audit principal fields if(securityManager != null) { String principalName = ctx.getEJBContext().getCallerPrincipal().getName(); if(createdPrincipal != null && createdPrincipal.getInstanceValue(ctx) == null) { createdPrincipal.setInstanceValue(ctx, principalName); } /* if(updatedPrincipal != null && updatedPrincipal.getInstanceValue(ctx) == null) { updatedPrincipal.setInstanceValue(ctx, principalName); } */ } // Audit time fields Date date = null; if(createdTime != null && createdTime.getInstanceValue(ctx) == null) { date = new Date(); createdTime.setInstanceValue(ctx, date); } /* if(updatedTime != null && updatedTime.getInstanceValue(ctx) == null) { if(date == null) date = new Date(); updatedTime.setInstanceValue(ctx, date); } */ }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void beforeInsert(EntityEnterpriseContext ctx) throws CreateException { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void performInsert(EntityEnterpriseContext ctx) throws CreateException { Connection c = null; PreparedStatement ps = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { c = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; } } try { if(debug) log.debug("Executing SQL: " + insertSQL); // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { c = entity.getDataSource().getConnection(); } ps = prepareStatement(c, insertSQL, ctx); // set the parameters int index = 1; for(int fieldInd = 0; fieldInd < insertFields.length; ++fieldInd) { index = insertFields[fieldInd].setInstanceParameters(ps, index, ctx); } // execute statement int rowsAffected = executeInsert(index, ps, ctx); if(rowsAffected != 1) { throw new CreateException("Expected one affected row but update returned" + rowsAffected + " for id=" + ctx.getId()); } } catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } // Mark the inserted fields as clean. for(int fieldInd = 0; fieldInd < insertFields.length; ++fieldInd) { insertFields[fieldInd].setClean(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void afterInsert(EntityEnterpriseContext ctx) throws CreateException { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
protected void beforeInsert(EntityEnterpriseContext ctx) throws CreateException { // are we checking existance by query? if(existsSQL != null) { Connection c = null; PreparedStatement ps = null; ResultSet rs = null; try { if(debug) log.debug("Executing SQL: " + existsSQL); c = entity.getDataSource().getConnection(); ps = c.prepareStatement(existsSQL); // bind PK // @todo add a method to EntityBridge that binds pk fields directly Object pk = entity.extractPrimaryKeyFromInstance(ctx); entity.setPrimaryKeyParameters(ps, 1, pk); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("Error checking if entity with primary pk " + pk + "exists: SQL returned no rows"); } if(rs.getInt(1) > 0) { throw new DuplicateKeyException("Entity with primary key " + pk + " already exists"); } } catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object createEntity(Method createMethod, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk = createEntityCommand.execute(createMethod, args, ctx); if(pk == null) throw new CreateException("Primary key for created instance is null."); return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
protected void generateFields(EntityEnterpriseContext ctx) throws CreateException { super.generateFields(ctx); Object pk = keyGenerator.generateKey(); log.debug("Generated new pk: " + pk); pkField.setInstanceValue(ctx, pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
protected void generateFields(EntityEnterpriseContext ctx) throws CreateException { super.generateFields(ctx); Connection con = null; Statement s = null; ResultSet rs = null; try { if(debug) { log.debug("Executing SQL: " + pkSQL); } DataSource dataSource = entity.getDataSource(); con = dataSource.getConnection(); s = con.createStatement(); rs = s.executeQuery(pkSQL); if(!rs.next()) { throw new CreateException("Error fetching next primary key value: result set contains no rows"); } pkField.loadInstanceResults(rs, 1, ctx); } catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); JDBCUtil.safeClose(con); } }
(Lib) FinderException 20
              
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object findEntity (Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if (finderMethod.getName ().equals ("findByPrimaryKey")) { if (!this.beans.containsKey (args[0])) throw new javax.ejb.FinderException (args[0]+" does not exist"); return factory.getEntityEJBObject(args[0]); } return null; }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object findEntity(final Method finderMethod, final Object[] args, final EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { if (finderMethod.getName().equals("findByPrimaryKey")) { if (!getFile(args[0]).exists()) throw new FinderException(args[0]+" does not exist"); return factory.getEntityEJBObject(args[0]); } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
public QueryCommand getQueryCommand(Method queryMethod) throws FinderException { QueryCommand queryCommand = (QueryCommand)queriesByMethod.get(queryMethod); if(queryCommand == null) { throw new FinderException("Unknown query method: " + queryMethod); } return queryCommand; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
static Object fetchOne(JDBCEntityBridge2 entity, String sql, QueryParameter[] params, ResultReader resultReader, Object[] args, GenericEntityObjectFactory factory, Logger log) throws FinderException { Object pk; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; } } try { if(log.isDebugEnabled()) { log.debug("executing: " + sql); } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entity.getDataSource().getConnection(); } ps = con.prepareStatement(sql); if(params != null) { for(int i = 0; i < params.length; i++) { params[i].set(log, ps, i + 1, args); } } rs = ps.executeQuery(); if(rs.next()) { pk = resultReader.readRow(rs, factory); if(rs.next()) { List list = new ArrayList(); list.add(pk); list.add(resultReader.readRow(rs, factory)); while(rs.next()) { list.add(resultReader.readRow(rs, factory)); } throw new FinderException("More than one instance matches the single-object finder criteria: " + list); } } else { throw new ObjectNotFoundException(); } } catch(FinderException e) { throw e; } catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Collection readResultSet(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, GenericEntityObjectFactory factory) throws FinderException { Collection result; try { if((limit == 0 || count-- > 0) && rs.next()) { result = collectionFactory.newCollection(); Object instance = resultReader.readRow(rs, factory); result.add(instance); while((limit == 0 || count-- > 0) && rs.next()) { instance = resultReader.readRow(rs, factory); result.add(instance); } } else { result = Collections.EMPTY_SET; } } catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
public Collection fetchCollection(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { if(log.isTraceEnabled()) { log.trace("executing dynamic-ql: " + args[0]); } JDBCStoreManager2 manager = (JDBCStoreManager2)entity.getManager(); QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog()); try { compiler.compileJBossQL((String)args[0], metadata.getMethod().getReturnType(), getParamTypes(args), metadata ); } catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); } String sql = compiler.getSQL(); int offsetParam = compiler.getOffsetParam(); int offsetValue = compiler.getOffsetValue(); int limitParam = compiler.getLimitParam(); int limitValue = compiler.getLimitValue(); AbstractQueryCommand.ResultReader resultReader; if(!compiler.isSelectEntity()) { if(compiler.isSelectField()) { resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2)compiler.getSelectField()); } else { resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction()); } } else { resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2)compiler.getSelectEntity(), compiler.isSelectDistinct()); } return AbstractQueryCommand.fetchCollection( entity, sql, toArray(compiler.getInputParameters()), AbstractQueryCommand.toInt(args, offsetParam, offsetValue), AbstractQueryCommand.toInt(args, limitParam, limitValue), new AbstractQueryCommand.EagerCollectionStrategy(collectionFactory, resultReader, log), schema, factory, (Object[])args[1], log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { if(log.isTraceEnabled()) { log.trace("executing dynamic-ql: " + args[0]); } JDBCStoreManager2 manager = (JDBCStoreManager2)entity.getManager(); QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog()); try { compiler.compileJBossQL((String)args[0], metadata.getMethod().getReturnType(), getParamTypes(args), metadata ); } catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); } String sql = compiler.getSQL(); AbstractQueryCommand.ResultReader resultReader; if(!compiler.isSelectEntity()) { if(compiler.isSelectField()) { resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2)compiler.getSelectField()); } else { resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction()); } } else { resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2)compiler.getSelectEntity(), compiler.isSelectDistinct()); } return AbstractQueryCommand.fetchOne(entity, sql, toArray(compiler.getInputParameters()), resultReader, (Object[])args[1], factory, log ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
private static Class[] getParamTypes(Object[] args) throws FinderException { Class[] parameterTypes; // get the parameters Object[] parameters = (Object[])args[1]; if(parameters == null) { parameterTypes = new Class[0]; } else { // get the parameter types parameterTypes = new Class[parameters.length]; for(int i = 0; i < parameters.length; i++) { if(parameters[i] == null) { throw new FinderException("Parameter[" + i + "] is null"); } parameterTypes[i] = parameters[i].getClass(); } } return parameterTypes; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/EJBSelectBridge.java
public Object execute(Object[] args) throws FinderException { JDBCStoreManager2 manager = command.getStoreManager(); GenericEntityObjectFactory factory = (metadata.isResultTypeMappingLocal() ? (GenericEntityObjectFactory)manager.getContainer().getLocalProxyFactory() : manager.getContainer().getProxyFactory()); Object result; switch(returnType) { case SINGLE: result = command.fetchOne(schema, factory, args); if(result == null && getMethod().getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + getMethod().getReturnType().getName() ); } break; case COLLECTION: result = command.fetchCollection(schema, factory, args); break; default: throw new IllegalStateException("Unexpected return type: " + returnType); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Collection createCollection(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, JDBCEntityBridge selectEntity, JDBCCMPFieldBridge selectField, SelectFunction selectFunction, JDBCStoreManager selectManager, List onFindCMRList, boolean[] eagerLoadMask, GenericEntityObjectFactory factory) throws FinderException { try { List results = new ArrayList(); if(selectEntity != null) { ReadAheadCache selectReadAheadCache = selectManager.getReadAheadCache(); List ids = new ArrayList(); boolean loadOnFindCmr = !onFindCMRList.isEmpty(); Object[] ref = new Object[1]; Object prevPk = null; while((limit == 0 || count-- > 0) && rs.next()) { int index = 1; // get the pk index = selectEntity.loadPrimaryKeyResults(rs, index, ref); Object pk = ref[0]; boolean addPk = (loadOnFindCmr ? !pk.equals(prevPk) : true); if(addPk) { ids.add(pk); results.add(factory.getEntityEJBObject(pk)); prevPk = pk; } // read the preload fields if(eagerLoadMask != null) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < eagerLoadMask.length; i++) { if(eagerLoadMask[i]) { JDBCFieldBridge field = tableFields[i]; ref[0] = null; // read the value and store it in the readahead cache index = field.loadArgumentResults(rs, index, ref); if(addPk) { selectReadAheadCache.addPreloadData(pk, field, ref[0]); } } } if(!onFindCMRList.isEmpty()) { index = loadOnFindCMRFields(pk, onFindCMRList, rs, index, log); } } } // add the results list to the cache selectReadAheadCache.addFinderResults(ids, queryMetaData.getReadAhead()); } else if(selectField != null) { // load the field Object[] valueRef = new Object[1]; while((limit == 0 || count-- > 0) && rs.next()) { valueRef[0] = null; selectField.loadArgumentResults(rs, 1, valueRef); results.add(valueRef[0]); } } else { while(rs.next()) { results.add(selectFunction.readResult(rs)); } } if(log.isDebugEnabled() && limit != 0 && count == 0) { log.debug("Query result was limited to " + limit + " row(s)"); } return results; } catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntityCommand.java
public Object execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(finderMethod); Collection result = query.execute(finderMethod, args, ctx, factory); if(result.isEmpty()) { throw new ObjectNotFoundException(NO_SUCH_ENTITY); } else if(result.size() == 1) { return result.iterator().next(); } else { throw new FinderException("More than one entity matches the finder criteria: " + result); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { String dynamicQL = (String)args[0]; if(getLog().isDebugEnabled()) { getLog().debug("DYNAMIC-QL: " + dynamicQL); } QLCompiler compiler = null; try { compiler = JDBCQueryManager.getInstance(metadata.getQLCompilerClass(), catalog); } catch(DeploymentException e) { throw new FinderException(e.getMessage()); } // get the parameters Object[] parameters = (Object[])args[1]; // parameter types Class[] parameterTypes; if(parameters == null) { parameterTypes = new Class[0]; } else { // get the parameter types parameterTypes = new Class[parameters.length]; for(int i = 0; i < parameters.length; i++) { if(parameters[i] == null) { throw new FinderException("Parameter[" + i + "] is null"); } parameterTypes[i] = parameters[i].getClass(); } } // compile the dynamic-ql try { compiler.compileJBossQL( dynamicQL, finderMethod.getReturnType(), parameterTypes, metadata); } catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); } int offset = toInt(parameters, compiler.getOffsetParam(), compiler.getOffsetValue()); int limit = toInt(parameters, compiler.getLimitParam(), compiler.getLimitValue()); JDBCEntityBridge selectEntity = null; JDBCCMPFieldBridge selectField = null; SelectFunction selectFunction = null; if(compiler.isSelectEntity()) { selectEntity = (JDBCEntityBridge) compiler.getSelectEntity(); } else if(compiler.isSelectField()) { selectField = (JDBCCMPFieldBridge) compiler.getSelectField(); } else { selectFunction = compiler.getSelectFunction(); } boolean[] mask; List leftJoinCMRList; JDBCReadAheadMetaData readahead = metadata.getReadAhead(); if(selectEntity != null && readahead.isOnFind()) { mask = selectEntity.getLoadGroupMask(readahead.getEagerLoadGroup()); boolean modifiedMask = false; leftJoinCMRList = compiler.getLeftJoinCMRList(); // exclude non-searchable columns if distinct is used if(compiler.isSelectDistinct()) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < tableFields.length; ++i) { if(mask[i] && !tableFields[i].getJDBCType().isSearchable()) { if(!modifiedMask) { boolean[] original = mask; mask = new boolean[original.length]; System.arraycopy(original, 0, mask, 0, mask.length); modifiedMask = true; } mask[i] = false; } } } } else { mask = null; leftJoinCMRList = Collections.EMPTY_LIST; } // get the parameter order setParameterList(compiler.getInputParameters()); EntityContainer con = ((JDBCStoreManager)compiler.getStoreManager()).getContainer(); factory = metadata.isResultTypeMappingLocal() && con.getLocalHomeClass() != null ? con.getLocalProxyFactory() : con.getProxyFactory(); return execute( compiler.getSQL(), parameters, offset, limit, selectEntity, selectField, selectFunction, (JDBCStoreManager) compiler.getStoreManager(), mask, compiler.getInputParameters(), leftJoinCMRList, metadata, factory, log ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public JDBCQueryCommand getQueryCommand(Method queryMethod) throws FinderException { JDBCQueryCommand queryCommand = (JDBCQueryCommand)knownQueries.get(queryMethod); if(queryCommand == null) { throw new FinderException("Unknown query: " + queryMethod); } return queryCommand; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object execute(Object[] args) throws FinderException { Collection retVal; Method method = getMethod(); try { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(method); EntityContainer selectedContainer = query.getSelectManager().getContainer(); GenericEntityObjectFactory factory; if(queryMetaData.isResultTypeMappingLocal() && selectedContainer.getLocalHomeClass() != null) { factory = selectedContainer.getLocalProxyFactory(); } else { factory = selectedContainer.getProxyFactory(); } retVal = query.execute(method, args, null, factory); } catch(FinderException e) { throw e; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); } if(!Collection.class.isAssignableFrom(getReturnType())) { // single object if(retVal.size() == 0) { throw new ObjectNotFoundException(); } if(retVal.size() > 1) { throw new FinderException(getSelectorName() + " returned " + retVal.size() + " objects"); } Object o = retVal.iterator().next(); if(o == null && method.getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + method.getReturnType().getName() ); } return o; } else { // collection or set if(Set.class.isAssignableFrom(getReturnType())) { return new HashSet(retVal); } else { return retVal; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
public Collection execute(Method unused, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { try { // invoke implementation method on ejb instance Object value = finderMethod.invoke(ctx.getInstance(), args); // if expected return type is Collection, return as is // if expected return type is not Collection, wrap value in Collection if(value instanceof Enumeration) { Enumeration enumeration = (Enumeration)value; List result = new ArrayList(); while(enumeration.hasMoreElements()) { result.add(enumeration.nextElement()); } cacheResults(result); return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, result); } else if(value instanceof Collection) { List result; if (value instanceof List) result = (List)value; else result = new ArrayList((Collection)value); cacheResults(result); return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, result); } else { // Don't bother trying to cache this return Collections.singleton(factory.getEntityEJBObject(value)); } } catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); } catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); } catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } } }
9
              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(DeploymentException e) { throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
29
              
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object findEntity(final Method finderMethod, final Object[] args, final EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { if (finderMethod.getName().equals("findByPrimaryKey")) { if (!getFile(args[0]).exists()) throw new FinderException(args[0]+" does not exist"); return factory.getEntityEJBObject(args[0]); } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
public QueryCommand getQueryCommand(Method queryMethod) throws FinderException { QueryCommand queryCommand = (QueryCommand)queriesByMethod.get(queryMethod); if(queryCommand == null) { throw new FinderException("Unknown query method: " + queryMethod); } return queryCommand; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/FindByPrimaryKeyCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { Object pk = args[0]; if(pk == null) { throw new IllegalArgumentException("Null argument for findByPrimaryKey"); } Object instance; boolean cached = entity.getTable().hasRow(pk); if(!cached) { instance = super.executeFetchOne(args, factory); if(instance == null) { throw new ObjectNotFoundException("Instance not find: entity=" + entity.getEntityName() + ", pk=" + pk); } } else { instance = factory.getEntityEJBObject(pk); } return instance; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws FinderException { QueryCommand query = queryFactory.getQueryCommand(finderMethod); return query.fetchOne(schema, factory, args); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws FinderException { QueryCommand query = queryFactory.getQueryCommand(finderMethod); return query.fetchCollection(schema, factory, args); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Collection fetchCollection(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { int offset = toInt(args, offsetParam, offsetValue); int limit = toInt(args, limitParam, limitValue); return fetchCollection(entity, sql, params, offset, limit, collectionStrategy, schema, factory, args, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { schema.flush(); return executeFetchOne(args, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
protected Object executeFetchOne(Object[] args, GenericEntityObjectFactory factory) throws FinderException { return fetchOne(entity, sql, params, resultReader, args, factory, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
static Collection fetchCollection(JDBCEntityBridge2 entity, String sql, QueryParameter[] params, int offset, int limit, CollectionStrategy collectionStrategy, Schema schema, GenericEntityObjectFactory factory, Object[] args, Logger log) throws FinderException { schema.flush(); int count = offset; Collection result; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; } } try { if(log.isDebugEnabled()) { log.debug("executing: " + sql); } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entity.getDataSource().getConnection(); } ps = con.prepareStatement(sql); if(params != null) { for(int i = 0; i < params.length; i++) { params[i].set(log, ps, i + 1, args); } } rs = ps.executeQuery(); // skip 'offset' results while(count > 0 && rs.next()) { count--; } count = limit; } catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; } result = collectionStrategy.readResultSet(con, ps, rs, limit, count, factory); return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
static Object fetchOne(JDBCEntityBridge2 entity, String sql, QueryParameter[] params, ResultReader resultReader, Object[] args, GenericEntityObjectFactory factory, Logger log) throws FinderException { Object pk; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; } } try { if(log.isDebugEnabled()) { log.debug("executing: " + sql); } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entity.getDataSource().getConnection(); } ps = con.prepareStatement(sql); if(params != null) { for(int i = 0; i < params.length; i++) { params[i].set(log, ps, i + 1, args); } } rs = ps.executeQuery(); if(rs.next()) { pk = resultReader.readRow(rs, factory); if(rs.next()) { List list = new ArrayList(); list.add(pk); list.add(resultReader.readRow(rs, factory)); while(rs.next()) { list.add(resultReader.readRow(rs, factory)); } throw new FinderException("More than one instance matches the single-object finder criteria: " + list); } } else { throw new ObjectNotFoundException(); } } catch(FinderException e) { throw e; } catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Collection readResultSet(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, GenericEntityObjectFactory factory) throws FinderException { Collection result; try { if((limit == 0 || count-- > 0) && rs.next()) { result = collectionFactory.newCollection(); Object instance = resultReader.readRow(rs, factory); result.add(instance); while((limit == 0 || count-- > 0) && rs.next()) { instance = resultReader.readRow(rs, factory); result.add(instance); } } else { result = Collections.EMPTY_SET; } } catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
public Collection fetchCollection(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { if(log.isTraceEnabled()) { log.trace("executing dynamic-ql: " + args[0]); } JDBCStoreManager2 manager = (JDBCStoreManager2)entity.getManager(); QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog()); try { compiler.compileJBossQL((String)args[0], metadata.getMethod().getReturnType(), getParamTypes(args), metadata ); } catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); } String sql = compiler.getSQL(); int offsetParam = compiler.getOffsetParam(); int offsetValue = compiler.getOffsetValue(); int limitParam = compiler.getLimitParam(); int limitValue = compiler.getLimitValue(); AbstractQueryCommand.ResultReader resultReader; if(!compiler.isSelectEntity()) { if(compiler.isSelectField()) { resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2)compiler.getSelectField()); } else { resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction()); } } else { resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2)compiler.getSelectEntity(), compiler.isSelectDistinct()); } return AbstractQueryCommand.fetchCollection( entity, sql, toArray(compiler.getInputParameters()), AbstractQueryCommand.toInt(args, offsetParam, offsetValue), AbstractQueryCommand.toInt(args, limitParam, limitValue), new AbstractQueryCommand.EagerCollectionStrategy(collectionFactory, resultReader, log), schema, factory, (Object[])args[1], log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { if(log.isTraceEnabled()) { log.trace("executing dynamic-ql: " + args[0]); } JDBCStoreManager2 manager = (JDBCStoreManager2)entity.getManager(); QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog()); try { compiler.compileJBossQL((String)args[0], metadata.getMethod().getReturnType(), getParamTypes(args), metadata ); } catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); } String sql = compiler.getSQL(); AbstractQueryCommand.ResultReader resultReader; if(!compiler.isSelectEntity()) { if(compiler.isSelectField()) { resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2)compiler.getSelectField()); } else { resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction()); } } else { resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2)compiler.getSelectEntity(), compiler.isSelectDistinct()); } return AbstractQueryCommand.fetchOne(entity, sql, toArray(compiler.getInputParameters()), resultReader, (Object[])args[1], factory, log ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
private static Class[] getParamTypes(Object[] args) throws FinderException { Class[] parameterTypes; // get the parameters Object[] parameters = (Object[])args[1]; if(parameters == null) { parameterTypes = new Class[0]; } else { // get the parameter types parameterTypes = new Class[parameters.length]; for(int i = 0; i < parameters.length; i++) { if(parameters[i] == null) { throw new FinderException("Parameter[" + i + "] is null"); } parameterTypes[i] = parameters[i].getClass(); } } return parameterTypes; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/EJBSelectBridge.java
public Object execute(Object[] args) throws FinderException { JDBCStoreManager2 manager = command.getStoreManager(); GenericEntityObjectFactory factory = (metadata.isResultTypeMappingLocal() ? (GenericEntityObjectFactory)manager.getContainer().getLocalProxyFactory() : manager.getContainer().getProxyFactory()); Object result; switch(returnType) { case SINGLE: result = command.fetchOne(schema, factory, args); if(result == null && getMethod().getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + getMethod().getReturnType().getName() ); } break; case COLLECTION: result = command.fetchCollection(schema, factory, args); break; default: throw new IllegalStateException("Unexpected return type: " + returnType); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public Object invoke(Object proxy, Method method, Object[] args) throws FinderException { // todo find a better workaround // CMP/CMR field bridges are mapped to its abstract method names because of the bug // in reflection introduced in Sun's 1.4 JVM, i.e. when an abstract class C1 extends a super class C2 // and implements interface I and C2 and I both declare method with the same signature M, // C1.getMethods() will contain M twice. // ejbSelect methods are mapped to Method objects instead. Because ejbSelect methods having the same name // might have different signatures. Hopefully, the probability of an ejbSelect method to appear in an interface // is lower. String methodName = method.getName(); BridgeInvoker invoker = (BridgeInvoker) fieldMap.get(methodName); if(invoker == null) { //invoker = (BridgeInvoker) selectorMap.get(methodName); invoker = (BridgeInvoker) selectorMap.get(method); if(invoker == null) { throw new EJBException("Method is not a known CMP field " + "accessor, CMR field accessor, or ejbSelect method: " + "methodName=" + methodName); } } try { return invoker.invoke(ctx, method, args); } catch(RuntimeException e) { throw e; } catch(FinderException e) { throw e; } catch(Exception e) { throw new EJBException("Internal error", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { int offset = toInt(args, offsetParam, offsetValue); int limit = toInt(args, limitParam, limitValue); return execute(sql, args, offset, limit, selectEntity, selectField, selectFunction, selectManager, eagerLoadMask, parameters, onFindCMRList, queryMetaData, factory, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected Collection execute(String sql, Object[] args, int offset, int limit, JDBCEntityBridge selectEntity, JDBCCMPFieldBridge selectField, SelectFunction selectFunction, JDBCStoreManager selectManager, boolean[] eagerLoadMask, List parameters, List onFindCMRList, JDBCQueryMetaData queryMetaData, GenericEntityObjectFactory factory, Logger log) throws FinderException { int count = offset; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; final JDBCEntityBridge entityBridge = (JDBCEntityBridge)selectManager.getEntityBridge(); boolean throwRuntimeExceptions = entityBridge.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entityBridge.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; } } try { // create the statement if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); if(limit != 0 || offset != 0) { log.debug("Query offset=" + offset + ", limit=" + limit); } } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entityBridge.getDataSource().getConnection(); } ps = con.prepareStatement(sql); // Set the fetch size of the statement if(entityBridge.getFetchSize() > 0) { ps.setFetchSize(entityBridge.getFetchSize()); } // set the parameters for(int i = 0; i < parameters.size(); i++) { QueryParameter parameter = (QueryParameter) parameters.get(i); parameter.set(log, ps, i + 1, args); } // execute statement rs = ps.executeQuery(); // skip 'offset' results while(count > 0 && rs.next()) { count--; } count = limit; } catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; } return collectionFactory.createCollection(con, ps, rs, limit, count, selectEntity, selectField, selectFunction, selectManager, onFindCMRList, eagerLoadMask, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Collection createCollection(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, JDBCEntityBridge selectEntity, JDBCCMPFieldBridge selectField, SelectFunction selectFunction, JDBCStoreManager selectManager, List onFindCMRList, boolean[] eagerLoadMask, GenericEntityObjectFactory factory) throws FinderException { try { List results = new ArrayList(); if(selectEntity != null) { ReadAheadCache selectReadAheadCache = selectManager.getReadAheadCache(); List ids = new ArrayList(); boolean loadOnFindCmr = !onFindCMRList.isEmpty(); Object[] ref = new Object[1]; Object prevPk = null; while((limit == 0 || count-- > 0) && rs.next()) { int index = 1; // get the pk index = selectEntity.loadPrimaryKeyResults(rs, index, ref); Object pk = ref[0]; boolean addPk = (loadOnFindCmr ? !pk.equals(prevPk) : true); if(addPk) { ids.add(pk); results.add(factory.getEntityEJBObject(pk)); prevPk = pk; } // read the preload fields if(eagerLoadMask != null) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < eagerLoadMask.length; i++) { if(eagerLoadMask[i]) { JDBCFieldBridge field = tableFields[i]; ref[0] = null; // read the value and store it in the readahead cache index = field.loadArgumentResults(rs, index, ref); if(addPk) { selectReadAheadCache.addPreloadData(pk, field, ref[0]); } } } if(!onFindCMRList.isEmpty()) { index = loadOnFindCMRFields(pk, onFindCMRList, rs, index, log); } } } // add the results list to the cache selectReadAheadCache.addFinderResults(ids, queryMetaData.getReadAhead()); } else if(selectField != null) { // load the field Object[] valueRef = new Object[1]; while((limit == 0 || count-- > 0) && rs.next()) { valueRef[0] = null; selectField.loadArgumentResults(rs, 1, valueRef); results.add(valueRef[0]); } } else { while(rs.next()) { results.add(selectFunction.readResult(rs)); } } if(log.isDebugEnabled() && limit != 0 && count == 0) { log.debug("Query result was limited to " + limit + " row(s)"); } return results; } catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Collection createCollection(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, JDBCEntityBridge selectEntity, JDBCCMPFieldBridge selectField, SelectFunction selectFunction, JDBCStoreManager selectManager, List onFindCMRList, boolean[] eagerLoadMask, GenericEntityObjectFactory factory) throws FinderException { return new LazyCollection(con, ps, rs, limit, count, selectEntity, selectField, selectFunction, selectManager, eagerLoadMask, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntityCommand.java
public Object execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(finderMethod); Collection result = query.execute(finderMethod, args, ctx, factory); if(result.isEmpty()) { throw new ObjectNotFoundException(NO_SUCH_ENTITY); } else if(result.size() == 1) { return result.iterator().next(); } else { throw new FinderException("More than one entity matches the finder criteria: " + result); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntitiesCommand.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(finderMethod); return query.execute(finderMethod, args, ctx, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { return findEntityCommand.execute(finderMethod, args, ctx, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { return findEntitiesCommand.execute(finderMethod, args, ctx, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { String dynamicQL = (String)args[0]; if(getLog().isDebugEnabled()) { getLog().debug("DYNAMIC-QL: " + dynamicQL); } QLCompiler compiler = null; try { compiler = JDBCQueryManager.getInstance(metadata.getQLCompilerClass(), catalog); } catch(DeploymentException e) { throw new FinderException(e.getMessage()); } // get the parameters Object[] parameters = (Object[])args[1]; // parameter types Class[] parameterTypes; if(parameters == null) { parameterTypes = new Class[0]; } else { // get the parameter types parameterTypes = new Class[parameters.length]; for(int i = 0; i < parameters.length; i++) { if(parameters[i] == null) { throw new FinderException("Parameter[" + i + "] is null"); } parameterTypes[i] = parameters[i].getClass(); } } // compile the dynamic-ql try { compiler.compileJBossQL( dynamicQL, finderMethod.getReturnType(), parameterTypes, metadata); } catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); } int offset = toInt(parameters, compiler.getOffsetParam(), compiler.getOffsetValue()); int limit = toInt(parameters, compiler.getLimitParam(), compiler.getLimitValue()); JDBCEntityBridge selectEntity = null; JDBCCMPFieldBridge selectField = null; SelectFunction selectFunction = null; if(compiler.isSelectEntity()) { selectEntity = (JDBCEntityBridge) compiler.getSelectEntity(); } else if(compiler.isSelectField()) { selectField = (JDBCCMPFieldBridge) compiler.getSelectField(); } else { selectFunction = compiler.getSelectFunction(); } boolean[] mask; List leftJoinCMRList; JDBCReadAheadMetaData readahead = metadata.getReadAhead(); if(selectEntity != null && readahead.isOnFind()) { mask = selectEntity.getLoadGroupMask(readahead.getEagerLoadGroup()); boolean modifiedMask = false; leftJoinCMRList = compiler.getLeftJoinCMRList(); // exclude non-searchable columns if distinct is used if(compiler.isSelectDistinct()) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < tableFields.length; ++i) { if(mask[i] && !tableFields[i].getJDBCType().isSearchable()) { if(!modifiedMask) { boolean[] original = mask; mask = new boolean[original.length]; System.arraycopy(original, 0, mask, 0, mask.length); modifiedMask = true; } mask[i] = false; } } } } else { mask = null; leftJoinCMRList = Collections.EMPTY_LIST; } // get the parameter order setParameterList(compiler.getInputParameters()); EntityContainer con = ((JDBCStoreManager)compiler.getStoreManager()).getContainer(); factory = metadata.isResultTypeMappingLocal() && con.getLocalHomeClass() != null ? con.getLocalProxyFactory() : con.getProxyFactory(); return execute( compiler.getSQL(), parameters, offset, limit, selectEntity, selectField, selectFunction, (JDBCStoreManager) compiler.getStoreManager(), mask, compiler.getInputParameters(), leftJoinCMRList, metadata, factory, log ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public JDBCQueryCommand getQueryCommand(Method queryMethod) throws FinderException { JDBCQueryCommand queryCommand = (JDBCQueryCommand)knownQueries.get(queryMethod); if(queryCommand == null) { throw new FinderException("Unknown query: " + queryMethod); } return queryCommand; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindByPrimaryKeyQuery.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { // Check in readahead cache. if(manager.getReadAheadCache().getPreloadDataMap(args[0], false) != null) { // copy pk [JBAS-1361] Object pk = null; JDBCFieldBridge[] pkFields = manager.getEntityBridge().getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCAbstractCMPFieldBridge pkField = ((JDBCAbstractCMPFieldBridge)pkFields[i]); Object fieldValue = pkField.getPrimaryKeyValue(args[0]); pk = pkField.setPrimaryKeyValue(pk, fieldValue); } final Object ejbObject = factory.getEntityEJBObject(pk); return Collections.singletonList(ejbObject); } return super.execute(finderMethod, args, ctx, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object execute(Object[] args) throws FinderException { Collection retVal; Method method = getMethod(); try { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(method); EntityContainer selectedContainer = query.getSelectManager().getContainer(); GenericEntityObjectFactory factory; if(queryMetaData.isResultTypeMappingLocal() && selectedContainer.getLocalHomeClass() != null) { factory = selectedContainer.getLocalProxyFactory(); } else { factory = selectedContainer.getProxyFactory(); } retVal = query.execute(method, args, null, factory); } catch(FinderException e) { throw e; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); } if(!Collection.class.isAssignableFrom(getReturnType())) { // single object if(retVal.size() == 0) { throw new ObjectNotFoundException(); } if(retVal.size() > 1) { throw new FinderException(getSelectorName() + " returned " + retVal.size() + " objects"); } Object o = retVal.iterator().next(); if(o == null && method.getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + method.getReturnType().getName() ); } return o; } else { // collection or set if(Set.class.isAssignableFrom(getReturnType())) { return new HashSet(retVal); } else { return retVal; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
public Collection execute(Method unused, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { try { // invoke implementation method on ejb instance Object value = finderMethod.invoke(ctx.getInstance(), args); // if expected return type is Collection, return as is // if expected return type is not Collection, wrap value in Collection if(value instanceof Enumeration) { Enumeration enumeration = (Enumeration)value; List result = new ArrayList(); while(enumeration.hasMoreElements()) { result.add(enumeration.nextElement()); } cacheResults(result); return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, result); } else if(value instanceof Collection) { List result; if (value instanceof List) result = (List)value; else result = new ArrayList((Collection)value); cacheResults(result); return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, result); } else { // Don't bother trying to cache this return Collections.singleton(factory.getEntityEJBObject(value)); } } catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); } catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); } catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } } }
(Lib) SQLException 18
              
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSourceName) throws SQLException { this.server = server; this.dataSourceName = dataSourceName; // Get the DataSource from JNDI try { String dsJndiTx = (String)server.getAttribute(dataSourceName, "BindName"); ds = (DataSource)new InitialContext().lookup(dsJndiTx); } catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); } // Get the DataSource meta data String dsName = dataSourceName.getKeyProperty("name"); metaDataName = ObjectNameFactory.create("jboss.jdbc:datasource=" + dsName + ",service=metadata"); if (this.server.isRegistered(metaDataName) == false) throw new IllegalStateException("Cannot find datasource meta data: " + metaDataName); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void initSequence(String tableName, String sequenceColumn, String sequenceName, String idColumnName) throws SQLException, DeploymentException { if(createTable) { createTableIfNotExists(tableName); } Connection con = null; Statement st = null; ResultSet rs = null; try { String sql = "select " + idColumnName + " from " + tableName + " where " + sequenceColumn + "='" + sequenceName + "'"; log.debug("Executing SQL: " + sql); con = ds.getConnection(); st = con.createStatement(); rs = st.executeQuery(sql); if(!rs.next()) { sql = "insert into " + tableName + "(" + sequenceColumn + ", " + idColumnName + ") values ('" + sequenceName + "', 0)"; log.debug("Executing SQL: " + sql); final Statement insertSt = con.createStatement(); try { final int i = insertSt.executeUpdate(sql); if(i != 1) { throw new SQLException("Expected one updated row but got: " + i); } } finally { JDBCUtil.safeClose(insertSt); } } else { HiLoKeyGenerator.setHighestHi(rs.getLong(1)); } } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static byte[] convertObjectToByteArray(Object value) throws SQLException { // Do we already have a byte array? if(value instanceof byte[]) { return (byte[])value; } ByteArrayOutputStream baos = null; ObjectOutputStream oos = null; try { // ejb-reference: store the handle if(value instanceof EJBObject) { value = ((EJBObject)value).getHandle(); } // Marshall the object using MashalledValue to handle classloaders value = new MarshalledValue(value); // return the serialize the value baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(value); return baos.toByteArray(); } catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); } catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); } finally { safeClose(oos); safeClose(baos); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object convertToObject(InputStream input) throws SQLException { Object value = null; if(input != null) { ObjectInputStream ois = null; try { // deserialize result ois = new ObjectInputStream(input); value = ois.readObject(); // de-marshall value if possible if(value instanceof MarshalledValue) { value = ((MarshalledValue)value).get(); } else if(value instanceof MarshalledObject) { value = ((MarshalledObject)value).get(); } // ejb-reference: get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } finally { // ois will close the input stream it wraps safeClose(ois); } } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static String getLongString(ResultSet rs, int index) throws SQLException { String value; Reader textData = rs.getCharacterStream(index); if(textData != null) { try { // Use a modest buffer here to reduce function call overhead // when reading extremely large data. StringBuffer textBuffer = new StringBuffer(); char[] tmpBuffer = new char[1000]; int charsRead; while((charsRead = textData.read(tmpBuffer)) != -1) textBuffer.append(tmpBuffer, 0, charsRead); value = textBuffer.toString(); } catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); } finally { safeClose(textData); } } else value = null; return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static byte[] getByteArray(InputStream input) throws SQLException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { // Use a modest buffer here to reduce function call overhead // when reading extremely large data. byte[] tmpBuffer = new byte[1000]; int bytesRead; while((bytesRead = input.read(tmpBuffer)) != -1) baos.write(tmpBuffer, 0, bytesRead); return baos.toByteArray(); } catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); } finally { safeClose(baos); safeClose(input); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
private static Object coerceToJavaType( Object value, Class destination) throws SQLException { try { // // null // if(value == null) { return null; } // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // // Primitive wrapper classes // // We have a primitive wrapper and we want a real primitive // just return the wrapper and the vm will convert it at the proxy if(destination.isPrimitive()) { if(value == null) throw new IllegalStateException("Loaded NULL value for a field of a primitive type."); if((destination.equals(Byte.TYPE) && value instanceof Byte) || (destination.equals(Short.TYPE) && value instanceof Short) || (destination.equals(Character.TYPE) && value instanceof Character) || (destination.equals(Boolean.TYPE) && value instanceof Boolean) || (destination.equals(Integer.TYPE) && value instanceof Integer) || (destination.equals(Long.TYPE) && value instanceof Long) || (destination.equals(Float.TYPE) && value instanceof Float) || (destination.equals(Double.TYPE) && value instanceof Double) ) { return value; } } // // java.util.Date // // make new copy as sub types have problems in comparions if(destination == java.util.Date.class && value instanceof java.util.Date) { // handle timestamp special becauses it hoses the milisecond values if(value instanceof java.sql.Timestamp) { java.sql.Timestamp ts = (java.sql.Timestamp)value; // Timestamp returns whole seconds from getTime and partial // seconds are retrieved from getNanos() // Adrian Brock: Not in 1.4 it doesn't long temp = ts.getTime(); if(temp % 1000 == 0) temp += ts.getNanos() / 1000000; return new java.util.Date(temp); } else { return new java.util.Date(((java.util.Date)value).getTime()); } } // // java.sql.Time // // make a new copy object; you never know what a driver will return if(destination == java.sql.Time.class && value instanceof java.sql.Time) { return new java.sql.Time(((java.sql.Time)value).getTime()); } // // java.sql.Date // // make a new copy object; you never know what a driver will return if(destination == java.sql.Date.class && value instanceof java.sql.Date) { return new java.sql.Date(((java.sql.Date)value).getTime()); } // // java.sql.Timestamp // // make a new copy object; you never know what a driver will return if(destination == java.sql.Timestamp.class && value instanceof java.sql.Timestamp) { // make a new Timestamp object; you never know // what a driver will return java.sql.Timestamp orignal = (java.sql.Timestamp)value; java.sql.Timestamp copy = new java.sql.Timestamp(orignal.getTime()); copy.setNanos(orignal.getNanos()); return copy; } // // java.lang.String --> java.lang.Character or char // // just grab first character if(value instanceof String && (destination == Character.class || destination == Character.TYPE)) { return new Character(((String)value).charAt(0)); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do throw new SQLException("Got a " + value.getClass().getName() + "[cl=" + System.identityHashCode(value.getClass().getClassLoader()) + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + System.identityHashCode(destination) + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Clob clob = rs.getClob(index); String content; if(clob == null) { content = null; } else { final Reader reader = clob.getCharacterStream(); if(reader != null) { int intLength = (int)clob.length(); char[] chars; try { if(intLength <= 8192) { chars = new char[intLength]; reader.read(chars); content = String.valueOf(chars); } else { StringBuffer buf = new StringBuffer(intLength); chars = new char[8192]; int i = reader.read(chars); while(i > 0) { buf.append(chars, 0, i); i = reader.read(chars); } content = buf.toString(); } } catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); } finally { JDBCUtil.safeClose(reader); } } else { content = null; } } return content; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object coerceToJavaType(Object value, Class destination) throws SQLException { try { // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do String className = null; Object interfaces = null; ClassLoader cl = null; if (value != null) { Class valueClass = value.getClass(); className = valueClass.getName(); interfaces = Arrays.asList(valueClass.getInterfaces()); cl = valueClass.getClassLoader(); } throw new SQLException("Got a " + className + "[cl=" + cl + " + interfaces=" + interfaces + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + destination.getClassLoader() + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
15
              
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
112
              
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSource, String tableName) throws SQLException { if (tableName == null) throw new IllegalArgumentException("Timers tableName is null"); if (tableName.length() == 0) throw new IllegalArgumentException("Timers tableName is empty"); this.tableName = tableName; init(server, dataSource); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSourceName) throws SQLException { this.server = server; this.dataSourceName = dataSourceName; // Get the DataSource from JNDI try { String dsJndiTx = (String)server.getAttribute(dataSourceName, "BindName"); ds = (DataSource)new InitialContext().lookup(dsJndiTx); } catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); } // Get the DataSource meta data String dsName = dataSourceName.getKeyProperty("name"); metaDataName = ObjectNameFactory.create("jboss.jdbc:datasource=" + dsName + ",service=metadata"); if (this.server.isRegistered(metaDataName) == false) throw new IllegalStateException("Cannot find datasource meta data: " + metaDataName); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void createTableIfNotExists() throws SQLException { Connection con = null; Statement st = null; try { JDBCTypeMappingMetaData typeMapping = (JDBCTypeMappingMetaData)server.getAttribute(metaDataName, "TypeMappingMetaData"); if (typeMapping == null) throw new IllegalStateException("Cannot obtain type mapping from: " + metaDataName); JDBCMappingMetaData objectMetaData = typeMapping.getTypeMappingMetaData(Object.class); binarySqlType = objectMetaData.getJdbcType(); if (!SQLUtil.tableExists(getTableName(), ds)) { con = ds.getConnection(); String dateType = typeMapping.getTypeMappingMetaData(Timestamp.class).getSqlType(); String longType = typeMapping.getTypeMappingMetaData(Long.class).getSqlType(); String objectType = objectMetaData.getSqlType(); // The create table DDL StringBuffer createTableDDL = new StringBuffer("create table " + getTableName() + " (" + " " + getColumnTimerID() + " varchar(80) not null," + " " + getColumnTargetID() + " varchar(250) not null," + " " + getColumnInitialDate() + " " + dateType + " not null," + " " + getColumnTimerInterval() + " " + longType + "," + " " + getColumnInstancePK() + " " + objectType + "," + " " + getColumnInfo() + " " + objectType + ", "); // Add the primary key constraint using the pk-constraint-template JDBCFunctionMappingMetaData pkConstraint = typeMapping.getPkConstraintTemplate(); String name = SQLUtil.unquote(getTableName(), ds) + "_PK"; name = SQLUtil.fixConstraintName(name, ds); String[] templateParams = new String[] { name, getColumnTimerID() + ", " + getColumnTargetID() }; pkConstraint.getFunctionSql(templateParams, createTableDDL); // Complete the statement createTableDDL.append(" )"); log.debug("Executing DDL: " + createTableDDL); st = con.createStatement(); st.executeUpdate(createTableDDL.toString()); } } catch (SQLException e) { throw e; } catch (Exception e) { log.error("Cannot create timer table", e); } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void insertTimer(String timerId, TimedObjectId timedObjectId, Date initialExpiration, long intervalDuration, Serializable info) throws SQLException { Connection con = null; PreparedStatement st = null; try { con = ds.getConnection(); String sql = "insert into " + getTableName() + " " + "(" + getColumnTimerID() + "," + getColumnTargetID() + "," + getColumnInitialDate() + "," + getColumnTimerInterval() + "," + getColumnInstancePK() + "," + getColumnInfo() + ") " + "values (?,?,?,?,?,?)"; st = con.prepareStatement(sql); st.setString(1, timerId); st.setString(2, timedObjectId.toString()); st.setTimestamp(3, new Timestamp(initialExpiration.getTime())); st.setLong(4, intervalDuration); byte[] bytes = serialize(timedObjectId.getInstancePk()); if(bytes == null) { st.setNull(5, binarySqlType); } else { st.setBytes(5, bytes); } bytes = serialize(info); if(bytes == null) { st.setNull(6, binarySqlType); } else { st.setBytes(6, bytes); } int rows = st.executeUpdate(); if (rows != 1) log.error("Unable to insert timer for: " + timedObjectId); } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public List selectTimers(ObjectName containerId) throws SQLException { Connection con = null; Statement st = null; ResultSet rs = null; try { con = ds.getConnection(); List list = new ArrayList(); st = con.createStatement(); rs = st.executeQuery("select * from " + getTableName()); while (rs.next()) { String timerId = rs.getString(getColumnTimerID()); TimedObjectId targetId = TimedObjectId.parse(rs.getString(getColumnTargetID())); // add this handle to the returned list, if a null containerId was used // or the containerId filter matches if (containerId == null || containerId.equals(targetId.getContainerId())) { Date initialDate = rs.getTimestamp(getColumnInitialDate()); long interval = rs.getLong(getColumnTimerInterval()); Serializable pKey = (Serializable)deserialize(rs.getBytes(getColumnInstancePK())); Serializable info = null; try { info = (Serializable)deserialize(rs.getBytes(getColumnInfo())); } catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); } // is this really needed? targetId encapsulates pKey as well! targetId = new TimedObjectId(targetId.getContainerId(), pKey); TimerHandleImpl handle = new TimerHandleImpl(timerId, targetId, initialDate, interval, info); list.add(handle); } } return list; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void deleteTimer(String timerId, TimedObjectId timedObjectId) throws SQLException { Connection con = null; PreparedStatement st = null; ResultSet rs = null; try { con = ds.getConnection(); String sql = "delete from " + getTableName() + " where " + getColumnTimerID() + "=? and " + getColumnTargetID() + "=?"; st = con.prepareStatement(sql); st.setString(1, timerId); st.setString(2, timedObjectId.toString()); int rows = st.executeUpdate(); // This appears when a timer is created & persisted inside a tx, // but then the tx is rolled back, at which point we go back // to remove the entry, but no entry is found. // Is this because we are "enlisting" the datasource in the tx, too? if (rows != 1) { log.debug("Unable to remove timer for: " + timerId); } } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void clearTimers() throws SQLException { Connection con = null; PreparedStatement st = null; ResultSet rs = null; try { con = ds.getConnection(); st = con.prepareStatement("delete from " + getTableName()); st.executeUpdate(); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
public void insertTimer( String timerId, TimedObjectId timedObjectId, Date initialExpiration, long intervalDuration, Serializable info) throws SQLException { Connection con = null; PreparedStatement st = null; try { con = ds.getConnection(); String sql = "insert into " + getTableName() + " " + "(" + getColumnTimerID() + "," + getColumnTargetID() + "," + getColumnInitialDate() + "," + getColumnTimerInterval() + "," + getColumnInstancePK() + "," + getColumnInfo() + ") " + "values (?,?,?,?,?,?)"; st = con.prepareStatement(sql); st.setString(1, timerId); st.setString(2, timedObjectId.toString()); st.setTimestamp(3, new Timestamp(initialExpiration.getTime())); st.setLong(4, intervalDuration); byte[] pkArr = serialize(timedObjectId.getInstancePk()); if (pkArr != null) { InputStream is = new ByteArrayInputStream(pkArr); st.setBinaryStream(5, is, pkArr.length); } else { st.setBytes(5, null); } byte[] infoArr = serialize(info); if (infoArr != null) { InputStream is = new ByteArrayInputStream(infoArr); st.setBinaryStream(6, is, infoArr.length); } else { st.setBytes(6, null); } int rows = st.executeUpdate(); if (rows != 1) log.error("Unable to insert timer for: " + timedObjectId); } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
public List selectTimers(ObjectName containerId) throws SQLException { Connection con = null; Statement st = null; ResultSet rs = null; try { con = ds.getConnection(); List list = new ArrayList(); st = con.createStatement(); rs = st.executeQuery("select * from " + getTableName()); while (rs.next()) { String timerId = rs.getString(getColumnTimerID()); TimedObjectId targetId = TimedObjectId.parse(rs.getString(getColumnTargetID())); // add this handle to the returned list, if a null containerId was used // or the containerId filter matches if (containerId == null || containerId.equals(targetId.getContainerId())) { Date initialDate = rs.getTimestamp(getColumnInitialDate()); long interval = rs.getLong(getColumnTimerInterval()); InputStream isPk = rs.getBinaryStream(getColumnInstancePK()); Serializable pKey = (Serializable)deserialize(isPk); Serializable info = null; try { InputStream isInfo = rs.getBinaryStream(getColumnInfo()); info = (Serializable)deserialize(isInfo); } catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); } // is this really needed? targetId encapsulates pKey as well! targetId = new TimedObjectId(targetId.getContainerId(), pKey); TimerHandleImpl handle = new TimerHandleImpl(timerId, targetId, initialDate, interval, info); list.add(handle); } } return list; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
public void resetAndRestoreTimers() throws SQLException { timersToRestore = dbpPlugin.selectTimers(null); log.debug("Found " + timersToRestore.size() + " timer(s)"); if (timersToRestore.size() > 0) { // delete all timers clearTimers(); } restoreTimers(); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void initSequence(String tableName, String sequenceColumn, String sequenceName, String idColumnName) throws SQLException, DeploymentException { if(createTable) { createTableIfNotExists(tableName); } Connection con = null; Statement st = null; ResultSet rs = null; try { String sql = "select " + idColumnName + " from " + tableName + " where " + sequenceColumn + "='" + sequenceName + "'"; log.debug("Executing SQL: " + sql); con = ds.getConnection(); st = con.createStatement(); rs = st.executeQuery(sql); if(!rs.next()) { sql = "insert into " + tableName + "(" + sequenceColumn + ", " + idColumnName + ") values ('" + sequenceName + "', 0)"; log.debug("Executing SQL: " + sql); final Statement insertSt = con.createStatement(); try { final int i = insertSt.executeUpdate(sql); if(i != 1) { throw new SQLException("Expected one updated row but got: " + i); } } finally { JDBCUtil.safeClose(insertSt); } } else { HiLoKeyGenerator.setHighestHi(rs.getLong(1)); } } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void createTableIfNotExists(String tableName) throws SQLException, DeploymentException { Connection con = null; Statement st = null; try { if(!SQLUtil.tableExists(tableName, ds)) { log.debug("Executing DDL: " + createTableDdl); con = ds.getConnection(); st = con.createStatement(); st.executeUpdate(createTableDdl); } } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void dropTableIfExists(String tableName) throws SQLException, DeploymentException { Connection con = null; Statement st = null; try { if(SQLUtil.tableExists(tableName, ds)) { final String ddl = "drop table " + tableName; log.debug("Executing DDL: " + ddl); con = ds.getConnection(); st = con.createStatement(); st.executeUpdate(ddl); } } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private void doGenerate() throws SQLException { long curHi; do { curHi = getCurrentHi(); lo = curHi + 1; hi = curHi + blockSize; } while(!updateHi(curHi, hi)); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private long getCurrentHi() throws SQLException { return selectHiSql != null ? selectHi() : getHighestHi(); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private boolean updateHi(long curHi, long newHi) throws SQLException { if(selectHiSql == null) { setHighestHi(newHi); } return updateTable(curHi, newHi); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private long selectHi() throws SQLException { Connection con = null; PreparedStatement selectHiSt = null; ResultSet rs = null; if(log.isTraceEnabled()) { log.trace("Executing SQL: " + selectHiSql); } try { con = ds.getConnection(); selectHiSt = con.prepareStatement(selectHiSql); rs = selectHiSt.executeQuery(); if(!rs.next()) { throw new IllegalStateException("The sequence has not been initialized in the service start phase!"); } return rs.getLong(1); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(selectHiSt); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private boolean updateTable(long curHi, long newHi) throws SQLException { Connection con = null; PreparedStatement updateHi = null; if(log.isTraceEnabled()) { log.trace("Executing SQL: " + updateHiSql + ", [" + newHi + "," + curHi + "]"); } try { con = ds.getConnection(); updateHi = con.prepareStatement(updateHiSql); updateHi.setLong(1, newHi); updateHi.setLong(2, curHi); return updateHi.executeUpdate() == 1; } finally { JDBCUtil.safeClose(updateHi); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/ASTSqrt.java
public Object readResult(ResultSet rs) throws SQLException { return JDBCResultSetReader.DOUBLE_READER.get(rs, 1, Double.class, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/ASTLocate.java
public Object readResult(ResultSet rs) throws SQLException { return JDBCResultSetReader.LONG_READER.get(rs, 1, Long.class, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/AbstractMappedTypeFunction.java
public void setJDBCType(final JDBCType jdbcType) { if(resultReader != null) { final JDBCResultSetReader jdbcResultReader = this.resultReader; resultReader = new JDBCResultSetReader() { public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { Object jdbcResult = jdbcResultReader.get(rs, index, destination, log); return jdbcType.setColumnValue(0, null, jdbcResult); } }; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/AbstractMappedTypeFunction.java
public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { Object jdbcResult = jdbcResultReader.get(rs, index, destination, log); return jdbcType.setColumnValue(0, null, jdbcResult); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/AbstractMappedTypeFunction.java
public Object readResult(ResultSet rs) throws SQLException { return resultReader.get(rs, 1, resultType, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/ASTLength.java
public Object readResult(ResultSet rs) throws SQLException { return JDBCResultSetReader.LONG_READER.get(rs, 1, Long.class, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
private void delete(View view) throws SQLException { if(view.deleted == null) { if(log.isTraceEnabled()) { log.trace("no rows to delete"); } return; } Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + deleteSql); } con = ds.getConnection(); ps = con.prepareStatement(deleteSql); int batchCount = 0; while(view.deleted != null) { RelationKeys keys = view.deleted; int paramInd = 1; JDBCCMPFieldBridge2[] keyFields = (JDBCCMPFieldBridge2[])leftField.getTableKeyFields(); for(int pkInd = 0; pkInd < keyFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = keyFields[pkInd]; Object fieldValue = pkField.getPrimaryKeyValue(keys.leftKey); paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } keyFields = (JDBCCMPFieldBridge2[])rightField.getTableKeyFields(); for(int pkInd = 0; pkInd < keyFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = keyFields[pkInd]; Object fieldValue = pkField.getPrimaryKeyValue(keys.rightKey); paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } ps.addBatch(); ++batchCount; keys.dereference(); } ps.executeBatch(); if(view.deleted != null) { throw new IllegalStateException("There are still rows to delete!"); } if(log.isTraceEnabled()) { log.trace("deleted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
private void insert(View view) throws SQLException { if(view.created == null) { if(log.isTraceEnabled()) { log.trace("no rows to insert"); } return; } Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + insertSql); } con = ds.getConnection(); ps = con.prepareStatement(insertSql); int batchCount = 0; while(view.created != null) { RelationKeys keys = view.created; JDBCCMPFieldBridge2[] keyFields = (JDBCCMPFieldBridge2[])leftField.getTableKeyFields(); int paramInd = 1; for(int fInd = 0; fInd < keyFields.length; ++fInd) { JDBCCMPFieldBridge2 field = keyFields[fInd]; Object fieldValue = field.getPrimaryKeyValue(keys.leftKey); paramInd = field.setArgumentParameters(ps, paramInd, fieldValue); } keyFields = (JDBCCMPFieldBridge2[])rightField.getTableKeyFields(); for(int fInd = 0; fInd < keyFields.length; ++fInd) { JDBCCMPFieldBridge2 field = keyFields[fInd]; Object fieldValue = field.getPrimaryKeyValue(keys.rightKey); paramInd = field.setArgumentParameters(ps, paramInd, fieldValue); } ps.addBatch(); ++batchCount; keys.dereference(); } ps.executeBatch(); if(log.isTraceEnabled()) { log.trace("inserted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
public void flushDeleted(Schema.Views views) throws SQLException { delete(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
public void flushCreated(Schema.Views views) throws SQLException { insert(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
public void flushUpdated() throws SQLException { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public Row loadRow(Object id) throws SQLException { View view = getView(); Row row = view.getRowByPk(id, false); if(row != null) { if(log.isTraceEnabled()) { log.trace("row is already loaded: pk=" + id); } return row; } JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + selectSql); } con = dataSource.getConnection(); ps = con.prepareStatement(selectSql); int paramInd = 1; for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object pkValue = pkField.getPrimaryKeyValue(id); paramInd = pkField.setArgumentParameters(ps, paramInd, pkValue); } rs = ps.executeQuery(); if(!rs.next()) { throw new NoSuchEntityException("Row not found: " + id); } return view.loadRow(rs, id, false); } catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void delete(View view) throws SQLException { JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + deleteSql); } con = dataSource.getConnection(); ps = con.prepareStatement(deleteSql); int batchCount = 0; while(view.deleted != null) { Row row = view.deleted; int paramInd = 1; for(int pkInd = 0; pkInd < pkFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = pkFields[pkInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } deleteStrategy.executeUpdate(ps); ++batchCount; row.flushStatus(); } deleteStrategy.executeBatch(ps); if(view.deleted != null) { throw new IllegalStateException("There are still rows to delete!"); } if(log.isTraceEnabled()) { log.trace("deleted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void update(View view) throws SQLException { JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + updateSql); } con = dataSource.getConnection(); ps = con.prepareStatement(updateSql); int batchCount = 0; while(view.dirty != null) { Row row = view.dirty; int paramInd = 1; for(int fInd = 0; fInd < tableFields.length; ++fInd) { JDBCCMPFieldBridge2 field = tableFields[fInd]; if(!field.isPrimaryKeyMember()) { Object fieldValue = row.fields[field.getRowIndex()]; paramInd = field.setArgumentParameters(ps, paramInd, fieldValue); } } for(int fInd = 0; fInd < pkFields.length; ++fInd) { JDBCCMPFieldBridge2 pkField = pkFields[fInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } JDBCCMPFieldBridge2 versionField = entity.getVersionField(); if(versionField != null) { int versionIndex = versionField.getVersionIndex(); Object curVersion = row.fields[versionIndex]; paramInd = versionField.setArgumentParameters(ps, paramInd, curVersion); Object newVersion = row.fields[versionField.getRowIndex()]; row.fields[versionIndex] = newVersion; } updateStrategy.executeUpdate(ps); ++batchCount; row.flushStatus(); } updateStrategy.executeBatch(ps); if(log.isTraceEnabled()) { log.trace("updated rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to update: table=" + tableName, e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void insert(View view) throws SQLException { JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + insertSql); } con = dataSource.getConnection(); ps = con.prepareStatement(insertSql); int batchCount = 0; while(view.created != null) { Row row = view.created; int paramInd = 1; for(int fInd = 0; fInd < tableFields.length; ++fInd) { JDBCCMPFieldBridge2 field = tableFields[fInd]; Object fieldValue = row.fields[field.getRowIndex()]; paramInd = field.setArgumentParameters(ps, paramInd, fieldValue); } insertStrategy.executeUpdate(ps); ++batchCount; row.flushStatus(); } insertStrategy.executeBatch(ps); if(log.isTraceEnabled()) { log.trace("inserted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flushDeleted(Schema.Views views) throws SQLException { if(rowsWithNullFks != null) { nullifyForeignKeys(); rowsWithNullFks = null; } if(deleted == null) { if(log.isTraceEnabled()) { log.trace("no rows to delete"); } return; } if(referencedBy != null) { if(inFlush) { if(log.isTraceEnabled()) { log.trace("inFlush, ignoring flushDeleted"); } return; } inFlush = true; try { for(int i = 0; i < referencedBy.length; ++i) { final Table.View view = views.entityViews[referencedBy[i]]; if(view != null) { view.flushDeleted(views); } } } finally { inFlush = false; } } delete(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flushCreated(Schema.Views views) throws SQLException { if(created == null || dontFlushCreated) { if(log.isTraceEnabled()) { log.trace("no rows to insert"); } return; } if(references != null) { if(inFlush) { if(log.isTraceEnabled()) { log.trace("inFlush, ignorning flushCreated"); } return; } else if(log.isTraceEnabled()) { log.trace("flushing created references"); } inFlush = true; try { for(int i = 0; i < references.length; ++i) { final Table.View view = views.entityViews[references[i]]; if(view != null) { view.flushCreated(views); } } } finally { inFlush = false; } } insert(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flushUpdated() throws SQLException { if(dirtyRelations != null) { while(dirtyRelations != null) { Row row = dirtyRelations; row.flushStatus(); } } if(dirty == null) { if(log.isTraceEnabled()) { log.trace("no rows to update"); } return; } update(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void nullifyForeignKeys() throws SQLException { if(log.isTraceEnabled()) { log.trace("nullifying foreign keys"); } Connection con = null; PreparedStatement[] ps = new PreparedStatement[fkConstraints.length]; try { final JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); con = dataSource.getConnection(); for(int i = 0; i < rowsWithNullFks.size(); ++i) { final Row row = (Row) rowsWithNullFks.get(i); final ForeignKeyConstraint[] cons = row.fkUpdates; for (int c = 0; c < fkConstraints.length; ++c) { if (cons[c] == null || row.state == DELETED && !cons[c].selfReference) continue; PreparedStatement s = ps[c]; if (s == null) { if (log.isDebugEnabled()) { log.debug("nullifying fk: " + cons[c].nullFkSql); } s = con.prepareStatement(cons[c].nullFkSql); ps[c] = s; } int paramInd = 1; for (int fInd = 0; fInd < pkFields.length; ++fInd) { JDBCCMPFieldBridge2 pkField = pkFields[fInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(s, paramInd, fieldValue); } final int affected = s.executeUpdate(); if (affected != 1) { throw new EJBException("Affected " + affected + " rows while expected just one"); } } } } finally { for(int i = 0; i < ps.length; ++i) { JDBCUtil.safeClose(ps[i]); } JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flush() throws SQLException, DuplicateKeyException { // todo needs refactoring if(state != CREATED) { if(log.isTraceEnabled()) { log.trace("The row is already inserted: pk=" + pk); } return; } Connection con = null; PreparedStatement duplicatePkPs = null; PreparedStatement insertPs = null; ResultSet rs = null; try { int paramInd; con = dataSource.getConnection(); // check for duplicate key /* if(log.isDebugEnabled()) { log.debug("executing : " + duplicatePkSql); } duplicatePkPs = con.prepareStatement(duplicatePkSql); paramInd = 1; JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object fieldValue = fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(duplicatePkPs, paramInd, fieldValue); } rs = duplicatePkPs.executeQuery(); if(rs.next()) { throw new DuplicateKeyException("Table " + tableName + ", pk=" + pk); } */ // insert if(log.isDebugEnabled()) { log.debug("executing : " + insertSql); } insertPs = con.prepareStatement(insertSql); paramInd = 1; JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); for(int fInd = 0; fInd < tableFields.length; ++fInd) { JDBCCMPFieldBridge2 field = tableFields[fInd]; Object fieldValue = fields[field.getRowIndex()]; paramInd = field.setArgumentParameters(insertPs, paramInd, fieldValue); } insertPs.executeUpdate(); flushStatus(); } catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(duplicatePkPs); JDBCUtil.safeClose(insertPs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeUpdate(PreparedStatement ps) throws SQLException { ps.addBatch(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeBatch(PreparedStatement ps) throws SQLException { int[] updates = ps.executeBatch(); for(int i = 0; i < updates.length; ++i) { int status = updates[i]; if(status != 1 && status != -2 /* java.sql.Statement.SUCCESS_NO_INFO since jdk1.4*/) { String msg = (status == -3 /* java.sql.Statement.EXECUTE_FAILED since jdk1.4 */ ? "One of the commands in the batch failed to execute" : "Each command in the batch should update exactly 1 row but " + "one of the commands updated " + updates[i] + " rows."); throw new EJBException(msg); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeUpdate(PreparedStatement ps) throws SQLException { int rows = ps.executeUpdate(); if(rows != 1) { throw new EJBException("Expected one updated row but got: " + rows); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PersistentContext.java
public void flush() throws SQLException, DuplicateKeyException { row.flush(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Object readRow(ResultSet rs, GenericEntityObjectFactory factory) throws SQLException { return field.loadArgumentResults(rs, 1); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Object readRow(ResultSet rs, GenericEntityObjectFactory factory) throws SQLException { return function.readResult(rs); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected PreparedStatement prepareStatement(Connection c, String sql, EntityEnterpriseContext ctx) throws SQLException { return c.prepareStatement(sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { return ps.executeUpdate(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
public void set(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { if(log.isTraceEnabled()) { log.trace("param: " + "i=" + index + ", " + "type=" + JDBCUtil.getJDBCTypeName(jdbcType) + ", " + "value=" + ((value == null) ? "NULL" : value)); } if(value == null) { ps.setNull(index, jdbcType); } else { value = JDBCUtil.coerceToSQLType(jdbcType, value); setNotNull(ps, index, jdbcType, value, log); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { String string = value.toString(); ps.setCharacterStream(index, new StringReader(string), string.length()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { byte[] bytes = JDBCUtil.convertObjectToByteArray(value); ps.setBytes(index, bytes); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { byte[] bytes = JDBCUtil.convertObjectToByteArray(value); ps.setBinaryStream(index, new ByteArrayInputStream(bytes), bytes.length); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { if(value instanceof BigDecimal) { ps.setBigDecimal(index, (BigDecimal)value); } else { ps.setObject(index, value, jdbcType, 0); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { ps.setObject(index, value, jdbcType); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static byte[] convertObjectToByteArray(Object value) throws SQLException { // Do we already have a byte array? if(value instanceof byte[]) { return (byte[])value; } ByteArrayOutputStream baos = null; ObjectOutputStream oos = null; try { // ejb-reference: store the handle if(value instanceof EJBObject) { value = ((EJBObject)value).getHandle(); } // Marshall the object using MashalledValue to handle classloaders value = new MarshalledValue(value); // return the serialize the value baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(value); return baos.toByteArray(); } catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); } catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); } finally { safeClose(oos); safeClose(baos); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object convertToObject(byte[] input) throws SQLException { ByteArrayInputStream bais = new ByteArrayInputStream(input); try { return convertToObject(bais); } finally { safeClose(bais); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object convertToObject(InputStream input) throws SQLException { Object value = null; if(input != null) { ObjectInputStream ois = null; try { // deserialize result ois = new ObjectInputStream(input); value = ois.readObject(); // de-marshall value if possible if(value instanceof MarshalledValue) { value = ((MarshalledValue)value).get(); } else if(value instanceof MarshalledObject) { value = ((MarshalledObject)value).get(); } // ejb-reference: get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } finally { // ois will close the input stream it wraps safeClose(ois); } } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static String getLongString(ResultSet rs, int index) throws SQLException { String value; Reader textData = rs.getCharacterStream(index); if(textData != null) { try { // Use a modest buffer here to reduce function call overhead // when reading extremely large data. StringBuffer textBuffer = new StringBuffer(); char[] tmpBuffer = new char[1000]; int charsRead; while((charsRead = textData.read(tmpBuffer)) != -1) textBuffer.append(tmpBuffer, 0, charsRead); value = textBuffer.toString(); } catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); } finally { safeClose(textData); } } else value = null; return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static byte[] getByteArray(InputStream input) throws SQLException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { // Use a modest buffer here to reduce function call overhead // when reading extremely large data. byte[] tmpBuffer = new byte[1000]; int bytesRead; while((bytesRead = input.read(tmpBuffer)) != -1) baos.write(tmpBuffer, 0, bytesRead); return baos.toByteArray(); } catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); } finally { safeClose(baos); safeClose(input); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object getParameter(Logger log, CallableStatement cs, int index, int jdbcType, Class destination) throws SQLException { Object value = null; switch(jdbcType) { // // Large types // case Types.CLOB: case Types.LONGVARCHAR: case Types.BLOB: case Types.LONGVARBINARY: throw new UnsupportedOperationException(); // // Small binary types // case Types.BINARY: case Types.VARBINARY: { byte[] bytes = cs.getBytes(index); if(!cs.wasNull()) { if(destination == byte[].class) value = bytes; else value = convertToObject(bytes); } if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Binary, value=" + value); } } break; // // Specialist types that the // driver should handle // case Types.JAVA_OBJECT: case Types.STRUCT: case Types.ARRAY: case Types.OTHER: { value = cs.getObject(index); if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Object, value=" + value); } } break; // // Non-binary types // default: Method method = (Method)csTypes.get(destination.getName()); if(method != null) { try { value = method.invoke(cs, new Object[]{new Integer(index)}); if(cs.wasNull()) { value = null; } if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Simple, value=" + value); } } catch(IllegalAccessException e) { // Whatever, I guess non-binary will not work for this field. } catch(InvocationTargetException e) { // Whatever, I guess non-binary will not work for this field. } } else { value = cs.getObject(index); if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Object, value=" + value); } } } return coerceToJavaType(value, destination); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
private static Object coerceToJavaType( Object value, Class destination) throws SQLException { try { // // null // if(value == null) { return null; } // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // // Primitive wrapper classes // // We have a primitive wrapper and we want a real primitive // just return the wrapper and the vm will convert it at the proxy if(destination.isPrimitive()) { if(value == null) throw new IllegalStateException("Loaded NULL value for a field of a primitive type."); if((destination.equals(Byte.TYPE) && value instanceof Byte) || (destination.equals(Short.TYPE) && value instanceof Short) || (destination.equals(Character.TYPE) && value instanceof Character) || (destination.equals(Boolean.TYPE) && value instanceof Boolean) || (destination.equals(Integer.TYPE) && value instanceof Integer) || (destination.equals(Long.TYPE) && value instanceof Long) || (destination.equals(Float.TYPE) && value instanceof Float) || (destination.equals(Double.TYPE) && value instanceof Double) ) { return value; } } // // java.util.Date // // make new copy as sub types have problems in comparions if(destination == java.util.Date.class && value instanceof java.util.Date) { // handle timestamp special becauses it hoses the milisecond values if(value instanceof java.sql.Timestamp) { java.sql.Timestamp ts = (java.sql.Timestamp)value; // Timestamp returns whole seconds from getTime and partial // seconds are retrieved from getNanos() // Adrian Brock: Not in 1.4 it doesn't long temp = ts.getTime(); if(temp % 1000 == 0) temp += ts.getNanos() / 1000000; return new java.util.Date(temp); } else { return new java.util.Date(((java.util.Date)value).getTime()); } } // // java.sql.Time // // make a new copy object; you never know what a driver will return if(destination == java.sql.Time.class && value instanceof java.sql.Time) { return new java.sql.Time(((java.sql.Time)value).getTime()); } // // java.sql.Date // // make a new copy object; you never know what a driver will return if(destination == java.sql.Date.class && value instanceof java.sql.Date) { return new java.sql.Date(((java.sql.Date)value).getTime()); } // // java.sql.Timestamp // // make a new copy object; you never know what a driver will return if(destination == java.sql.Timestamp.class && value instanceof java.sql.Timestamp) { // make a new Timestamp object; you never know // what a driver will return java.sql.Timestamp orignal = (java.sql.Timestamp)value; java.sql.Timestamp copy = new java.sql.Timestamp(orignal.getTime()); copy.setNanos(orignal.getNanos()); return copy; } // // java.lang.String --> java.lang.Character or char // // just grab first character if(value instanceof String && (destination == Character.class || destination == Character.TYPE)) { return new Character(((String)value).charAt(0)); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do throw new SQLException("Got a " + value.getClass().getName() + "[cl=" + System.identityHashCode(value.getClass().getClassLoader()) + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + System.identityHashCode(destination) + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public InputStream getBinaryStream() throws SQLException { return new ByteArrayInputStream(mBytes); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public byte[] getBytes(long pos, int length) throws SQLException { // Defensive code, parameter checks. if (length < 0 || length > mBytes.length || pos > mBytes.length) { return new byte[0]; } if (pos <= 0) { pos = 1; // One since the copy starts at pos. } byte[] buffer = new byte[length]; System.arraycopy(mBytes, (int)pos - 1, buffer, 0, length); return buffer; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public long length() throws SQLException { return mBytes.length; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public long position(Blob pattern , long start) throws SQLException { return position(pattern.getBytes(0, (int)pattern.length()), start); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public long position(byte pattern[], long start) throws SQLException { // Small optimization, no need to look beyond this. int max = mBytes.length - pattern.length; if (start < 0) { start = 0; // Cannot start negative, so put it at the beginning. } else if (start >= mBytes.length) { return -1; // Out of bounds, start was past the end of the buffer. } if (pattern.length == 0) { return -1; // Indicate that the pattern was not found. } byte first = pattern[0]; int i = (int)start; while (true) { // Look for the first character. while (i <= max && mBytes[i] != first) { i++; } if (i > max) { return -1; // Went to far, reject the pattern. } // Found the first character, now look for remainder of v2. int j = i + 1; int end = j + pattern.length - 1; int k = 1; boolean cont = true; // While the bytes remain equal and the end of v1 is not reached // continue the either rejecting this match, or accepting it. while (cont && j < end) { if (mBytes[j++] != pattern[k++]) { i++; cont = false; } } // If cont == false then the pattern was found. if (cont) { return i; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public void free() throws SQLException { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public InputStream getBinaryStream(long pos, long length) throws SQLException { throw new UnsupportedOperationException("Unimplemented JDK6 method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public OutputStream setBinaryStream(long pos) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public int setBytes(long pos, byte[] bytes) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public int setBytes(long pos, byte[] bytes, int offset, int length) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public void truncate(long length) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); Connection c; Statement s = null; ResultSet rs = null; try { c = ps.getConnection(); s = c.createStatement(); rs = s.executeQuery(pkSQL); if (!rs.next()) { throw new EJBException("ResultSet was empty"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Clob clob = rs.getClob(index); String content; if(clob == null) { content = null; } else { final Reader reader = clob.getCharacterStream(); if(reader != null) { int intLength = (int)clob.length(); char[] chars; try { if(intLength <= 8192) { chars = new char[intLength]; reader.read(chars); content = String.valueOf(chars); } else { StringBuffer buf = new StringBuffer(intLength); chars = new char[8192]; int i = reader.read(chars); while(i > 0) { buf.append(chars, 0, i); i = reader.read(chars); } content = buf.toString(); } } catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); } finally { JDBCUtil.safeClose(reader); } } else { content = null; } } return content; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return JDBCUtil.getLongString(rs, index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Object value = null; byte[] bytes = rs.getBytes(index); if(!rs.wasNull()) { if(destination == byte[].class) value = bytes; else value = JDBCUtil.convertToObject(bytes); } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Object value = null; byte[] bytes = rs.getBytes(index); if(!rs.wasNull()) { if(destination == byte[].class) value = bytes; else value = JDBCUtil.convertToObject(bytes); } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Blob blob = rs.getBlob(index); Object value; if(blob == null) { value = null; } else { InputStream binaryData = blob.getBinaryStream(); if(binaryData != null) { if(destination == byte[].class) value = JDBCUtil.getByteArray(binaryData); else value = JDBCUtil.convertToObject(binaryData); } else { value = null; } } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Object value = null; InputStream binaryData = rs.getBinaryStream(index); if(binaryData != null && !rs.wasNull()) { if(destination == byte[].class) value = JDBCUtil.getByteArray(binaryData); else value = JDBCUtil.convertToObject(binaryData); } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getTimestamp(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getDate(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getTime(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getTimestamp(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getBigDecimal(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getRef(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getBytes(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { final String result = rs.getString(index); if(log.isTraceEnabled()) { log.trace("result: i=" + index + ", type=" + destination.getName() + ", value=" + result); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { Object result = readResult(rs, index, destination); if(rs.wasNull()) result = null; else result = coerceToJavaType(result, destination); if(log.isTraceEnabled()) { log.trace("result: i=" + index + ", type=" + destination.getName() + ", value=" + result); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object coerceToJavaType(Object value, Class destination) throws SQLException { return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return (rs.getBoolean(index) ? Boolean.TRUE : Boolean.FALSE); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Byte(rs.getByte(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getString(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Short(rs.getShort(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Integer(rs.getInt(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Long(rs.getLong(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Float(rs.getFloat(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Double(rs.getDouble(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { Object result = readResult(rs, index, destination); if(result != null) result = coerceToJavaType(result, destination); if(log.isTraceEnabled()) { log.trace("result: i=" + index + ", type=" + destination.getName() + ", value=" + result); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object coerceToJavaType(Object value, Class destination) throws SQLException { try { // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do String className = null; Object interfaces = null; ClassLoader cl = null; if (value != null) { Class valueClass = value.getClass(); className = valueClass.getName(); interfaces = Arrays.asList(valueClass.getInterfaces()); cl = valueClass.getClassLoader(); } throw new SQLException("Got a " + className + "[cl=" + cl + " + interfaces=" + interfaces + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + destination.getClassLoader() + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
protected int executeInsert(int index, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { ps.execute(); ResultSet rs = null; try { int rows = ps.getUpdateCount(); if(rows != 1) { throw new EJBException("Expected updateCount of 1, got " + rows); } if(ps.getMoreResults() == false) { throw new EJBException("Expected ResultSet but got an updateCount. Is NOCOUNT set for all triggers?"); } rs = ps.getResultSet(); if(!rs.next()) { throw new EJBException("ResultSet was empty"); } pkField.loadInstanceResults(rs, 1, ctx); return rows; } catch(RuntimeException e) { throw e; } catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); // remove any JCA wrappers Statement stmt = ps; do { try { Object[] args = {}; stmt = (Statement) getUnderlyingStatement.invoke(stmt, args); } catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } } while (stmt != null && method.getDeclaringClass().isInstance(stmt) == false); try { Number pk = (Number)method.invoke(stmt, null); pkField.setInstanceValue(ctx, pk); return rows; } catch(RuntimeException e) { throw e; } catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
protected PreparedStatement prepareStatement(Connection c, String sql, EntityEnterpriseContext ctx) throws SQLException { try { return (PreparedStatement) CONNECTION_PREPARE.invoke(c, new Object[] { sql, GENERATE_KEYS }); } catch (Exception e) { throw processException(e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); ResultSet rs = null; try { rs = (ResultSet) GET_GENERATED_KEYS.invoke(ps, null); if (!rs.next()) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("getGeneratedKeys returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); // remove any JCA wrappers Statement stmt = ps; do { try { Object[] args = {}; stmt = (Statement) getUnderlyingStatement.invoke(stmt, args); } catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } } while (stmt != null && method.getDeclaringClass().isInstance(stmt) == false); ResultSet rs = null; try { rs = (ResultSet) method.invoke(stmt, null); if (!rs.next()) { throw new EJBException("getGeneratedKeys returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx ) throws SQLException { int rows = ps.executeUpdate(); ResultSet results = null; try { Connection conn = ps.getConnection(); results = conn.prepareStatement( SQL ).executeQuery(); if( !results.next() ) { throw new EJBException( "identity_val_local() returned an empty ResultSet" ); } pkField.loadInstanceResults( results, 1, ctx ); } catch( RuntimeException e ) { throw e; } catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); } finally { JDBCUtil.safeClose( results ); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
protected int executeInsert(int index, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); Statement s = null; ResultSet rs = null; try { if (trace) { log.trace("Executing SQL :"+sequenceSQL); } Connection c = ps.getConnection(); s = c.createStatement(); rs = s.executeQuery(sequenceSQL); if (!rs.next()) { throw new EJBException("sequence sql returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
protected PreparedStatement prepareStatement(Connection c, String sql, EntityEnterpriseContext ctx) throws SQLException { return c.prepareCall(sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { CallableStatement cs = (CallableStatement) ps; cs.registerOutParameter(paramIndex, jdbcType); cs.execute(); Object pk = JDBCUtil.getParameter(log, cs, paramIndex, jdbcType, pkField.getFieldType()); pkField.setInstanceValue(ctx, pk); return 1; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
protected PreparedStatement prepareStatement(Connection c, String sql, EntityEnterpriseContext ctx) throws SQLException { return c.prepareCall(sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
protected int executeInsert(int paramInd, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { CallableStatement cs = (CallableStatement) ps; cs.registerOutParameter(pkIndex, jdbcType); cs.execute(); Object pk = JDBCUtil.getParameter(log, cs, pkIndex, jdbcType, pkField.getFieldType()); pkField.setInstanceValue(ctx, pk); return 1; }
(Lib) RemoteException 16
              
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); ejbObject.remove(); return null; } else throw new RemoveException("EJBHome.remove(Object) not allowed for session beans"); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object getPrimaryKey() throws RemoteException { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { // All we need is an EJBObject for this Id, the first argument is the Id EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Object id = mi.getArguments()[0]; if (id == null) throw new IllegalStateException("Cannot get a session interface with a null id"); // Does the session still exist? InstanceCache cache = getInstanceCache(); BeanLock lock = getLockManager().getLock(id); lock.sync(); try { if (cache.get(id) == null) throw new RemoteException("Session no longer exists: " + id); } finally { lock.releaseSync(); getLockManager().removeLockRef(id); } // Ok lets create the proxy return (EJBObject) ci.getStatefulSessionEJBObject(id); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); boolean nonReentrant = !(reentrant || isReentrantMethod(mi)); // Not a reentrant method like getPrimaryKey NonReentrantLock methodLock = ctx.getMethodLock(); Transaction miTx = ctx.getTransaction(); boolean locked = false; try { while (!locked) { if (methodLock.attempt(5000, miTx, nonReentrant)) { locked = true; } else { if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } } } catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } } try { ctx.lock(); return getNext().invoke(mi); } finally { ctx.unlock(); methodLock.release(nonReentrant); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context InstancePool pool = container.getInstancePool(); StatelessSessionEnterpriseContext ctx = null; try { ctx = (StatelessSessionEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Use this context mi.setEnterpriseContext(ctx); // JAXRPC/JAXWS message context Object msgContext = mi.getValue(InvocationKey.SOAP_MESSAGE_CONTEXT); // Timer invocation if (ejbTimeout.equals(mi.getMethod())) { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); } // Service Endpoint invocation else if (msgContext != null) { if (msgContext instanceof javax.xml.rpc.handler.MessageContext) ctx.setMessageContext((javax.xml.rpc.handler.MessageContext)msgContext); AllowedOperationsAssociation.pushInMethodFlag(IN_SERVICE_ENDPOINT_METHOD); } // Business Method Invocation else { AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); } // There is no need for synchronization since the instance is always fresh also there should // never be a tx associated with the instance. try { Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/local/StatefulSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { if (args == null) args = EMPTY_ARGS; // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (m.equals(GET_PRIMARY_KEY)) { if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } Object retValue = super.invoke( proxy, m, args ); if (retValue == null) { // If not taken care of, go on and call the container retValue = factory.invoke(id, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/local/StatelessSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { Object retValue = null; if (args == null) args = EMPTY_ARGS; // Implement local methods if (m.equals(TO_STRING)) { retValue = jndiName + ":Stateless"; } else if (m.equals(EQUALS)) { retValue = invoke(proxy, IS_IDENTICAL, args); } else if (m.equals(HASH_CODE)) { // We base the stateless hash on the hash of the proxy... // MF XXX: it could be that we want to return the hash of the name? retValue = new Integer(this.hashCode()); } else if (m.equals(GET_PRIMARY_KEY)) { // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } else if (m.equals(GET_EJB_HOME)) { InitialContext ctx = new InitialContext(); return ctx.lookup(jndiName); } else if (m.equals(IS_IDENTICAL)) { // All stateless beans are identical within a home, // if the names are equal we are equal retValue = isIdentical(args[0], jndiName + ":Stateless"); } // If not taken care of, go on and call the container else { retValue = factory.invoke(jndiName, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // The key Object key = mi.getId(); EntityEnterpriseContext ctx = null; EntityContainer ec = (EntityContainer) container; if (mi.getTransaction() != null) { //ctx = ec.getTxEntityMap().getCtx(mi.getTransaction(), key); } if (ctx == null) { InstancePool pool = ec.getInstancePool(); try { ctx = (EntityEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } ctx.setCacheKey(key); ctx.setId(key); EntityPersistenceManager pm = ec.getPersistenceManager(); pm.activateEntity(ctx); } boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Begin invoke, key="+key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); try { Object ret = getNext().invoke(mi); return ret; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
private void checkStatelessDone() throws RemoteException { int status = Status.STATUS_NO_TRANSACTION; try { status = tm.getStatus(); } catch (SystemException ex) { log.error("Failed to get status", ex); } try { switch (status) { case Status.STATUS_ACTIVE : case Status.STATUS_COMMITTING : case Status.STATUS_MARKED_ROLLBACK : case Status.STATUS_PREPARING : case Status.STATUS_ROLLING_BACK : try { tm.rollback(); } catch (Exception ex) { log.error("Failed to rollback", ex); } // fall through... case Status.STATUS_PREPARED : String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before" + " returning (ejb1.1 spec, 11.6.1)"; log.error(msg); // the instance interceptor will discard the instance throw new RemoteException(msg); } } finally { Transaction tx = null; try { tx = tm.suspend(); } catch (SystemException ex) { log.error("Failed to suspend transaction", ex); } if (tx != null) { String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ; log.error(msg); throw new RemoteException(msg); } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { InstanceCache cache = container.getInstanceCache(); InstancePool pool = container.getInstancePool(); Object methodID = mi.getId(); EnterpriseContext ctx = null; BeanLock lock = container.getLockManager().getLock(methodID); boolean callerRunAsIdentityPresent = SecurityActions.peekRunAsIdentity() != null; boolean pushSecurityContext = SecurityActions.getSecurityContext() == null; try { /* The security context must be established before the cache lookup because the activation of a session should have the caller's security context as ejbActivate is allowed to call other secured resources. Since the pm makes the ejbActivate call, we need to set the caller's security context. The only reason this shows up for stateful session is that we moved the SecurityInterceptor to after the instance interceptor to allow security exceptions to result in invalidation of the session. This may be too literal an interpretation of the ejb spec requirement that runtime exceptions should invalidate the session. */ if(!callerRunAsIdentityPresent && pushSecurityContext) { AuthenticationManager am = container.getSecurityManager(); String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(am != null) securityDomain = am.getSecurityDomain(); SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain , null); //SecurityActions.pushSubjectContext(mi.getPrincipal(), mi.getCredential(), null); } lock.sync(); try { // Get context try { ctx = cache.get(methodID); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } // Associate it with the method invocation mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // BMT beans will lock and replace tx no matter what, CMT do work on transaction boolean isBMT = ((SessionMetaData)container.getBeanMetaData()).isBeanManagedTx(); if (isBMT == false) { // Do we have a running transaction with the context if (ctx.getTransaction() != null && // And are we trying to enter with another transaction !ctx.getTransaction().equals(mi.getTransaction())) { // Calls must be in the same transaction StringBuffer msg = new StringBuffer("Application Error: " + "tried to enter Stateful bean with different tx context"); msg.append(", contextTx: " + ctx.getTransaction()); msg.append(", methodTx: " + mi.getTransaction()); throw new EJBException(msg.toString()); } //If the instance will participate in a new transaction we register a sync for it if (ctx.getTransaction() == null && mi.getTransaction() != null) { register(ctx, mi.getTransaction(), lock); } } if (!ctx.isLocked()) { //take it! ctx.lock(); } else { if (!isCallAllowed(mi)) { // Concurent calls are not allowed throw new EJBException("Application Error: no concurrent " + "calls on stateful beans"); } else { ctx.lock(); } } } finally { lock.releaseSync(); } // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); boolean validContext = true; try { // Invoke through interceptors Object ret = getNext().invoke(mi); return ret; } catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } } } finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Map to EJBHome.remove(Object) to EJBObject.remove() InvocationType type = mi.getType(); if (type == InvocationType.HOME) mi.setType(InvocationType.REMOTE); else if (type == InvocationType.LOCALHOME) mi.setType(InvocationType.LOCAL); mi.setMethod(EJBOBJECT_REMOVE); // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); mi.setId(ejbObject.getPrimaryKey()); } else mi.setId(arg); mi.setArguments(new Object[0]); return getInterceptor().invoke(mi); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
protected EJBObject getEjbObjectViaJndi() throws RemoteException { try { if (log.isTraceEnabled()) { log.trace("Using JNDI method for getEJBObject() invocation."); } InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); Proxy proxy = (Proxy) ic.lookup(jndiName); // call findByPrimary on the target InvocationHandler ih = Proxy.getInvocationHandler(proxy); return (EJBObject) ih.invoke(proxy, GET_EJB_OBJECT, new Object[] {id}); } catch (RemoteException e) { throw e; } catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); } }
// in src/main/java/org/jboss/proxy/ejb/StatelessSessionInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return toString(ctx); } else if (m.equals(EQUALS)) { Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { // We base the stateless hash on the hash of the proxy... // MF XXX: it could be that we want to return the hash of the name? return new Integer(this.hashCode()); } // Implement local EJB calls else if (m.equals(GET_HANDLE)) { return new StatelessHandleImpl( (String)ctx.getValue(InvocationKey.JNDI_NAME)); } else if (m.equals(GET_PRIMARY_KEY)) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } else if (m.equals(GET_EJB_HOME)) { return getEJBHome(invocation); } else if (m.equals(IS_IDENTICAL)) { // All stateless beans are identical within a home, // if the names are equal we are equal Object[] args = invocation.getArguments(); String argsString = args[0].toString(); String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } // If not taken care of, go on and call the container else { invocation.setType(InvocationType.REMOTE); return getNext().invoke(invocation); } }
// in src/main/java/org/jboss/proxy/ejb/StatefulSessionInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return toString(ctx); } else if (m.equals(EQUALS)) { Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { return new Integer(ctx.getCacheId().hashCode()); } // Implement local EJB calls else if (m.equals(GET_HANDLE)) { int objectName = ((Integer) ctx.getObjectName()).intValue(); String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME); Invoker invoker = ctx.getInvoker(); Object id = ctx.getCacheId(); return createHandle(objectName, jndiName, invoker, id, ctx); } else if (m.equals(GET_EJB_HOME)) { return getEJBHome(invocation); } else if (m.equals(GET_PRIMARY_KEY)) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } else if (m.equals(IS_IDENTICAL)) { Object[] args = invocation.getArguments(); String argsString = args[0].toString(); String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } // If not taken care of, go on and call the container else { // It is a remote invocation invocation.setType(InvocationType.REMOTE); // On this entry in cache invocation.setId(ctx.getCacheId()); return getNext().invoke(invocation); } }
6
              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); }
89
              
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void addNotificationListener(ObjectName name, RMINotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("addNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = new NotificationListenerDelegate(listener, name); remoteListeners.put(listener, delegate); getServer().addNotificationListener(name, delegate, filter, handback); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void removeNotificationListener(ObjectName name, RMINotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("removeNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = (NotificationListenerDelegate) remoteListeners.remove(listener); if( delegate == null ) throw new ListenerNotFoundException("No listener matches: "+listener); getServer().removeNotificationListener(name, delegate); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void destroy() throws RemoteException { unreferenced(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public Object begin(int timeout) throws RemoteException, NotSupportedException, SystemException { TransactionManager tm = getTransactionManager(); // Set timeout value tm.setTransactionTimeout(timeout); // Start tx, and get its TPC. tm.begin(); Object tpc = getTPCFactory().getTransactionPropagationContext(); // Suspend thread association. Transaction tx = tm.suspend(); // Remember that a new tx is now active. activeTx.put(tpc, tx); // return the TPC return tpc; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void setRollbackOnly(Object tpc) throws RemoteException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); tx.setRollbackOnly(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public int getStatus(Object tpc) throws RemoteException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) return Status.STATUS_NO_TRANSACTION; return tx.getStatus(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionFactoryImpl.java
public UserTransactionSession newInstance() throws RemoteException { return new UserTransactionSessionImpl(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Handle getHandle(Invocation mi) throws RemoteException { // TODO return null; }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object getPrimaryKey(Invocation mi) throws RemoteException { return getPrimaryKey(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object getPrimaryKey() throws RemoteException { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBHome getEJBHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return (EJBHome) ci.getEJBHome(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public boolean isIdentical(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.isIdentical(this, mi); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBMetaData getEJBMetaDataHome(Invocation mi) throws RemoteException { return getEJBMetaDataHome(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBMetaData getEJBMetaDataHome() throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.getEJBMetaData(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public HomeHandle getHomeHandleHome(Invocation mi) throws RemoteException { return getHomeHandleHome(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public HomeHandle getHomeHandleHome() throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } EJBHome home = (EJBHome) ci.getEJBHome(); return home.getHomeHandle(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { log.debug("Useless invocation of remove() for stateless session bean"); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBObject createHome() throws RemoteException, CreateException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; Object obj = ci.getStatelessSessionEJBObject(); return (EJBObject) obj; }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Handle handle) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Object primaryKey) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void discard() throws RemoteException { ((SessionBean)instance).ejbRemove(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // if the session is removed already then let the user know they have a problem StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); if (ctx.getId() == null) { throw new RemoveException("SFSB has been removed already"); } // Remove from storage try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); getPersistenceManager().removeSession(ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // We signify "removed" with a null id ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { // All we need is an EJBObject for this Id, the first argument is the Id EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Object id = mi.getArguments()[0]; if (id == null) throw new IllegalStateException("Cannot get a session interface with a null id"); // Does the session still exist? InstanceCache cache = getInstanceCache(); BeanLock lock = getLockManager().getLock(id); lock.sync(); try { if (cache.get(id) == null) throw new RemoteException("Session no longer exists: " + id); } finally { lock.releaseSync(); getLockManager().removeLockRef(id); } // Ok lets create the proxy return (EJBObject) ci.getStatefulSessionEJBObject(id); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public void discard() throws RemoteException { ((MessageDrivenBean)instance).ejbRemove(); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public void discard() throws RemoteException { ((EntityBean)instance).unsetEntityContext(); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public void discard() throws RemoteException { // Do nothing }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBObject createHome() throws java.rmi.RemoteException, CreateException { throw new Error("createHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Handle handle) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Object primaryKey) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBMetaData getEJBMetaDataHome() throws java.rmi.RemoteException { // TODO //return null; throw new Error("getEJBMetaDataHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public HomeHandle getHomeHandleHome() throws java.rmi.RemoteException { // TODO //return null; throw new Error("getHomeHandleHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void activateEntity(EntityEnterpriseContext ctx) throws RemoteException { // Create a new CacheKey Object id = ctx.getId(); Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id ); // Give it to the context ctx.setCacheKey(cacheKey); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); ejbActivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void loadEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_LOAD); ejbLoad.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void invokeEjbStore(EntityEnterpriseContext ctx) throws RemoteException { try { if(!isStoreRequired(ctx)) { return; } } catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); } try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE); ejbStore.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void storeEntity(EntityEnterpriseContext ctx) throws RemoteException { }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void passivateEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); ejbPassivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } ctx.setEJBObject(null); ctx.setEJBLocalObject(null); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); ejbRemove.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void activateSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to activate; ctx=" + ctx); } Object id = ctx.getId(); // Load state File file = getFile(id); if (trace) { log.trace("Reading session state from: " + file); } try { FileInputStream fis = FISAction.open(file); SessionObjectInputStream in = new SessionObjectInputStream(ctx, new BufferedInputStream(fis)); try { Object obj = in.readObject(); if (trace) { log.trace("Session state: " + obj); } ctx.setInstance(obj); } finally { in.close(); } } catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); } removePassivated(id); try { // Instruct the bean to perform activation logic AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbActivate(); } finally { AllowedOperationsAssociation.popInMethodFlag(); } if (trace) { log.trace("Activation complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void passivateSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to passivate; ctx=" + ctx); } try { // Instruct the bean to perform passivation logic AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbPassivate(); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Store state File file = getFile(ctx.getId()); if (trace) { log.trace("Saving session state to: " + file); } try { FileOutputStream fos = FOSAction.open(file); SessionObjectOutputStream out = new SessionObjectOutputStream( new BufferedOutputStream(fos)); Object obj = ctx.getInstance(); if (trace) { log.trace("Writing session state: " + obj); } try { out.writeObject(obj); } finally { out.close(); } } catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); } if (trace) { log.trace("Passivation complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void removeSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException, RemoveException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to remove; ctx=" + ctx); } // Instruct the bean to perform removal logic SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbRemove(); if (trace) { log.trace("Removal complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { EnterpriseContext rtn = null; rtn = super.get(id); return rtn; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
protected void passivate(EnterpriseContext ctx) throws RemoteException { removeTimerServiceIfAllCancelledOrExpired(ctx); m_container.getPersistenceManager().passivateEntity((EntityEnterpriseContext)ctx); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
protected void activate(EnterpriseContext ctx) throws RemoteException { m_container.getPersistenceManager().activateEntity((EntityEnterpriseContext)ctx); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if (id == null) throw new IllegalArgumentException("Can't get an object with a null key"); EnterpriseContext ctx; synchronized (getCacheLock()) { CachePolicy cache = getCache(); ctx = (EnterpriseContext)cache.get(id); if (ctx == null) { try { ctx = acquireContext(); setKey(id, ctx); if (doActivate(ctx) == false) // This is a recursive activation return ctx; logActivation(id); // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here cache.insert(id, ctx); } catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
protected boolean doActivate(EnterpriseContext ctx) throws RemoteException { activate(ctx); return true; }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void activateEntity(EntityEnterpriseContext ctx) throws RemoteException { // Create a new CacheKey Object id = ctx.getId(); Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id); // Give it to the context ctx.setCacheKey(cacheKey); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbActivate(); } catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // The implementation of the call can be left absolutely empty, the // propagation of the call is just a notification for stores that would // need to know that an instance is being activated store.activateEntity(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void loadEntity(EntityEnterpriseContext ctx) throws RemoteException { //long lStart = System.currentTimeMillis(); // Have the store load the fields of the instance store.loadEntity(ctx); //mLoad.add( System.currentTimeMillis() - lStart ); invokeLoad(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void storeEntity(EntityEnterpriseContext ctx) throws RemoteException { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE); try { store.storeEntity(ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void invokeEjbStore(EntityEnterpriseContext ctx) throws RemoteException { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE); try { // if call-ejb-store-for-clean=true then invoke ejbStore first (the last chance to modify the instance) if(ejbStoreForClean) { ejbStore(ctx); } else { // else check whether the instance is dirty and invoke ejbStore only if it is really dirty boolean modified = false; try { modified = isStoreRequired(ctx); } catch(Exception e) { throwRemoteException(e); } if(modified) { ejbStore(ctx); } } } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void passivateEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbPassivate(); } catch(Exception e) { throwRemoteException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); } store.passivateEntity(ctx); ctx.setEJBObject(null); ctx.setEJBLocalObject(null); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbRemove(); } catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } store.removeEntity(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
protected void invokeLoad(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_LOAD); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbLoad(); } catch(Exception e) { throwRemoteException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void ejbStore(EntityEnterpriseContext ctx) throws RemoteException { try { EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbStore(); } catch(Exception e) { throwRemoteException(e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void throwRemoteException(Exception e) throws RemoteException { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
protected void passivate(EnterpriseContext ctx) throws RemoteException { m_container.getPersistenceManager().passivateSession((StatefulSessionEnterpriseContext) ctx); passivatedIDs.put(ctx.getId(), new Long(System.currentTimeMillis())); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
protected void activate(EnterpriseContext ctx) throws RemoteException { m_container.getPersistenceManager().activateSession((StatefulSessionEnterpriseContext) ctx); passivatedIDs.remove(ctx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
protected boolean doActivate(EnterpriseContext ctx) throws RemoteException { Object id = ctx.getId(); synchronized (activating) { // This is a recursive invocation if (activating.contains(id)) return false; activating.add(id); } try { return super.doActivate(ctx); } finally { synchronized (activating) { activating.remove(id); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); } else if(trace) { log.trace(oldValue + " already removed"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); } else if(trace) { log.trace(oldValue + " already removed"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean didDelete = false; boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); didDelete = true; } else if(trace) { log.trace(oldValue + " already removed"); } } if(didDelete) { executeDeleteSQL(batchCascadeDeleteSql, ctx.getId()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void invokeRemoveRelated(Object relatedId) throws RemoveException, RemoteException { EntityContainer container = relatedManager.getContainer(); /* try { EntityCache instanceCache = (EntityCache) container.getInstanceCache(); SecurityActions actions = SecurityActions.UTIL.getSecurityActions(); org.jboss.invocation.Invocation invocation = new org.jboss.invocation.Invocation(); invocation.setId(instanceCache.createCacheKey(relatedId)); invocation.setArguments(new Object[]{}); invocation.setTransaction(container.getTransactionManager().getTransaction()); invocation.setPrincipal(actions.getPrincipal()); invocation.setCredential(actions.getCredential()); invocation.setType(invocationType); invocation.setMethod(removeMethod); container.invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in remove instance", e); } */ /** * Have to remove through EJB[Local}Object interface since the proxy contains the 'removed' flag * to be set on removal. */ if(container.getLocalProxyFactory() != null) { final EJBLocalObject ejbObject = container.getLocalProxyFactory().getEntityEJBLocalObject(relatedId); ejbObject.remove(); } else { final EJBObject ejbObject = (EJBObject)container.getProxyFactory().getEntityEJBObject(relatedId); ejbObject.remove(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
public void execute(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { if(entity.isRemoved(ctx)) { throw new IllegalStateException("Instance was already removed: id=" + ctx.getId()); } entity.setIsBeingRemoved(ctx); // remove entity from all relations Object[] oldRelationsRef = new Object[1]; boolean needsSync = entity.removeFromRelations(ctx, oldRelationsRef); // update the related entities (stores the removal from relationships) // if one of the store fails an EJBException will be thrown if(!syncOnCommitOnly && needsSync) { EntityContainer.synchronizeEntitiesWithinTransaction(ctx.getTransaction()); } if(!batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.trace("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } // cascate-delete to old relations, if relation uses cascade. if(oldRelationsRef[0] != null) { Map oldRelations = (Map)oldRelationsRef[0]; entity.cascadeDelete(ctx, oldRelations); } if(batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.debug("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } entity.setRemoved(ctx); manager.getReadAheadCache().removeCachedData(ctx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { removeEntityCommand.execute(ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void cascadeDelete(EntityEnterpriseContext ctx, Map oldRelations) throws RemoveException, RemoteException { for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge cmrField = cmrFields[i]; Object value = oldRelations.get(cmrField); if(value != null) cmrField.cascadeDelete(ctx, (List)value); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { cascadeDeleteStrategy.cascadeDelete(ctx, oldValues); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if(id == null) throw new IllegalArgumentException("Can't get an object with a null key"); Map cache = getLocalCache(); EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id); if(instance == null) { try { // acquire instance = (EntityEnterpriseContext) container.getInstancePool().get(); // set key instance.setId(id); instance.setCacheKey(id); // activate container.getPersistenceManager().activateEntity(instance); // insert cache.put(id, instance); } catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); } } return instance; }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
private void checkStatelessDone() throws RemoteException { int status = Status.STATUS_NO_TRANSACTION; try { status = tm.getStatus(); } catch (SystemException ex) { log.error("Failed to get status", ex); } try { switch (status) { case Status.STATUS_ACTIVE : case Status.STATUS_COMMITTING : case Status.STATUS_MARKED_ROLLBACK : case Status.STATUS_PREPARING : case Status.STATUS_ROLLING_BACK : try { tm.rollback(); } catch (Exception ex) { log.error("Failed to rollback", ex); } // fall through... case Status.STATUS_PREPARED : String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before" + " returning (ejb1.1 spec, 11.6.1)"; log.error(msg); // the instance interceptor will discard the instance throw new RemoteException(msg); } } finally { Transaction tx = null; try { tx = tm.suspend(); } catch (SystemException ex) { log.error("Failed to suspend transaction", ex); } if (tx != null) { String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ; log.error(msg); throw new RemoteException(msg); } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
private void checkBadStateful() throws RemoteException { int status = Status.STATUS_NO_TRANSACTION; try { status = tm.getStatus(); } catch (SystemException ex) { log.error("Failed to get status", ex); } switch (status) { case Status.STATUS_COMMITTING : case Status.STATUS_MARKED_ROLLBACK : case Status.STATUS_PREPARING : case Status.STATUS_ROLLING_BACK : try { tm.rollback(); } catch (Exception ex) { log.error("Failed to rollback", ex); } String msg = "BMT stateful bean '" + container.getBeanMetaData().getEjbName() + "' did not complete user transaction properly status=" + TxUtils.getStatusAsString(status); log.error(msg); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // synchronize entities with the datastore before the bean is removed // this will write queued updates so datastore will be consistent before removal Transaction tx = mi.getTransaction(); if (!getBeanMetaData().getContainerConfiguration().getSyncOnCommitOnly()) synchronizeEntitiesWithinTransaction(tx); // Get the persistence manager to do the dirty work EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().removeEntity(ctx); final Object pk = ctx.getId(); AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { removeTimerService(pk); return null; } }); // We signify "removed" with a null id // There is no need to synchronize on the context since all the threads reaching here have // gone through the InstanceInterceptor so the instance is locked and we only have one thread // the case of reentrant threads is unclear (would you want to delete an instance in reentrancy) ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Handle getHandle(Invocation mi) throws RemoteException { // TODO throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object getPrimaryKey(Invocation mi) throws RemoteException { return mi.getId(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBHome getEJBHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return (EJBHome) ci.getEJBHome(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public boolean isIdentical(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.isIdentical(this, mi); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } // All we need is an EJBObject for this Id; return (EJBObject)ci.getEntityEJBObject(((EntityCache) instanceCache).createCacheKey(mi.getId())); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBMetaData getEJBMetaDataHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.getEJBMetaData(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public HomeHandle getHomeHandleHome(Invocation mi) throws RemoteException { // TODO throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
public EJBObject getEJBObject() throws RemoteException { if (invokerProxyBinding != null) { try { return getEjbObjectViaInvoker(); } catch(Exception e) { log.debug("Exception reported, try JNDI method to recover EJB object instead", e); return getEjbObjectViaJndi(); } } return getEjbObjectViaJndi(); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
protected EJBObject getEjbObjectViaJndi() throws RemoteException { try { if (log.isTraceEnabled()) { log.trace("Using JNDI method for getEJBObject() invocation."); } InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); Proxy proxy = (Proxy) ic.lookup(jndiName); // call findByPrimary on the target InvocationHandler ih = Proxy.getInvocationHandler(proxy); return (EJBObject) ih.invoke(proxy, GET_EJB_OBJECT, new Object[] {id}); } catch (RemoteException e) { throw e; } catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
public EJBHome getEJBHome() throws RemoteException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); return home; } catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); } }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
public EJBObject getEJBObject() throws RemoteException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); Class type = home.getClass(); Method method = type.getMethod("findByPrimaryKey", new Class[]{home.getEJBMetaData().getPrimaryKeyClass()}); // call findByPrimary on the target return (EJBObject) method.invoke(home, new Object[]{id}); } catch (Exception e) { throw new ServerException("Could not get EJBObject", e); } }
(Lib) ExceptionInInitializerError 14 14
              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
0
(Lib) IOException 14
              
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public Object addDecoration(Object dataObject) throws IOException { if(dataObject instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) dataObject; if(remoteInv.getParameter() instanceof Invocation) { Invocation inv = (Invocation) remoteInv.getParameter(); MarshalledInvocation marshInv = new MarshalledInvocation(inv); if(inv != null) { // now that have invocation object related to ejb invocations, // need to get the possible known payload objects and make sure // they get serialized. try { marshInv.setTransactionPropagationContext(getTransactionPropagationContext()); } catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); } // reset the invocation parameter within remote invocation remoteInv.setParameter(marshInv); } else { //Should never get here, but will check anyways log.error("Attempting to marshall Invocation but is null. Can not proceed."); throw new IOException("Can not process data object due to the InvocationRequest's parameter being null."); } } } return dataObject; }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
public void write(Object dataObject, OutputStream output, int version) throws IOException { if(dataObject instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) dataObject; if(remoteInv.getParameter() instanceof Invocation) { Invocation inv = (Invocation) remoteInv.getParameter(); MarshalledInvocation marshInv = new MarshalledInvocation(inv); if(inv != null) { // now that have invocation object related to ejb invocations, // need to get the possible known payload objects and make sure // they get serialized. try { marshInv.setTransactionPropagationContext(getTransactionPropagationContext()); } catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); } // reset the invocation parameter within remote invocation remoteInv.setParameter(marshInv); } else { //Should never get here, but will check anyways log.error("Attempting to marshall Invocation but is null. Can not proceed."); throw new IOException("Can not process data object due to the InvocationRequest's parameter being null."); } } super.write(dataObject, output, version); } else // assume this is going to be the response { super.write(dataObject, output); } }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void loadProperties(String contextPropsURL) throws IOException { InputStream is = null; contextProps = new Properties(); // See if this is a URL we can load try { URL url = new URL(contextPropsURL); is = url.openStream(); contextProps.load(is); return; } catch (IOException e) { // Failed, try to locate a classpath resource below is = null; } is = Thread.currentThread().getContextClassLoader().getResourceAsStream(contextPropsURL); if( is == null ) { throw new IOException("Failed to locate context props as URL or resource:"+contextPropsURL); } contextProps.load(is); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Object resolveObject(Object obj) throws IOException { Object resolved = obj; // section 6.4.1 of the ejb1.1 specification states what must be taken care of // ejb reference (remote interface) : resolve handle to EJB if (obj instanceof Handle) resolved = ((Handle)obj).getEJBObject(); // ejb reference (home interface) : resolve handle to EJB Home else if (obj instanceof HomeHandle) resolved = ((HomeHandle)obj).getEJBHome(); // naming context: the jnp implementation of contexts is serializable, do nothing else if( obj instanceof HandleWrapper ) { HandleWrapper wrapper = (HandleWrapper) obj; try { resolved = wrapper.get(); } catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); } } else if (obj instanceof StatefulSessionBeanField) { byte type = ((StatefulSessionBeanField)obj).type; // session context: recreate it if (type == StatefulSessionBeanField.SESSION_CONTEXT) resolved = ctx.getSessionContext(); // user transaction: restore it else if (type == StatefulSessionBeanField.USER_TRANSACTION) resolved = ctx.getSessionContext().getUserTransaction(); } return resolved; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
protected void createService() throws Exception { // Initialize the dataStore String ejbName = con.getBeanMetaData().getEjbName(); // Get the system data directory File dir = new File(ServerConfigLocator.locate().getServerTempLocation().toURI()); // Setup the reference to the session data store directory dir = new File(dir, storeDirName); // ejbName is not unique across all deployments, so use a unique token dir = new File(dir, ejbName + "-" + new UID().toString()); storeDir = dir; log.debug("Storing sessions for '" + ejbName + "' in: " + storeDir); // if the directory does not exist then try to create it if( !storeDir.exists() ) { if( MkdirsFileAction.mkdirs(storeDir) == false ) { throw new IOException("Failed to create directory: " + storeDir); } } // make sure we have a directory if( !storeDir.isDirectory() ) { throw new IOException("File exists where directory expected: " + storeDir); } // make sure we can read and write to it if( !storeDir.canWrite() || !storeDir.canRead() ) { throw new IOException("Directory must be readable and writable: " + storeDir); } // Purge state session state files, should be none, due to unique directory purgeAllSessionData(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected void createService() throws Exception { // Initialize the dataStore String ejbName = con.getBeanMetaData().getEjbName(); // Get the system data directory File dir = new File(ServerConfigLocator.locate().getServerDataLocation().toURI()); // // jason: may have to use a generated token from container config // to determine a unique name for this config for the given // entity name. it must persist through restarts though... // // Setup the reference to the entity data store directory dir = new File(dir, storeDirName); dir = new File(dir, ejbName); storeDir = dir; log.debug("Storing entity state for '" + ejbName + "' in: " + storeDir); // if the directory does not exist then try to create it if (!storeDir.exists()) { if (!storeDir.mkdirs()) { throw new IOException("Failed to create directory: " + storeDir); } } // make sure we have a directory if (!storeDir.isDirectory()) { throw new IOException("File exists where directory expected: " + storeDir); } // make sure we can read and write to it if (!storeDir.canWrite() || !storeDir.canRead()) { throw new IOException("Directory must be readable and writable: " + storeDir); } // Get the ID field idField = con.getBeanClass().getField("id"); log.debug("Using id field: " + idField); // Lookup the isModified method if it exists try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) { isModified = null; // Has to have "boolean" as return type! log.warn("Found isModified method, but return type is not boolean; ignoring"); } else { log.debug("Using isModified method: " + isModified); } } catch (NoSuchMethodException ignored) {} }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
protected void reconnect(Object object) throws IOException { if (object instanceof ObjectImpl) { try { // Check we are still connected ObjectImpl objectImpl = (ObjectImpl) object; objectImpl._get_delegate(); } catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } } } else throw new IOException("Not an ObjectImpl " + object.getClass().getName()); }
4
              
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); }
103
              
// in src/main/java/org/jboss/invocation/DataContainerMarshallingInvokerInterceptor.java
protected IMarshalledValue createMarshalledValueForCallByValue(Object value) throws IOException { return new LocalMarshalledValue(value,new SafeCloningRepository(safeToReuse)); }
// in src/main/java/org/jboss/invocation/MarshalledValueOutputStream.java
protected void annotateClass(Class cl) throws IOException { super.annotateClass(cl); }
// in src/main/java/org/jboss/invocation/MarshalledValueOutputStream.java
protected void annotateProxyClass(Class cl) throws IOException { super.annotateProxyClass(cl); }
// in src/main/java/org/jboss/invocation/MarshalledValueOutputStream.java
protected Object replaceObject(Object obj) throws IOException { if( (obj instanceof Remote) && !(obj instanceof RemoteStub) ) { Remote remote = (Remote) obj; try { obj = RemoteObject.toStub(remote); } catch(IOException ignore) { // Let the Serialization layer try with the orignal obj } } return obj; }
// in src/main/java/org/jboss/invocation/ByValueInvokerInterceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { // We have no state }
// in src/main/java/org/jboss/invocation/ByValueInvokerInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { // We have no state }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeObject(externalURLValue); }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { externalURLValue = (String) in.readObject(); externalURL = Util.resolveURL(externalURLValue); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected IMarshalledValue createMarshalledValueForCallByValue(Object value) throws IOException { return SerializationStreamFactory.getManagerInstance().createdMarshalledValue(value); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
private MarshalledInvocation createInvocationCopy(Invocation invocation, IMarshalledValue value) throws IOException, ClassNotFoundException { MarshalledInvocation invocationCopy = new MarshalledInvocation(invocation); invocationCopy.setMethod(null); invocationCopy.setMethodHash(MarshalledInvocation.calculateHash(invocation.getMethod())); invocationCopy.setMarshalledArguments(value); invocationCopy.setArguments(null); InvocationContext copyContext = null; if (invocation.getInvocationContext()!=null) { copyContext = (InvocationContext)createMarshalledValueForCallByValue(invocation.getInvocationContext()).get(); } invocationCopy.setInvocationContext(copyContext); Map payLoad = invocation.getPayload(); Map payloadCopy = new HashMap(); if (payLoad!=null && payLoad.size()!=0) { Iterator keys = payLoad.keySet().iterator(); while (keys.hasNext()) { Object currentKey = keys.next(); Object valueSource = payLoad.get(currentKey); payloadCopy.put(currentKey,this.createMarshalledValueForCallByValue(valueSource)); } } invocationCopy.payload = payloadCopy; return invocationCopy; }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeObject(invokerID); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { invokerID = (GUID)in.readObject(); }
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { String className = v.getName(); Class resolvedClass = null; // Check the class cache first if it exists if( classCache != null ) { synchronized( classCache ) { resolvedClass = (Class) classCache.get(className); } } if( resolvedClass == null ) { ClassLoader loader = SecurityActions.getContextClassLoader(); try { resolvedClass = loader.loadClass(className); } catch(ClassNotFoundException e) { /* Use the super.resolveClass() call which will resolve array classes and primitives. We do not use this by default as this can result in caching of stale values across redeployments. */ resolvedClass = super.resolveClass(v); } if( classCache != null ) { synchronized( classCache ) { classCache.put(className, resolvedClass); } } } return resolvedClass; }
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("["); for(int i = 0; i < interfaces.length; i ++) { if( i > 0 ) tmp.append(','); tmp.append(interfaces[i]); } tmp.append(']'); log.trace("resolveProxyClass called, ifaces="+tmp.toString()); } // Load the interfaces from the cache or thread context class loader ClassLoader loader = null; Class[] ifaceClasses = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { Class iface = null; String className = interfaces[i]; // Check the proxy cache if it exists if( classCache != null ) { synchronized( classCache ) { iface = (Class) classCache.get(className); } } // Load the interface class using the thread context ClassLoader if( iface == null ) { if( loader == null ) loader = Thread.currentThread().getContextClassLoader(); iface = loader.loadClass(className); if( classCache != null ) { synchronized( classCache ) { classCache.put(className, iface); } } } ifaceClasses[i] = iface; } return Proxy.getProxyClass(loader, ifaceClasses); }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public Object get() throws IOException, ClassNotFoundException { if (serializedForm == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream(serializedForm); MarshalledValueInputStream mvis = new MarshalledValueInputStream(bais); Object retValue = mvis.readObject(); mvis.close(); return retValue; }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int length = in.readInt(); serializedForm = null; if( length > 0 ) { serializedForm = new byte[length]; in.readFully(serializedForm); } hashCode = in.readInt(); }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public void writeExternal(ObjectOutput out) throws IOException { int length = serializedForm != null ? serializedForm.length : 0; out.writeInt(length); if( length > 0 ) { out.write(serializedForm); } out.writeInt(hashCode); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
public void writeExternal(java.io.ObjectOutput out) throws IOException { // TODO invocationType should be removed from as is payload // for now, it is in there for binary compatibility getAsIsPayload().put(InvocationKey.TYPE, invocationType); // FIXME marcf: the "specific" treatment of Transactions should be abstracted. // Write the TPC, not the local transaction out.writeObject(tpc); long methodHash = this.methodHash; if(methodHash == 0) { methodHash = calculateHash(this.method); } out.writeLong(methodHash); out.writeObject(this.objectName); String serializationType = null; if (invocationContext!=null) { serializationType = (String)invocationContext.getValue("SERIALIZATION_TYPE"); } if(this.args == null && this.marshalledArgs != null) { out.writeObject(this.marshalledArgs); } else { out.writeObject(createMarshalledValue(serializationType,this.args)); } // Write out payload hashmap // Don't use hashmap serialization to avoid not-needed data being // marshalled // The map contains only serialized representations of every other object // Everything else is possibly tied to classloaders that exist inside the // server but not in the generic JMX land. they will travel in the payload // as MarshalledValue objects, see the Invocation getter logic // if (payload == null) out.writeInt(0); else { out.writeInt(payload.size()); Iterator keys = payload.keySet().iterator(); while (keys.hasNext()) { Object currentKey = keys.next(); // This code could be if (object.getClass().getName().startsWith("java")) then don't serialize. // Bench the above for speed. out.writeObject(currentKey); Object value = payload.get(currentKey); // no reason to marshall an already marshalled value if(!(value instanceof MarshalledValue)) { value = createMarshalledValue(serializationType,value); } out.writeObject(value); } } // This map is "safe" as is //out.writeObject(as_is_payload); if (as_is_payload == null) out.writeInt(0); else { out.writeInt(as_is_payload.size()); Iterator keys = as_is_payload.keySet().iterator(); while (keys.hasNext()) { Object currentKey = keys.next(); out.writeObject(currentKey); out.writeObject(as_is_payload.get(currentKey)); } } }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
private Object createMarshalledValue(String serializationType, Object valueToBeMarshalled) throws IOException { if (serializationType!=null) { return (IMarshalledValue)SerializationStreamFactory.getManagerInstance(serializationType).createdMarshalledValue(valueToBeMarshalled); } else { return new MarshalledValue(valueToBeMarshalled); } }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
public void readExternal(java.io.ObjectInput in) throws IOException, ClassNotFoundException { tpc = in.readObject(); this.methodHash = in.readLong(); this.objectName = in.readObject(); marshalledArgs = in.readObject(); int payloadSize = in.readInt(); if (payloadSize > 0) { payload = new HashMap(); for (int i = 0; i < payloadSize; i++) { Object key = in.readObject(); Object value = in.readObject(); payload.put(key, value); } } int as_is_payloadSize = in.readInt(); if (as_is_payloadSize > 0) { as_is_payload = new HashMap(); for (int i = 0; i < as_is_payloadSize; i++) { Object key = in.readObject(); Object value = in.readObject(); as_is_payload.put(key, value); } } // TODO invocationType should be removed from as is payload // for now, it is in there for binary compatibility invocationType = (InvocationType)getAsIsValue(InvocationKey.TYPE); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata); return removeDecoration(ret); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); return removeDecoration(ret); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object removeDecoration(Object obj) throws IOException { if(obj instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) obj; Object param = remoteInv.getParameter(); if(param instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) param; Object txCxt = mi.getTransactionPropagationContext(); if(txCxt != null) { TransactionPropagationContextImporter tpcImporter = TransactionPropagationContextUtil.getTPCImporter(); mi.setTransaction(tpcImporter.importTransactionPropagationContext(txCxt)); } } } return obj; }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); if(ret instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) ret; Object param = remoteInv.getParameter(); if(param instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) param; Object txCxt = mi.getTransactionPropagationContext(); if(txCxt != null) { TransactionPropagationContextImporter tpcImporter = TransactionPropagationContextUtil.getTPCImporter(); mi.setTransaction(tpcImporter.importTransactionPropagationContext(txCxt)); } } } return ret; }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public void write(Object dataObject, OutputStream output) throws IOException { super.write(addDecoration(dataObject), output); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public void write(Object dataObject, OutputStream output, int version) throws IOException { super.write(addDecoration(dataObject), output, version); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public Object addDecoration(Object dataObject) throws IOException { if(dataObject instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) dataObject; if(remoteInv.getParameter() instanceof Invocation) { Invocation inv = (Invocation) remoteInv.getParameter(); MarshalledInvocation marshInv = new MarshalledInvocation(inv); if(inv != null) { // now that have invocation object related to ejb invocations, // need to get the possible known payload objects and make sure // they get serialized. try { marshInv.setTransactionPropagationContext(getTransactionPropagationContext()); } catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); } // reset the invocation parameter within remote invocation remoteInv.setParameter(marshInv); } else { //Should never get here, but will check anyways log.error("Attempting to marshall Invocation but is null. Can not proceed."); throw new IOException("Can not process data object due to the InvocationRequest's parameter being null."); } } } return dataObject; }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
public void write(Object dataObject, OutputStream output, int version) throws IOException { if(dataObject instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) dataObject; if(remoteInv.getParameter() instanceof Invocation) { Invocation inv = (Invocation) remoteInv.getParameter(); MarshalledInvocation marshInv = new MarshalledInvocation(inv); if(inv != null) { // now that have invocation object related to ejb invocations, // need to get the possible known payload objects and make sure // they get serialized. try { marshInv.setTransactionPropagationContext(getTransactionPropagationContext()); } catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); } // reset the invocation parameter within remote invocation remoteInv.setParameter(marshInv); } else { //Should never get here, but will check anyways log.error("Attempting to marshall Invocation but is null. Can not proceed."); throw new IOException("Can not process data object due to the InvocationRequest's parameter being null."); } } super.write(dataObject, output, version); } else // assume this is going to be the response { super.write(dataObject, output); } }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
public IMarshalledValue createdMarshalledValue(Object source) throws IOException { if (source instanceof IMarshalledValue) { return (IMarshalledValue) source; } else { return new MarshalledValueEX(source); } }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeInt(CURRENT_VERSION); out.writeUTF(locator.getOriginalURI()); out.writeBoolean(strictRMIException); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { int version = in.readInt(); // Read in and map the version of the serialized data seen switch(version) { case VERSION_5_0: locator = new InvokerLocator(in.readUTF()); strictRMIException = in.readBoolean(); init(locator); break; default: throw new StreamCorruptedException("Unknown version seen: " + version); } }
// in src/main/java/org/jboss/deployment/EARStructure.java
private void scanEar(VirtualFile root, JBossAppMetaData appMetaData) throws IOException { List<VirtualFile> archives = root.getChildren(); if (archives != null) { String earPath = root.getPathName(); ModulesMetaData modules = appMetaData.getModules(); if (modules == null) { modules = new ModulesMetaData(); appMetaData.setModules(modules); } for (VirtualFile vfArchive : archives) { String filename = earRelativePath(earPath, vfArchive.getPathName()); // Check if the module already exists, i.e. it is declared in jboss-app.xml ModuleMetaData moduleMetaData = appMetaData.getModule(filename); int type = typeFromSuffix(filename, vfArchive); if (type >= 0 && moduleMetaData == null) { moduleMetaData = new ModuleMetaData(); AbstractModule module = null; switch(type) { case J2eeModuleMetaData.EJB: module = new EjbModuleMetaData(); break; case J2eeModuleMetaData.CLIENT: module = new JavaModuleMetaData(); break; case J2eeModuleMetaData.CONNECTOR: module = new ConnectorModuleMetaData(); break; case J2eeModuleMetaData.SERVICE: case J2eeModuleMetaData.HAR: module = new ServiceModuleMetaData(); break; case J2eeModuleMetaData.WEB: module = new WebModuleMetaData(); break; } module.setFileName(filename); moduleMetaData.setValue(module); modules.add(moduleMetaData); } } } }
// in src/main/java/org/jboss/deployment/EARStructure.java
private int typeFromSuffix(String path, VirtualFile archive) throws IOException { int type = -1; if( path.endsWith(".war") ) type = J2eeModuleMetaData.WEB; else if( path.endsWith(".rar") ) type = J2eeModuleMetaData.CONNECTOR; else if( path.endsWith(".har") ) type = J2eeModuleMetaData.HAR; else if( path.endsWith(".sar") ) type = J2eeModuleMetaData.SERVICE; else if( path.endsWith(".jar") ) { // Look for a META-INF/application-client.xml VirtualFile mfFile = getMetaDataFile(archive, "META-INF/MANIFEST.MF"); VirtualFile clientXml = getMetaDataFile(archive, "META-INF/application-client.xml"); VirtualFile ejbXml = getMetaDataFile(archive, "META-INF/ejb-jar.xml"); VirtualFile jbossXml = getMetaDataFile(archive, "META-INF/jboss.xml"); if( clientXml != null ) { type = J2eeModuleMetaData.CLIENT; } else if( mfFile != null ) { Manifest mf = VFSUtils.readManifest(mfFile); Attributes attrs = mf.getMainAttributes(); if( attrs.containsKey(Attributes.Name.MAIN_CLASS) ) { type = J2eeModuleMetaData.CLIENT; } else { // TODO: scan for annotations. Assume EJB for now type = J2eeModuleMetaData.EJB; } } else if( ejbXml != null || jbossXml != null ) { type = J2eeModuleMetaData.EJB; } else { // TODO: scan for annotations. Assume EJB for now type = J2eeModuleMetaData.EJB; } } return type; }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
private void scanEar(VFSDeploymentUnit unit, VirtualFile root, JBossAppMetaData j2eeMetaData) throws IOException { List<VirtualFile> archives = root.getChildren(); if (archives != null) { String earPath = root.getPathName(); ModulesMetaData modules = j2eeMetaData.getModules(); if (modules == null) { modules = new ModulesMetaData(); j2eeMetaData.setModules(modules); } for (VirtualFile vfArchive : archives) { String filename = earRelativePath(earPath, vfArchive.getPathName()); // Check if the module already exists, i.e. it is declared in jboss-app.xml ModuleMetaData moduleMetaData = j2eeMetaData.getModule(filename); int type = typeFromSuffix(unit, filename, vfArchive); if (type >= 0 && moduleMetaData == null) { moduleMetaData = new ModuleMetaData(); AbstractModule module = null; switch(type) { case J2eeModuleMetaData.EJB: module = new EjbModuleMetaData(); break; case J2eeModuleMetaData.CLIENT: module = new JavaModuleMetaData(); break; case J2eeModuleMetaData.CONNECTOR: module = new ConnectorModuleMetaData(); break; case J2eeModuleMetaData.SERVICE: case J2eeModuleMetaData.HAR: module = new ServiceModuleMetaData(); break; case J2eeModuleMetaData.WEB: module = new WebModuleMetaData(); break; } module.setFileName(filename); moduleMetaData.setValue(module); modules.add(moduleMetaData); } } } }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
private int typeFromSuffix(VFSDeploymentUnit unit, String path, VirtualFile archive) throws IOException { int type = -1; if( path.endsWith(".war") ) type = J2eeModuleMetaData.WEB; else if( path.endsWith(".rar") ) type = J2eeModuleMetaData.CONNECTOR; else if( path.endsWith(".har") ) type = J2eeModuleMetaData.HAR; else if( path.endsWith(".sar") ) type = J2eeModuleMetaData.SERVICE; else if( path.endsWith(".jar") ) { // Look for a META-INF/application-client.xml VirtualFile mfFile = unit.getMetaDataFile("MANIFEST.MF"); VirtualFile clientXml = unit.getMetaDataFile("application-client.xml"); VirtualFile ejbXml = unit.getMetaDataFile("ejb-jar.xml"); VirtualFile jbossXml = unit.getMetaDataFile("jboss.xml"); if( clientXml != null ) { type = J2eeModuleMetaData.CLIENT; } else if( mfFile != null ) { Manifest mf = VFSUtils.readManifest(mfFile); Attributes attrs = mf.getMainAttributes(); if( attrs.containsKey(Attributes.Name.MAIN_CLASS) ) { type = J2eeModuleMetaData.CLIENT; } else { // TODO: scan for annotations. Assume EJB for now type = J2eeModuleMetaData.EJB; } } else if( ejbXml != null || jbossXml != null ) { type = J2eeModuleMetaData.EJB; } else { // TODO: scan for annotations. Assume EJB for now type = J2eeModuleMetaData.EJB; } } return type; }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
protected String getClassName(VirtualFile classFile) throws IOException { String pathName = classFile.getPathName(); String name = pathName.substring(rootLength, pathName.length()-6); name = name.replace('/', '.'); return name; }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, String mainClassName, VirtualFile classpath) throws IOException { AnnotatedClassFilter classVisitor = new AnnotatedClassFilter(unit, unit.getClassLoader(), classpath, mainClassName); classpath.visit(classVisitor); Map<VirtualFile, Class<?>> classes = classVisitor.getAnnotatedClasses(); if (classes != null && classes.size() > 0) { if(log.isTraceEnabled()) log.trace("Annotated classes: " + classes); } else { classes = new HashMap<VirtualFile, Class<?>>(); } return classes.values(); }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
protected String getMainClassName(VFSDeploymentUnit unit) throws IOException { VirtualFile file = unit.getMetaDataFile("MANIFEST.MF"); if (log.isTraceEnabled()) log.trace("parsing " + file); if(file == null) { return null; } Manifest mf = VFSUtils.readManifest(file); Attributes attrs = mf.getMainAttributes(); return attrs.getValue(Attributes.Name.MAIN_CLASS); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void setPropertiesURL(String contextPropsURL) throws IOException { contextInfo.loadProperties(contextPropsURL); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void setProperties(final Properties props) throws IOException { contextInfo.setProperties(props); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public Properties getProperties() throws IOException { return contextInfo.getProperties(); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void loadProperties(String contextPropsURL) throws IOException { InputStream is = null; contextProps = new Properties(); // See if this is a URL we can load try { URL url = new URL(contextPropsURL); is = url.openStream(); contextProps.load(is); return; } catch (IOException e) { // Failed, try to locate a classpath resource below is = null; } is = Thread.currentThread().getContextClassLoader().getResourceAsStream(contextPropsURL); if( is == null ) { throw new IOException("Failed to locate context props as URL or resource:"+contextPropsURL); } contextProps.load(is); }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
protected void establishBootStrapURL() throws IOException { if (getBootstrapURL() == null && getBootstrapAddress() != null) { InetAddress addr = InetAddress.getByName(getBootstrapAddress()); if (addr.isAnyLocalAddress()) { addr = findLoopbackAddress(); if (addr == null) { addr = InetAddress.getLocalHost(); } } // Build the bootstrap URL StringBuilder sb = new StringBuilder("jnp://"); if (addr instanceof Inet6Address) { sb.append('['); sb.append(addr.getHostAddress()); sb.append(']'); } else { sb.append(addr.getHostAddress()); } sb.append(':'); sb.append(getBootstrapPort()); setBootstrapURL(sb.toString()); } }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
private Naming getNamingServer(URL providerURL) throws ClassNotFoundException, IOException, InvocationTargetException, IllegalAccessException { // Initialize the proxy Util class to integrate JAAS authentication Util.init(); if( log.isTraceEnabled() ) log.trace("Retrieving content from : "+providerURL); HttpURLConnection conn = (HttpURLConnection) providerURL.openConnection(); Util.configureHttpsHostVerifier(conn); Util.configureSSLSocketFactory(conn); int length = conn.getContentLength(); String type = conn.getContentType(); if( log.isTraceEnabled() ) log.trace("ContentLength: "+length+"\nContentType: "+type); InputStream is = conn.getInputStream(); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); ois.close(); Object obj = mv.get(); if( (obj instanceof Naming) == false ) { String msg = "Invalid reply content seen: "+obj.getClass(); Throwable t = null; if( obj instanceof Throwable ) { t = (Throwable) obj; if( t instanceof InvocationException ) t = ((InvocationException)t).getTargetException(); } if( t != null ) log.warn(msg, t); else log.warn(msg); IOException e = new IOException(msg); throw e; } Naming namingServer = (Naming) obj; return namingServer; }
// in src/main/java/org/jboss/naming/NamingService.java
public void setNamingProxy(Object proxy) throws IOException { namingMain.setNamingProxy(proxy); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException { // No state }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // No state }
// in src/main/java/org/jboss/ejb/CacheKey.java
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(id); out.writeObject(mo); out.writeInt(hashCode); }
// in src/main/java/org/jboss/ejb/CacheKey.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { id = in.readObject(); mo = (MarshalledObject) in.readObject(); hashCode = in.readInt(); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected Object replaceObject (Object obj) throws IOException { if (obj instanceof javax.ejb.EJBObject) return ((javax.ejb.EJBObject)obj).getHandle (); return obj; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected Object resolveObject (Object obj) throws IOException { if (obj instanceof javax.ejb.Handle) return ((javax.ejb.Handle)obj).getEJBObject (); return obj; }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectOutputStream.java
protected Object replaceObject(Object obj) throws IOException { Object replacement = obj; // section 6.4.1 of the ejb1.1 specification states what must be taken care of // ejb reference (remote interface) : store handle if (obj instanceof EJBObject) replacement = ((EJBObject)obj).getHandle(); // ejb reference (home interface) : store handle else if (obj instanceof EJBHome) replacement = ((EJBHome)obj).getHomeHandle(); // session context : store a typed dummy object else if (obj instanceof SessionContext) replacement = new StatefulSessionBeanField(StatefulSessionBeanField.SESSION_CONTEXT); // naming context : the jnp implementation is serializable, do nothing // user transaction : store a typed dummy object else if (obj instanceof UserTransaction) replacement = new StatefulSessionBeanField(StatefulSessionBeanField.USER_TRANSACTION); else if( obj instanceof Handle ) replacement = new HandleWrapper((Handle)obj); else if( (obj instanceof Remote) && !(obj instanceof RemoteStub) ) { Remote remote = (Remote) obj; try { replacement = RemoteObject.toStub(remote); } catch(IOException ignore) { // Let the Serialization layer try with original object } } return replacement; }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Object resolveObject(Object obj) throws IOException { Object resolved = obj; // section 6.4.1 of the ejb1.1 specification states what must be taken care of // ejb reference (remote interface) : resolve handle to EJB if (obj instanceof Handle) resolved = ((Handle)obj).getEJBObject(); // ejb reference (home interface) : resolve handle to EJB Home else if (obj instanceof HomeHandle) resolved = ((HomeHandle)obj).getEJBHome(); // naming context: the jnp implementation of contexts is serializable, do nothing else if( obj instanceof HandleWrapper ) { HandleWrapper wrapper = (HandleWrapper) obj; try { resolved = wrapper.get(); } catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); } } else if (obj instanceof StatefulSessionBeanField) { byte type = ((StatefulSessionBeanField)obj).type; // session context: recreate it if (type == StatefulSessionBeanField.SESSION_CONTEXT) resolved = ctx.getSessionContext(); // user transaction: restore it else if (type == StatefulSessionBeanField.USER_TRANSACTION) resolved = ctx.getSessionContext().getUserTransaction(); } return resolved; }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { try { // use the application classloader to resolve the class return appCl.loadClass(v.getName()); } catch (ClassNotFoundException e) { // we should probably never get here return super.resolveClass(v); } }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { Class clazz = null; Class[] ifaceClasses = new Class[interfaces.length]; for(int i = 0; i < interfaces.length; i ++) ifaceClasses[i] = Class.forName(interfaces[i], false, appCl); try { clazz = Proxy.getProxyClass(appCl, ifaceClasses); } catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); } return clazz; }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected Object replaceObject(final Object obj) throws IOException { if (obj instanceof EJBObject) return ((EJBObject)obj).getHandle(); return obj; }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected Object resolveObject(final Object obj) throws IOException { if (obj instanceof Handle) return ((Handle)obj).getEJBObject(); return obj; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); factory = (BaseLocalProxyFactory) BaseLocalProxyFactory.invokerMap.get(jndiName); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); }
// in src/main/java/org/jboss/ejb/ListCacheKey.java
public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); out.writeLong(listId); out.writeInt(index); }
// in src/main/java/org/jboss/ejb/ListCacheKey.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); listId = in.readLong(); index = in.readInt(); }
// in src/main/java/org/jboss/web/WebServer.java
protected String getPath(BufferedReader in) throws IOException { String line = in.readLine(); log.trace("raw request=" + line); // Find the request path by parsing the 'REQUEST_TYPE filePath HTTP_VERSION' string int start = line.indexOf(' ') + 1; int end = line.indexOf(' ', start + 1); // The file minus the leading '/' String filePath = line.substring(start + 1, end); return filePath; }
// in src/main/java/org/jboss/web/WebServer.java
protected byte[] getBytes(URL url) throws IOException { InputStream in = new BufferedInputStream(url.openStream()); log.debug("Retrieving " + url); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] tmp = new byte[1024]; int bytes; while ((bytes = in.read(tmp)) != -1) { out.write(tmp, 0, bytes); } in.close(); return out.toByteArray(); }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
public static void parse(final DeploymentUnit unit, final URL facesConfigXmlURL, final JSFDeployment jsfDeployment) throws Exception { logger.debug("Checking for the presence of JSF managed-bean(s) in JSF config file: " + facesConfigXmlURL + " in deployment unit: " + unit); // get the parser factory SAXParserFactory parserFactory = getParserFactory(); // create a parser SAXParser saxParser = parserFactory.newSAXParser(); InputStream inputStream = null; try { // get the input stream and the input source for the faces config file inputStream = getInputStream(facesConfigXmlURL); InputSource inputSource = new InputSource(getInputStream(facesConfigXmlURL)); inputSource.setSystemId(facesConfigXmlURL.toExternalForm()); // parse it! saxParser.parse(inputSource, new DefaultHandler() { /** * Flag to keep track of managed-bean-class element being processed */ private boolean managedBeanClassElementProcessingInProgress; /** * Uses the {@link JBossEntityResolver} to resolve the entity. If it cannot be resolved by the {@link JBossEntityResolver} * then this method lets the {@link DefaultHandler} to resolve it. * * @param publicId * @param systemId * @return * @throws IOException * @throws SAXException */ @Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { // try resolving it with the JBossEntityResolver InputSource source = jBossJSFEntityResolver.resolveEntity(publicId, systemId); if (source != null) { return source; } // we couldn't resolve, so let the default handler try to resolve it return super.resolveEntity(publicId, systemId); } @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // we are only interested in managed-bean-class element. if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = true; } // let the super do its job super.startElement(uri, localName, qName, attributes); } @Override public void endElement(String uri, String localName, String qName) throws SAXException { // reset the flag when the managed-bean-class element ends if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = false; } // let super do its job super.endElement(uri, localName, qName); } @Override public void characters(char[] ch, int start, int length) throws SAXException { // if we are currently processing the managed-bean-class element, then fetch the managed bean // class name text if (this.managedBeanClassElementProcessingInProgress) { // get the managed bean class name String managedBeanClassName = new String(ch, start, length); if (!managedBeanClassName.trim().isEmpty()) { logger.debug("Found JSF managed bean class: " + managedBeanClassName + " in unit " + unit); // add it to the jsf deployment jsfDeployment.addManagedBean(managedBeanClassName); } } // let super do its job now super.characters(ch, start, length); } }); } finally { if (inputStream != null) { inputStream.close(); } } return; }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { // try resolving it with the JBossEntityResolver InputSource source = jBossJSFEntityResolver.resolveEntity(publicId, systemId); if (source != null) { return source; } // we couldn't resolve, so let the default handler try to resolve it return super.resolveEntity(publicId, systemId); }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
private static InputStream getInputStream(URL url) throws IOException { URLConnection conn = url.openConnection(); conn.setUseCaches(false); return new BufferedInputStream(conn.getInputStream()); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
Override protected void performMount(VirtualFile file) throws IOException { Automounter.mount(file, MountOption.EXPANDED, MountOption.COPY); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
protected void addPathsRecursively(StructureContext context, ContextInfo info, VirtualFile parent, String path) throws IOException { List<VirtualFile> children = parent.getChildren(); for (VirtualFile child : children) { if (!isLeaf(child)) { String newPath = path + "/" + child.getName(); addMetaDataPath(context, info, newPath, MetaDataType.ALTERNATIVE); addPathsRecursively(context, info, child, newPath); } } }
// in src/main/java/org/jboss/proxy/Interceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeObject(nextInterceptor); }
// in src/main/java/org/jboss/proxy/Interceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { nextInterceptor = (Interceptor)in.readObject(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public byte[] internalGetCode() throws IOException { // first, flush out all references to the cpool getIndex(this); getIndex(superClass); for (int i = 0; i < interfaces.length; i++) { getIndex(interfaces[i]); } int nfields = 0; int nmethods = 0; for (int i = 0; i < members.size(); i++) { AMember m = (AMember) members.elementAt(i); if (m.code != null) { byte[] codeAttr = getMethodCode(m, m.code); if (codeAttr != null) { addAttribute(m, "Code", codeAttr); } } for (int j = 0; j < m.attr.size(); j++) { Attr a = (Attr) m.attr.elementAt(j); getUtfIndex(a.name); } if (m.name.length() == 0) { continue; } getUtfIndex(m.name); getUtfIndex(m.sig); if (isMethodSig(m.sig)) { nmethods += 1; } else { nfields += 1; } } // next, deal with internal references in the cpool for (int i = 0; i < cv.size(); i++) { Object x = cv.elementAt(i); if (x == null) { continue; } else if (x instanceof String) { String s = (String)x; short si = getUtfIndex(s); short data[] = { CONSTANT_STRING, si }; x = data; } else if (x instanceof Class) { Class c = (Class)x; short ci = getUtfIndex(c.getName().replace('.', '/')); short data[] = { CONSTANT_CLASS, ci }; x = data; } else if (x instanceof Field) { Field m = (Field)x; short ci = getIndex(m.getDeclaringClass()); short nt = getNTIndex(m.getName(), getSig(m.getType())); short data[] = { CONSTANT_FIELD, ci, nt }; x = data; } else if (x instanceof Constructor) { Constructor m = (Constructor)x; short ci = getIndex(m.getDeclaringClass()); short nt = getNTIndex("<init>", getSig(Void.TYPE, m.getParameterTypes())); short data[] = { CONSTANT_METHOD, ci, nt }; x = data; } else if (x instanceof Method) { Method m = (Method)x; Class c = m.getDeclaringClass(); short kind = c.isInterface() ? CONSTANT_INTERFACEMETHOD : CONSTANT_METHOD; short ci = getIndex(c); short nt = getNTIndex(m.getName(), getSig(m.getReturnType(), m.getParameterTypes())); short data[] = { kind, ci, nt }; x = data; } else if (x instanceof ProxyAssembler) { ProxyAssembler asm = (ProxyAssembler)x; short ci = getUtfIndex(asm.className.replace('.', '/')); short data[] = { CONSTANT_CLASS, ci }; x = data; } else if (x instanceof AMember) { AMember m = (AMember) x; short kind = !isMethodSig(m.sig) ? CONSTANT_FIELD : m.asm.isInterface() ? CONSTANT_INTERFACEMETHOD : CONSTANT_METHOD; short ci = getIndex(m.asm); short nt = getNTIndex(m.name, m.sig); short data[] = { kind, ci, nt }; x = data; } else if (x instanceof NameAndType) { NameAndType nt = (NameAndType) x; short data[] = { CONSTANT_NAMEANDTYPE, nt.name, nt.sig }; x = data; } cv.setElementAt(x, i); // update } ByteArrayOutputStream bytes = new ByteArrayOutputStream(400); DataOutputStream ds = new DataOutputStream(bytes); ds.writeInt(JAVA_MAGIC); ds.writeShort(JAVA_MINOR_VERSION); ds.writeShort(JAVA_VERSION); int cvsize = cv.size(); ds.writeShort(cvsize); for (int i = 0; i < cv.size(); i++) { Object x = cv.elementAt(i); if (x == null) { continue; } else if (x instanceof short[]) { short data[] = (short[])x; ds.writeByte(data[0]); for (int j = 1; j < data.length; j++) { ds.writeShort(data[j]); } } else if (x instanceof byte[]) { ds.write((byte[])x); } else if (x instanceof Integer) { ds.writeByte(CONSTANT_INTEGER); ds.writeInt(((Integer)x).intValue()); // (do other primitive literal types?) } else { throw new RuntimeException("unexpected"); } } ds.writeShort(modifiers); ds.writeShort(getIndex(this)); ds.writeShort(getIndex(superClass)); ds.writeShort(interfaces.length); for (int i = 0; i < interfaces.length; i++) { ds.writeShort(getIndex(interfaces[i])); } for (int pass = 0; pass <= 1; pass++) { boolean methods = (pass > 0); ds.writeShort(methods ? nmethods : nfields); for (int i = 0; i < members.size(); i++) { AMember m = (AMember) members.elementAt(i); if (m.name.length() == 0 || isMethodSig(m.sig) != methods) { continue; } ds.writeShort(m.mods); ds.writeShort(getUtfIndex(m.name)); ds.writeShort(getUtfIndex(m.sig)); writeAttrs(ds, m.attr); } } AMember m0 = (AMember) members.elementAt(0); writeAttrs(ds, (Vector) m0.attr); // sanity check if (cvsize != cv.size()) { throw new RuntimeException("cvsize"); } return bytes.toByteArray(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
private byte[] getMethodCode(AMember m, ByteArrayOutputStream code) throws IOException { if (code.size() == 0) { if ((current.mods & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0) { current.mods |= Modifier.ABSTRACT; modifiers |= Modifier.ABSTRACT; } return null; } ByteArrayOutputStream bytes = new ByteArrayOutputStream(code.size()+30); DataOutputStream ds = new DataOutputStream(bytes); int slop = 10; // ?? int max_stack = current.locmax + slop; int max_locals = current.spmax + slop; ds.writeShort(max_stack); ds.writeShort(max_locals); ds.writeInt(code.size()); code.writeTo(ds); ds.writeShort(0); // exception_table.length Vector attrs = new Vector(); for (int i = m.attr.size(); --i >= 0; ) { Attr ma = (Attr) m.attr.elementAt(i); if (ma.name.startsWith("Code.")) { m.attr.removeElementAt(i); ma.name = ma.name.substring("Code.".length()); attrs.addElement(ma); getUtfIndex(ma.name); } } writeAttrs(ds, attrs); return bytes.toByteArray(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
private void writeAttrs(DataOutputStream ds, Vector attrs) throws IOException { ds.writeShort(attrs.size()); for (int i = 0; i < attrs.size(); i++) { Attr a = (Attr) attrs.elementAt(i); ds.writeShort(getUtfIndex(a.name)); if (a.data instanceof byte[]) { byte[] xa = (byte[])a.data; ds.writeInt(xa.length); ds.write(xa); } else { throw new RuntimeException("unexpected"); } } }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
private void writeObject(ObjectOutputStream oos) throws IOException { ObjectOutputStream.PutField putField = oos.putFields(); putField.put("jndiName", jndiName); putField.put("jndiEnv", jndiEnv); oos.writeFields(); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
private void writeObject(ObjectOutputStream oos) throws IOException { ObjectOutputStream.PutField putField = oos.putFields(); putField.put("jndiName", jndiName); putField.put("jndiEnv", jndiEnv); oos.writeFields(); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); id = getField.get("id", null); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
private void writeObject(ObjectOutputStream oos) throws IOException { ObjectOutputStream.PutField putField = oos.putFields(); putField.put("id", id); putField.put("jndiName", jndiName); putField.put("jndiEnv", jndiEnv); oos.writeFields(); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public void writeEJBObject(EJBObject ejbObject, ObjectOutputStream oostream) throws IOException { oostream.writeObject(ejbObject); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public EJBObject readEJBObject(ObjectInputStream oistream) throws IOException, ClassNotFoundException { Object ejbObject = oistream.readObject(); reconnect(ejbObject); return (EJBObject) PortableRemoteObject.narrow(ejbObject, EJBObject.class); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public void writeEJBHome(EJBHome ejbHome, ObjectOutputStream oostream) throws IOException { oostream.writeObject(ejbHome); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public EJBHome readEJBHome(ObjectInputStream oistream) throws IOException, ClassNotFoundException { Object ejbHome = oistream.readObject(); reconnect(ejbHome); return (EJBHome) PortableRemoteObject.narrow(ejbHome, EJBHome.class); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
protected void reconnect(Object object) throws IOException { if (object instanceof ObjectImpl) { try { // Check we are still connected ObjectImpl objectImpl = (ObjectImpl) object; objectImpl._get_delegate(); } catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } } } else throw new IOException("Not an ObjectImpl " + object.getClass().getName()); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { super.writeExternal(out); // Write out a version identifier for future extensibility out.writeInt(EXTERNAL_VERSION); // There is no additional data currently }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); // Read the version identifier int version = in.readInt(); if( version == EXTERNAL_VERSION ) { // This version has no additional data } // Set the logging trace level trace = log.isTraceEnabled(); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { super.writeExternal(out); out.writeObject(list); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); list = (List) in.readObject(); }
// in src/main/java/org/jboss/proxy/ejb/ReadAheadResult.java
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(mainResult); out.writeObject(getAheadResult()); }
// in src/main/java/org/jboss/proxy/ejb/ReadAheadResult.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { mainResult = in.readObject(); aheadArray = (Object[]) in.readObject(); }
// in src/main/java/org/jboss/proxy/ClientContainer.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeObject(next); out.writeObject(context); }
// in src/main/java/org/jboss/proxy/ClientContainer.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { next = (Interceptor) in.readObject(); context = (InvocationContext) in.readObject(); }
(Lib) NamingException 12
              
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception { // Get the j2ee.clientName value String clientName = (String) env.get(J2EE_CLIENT_NAME_PROP); if (clientName == null) { // Look for the name as a system property clientName = (String) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { try { return System.getProperty(J2EE_CLIENT_NAME_PROP); } catch (SecurityException e) { return null; } } } ); if (clientName == null) throw new NamingException("Failed to find j2ee.clientName in jndi env"); }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object getSpecialObject(Name name) throws NamingException { if (name.size() > 0 && "java:comp".equals(name.get(0))) { if (name.size() == 2 && "ORB".equals(name.get(1))) return ORBFactory.getORB(); else if (name.size() == 2 && "HandleDelegate".equals(name.get(1))) return HandleDelegateFactory.getHandleDelegateSingleton(); } throw new NamingException("Name not found " + name); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx) throws NamingException { for (ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs) { String resourceName = ref.getJndiName(); String refName = ref.getResourceEnvRefName(); if (ref.getType().equals("java.net.URL")) { try { log.debug("Binding '" + refName + "' to URL: " + resourceName); URL url = new URL(resourceName); Util.bind(envCtx, refName, url); } catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); } } else if (resourceName != null) { log.debug("Linking '" + refName + "' to JNDI name: " + resourceName); Util.bind(envCtx, refName, new LinkRef(resourceName)); } else { throw new NamingException("resource-env-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-env-ref."); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx) throws NamingException { for (ResourceReferenceMetaData ref : resourceRefs) { String jndiName = ref.getJndiName(); String refName = ref.getResourceName(); if (ref.getType().equals("java.net.URL")) { try { String resURL = ref.getResUrl(); if (resURL != null) { log.debug("Binding '" + refName + "' to URL: " + resURL); URL url = new URL(resURL); Util.bind(envCtx, refName, url); } else { log.debug("Linking '" + refName + "' to URL: " + resURL); LinkRef urlLink = new LinkRef(jndiName); Util.bind(envCtx, refName, urlLink); } } catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); } } else if (jndiName != null) { log.debug("Linking '" + refName + "' to JNDI name: " + jndiName); Util.bind(envCtx, refName, new LinkRef(jndiName)); } else { throw new NamingException("resource-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-ref."); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx) throws NamingException { for (MessageDestinationReferenceMetaData ref : msgRefs) { String refName = ref.getName(); String jndiName = ref.getJndiName(); String link = ref.getLink(); if (link != null) { if (jndiName == null) { MessageDestinationMetaData messageDestination = EjbUtil50.findMessageDestination(mainDeployer, unit, link); if (messageDestination == null) throw new NamingException("message-destination-ref '" + refName + "' message-destination-link '" + link + "' not found and no jndi-name in jboss-web.xml"); else { String linkJNDIName = messageDestination.getJndiName(); if (linkJNDIName == null) log.warn("message-destination '" + link + "' has no jndi-name in jboss-web.xml"); else jndiName = linkJNDIName; } } else log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml"); } else if (jndiName == null) throw new NamingException("message-destination-ref '" + refName + "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml"); Util.bind(envCtx, refName, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx) throws NamingException { for (EJBReferenceMetaData ejb : ejbRefs) { String name = ejb.getName(); String linkName = ejb.getLink(); String jndiName = null; // use ejb-link if it is specified if (linkName != null) { jndiName = EjbUtil50.findEjbLink(mainDeployer, unit, linkName); // if flag does not allow misconfigured ejb-links, it is an error if ((jndiName == null) && !(getLenientEjbLink())) throw new NamingException("ejb-ref: " + name + ", no ejb-link match"); } // fall through to the jndiName if (jndiName == null) { jndiName = ejb.getJndiName(); if (jndiName == null) throw new NamingException("ejb-ref: " + name + ", no ejb-link in web.xml and no jndi-name in jboss-web.xml"); } log.debug("Linking ejb-ref: " + name + " to JNDI name: " + jndiName); Util.bind(envCtx, name, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx) throws NamingException { for (EJBLocalReferenceMetaData ejb : ejbLocalRefs) { String name = ejb.getName(); String linkName = ejb.getLink(); String jndiName = null; // use the ejb-link field if it is specified if (linkName != null) { jndiName = EjbUtil50.findLocalEjbLink(mainDeployer, unit, linkName); // if flag does not allow misconfigured ejb-links, it is an error if ((jndiName == null) && !(getLenientEjbLink())) throw new NamingException("ejb-ref: " + name + ", no ejb-link match"); } if (jndiName == null) { jndiName = ejb.getJndiName(); if (jndiName == null) { String msg = null; if (linkName == null) { msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and " + "no local-jndi-name in jboss-web.xml"; } else { msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '" + linkName + "' failed to resolve to an ejb with a LocalHome"; } throw new NamingException(msg); } } log.debug("Linking ejb-local-ref: " + name + " to JNDI name: " + jndiName); Util.bind(envCtx, name, new LinkRef(jndiName)); } }
2
              
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
35
              
// in src/main/java/org/jboss/metadata/EnvEntryBinder.java
public static void bindEnvEntry(Context ctx, EnvEntryMetaData entry) throws ClassNotFoundException, NamingException { ClassLoader loader = EnvEntryMetaData.class.getClassLoader(); Class type = loader.loadClass(entry.getType()); if (type == String.class) { Util.bind(ctx, entry.getName(), entry.getValue()); } else if (type == Integer.class) { Util.bind(ctx, entry.getName(), new Integer(entry.getValue())); } else if (type == Long.class) { Util.bind(ctx, entry.getName(), new Long(entry.getValue())); } else if (type == Double.class) { Util.bind(ctx, entry.getName(), new Double(entry.getValue())); } else if (type == Float.class) { Util.bind(ctx, entry.getName(), new Float(entry.getValue())); } else if (type == Byte.class) { Util.bind(ctx, entry.getName(), new Byte(entry.getValue())); } else if (type == Character.class) { Object value = null; String input = entry.getValue(); if (input == null || input.length() == 0) { value = new Character((char) 0); } else { value = new Character(input.charAt(0)); } Util.bind(ctx, entry.getName(), value); } else if (type == Short.class) { Util.bind(ctx, entry.getName(), new Short(entry.getValue())); } else if (type == Boolean.class) { Util.bind(ctx, entry.getName(), new Boolean(entry.getValue())); } else { // Default to a String type Util.bind(ctx, entry.getName(), entry.getValue()); } }
// in src/main/java/org/jboss/jms/jndi/JNDIProviderAdapter.java
public Context getInitialContext() throws NamingException { if (properties == null) return new InitialContext(); else return new InitialContext(properties); }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
private void bind(Context ctx, String name, Object val) throws NamingException { log.debug("attempting to bind " + val + " to " + name); // Bind val to name in ctx, and make sure that all // intermediate contexts exist Name n = ctx.getNameParser("").parse(name); while (n.size() > 1) { String ctxName = n.get(0); try { ctx = (Context) ctx.lookup(ctxName); } catch (NameNotFoundException e) { ctx = ctx.createSubcontext(ctxName); } n = n.getSuffix(1); } ctx.bind(n.get(0), val); }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object getSpecialObject(Name name) throws NamingException { if (name.size() > 0 && "java:comp".equals(name.get(0))) { if (name.size() == 2 && "ORB".equals(name.get(1))) return ORBFactory.getORB(); else if (name.size() == 2 && "HandleDelegate".equals(name.get(1))) return HandleDelegateFactory.getHandleDelegateSingleton(); } throw new NamingException("Name not found " + name); }
// in src/main/java/org/jboss/naming/NamingAlias.java
public void setFromName(String name) throws NamingException { removeLinkRef(fromName); this.fromName = name; createLinkRef(); }
// in src/main/java/org/jboss/naming/NamingAlias.java
public void setToName(String name) throws NamingException { this.toName = name; createLinkRef(); }
// in src/main/java/org/jboss/naming/NamingAlias.java
private void createLinkRef() throws NamingException { if( super.getState() == ServiceMBean.STARTING || super.getState() == ServiceMBean.STARTED ) Util.createLinkRef(fromName, toName); }
// in src/main/java/org/jboss/naming/NamingAlias.java
private void removeLinkRef(String name) throws NamingException { if(super.getState() == ServiceMBean.STOPPING) Util.removeLinkRef(name); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void setJndiName(String jndiName) throws NamingException { contextInfo.setJndiName(jndiName); if( super.getState() == STARTED ) { unbind(jndiName); try { rebind(); } catch(Exception e) { NamingException ne = new NamingException("Failed to update jndiName"); ne.setRootCause(e); throw ne; } } }
// in src/main/java/org/jboss/naming/ExternalContext.java
private static Context createContext(Context rootContext, Name name) throws NamingException { Context subctx = rootContext; for(int n = 0; n < name.size(); n ++) { String atom = name.get(n); try { Object obj = subctx.lookup(atom); subctx = (Context) obj; } catch(NamingException e) { // No binding exists, create a subcontext subctx = subctx.createSubcontext(atom); } } return subctx; }
// in src/main/java/org/jboss/naming/ExternalContext.java
public Reference getReference() throws NamingException { Reference ref = new Reference(Context.class.getName(), this, this.getClass().getName(), null); return ref; }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
public Context getInitialContext(Hashtable env) throws NamingException { // Parse the Context.PROVIDER_URL String provider = (String) env.get(Context.PROVIDER_URL); if( provider.startsWith("jnp:") == true ) provider = "http:" + provider.substring(4); else if( provider.startsWith("jnps:") == true ) provider = "https:" + provider.substring(5); else if( provider.startsWith("jnp-http:") == true ) provider = "http:" + provider.substring(9); else if( provider.startsWith("jnp-https:") == true ) provider = "https:" + provider.substring(10); tryLogin(env); URL providerURL = null; Naming namingServer = null; try { providerURL = new URL(provider); // Retrieve the Naming interface namingServer = getNamingServer(providerURL); } catch(Exception e) { NamingException ex = new NamingException("Failed to retrieve Naming interface for provider " + provider); ex.setRootCause(e); throw ex; } // Copy the context env env = (Hashtable) env.clone(); return new NamingContext(env, null, namingServer); }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
private void tryLogin(Hashtable env) throws NamingException { // Get the login configuration name to use, initially set to default. String protocol = SecurityConstants.DEFAULT_APPLICATION_POLICY; Object prop = env.get(Context.SECURITY_PROTOCOL); if( prop != null ) protocol = prop.toString(); // Get the login principal and credentials from the JNDI env Object credentials = env.get(Context.SECURITY_CREDENTIALS); Object principal = env.get(Context.SECURITY_PRINCIPAL); if(principal == null || credentials == null) { return; //don't bother and don't throw any exceptions } try { // Get the principal username String username; if( principal instanceof Principal ) { Principal p = (Principal) principal; username = p.getName(); } else { username = principal.toString(); } UsernamePasswordHandler handler = new UsernamePasswordHandler(username, credentials); Configuration conf = getConfiguration(); // Do the JAAS login LoginContext lc = new LoginContext(protocol, null, handler, conf); lc.login(); } catch(LoginException e) { AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol); ex.setRootCause(e); throw ex; } }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
public void addBindings() throws NamingException { Context ctx = new InitialContext(); if( rootName != null ) ctx = (Context) ctx.lookup(rootName); JNDIBinding[] values = bindings.getBindings(); for(int n = 0; n < values.length; n ++) { String name = values[n].getName(); Object value; try { value = values[n].getValue(); } catch(Exception e) { NamingException ne = new NamingException("Failed to obtain value from binding: "+name); ne.setRootCause(e); throw ne; } Util.bind(ctx, name, value); } ctx.close(); }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
public void removeBindings() throws NamingException { Context ctx = new InitialContext(); if( rootName != null ) ctx = (Context) ctx.lookup(rootName); JNDIBinding[] values = bindings.getBindings(); for(int n = 0; n < values.length; n ++) { String name = values[n].getName(); Util.unbind(ctx, name); } ctx.close(); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public Reference getReference() throws NamingException { Reference ref = new Reference("org.jboss.tm.usertx.client.ClientUserTransaction", "org.jboss.tm.usertx.client.ClientUserTransactionObjectFactory", null); return ref; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void initializeContainer(Container container, ConfigurationMetaData conf, BeanMetaData bean, int transType, DeploymentUnit unit) throws NamingException, DeploymentException { // Create local classloader for this container // For loading resources that must come from the local jar. Not for loading classes! // The VFS should be used for this // container.setLocalClassLoader(new URLClassLoader(new URL[0], localCl)); // Set metadata (do it *before* creating the container's WebClassLoader) container.setEjbModule(this); container.setBeanMetaData(bean); ClassLoader unitCl = unit.getClassLoader(); // Create the container's WebClassLoader // and register it with the web service. String webClassLoaderName = getWebClassLoader(conf, bean); log.debug("Creating WebClassLoader of class " + webClassLoaderName); WebClassLoader wcl = null; try { Class clazz = unitCl.loadClass(webClassLoaderName); wcl = WebClassLoaderFactory.createWebClassLoader(clazz, container.getJmxName(), (RealClassLoader) unitCl); } catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); } if (webServiceName != null) { WebServiceMBean webServer = (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName); URL[] codebase = {webServer.addClassLoader(wcl)}; wcl.setWebURLs(codebase); } // end of if () container.setWebClassLoader(wcl); // Create classloader for this container // Only used to unique the bean ENC and does not augment class loading container.setClassLoader(new DelegatingClassLoader(wcl)); // Set transaction manager InitialContext iniCtx = new InitialContext(); container.setTransactionManager(tmFactory.getTransactionManager()); // Set container.setTimerService(timerService); // Set security domain manager String securityDomain = bean.getApplicationMetaData().getSecurityDomain(); // JBAS-5960: Set default security domain if there is security metadata boolean hasSecurityMetaData = hasSecurityMetaData(bean); if (securityDomain == null && hasSecurityMetaData) { securityDomain = SecurityConstants.DEFAULT_EJB_APPLICATION_POLICY; } String confSecurityDomain = conf.getSecurityDomain(); // Default the config security to the application security manager if (confSecurityDomain == null) confSecurityDomain = securityDomain; // Check for an empty confSecurityDomain which signifies to disable security if (confSecurityDomain != null && confSecurityDomain.length() == 0) confSecurityDomain = null; if (confSecurityDomain != null) { // Either the application has a security domain or the container has security setup try { String unprefixed = SecurityUtil.unprefixSecurityDomain(confSecurityDomain); log.debug("Setting security domain from: " + confSecurityDomain); String domainCtx = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + unprefixed + "/domainContext"; SecurityDomainContext sdc = (SecurityDomainContext) iniCtx.lookup(domainCtx); Object securityMgr = sdc.getSecurityManager(); // Object securityMgr = iniCtx.lookup(confSecurityDomain); AuthenticationManager ejbS = (AuthenticationManager) securityMgr; RealmMapping rM = (RealmMapping) securityMgr; container.setSecurityManager(ejbS); container.setRealmMapping(rM); container.setSecurityManagement(securityManagement); container.setPolicyRegistration(policyRegistration); container.setDefaultSecurityDomain((String) unit.getAttachment("EJB.defaultSecurityDomain")); container.setSecurityContextClassName((String) unit.getAttachment("EJB.securityContextClassName")); } catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); } catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); } } else { if ("".equals(securityDomain) && hasSecurityMetaData) log.warn("EJB configured to bypass security. Please verify if this is intended. Bean=" + bean.getEjbName() + " Deployment=" + unit.getName()); } // Load the security proxy instance if one was configured String securityProxyClassName = bean.getSecurityProxy(); if (securityProxyClassName != null) { try { Class proxyClass = unitCl.loadClass(securityProxyClassName); Object proxy = proxyClass.newInstance(); container.setSecurityProxy(proxy); log.debug("setSecurityProxy, " + proxy); } catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); } } // Install the container interceptors based on the configuration addInterceptors(container, transType, conf.getContainerInterceptorsConf()); }
// in src/main/java/org/jboss/ejb/Container.java
public Context getEnvContext() throws NamingException { pushENC(); try { return (Context)new InitialContext().lookup("java:comp/env"); } finally { popENC(); } }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
protected InitialContext getInitialContext() throws NamingException { if (providerUrl == null) { return new InitialContext(); } else { log.debug("Using Context.PROVIDER_URL: " + providerUrl); java.util.Properties props = new java.util.Properties(System.getProperties()); props.put(Context.PROVIDER_URL, providerUrl); return new InitialContext(props); } }
// in src/main/java/org/jboss/monitor/EntityLockMonitor.java
private void bind() throws NamingException { Context ctx = new InitialContext(); // Ah ! We aren't serializable, so we use a helper class NonSerializableFactory.bind(JNDI_NAME, this); // The helper class NonSerializableFactory uses address type nns, we go on to // use the helper class to bind ourselves in JNDI StringRefAddr addr = new StringRefAddr("nns", JNDI_NAME); Reference ref = new Reference(EntityLockMonitor.class.getName(), addr, NonSerializableFactory.class.getName(), null); ctx.bind(JNDI_NAME, ref); }
// in src/main/java/org/jboss/monitor/EntityLockMonitor.java
private void unbind() throws NamingException { new InitialContext().unbind(JNDI_NAME); NonSerializableFactory.unbind(JNDI_NAME); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void processEncReferences(WebApplication webApp, Context envCtx) throws ClassNotFoundException, NamingException { DeploymentUnit unit = webApp.getDeploymentUnit(); JBossWebMetaData metaData = webApp.getMetaData(); EnvironmentEntriesMetaData envEntries = metaData.getEnvironmentEntries(); log.debug("addEnvEntries"); addEnvEntries(envEntries, envCtx); ResourceEnvironmentReferencesMetaData resourceEnvRefs = metaData.getResourceEnvironmentReferences(); log.debug("linkResourceEnvRefs"); linkResourceEnvRefs(resourceEnvRefs, envCtx); ResourceReferencesMetaData resourceRefs = metaData.getResourceReferences(); log.debug("linkResourceRefs"); linkResourceRefs(resourceRefs, envCtx); log.debug("linkMessageDestinationRefs"); MessageDestinationReferencesMetaData msgRefs = metaData.getMessageDestinationReferences(); linkMessageDestinationRefs(unit, msgRefs, envCtx); EJBReferencesMetaData ejbRefs = metaData.getEjbReferences(); log.debug("linkEjbRefs"); linkEjbRefs(unit, ejbRefs, envCtx); EJBLocalReferencesMetaData ejbLocalRefs = metaData.getEjbLocalReferences(); log.debug("linkEjbLocalRefs"); linkEjbLocalRefs(unit, ejbLocalRefs, envCtx); log.debug("linkServiceRefs"); ServiceReferencesMetaData serviceRefs = metaData.getServiceReferences(); linkServiceRefs(unit, serviceRefs, envCtx); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
private void linkServiceRefs(DeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx) throws NamingException { if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit; ClassLoader loader = unit.getClassLoader(); UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(vfsUnit.getRoot()); for (ServiceReferenceMetaData sref : serviceRefs) { String refName = sref.getServiceRefName(); new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx) throws ClassNotFoundException, NamingException { for (EnvironmentEntryMetaData entry : envEntries) { log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue()); bindEnvEntry(envCtx, entry); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx) throws NamingException { for (ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs) { String resourceName = ref.getJndiName(); String refName = ref.getResourceEnvRefName(); if (ref.getType().equals("java.net.URL")) { try { log.debug("Binding '" + refName + "' to URL: " + resourceName); URL url = new URL(resourceName); Util.bind(envCtx, refName, url); } catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); } } else if (resourceName != null) { log.debug("Linking '" + refName + "' to JNDI name: " + resourceName); Util.bind(envCtx, refName, new LinkRef(resourceName)); } else { throw new NamingException("resource-env-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-env-ref."); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx) throws NamingException { for (ResourceReferenceMetaData ref : resourceRefs) { String jndiName = ref.getJndiName(); String refName = ref.getResourceName(); if (ref.getType().equals("java.net.URL")) { try { String resURL = ref.getResUrl(); if (resURL != null) { log.debug("Binding '" + refName + "' to URL: " + resURL); URL url = new URL(resURL); Util.bind(envCtx, refName, url); } else { log.debug("Linking '" + refName + "' to URL: " + resURL); LinkRef urlLink = new LinkRef(jndiName); Util.bind(envCtx, refName, urlLink); } } catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); } } else if (jndiName != null) { log.debug("Linking '" + refName + "' to JNDI name: " + jndiName); Util.bind(envCtx, refName, new LinkRef(jndiName)); } else { throw new NamingException("resource-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-ref."); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx) throws NamingException { for (MessageDestinationReferenceMetaData ref : msgRefs) { String refName = ref.getName(); String jndiName = ref.getJndiName(); String link = ref.getLink(); if (link != null) { if (jndiName == null) { MessageDestinationMetaData messageDestination = EjbUtil50.findMessageDestination(mainDeployer, unit, link); if (messageDestination == null) throw new NamingException("message-destination-ref '" + refName + "' message-destination-link '" + link + "' not found and no jndi-name in jboss-web.xml"); else { String linkJNDIName = messageDestination.getJndiName(); if (linkJNDIName == null) log.warn("message-destination '" + link + "' has no jndi-name in jboss-web.xml"); else jndiName = linkJNDIName; } } else log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml"); } else if (jndiName == null) throw new NamingException("message-destination-ref '" + refName + "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml"); Util.bind(envCtx, refName, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx) throws NamingException { for (EJBReferenceMetaData ejb : ejbRefs) { String name = ejb.getName(); String linkName = ejb.getLink(); String jndiName = null; // use ejb-link if it is specified if (linkName != null) { jndiName = EjbUtil50.findEjbLink(mainDeployer, unit, linkName); // if flag does not allow misconfigured ejb-links, it is an error if ((jndiName == null) && !(getLenientEjbLink())) throw new NamingException("ejb-ref: " + name + ", no ejb-link match"); } // fall through to the jndiName if (jndiName == null) { jndiName = ejb.getJndiName(); if (jndiName == null) throw new NamingException("ejb-ref: " + name + ", no ejb-link in web.xml and no jndi-name in jboss-web.xml"); } log.debug("Linking ejb-ref: " + name + " to JNDI name: " + jndiName); Util.bind(envCtx, name, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx) throws NamingException { for (EJBLocalReferenceMetaData ejb : ejbLocalRefs) { String name = ejb.getName(); String linkName = ejb.getLink(); String jndiName = null; // use the ejb-link field if it is specified if (linkName != null) { jndiName = EjbUtil50.findLocalEjbLink(mainDeployer, unit, linkName); // if flag does not allow misconfigured ejb-links, it is an error if ((jndiName == null) && !(getLenientEjbLink())) throw new NamingException("ejb-ref: " + name + ", no ejb-link match"); } if (jndiName == null) { jndiName = ejb.getJndiName(); if (jndiName == null) { String msg = null; if (linkName == null) { msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and " + "no local-jndi-name in jboss-web.xml"; } else { msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '" + linkName + "' failed to resolve to an ejb with a LocalHome"; } throw new NamingException(msg); } } log.debug("Linking ejb-local-ref: " + name + " to JNDI name: " + jndiName); Util.bind(envCtx, name, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkSecurityDomain(String securityDomain, Context javaCompCtx) throws NamingException { if (securityDomain == null) { securityDomain = getDefaultSecurityDomain(); log.debug("No security-domain given, using default: " + securityDomain); } // JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix if (securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false) securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain; log.debug("Linking security/securityMgr to JNDI name: " + securityDomain); Util.bind(javaCompCtx, "env/security/securityMgr", new LinkRef(securityDomain)); Util.bind(javaCompCtx, "env/security/realmMapping", new LinkRef(securityDomain + "/realmMapping")); Util.bind(javaCompCtx, "env/security/authorizationMgr", new LinkRef(securityDomain + "/authorizationMgr")); Util.bind(javaCompCtx, "env/security/security-domain", new LinkRef(securityDomain)); Util.bind(javaCompCtx, "env/security/subject", new LinkRef(securityDomain + "/subject")); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void unlinkSecurityDomain(String securityDomain, Context javaCompCtx) throws NamingException { log.debug("UnLinking security/securityMgr from JNDI "); Util.unbind(javaCompCtx, "env/security/securityMgr"); Util.unbind(javaCompCtx, "env/security/realmMapping"); Util.unbind(javaCompCtx, "env/security/authorizationMgr"); Util.unbind(javaCompCtx, "env/security/security-domain"); Util.unbind(javaCompCtx, "env/security/subject"); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry) throws ClassNotFoundException, NamingException { ClassLoader loader = EnvironmentEntryMetaData.class.getClassLoader(); Class type = loader.loadClass(entry.getType()); if (type == String.class) { Util.bind(ctx, entry.getName(), entry.getValue()); } else if (type == Integer.class) { Util.bind(ctx, entry.getName(), new Integer(entry.getValue())); } else if (type == Long.class) { Util.bind(ctx, entry.getName(), new Long(entry.getValue())); } else if (type == Double.class) { Util.bind(ctx, entry.getName(), new Double(entry.getValue())); } else if (type == Float.class) { Util.bind(ctx, entry.getName(), new Float(entry.getValue())); } else if (type == Byte.class) { Util.bind(ctx, entry.getName(), new Byte(entry.getValue())); } else if (type == Character.class) { Object value = null; String input = entry.getValue(); if (input == null || input.length() == 0) { value = new Character((char)0); } else { value = new Character(input.charAt(0)); } Util.bind(ctx, entry.getName(), value); } else if (type == Short.class) { Util.bind(ctx, entry.getName(), new Short(entry.getValue())); } else if (type == Boolean.class) { Util.bind(ctx, entry.getName(), new Boolean(entry.getValue())); } else { // Default to a String type Util.bind(ctx, entry.getName(), entry.getValue()); } }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
protected EJBHome getEJBHome(Invocation invocation) throws NamingException { // Look to the context for the home InvocationContext ctx = invocation.getInvocationContext(); EJBHome home = (EJBHome) ctx.getValue(InvocationKey.EJB_HOME); // If there is no home use the legacy lookup method if( home == null ) { String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME); InitialContext iniCtx = new InitialContext(); home = (EJBHome) iniCtx.lookup(jndiName); } return home; }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void rebindHomeProxy() throws NamingException { // (Re-)Bind the home in the JNDI naming space log.debug("(re-)Binding Home " + jndiBinding); Util.rebind( // The context new InitialContext(), // Jndi name jndiBinding, // The Home getEJBHome() ); log.info("Bound EJB Home '" + container.getBeanMetaData().getEjbName() + "' to jndi '" + jndiBinding + "'"); }
(Lib) NestedRuntimeException 12
              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
protected void register(EntityEnterpriseContext ctx, Transaction tx) { boolean trace = log.isTraceEnabled(); if(trace) log.trace("register, ctx=" + ctx + ", tx=" + tx); EntityContainer ctxContainer = null; try { ctxContainer = (EntityContainer)ctx.getContainer(); if(!ctx.hasTxSynchronization()) { // Create a new synchronization Synchronization synch = createSynchronization(tx, ctx); // We want to be notified when the transaction commits tx.registerSynchronization(synch); ctx.hasTxSynchronization(true); } //mark it dirty in global tx entity map if it is not read only if(!ctxContainer.isReadOnly()) { ctx.getTxAssociation().scheduleSync(tx, ctx); } } catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); } catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public EJBLocalObject getStatefulSessionEJBLocalObject(Object id) { InvocationHandler handler = new StatefulSessionProxy(localJndiName, id, this); try { return (EJBLocalObject) proxyClassConstructor.newInstance(new Object[]{handler}); } catch(Exception ex) { throw new NestedRuntimeException(ex); } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
private EJBLocalObject createEJBLocalObject(Object id) { InvocationHandler handler = new EntityProxy(localJndiName, id, this); try { return (EJBLocalObject) proxyClassConstructor.newInstance(new Object[]{handler}); } catch(Exception ex) { throw new NestedRuntimeException(ex); } }
// in src/main/java/org/jboss/proxy/compiler/Proxy.java
public static Object newProxyInstance(final ClassLoader loader, final Class[] interfaces, final InvocationHandler h) { // Make all proxy instances implement Serializable Class[] interfaces2 = new Class[interfaces.length + 1]; System.arraycopy(interfaces, 0, interfaces2, 0, interfaces.length); interfaces2[interfaces2.length - 1] = Serializable.class; try { // create a new proxy return Proxies.newTarget(loader, h, interfaces2); } catch (Exception e) { throw new NestedRuntimeException("Failed to create new proxy target", e); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public static HandleDelegate getDelegate() { try { InitialContext ctx = new InitialContext(); return (HandleDelegate) ctx.lookup("java:comp/HandleDelegate"); } catch (NamingException e) { throw new NestedRuntimeException(e); } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public Object getStatefulSessionEJBObject(Object id) { // Create a stack from the description (in the future) for now we hardcode it InvocationContext context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setCacheId(id); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); context.setInvoker(beanInvoker); log.debug("seting invoker proxy binding for stateful session: " + invokerMetaData.getName()); context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); context.setValue("InvokerID", Invoker.ID); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } ClientContainer client; if( includeIClientIface ) { client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } try { loadInterceptorChain(beanInterceptorClasses, client); } catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); } try { return (EJBObject) proxyClassConstructor.newInstance(new Object[]{client}); } catch(Exception ex) { throw new NestedRuntimeException(ex); } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public Object getEntityEJBObject(Object id) { Object result; if(id == null) { result = null; } else { // Create a stack from the description (in the future) for now we hardcode it InvocationContext context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setCacheId(id); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); context.setInvoker(beanInvoker); context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } ClientContainer client; if( includeIClientIface ) { client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } try { loadInterceptorChain(beanInterceptorClasses, client); } catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); } try { result = proxyClassConstructor.newInstance(new Object[]{client}); } catch(Exception ex) { throw new NestedRuntimeException(ex); } } return result; }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
public Object createProxy(Object id, ObjectName targetName, Invoker invoker, String jndiName, String proxyBindingName, ArrayList interceptorClasses, ClassLoader loader, Class[] ifaces, HashMap ctx) { InvocationContext context; if (ctx != null) context = new InvocationContext(ctx); else context = new InvocationContext(); Integer nameHash = new Integer(targetName.hashCode()); if (log.isTraceEnabled()) { log.trace("Target name " + targetName + " and corresponding hash code" + nameHash); } context.setObjectName(nameHash); context.setCacheId(id); if( jndiName != null ) context.setValue(InvocationKey.JNDI_NAME, jndiName); if( invoker == null ) throw new RuntimeException("Null invoker given for name: " + targetName); context.setInvoker(invoker); if( proxyBindingName != null ) context.setInvokerProxyBinding(proxyBindingName); // If the IClientContainer interceptor was specified, use the ClientContainerEx boolean wantIClientAccess = false; for(int n = 0; wantIClientAccess == false && n < interceptorClasses.size(); n ++) { Class type = (Class) interceptorClasses.get(n); wantIClientAccess = type.isAssignableFrom(IClientContainer.class); } ClientContainer client; if( wantIClientAccess ) { client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } try { loadInterceptorChain(interceptorClasses, client); } catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); } ArrayList tmp = new ArrayList(Arrays.asList(ifaces)); Class[] ifaces2 = new Class[tmp.size()]; tmp.toArray(ifaces2); return Proxy.newProxyInstance( // Classloaders loader, // Interfaces ifaces2, // Client container as invocation handler client); }
12
              
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/compiler/Proxy.java
catch (Exception e) { throw new NestedRuntimeException("Failed to create new proxy target", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException e) { throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
0
(Lib) SystemException 12
              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void begin() throws NotSupportedException, SystemException { if(getStatus() != Status.STATUS_NO_TRANSACTION) throw new NotSupportedException("Attempt to start a nested transaction (the transaction started previously hasn't been ended yet)."); ThreadInfo info = getThreadInfo(); trace = log.isTraceEnabled(); // Only check for trace enabled once per transaction if (trace) { log.trace("Calling UserTransaction.begin()"); } try { Object tpc = getSession().begin(info.getTimeout()); info.push(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void rollback() throws SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.rollback(" + tpc + ")"); } try { getSession().rollback(tpc); } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void setRollbackOnly() throws IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.setRollbackOnly(" + tpc + ")"); } try { getSession().setRollbackOnly(tpc); } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public int getStatus() throws SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (log.isTraceEnabled()) { log.trace("Calling UserTransaction.getStatus(" + tpc + ")"); } if (tpc == null) { return Status.STATUS_NO_TRANSACTION; } try { return getSession().getStatus(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
12
              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
33
              
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public Object getTransactionPropagationContext() throws SystemException { TransactionPropagationContextFactory tpcFactory = TransactionPropagationContextUtil.getTPCFactoryClientSide(); return (tpcFactory == null) ? null : tpcFactory.getTransactionPropagationContext(); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
public Object getTransactionPropagationContext() throws SystemException { TransactionPropagationContextFactory tpcFactory = TransactionPropagationContextUtil.getTPCFactoryClientSide(); return (tpcFactory == null) ? null : tpcFactory.getTransactionPropagationContext(); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void begin() throws NotSupportedException, SystemException { if(getStatus() != Status.STATUS_NO_TRANSACTION) throw new NotSupportedException("Attempt to start a nested transaction (the transaction started previously hasn't been ended yet)."); ThreadInfo info = getThreadInfo(); trace = log.isTraceEnabled(); // Only check for trace enabled once per transaction if (trace) { log.trace("Calling UserTransaction.begin()"); } try { Object tpc = getSession().begin(info.getTimeout()); info.push(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void rollback() throws SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.rollback(" + tpc + ")"); } try { getSession().rollback(tpc); } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void setRollbackOnly() throws IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.setRollbackOnly(" + tpc + ")"); } try { getSession().setRollbackOnly(tpc); } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public int getStatus() throws SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (log.isTraceEnabled()) { log.trace("Calling UserTransaction.getStatus(" + tpc + ")"); } if (tpc == null) { return Status.STATUS_NO_TRANSACTION; } try { return getSession().getStatus(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void setTransactionTimeout(int seconds) throws SystemException { getThreadInfo().setTimeout(seconds); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public Object begin(int timeout) throws RemoteException, NotSupportedException, SystemException { TransactionManager tm = getTransactionManager(); // Set timeout value tm.setTransactionTimeout(timeout); // Start tx, and get its TPC. tm.begin(); Object tpc = getTPCFactory().getTransactionPropagationContext(); // Suspend thread association. Transaction tx = tm.suspend(); // Remember that a new tx is now active. activeTx.put(tpc, tx); // return the TPC return tpc; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void setRollbackOnly(Object tpc) throws RemoteException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); tx.setRollbackOnly(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public int getStatus(Object tpc) throws RemoteException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) return Status.STATUS_NO_TRANSACTION; return tx.getStatus(); }
// in src/main/java/org/jboss/ejb/TxEntityMap.java
public void associate(Transaction tx, EntityEnterpriseContext entity) throws RollbackException, SystemException { HashMap entityMap = (HashMap) m_map.get(tx); if(entityMap == null) { entityMap = new HashMap(); m_map.set(tx, entityMap); } //EntityContainer.getGlobalTxEntityMap().associate(tx, entity); entityMap.put(entity.getCacheKey(), entity); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void begin() throws NotSupportedException, SystemException { TransactionManager tm = con.getTransactionManager(); int oldTimeout = -1; if (tm instanceof TransactionTimeoutConfiguration) oldTimeout = ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); // Set the timeout value tm.setTransactionTimeout(timeout); try { // Start the transaction tm.begin(); //notify checked out connections EJB2UserTransactionProvider.getSingleton().userTransactionStarted(); if (tsl != null) tsl.userTransactionStarted(); Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx begin: " + tx); // keep track of the transaction in enterprise context for BMT setTransaction(tx); } finally { // Reset the transaction timeout (if we know what it was) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx commit: " + tx); int status = tm.getStatus(); tm.commit(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx rollback: " + tx); tm.rollback(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void setRollbackOnly() throws IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx setRollbackOnly: " + tx); tm.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public int getStatus() throws SystemException { TransactionManager tm = con.getTransactionManager(); return tm.getStatus(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void setTransactionTimeout(int seconds) throws SystemException { timeout = seconds; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private void endTransaction(final Invocation invocation, final Transaction tx, final Transaction oldTx, final int oldTimeout) throws TransactionRolledbackException, SystemException { // Assert the correct transaction association Transaction current = tm.getTransaction(); if ((tx == null && current != null) || tx.equals(current) == false) throw new IllegalStateException("Wrong transaction association: expected " + tx + " was " + current); try { // Marked rollback if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) { tx.rollback(); } else { // Commit tx // This will happen if // a) everything goes well // b) app. exception was thrown tx.commit(); } } catch (RollbackException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicMixedException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicRollbackException e) { throwJBossException(e, invocation.getType()); } catch (SystemException e) { throwJBossException(e, invocation.getType()); } catch (IllegalStateException e) { throwJBossException(e, invocation.getType()); } finally { // reassociate the oldTransaction with the Invocation (even null) invocation.setTransaction(oldTx); // Always drop thread association even if committing or // rolling back the newTransaction because not all TMs // will drop thread associations when commit() or rollback() // are called through tx itself (see JTA spec that seems to // indicate that thread assoc is required to be dropped only // when commit() and rollback() are called through TransactionManager // interface) //tx has committed, so we can't throw txRolledbackException. tm.suspend(); // Reset the transaction timeout (unless we didn't set it) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
private void registerTimer(Invocation invocation) throws RollbackException, SystemException { Timer timer = (Timer) invocation.getArguments()[0]; Transaction transaction = invocation.getTransaction(); if (transaction != null && timer instanceof Synchronization) transaction.registerSynchronization((Synchronization) timer); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
Transaction getTransaction() throws javax.transaction.SystemException { if(transactionManager == null) { return null; } return transactionManager.getTransaction(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private Transaction getTransaction() throws SystemException { return tm.getTransaction(); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void scheduleSync(Transaction tx, EntityEnterpriseContext instance) throws SystemException, RollbackException { EntityContainer.getGlobalTxEntityMap().associate(tx, instance); instance.setTxAssociation(SYNC_SCHEDULED); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public GlobalTxSynchronization getGlobalSynchronization(Transaction tx) throws RollbackException, SystemException { GlobalTxSynchronization globalSync = (GlobalTxSynchronization) txSynch.get(tx); if(globalSync == null) { globalSync = new GlobalTxSynchronization(tx); txSynch.set(tx, globalSync); tx.registerSynchronization(globalSync); } return globalSync; }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
private void associate(Transaction tx, EntityEnterpriseContext entity) throws RollbackException, SystemException { GlobalTxSynchronization globalSync = getGlobalSynchronization(tx); //There should be only one thread associated with this tx at a time. //Therefore we should not need to synchronize on entityFifoList to ensure exclusive //access. entityFifoList is correct since it was obtained in a synch block. globalSync.associate(entity); }
(Domain) RemoveException 11
              
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); ejbObject.remove(); return null; } else throw new RemoveException("EJBHome.remove(Object) not allowed for session beans"); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // if the session is removed already then let the user know they have a problem StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); if (ctx.getId() == null) { throw new RemoveException("SFSB has been removed already"); } // Remove from storage try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); getPersistenceManager().removeSession(ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // We signify "removed" with a null id ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) getBeanMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // wire the transaction on the context, this is how the instance remember the tx // Unlike Entity beans we can't do that in the previous interceptors (ordering) EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); else if(ejbObjectRemove.equals(miMethod) || ejbLocalObjectRemove.equals(miMethod)) { throw new RemoveException("An attempt to remove a session " + "object while the object is in a transaction " + "(EJB2.1, 7.6.4 Restrictions for Transactions): ejb-name=" + metaData.getEjbName() + ", method=" + mi.getMethod() + ", tx=" + ctx.getTransaction()); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(StatefulSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { // Invoke and handle exceptions try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public void removeEntity (EntityEnterpriseContext ctx) throws javax.ejb.RemoveException { if (this.beans.remove (ctx.getId ()) == null) throw new javax.ejb.RemoveException ("Could not remove bean:" + ctx.getId ()); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public void removeEntity(final EntityEnterpriseContext ctx) throws RemoveException { // Remove file File file = getFile(ctx.getId()); if (!file.delete()) { throw new RemoveException("Could not remove file: " + file); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void remove(Transaction tx, Object pk) { CachedRow row = (CachedRow) rowsById.remove(pk); if(row == null || row.locker != null && !tx.equals(row.locker)) { String msg = "removal of " + pk + " rejected for " + tx + ": " + (row == null ? "the entry could not be found" : "the entry is locked for update by " + row.locker); throw new RemoveException(msg); } dereference(row); row.locker = null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
protected void executeDeleteSQL(String sql, Object key) throws RemoveException { Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { if(log.isDebugEnabled()) log.debug("Executing SQL: " + sql); // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql); // set the parameters entity.setPrimaryKeyParameters(ps, 1, key); // execute statement rowsAffected = ps.executeUpdate(); } catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected == 0) { log.error("Could not remove entity " + key); throw new RemoveException("Could not remove entity"); } if(log.isDebugEnabled()) log.debug("Remove: Rows affected = " + rowsAffected); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
private void executeDeleteSQL(EntityEnterpriseContext ctx) throws RemoveException { Object key = ctx.getId(); Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { if(log.isDebugEnabled()) log.debug("Executing SQL: " + removeEntitySQL); // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(removeEntitySQL); // set the parameters entity.setPrimaryKeyParameters(ps, 1, key); // execute statement rowsAffected = ps.executeUpdate(); } catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected == 0) { log.error("Could not remove entity " + key); throw new RemoveException("Could not remove entity"); } if(log.isTraceEnabled()) log.trace("Remove: Rows affected = " + rowsAffected); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home"; } else if (m.equals(EQUALS)) { // equality of the proxy home is based on names... Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home"; return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { return new Integer(this.hashCode()); } // Implement local EJB calls else if (m.equals(GET_HOME_HANDLE)) { return new HomeHandleImpl( (String)ctx.getValue(InvocationKey.JNDI_NAME)); } else if (m.equals(GET_EJB_META_DATA)) { return ctx.getValue(InvocationKey.EJB_METADATA); } else if (m.equals(REMOVE_BY_HANDLE)) { // First get the EJBObject EJBObject object = ((Handle) invocation.getArguments()[0]).getEJBObject(); // remove the object from here object.remove(); // Return Void return Void.TYPE; } else if (m.equals(REMOVE_BY_PRIMARY_KEY)) { // Session beans must throw RemoveException (EJB 1.1, 5.3.2) if(((EJBMetaData)ctx.getValue(InvocationKey.EJB_METADATA)).isSession()) throw new RemoveException("Session beans cannot be removed " + "by primary key."); // The trick is simple we trick the container in believe it // is a remove() on the instance Object id = invocation.getArguments()[0]; // Just override the Invocation going out invocation.setId(id); invocation.setType(InvocationType.REMOTE); invocation.setMethod(REMOVE_OBJECT); invocation.setArguments(EMPTY_ARGS); return getNext().invoke(invocation); } // If not taken care of, go on and call the container else { invocation.setType(InvocationType.HOME); // Create an Invocation return getNext().invoke(invocation); } }
2
              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); }
31
              
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { log.debug("Useless invocation of remove() for stateless session bean"); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Handle handle) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Object primaryKey) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // if the session is removed already then let the user know they have a problem StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); if (ctx.getId() == null) { throw new RemoveException("SFSB has been removed already"); } // Remove from storage try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); getPersistenceManager().removeSession(ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // We signify "removed" with a null id ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Handle handle) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Object primaryKey) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public void removeEntity (EntityEnterpriseContext ctx) throws javax.ejb.RemoveException { if (this.beans.remove (ctx.getId ()) == null) throw new javax.ejb.RemoveException ("Could not remove bean:" + ctx.getId ()); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); ejbRemove.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void removeSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException, RemoveException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to remove; ctx=" + ctx); } // Instruct the bean to perform removal logic SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbRemove(); if (trace) { log.trace("Removal complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbRemove(); } catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } store.removeEntity(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public void removeEntity(final EntityEnterpriseContext ctx) throws RemoveException { // Remove file File file = getFile(ctx.getId()); if (!file.delete()) { throw new RemoveException("Could not remove file: " + file); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoveException { entityBridge.remove(ctx); PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext(); pctx.remove(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void remove(EntityEnterpriseContext ctx) throws RemoveException { if(metadata.getRelatedRole().isCascadeDelete()) { FieldState state = getFieldState(ctx); state.cascadeDelete(ctx); } else { destroyExistingRelationships(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void cascadeDelete(EntityEnterpriseContext ctx) throws RemoveException { if(manager.registerCascadeDelete(ctx.getId(), ctx.getId())) { EJBLocalObject value = (EJBLocalObject)getValue(ctx); if(value != null) { changeValue(null); final Object relatedId = value.getPrimaryKey(); final JDBCStoreManager2 relatedManager = (JDBCStoreManager2)relatedEntity.getManager(); if(!relatedManager.isCascadeDeleted(relatedId)) { value.remove(); } } manager.unregisterCascadeDelete(ctx.getId()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void cascadeDelete(EntityEnterpriseContext ctx) throws RemoveException { Collection value = (Collection)getValue(ctx); if(!value.isEmpty()) { EJBLocalObject[] locals = (EJBLocalObject[])value.toArray(); for(int i = 0; i < locals.length; ++i) { locals[i].remove(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void remove(EntityEnterpriseContext ctx) throws RemoveException { if(cmrFields != null) { for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].remove(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); } else if(trace) { log.trace(oldValue + " already removed"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); } else if(trace) { log.trace(oldValue + " already removed"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean didDelete = false; boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); didDelete = true; } else if(trace) { log.trace(oldValue + " already removed"); } } if(didDelete) { executeDeleteSQL(batchCascadeDeleteSql, ctx.getId()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
protected void executeDeleteSQL(String sql, Object key) throws RemoveException { Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { if(log.isDebugEnabled()) log.debug("Executing SQL: " + sql); // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql); // set the parameters entity.setPrimaryKeyParameters(ps, 1, key); // execute statement rowsAffected = ps.executeUpdate(); } catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected == 0) { log.error("Could not remove entity " + key); throw new RemoveException("Could not remove entity"); } if(log.isDebugEnabled()) log.debug("Remove: Rows affected = " + rowsAffected); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void invokeRemoveRelated(Object relatedId) throws RemoveException, RemoteException { EntityContainer container = relatedManager.getContainer(); /* try { EntityCache instanceCache = (EntityCache) container.getInstanceCache(); SecurityActions actions = SecurityActions.UTIL.getSecurityActions(); org.jboss.invocation.Invocation invocation = new org.jboss.invocation.Invocation(); invocation.setId(instanceCache.createCacheKey(relatedId)); invocation.setArguments(new Object[]{}); invocation.setTransaction(container.getTransactionManager().getTransaction()); invocation.setPrincipal(actions.getPrincipal()); invocation.setCredential(actions.getCredential()); invocation.setType(invocationType); invocation.setMethod(removeMethod); container.invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in remove instance", e); } */ /** * Have to remove through EJB[Local}Object interface since the proxy contains the 'removed' flag * to be set on removal. */ if(container.getLocalProxyFactory() != null) { final EJBLocalObject ejbObject = container.getLocalProxyFactory().getEntityEJBLocalObject(relatedId); ejbObject.remove(); } else { final EJBObject ejbObject = (EJBObject)container.getProxyFactory().getEntityEJBObject(relatedId); ejbObject.remove(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
public void execute(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { if(entity.isRemoved(ctx)) { throw new IllegalStateException("Instance was already removed: id=" + ctx.getId()); } entity.setIsBeingRemoved(ctx); // remove entity from all relations Object[] oldRelationsRef = new Object[1]; boolean needsSync = entity.removeFromRelations(ctx, oldRelationsRef); // update the related entities (stores the removal from relationships) // if one of the store fails an EJBException will be thrown if(!syncOnCommitOnly && needsSync) { EntityContainer.synchronizeEntitiesWithinTransaction(ctx.getTransaction()); } if(!batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.trace("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } // cascate-delete to old relations, if relation uses cascade. if(oldRelationsRef[0] != null) { Map oldRelations = (Map)oldRelationsRef[0]; entity.cascadeDelete(ctx, oldRelations); } if(batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.debug("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } entity.setRemoved(ctx); manager.getReadAheadCache().removeCachedData(ctx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
private void executeDeleteSQL(EntityEnterpriseContext ctx) throws RemoveException { Object key = ctx.getId(); Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { if(log.isDebugEnabled()) log.debug("Executing SQL: " + removeEntitySQL); // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(removeEntitySQL); // set the parameters entity.setPrimaryKeyParameters(ps, 1, key); // execute statement rowsAffected = ps.executeUpdate(); } catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected == 0) { log.error("Could not remove entity " + key); throw new RemoveException("Could not remove entity"); } if(log.isTraceEnabled()) log.trace("Remove: Rows affected = " + rowsAffected); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { removeEntityCommand.execute(ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void cascadeDelete(EntityEnterpriseContext ctx, Map oldRelations) throws RemoveException, RemoteException { for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge cmrField = cmrFields[i]; Object value = oldRelations.get(cmrField); if(value != null) cmrField.cascadeDelete(ctx, (List)value); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { cascadeDeleteStrategy.cascadeDelete(ctx, oldValues); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // synchronize entities with the datastore before the bean is removed // this will write queued updates so datastore will be consistent before removal Transaction tx = mi.getTransaction(); if (!getBeanMetaData().getContainerConfiguration().getSyncOnCommitOnly()) synchronizeEntitiesWithinTransaction(tx); // Get the persistence manager to do the dirty work EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().removeEntity(ctx); final Object pk = ctx.getId(); AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { removeTimerService(pk); return null; } }); // We signify "removed" with a null id // There is no need to synchronize on the context since all the threads reaching here have // gone through the InstanceInterceptor so the instance is locked and we only have one thread // the case of reentrant threads is unclear (would you want to delete an instance in reentrancy) ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not yet implemented"); }
(Lib) MalformedLinkException 9
              
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getGUID() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(guidAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getRemoteLinkName() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(remoteAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getLocalLinkName() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(localAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
0 3
              
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getGUID() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(guidAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getRemoteLinkName() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(remoteAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getLocalLinkName() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(localAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
(Lib) NoSuchObjectLocalException 10
              
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
public Timer getTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { EJBTimerService ejbTimerService = EJBTimerServiceLocator.getEjbTimerService(); ObjectName containerId = timedObjectId.getContainerId(); Object instancePk = timedObjectId.getInstancePk(); TimerServiceImpl timerService = (TimerServiceImpl)ejbTimerService.getTimerService(containerId, instancePk); if (timerService == null) throw new NoSuchObjectLocalException("TimerService not available: " + timedObjectId); TimerImpl timer = (TimerImpl)timerService.getTimer(this); if (timer == null || timer.isActive() == false) throw new NoSuchObjectLocalException("Timer not available: " + timedObjectId); return timer; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
private void assertTimedOut() { if (timerState == EXPIRED) throw new NoSuchObjectLocalException("Timer has expired"); if (timerState == CANCELED_IN_TX || timerState == CANCELED) throw new NoSuchObjectLocalException("Timer was canceled"); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/EntityProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { if(removed) { throw new javax.ejb.NoSuchObjectLocalException("The instance has been removed: " + toStringImpl()); } if (args == null) args = EMPTY_ARGS; Object retValue = super.invoke( proxy, m, args ); if( retValue == null ) { // If not taken care of, go on and call the container retValue = factory.invoke(cacheKey, m, args); } if(m.equals(REMOVE)) { removed = true; } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public Object getFieldValue(int i) { if(state == DELETED) { throw new NoSuchObjectLocalException("The instance was removed: " + pk); } Object value = fields[i]; if(value == NOT_LOADED) { value = loadField(i); } return value; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { InstanceCache cache = container.getInstanceCache(); InstancePool pool = container.getInstancePool(); Object methodID = mi.getId(); EnterpriseContext ctx = null; BeanLock lock = container.getLockManager().getLock(methodID); boolean callerRunAsIdentityPresent = SecurityActions.peekRunAsIdentity() != null; boolean pushSecurityContext = SecurityActions.getSecurityContext() == null; try { /* The security context must be established before the cache lookup because the activation of a session should have the caller's security context as ejbActivate is allowed to call other secured resources. Since the pm makes the ejbActivate call, we need to set the caller's security context. The only reason this shows up for stateful session is that we moved the SecurityInterceptor to after the instance interceptor to allow security exceptions to result in invalidation of the session. This may be too literal an interpretation of the ejb spec requirement that runtime exceptions should invalidate the session. */ if(!callerRunAsIdentityPresent && pushSecurityContext) { AuthenticationManager am = container.getSecurityManager(); String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(am != null) securityDomain = am.getSecurityDomain(); SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain , null); //SecurityActions.pushSubjectContext(mi.getPrincipal(), mi.getCredential(), null); } lock.sync(); try { // Get context try { ctx = cache.get(methodID); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } // Associate it with the method invocation mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // BMT beans will lock and replace tx no matter what, CMT do work on transaction boolean isBMT = ((SessionMetaData)container.getBeanMetaData()).isBeanManagedTx(); if (isBMT == false) { // Do we have a running transaction with the context if (ctx.getTransaction() != null && // And are we trying to enter with another transaction !ctx.getTransaction().equals(mi.getTransaction())) { // Calls must be in the same transaction StringBuffer msg = new StringBuffer("Application Error: " + "tried to enter Stateful bean with different tx context"); msg.append(", contextTx: " + ctx.getTransaction()); msg.append(", methodTx: " + mi.getTransaction()); throw new EJBException(msg.toString()); } //If the instance will participate in a new transaction we register a sync for it if (ctx.getTransaction() == null && mi.getTransaction() != null) { register(ctx, mi.getTransaction(), lock); } } if (!ctx.isLocked()) { //take it! ctx.lock(); } else { if (!isCallAllowed(mi)) { // Concurent calls are not allowed throw new EJBException("Application Error: no concurrent " + "calls on stateful beans"); } else { ctx.lock(); } } } finally { lock.releaseSync(); } // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); boolean validContext = true; try { // Invoke through interceptors Object ret = getNext().invoke(mi); return ret; } catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } } } finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
4
              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
6
              
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
public Timer getTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { EJBTimerService ejbTimerService = EJBTimerServiceLocator.getEjbTimerService(); ObjectName containerId = timedObjectId.getContainerId(); Object instancePk = timedObjectId.getInstancePk(); TimerServiceImpl timerService = (TimerServiceImpl)ejbTimerService.getTimerService(containerId, instancePk); if (timerService == null) throw new NoSuchObjectLocalException("TimerService not available: " + timedObjectId); TimerImpl timer = (TimerImpl)timerService.getTimer(this); if (timer == null || timer.isActive() == false) throw new NoSuchObjectLocalException("Timer not available: " + timedObjectId); return timer; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public void cancel() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.cancel"); registerTimerWithTx(); cancelInTx(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public long getTimeRemaining() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getTimeRemaining"); return nextExpire - System.currentTimeMillis(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Date getNextTimeout() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getNextTimeout"); return new Date(nextExpire); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Serializable getInfo() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getInfo"); return info; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public TimerHandle getHandle() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getHandle"); return new TimerHandleImpl(this); }
(Lib) UndeclaredThrowableException 9
              
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeMarshalled(Invocation invocation) throws Exception { MarshalledInvocation mi = new MarshalledInvocation(invocation); MarshalledValue copy = new MarshalledValue(mi); Invocation invocationCopy = (Invocation) copy.get(); // copy the Tx Transaction tx = invocation.getTransaction(); invocationCopy.setTransaction(tx); try { Object rtnValue = localInvoker.invoke(invocationCopy); MarshalledValue mv = new MarshalledValue(rtnValue); return mv.get(); } catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); } }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeLocalMarshalled(Invocation invocation) throws Exception { IMarshalledValue value = createMarshalledValueForCallByValue(invocation.getArguments()); MarshalledInvocation invocationCopy = createInvocationCopy(invocation, value); // copy the Tx Transaction tx = invocation.getTransaction(); invocationCopy.setTransaction(tx); try { Object rtnValue = localInvoker.invoke(invocationCopy); IMarshalledValue mv = createMarshalledValueForCallByValue(rtnValue); return mv.get(); } catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); } }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public Object invoke(Invocation invocation) throws Exception { try { // Make sure we have the correct classloader before unmarshalling ClassLoader oldCL = SecurityActions.getContextClassLoader(); ClassLoader newCL = null; // Get the MBean this operation applies to ObjectName objectName = (ObjectName) invocation.getValue("JMX_OBJECT_NAME"); if (objectName != null) { newCL = server.getClassLoaderFor(objectName); } if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(newCL); //JBAS-6449: Cache the incoming security context to be retained on exit SecurityContext previousSecurityContext = SecurityActions.getSecurityContext(); try { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the MBeanServer method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Principal principal = invocation.getPrincipal(); Object credential = invocation.getCredential(); Object value = null; SecurityContext sc = SecurityActions.createSecurityContext(SecurityConstants.DEFAULT_APPLICATION_POLICY); SecurityActions.setSecurityContext(sc); // Associate the method SecurityActions.pushSubjectContext(principal, credential, null); try { if( addNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; NotificationFilter filter = (NotificationFilter) args[2]; Object handback = args[3]; addNotificationListener(name, listener, filter, handback); } else if( removeNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; removeNotificationListener(name, listener); } else { String name = method.getName(); Class[] paramTypes = method.getParameterTypes(); Method mbeanServerMethod = MBeanServer.class.getMethod(name, paramTypes); value = mbeanServerMethod.invoke(server, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; } finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); } } catch (Throwable t) { throw new InvokerAdaptorException(t); } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
private void checkAuthorization(Principal caller, String objname, String opname) throws Exception { // Get the active Subject Subject subject = SecurityActions.getActiveSubject(); if( subject == null ) throw new SecurityException("No active Subject found, add th AuthenticationInterceptor"); //We will try to use the authorizing class try { Object[] args = {caller, subject, objname, opname}; authorize.invoke(authenticator, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); } }
// in src/main/java/org/jboss/naming/NamingService.java
public Object invoke(Invocation invocation) throws Exception { Naming theServer = namingMain.getNamingInstance(); // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the Naming method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Object value = null; try { value = method.invoke(theServer, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
public Object invoke(Invocation invocation) throws Exception { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Object value = null; try { if( UserTransactionSessionFactory.class.isAssignableFrom(method.getDeclaringClass()) ) { // Just return the UserTransactionSession proxy as its stateless value = txProxy; } else if( method.getName().equals("begin") ) { // Begin a new transaction Integer timeout = (Integer) args[0]; UserTransactionSession session = UserTransactionSessionImpl.getInstance(); value = session.begin(timeout.intValue()); } else if( method.getName().equals("destroy")) { /* We do nothing as the tx will timeout and the tx map is shared across all sessions as we have no association with the txs a given client has started. */ } else { UserTransactionSession session = UserTransactionSessionImpl.getInstance(); value = method.invoke(session, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { try { return (Subject) AccessController.doPrivileged(exAction); } catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { try { return (Subject) AccessController.doPrivileged(exAction); } catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { try { return (Subject) AccessController.doPrivileged(exAction); } catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); } }
9
              
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
0
(Lib) SecurityException 7
              
// in src/main/java/org/jboss/jmx/connector/invoker/RolesAuthorization.java
public void authorize(Principal caller, Subject subject, String objectname, String opname) { Set groups = subject.getPrincipals(Group.class); Group roles = null; Iterator iter = groups.iterator(); while( iter.hasNext() ) { Group grp = (Group) iter.next(); if( grp.getName().equals("Roles") ) { roles = grp; break; } } if( roles == null ) { throw new SecurityException("Subject has no Roles"); } iter = requiredRoles.iterator(); boolean hasRole = false; while( iter.hasNext() && hasRole == false ) { Principal p = (Principal) iter.next(); hasRole = roles.isMember(p); } if( hasRole == false ) { throw new SecurityException("Authorization failure, requiredRoles="+requiredRoles +", callerRoles="+roles); } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
private void checkAuthorization(Principal caller, String objname, String opname) throws Exception { // Get the active Subject Subject subject = SecurityActions.getActiveSubject(); if( subject == null ) throw new SecurityException("No active Subject found, add th AuthenticationInterceptor"); //We will try to use the authorizing class try { Object[] args = {caller, subject, objname, opname}; authorize.invoke(authenticator, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthenticationInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { SecurityContext previousSC = null; String type = invocation.getType(); Subject subject = null; if (!initialized) initialize(); if (type == Invocation.OP_INVOKE && securityMgr != null) { String opName = invocation.getName(); if (opName.equals("invoke")) { Object[] args = invocation.getArgs(); org.jboss.invocation.Invocation inv = (org.jboss.invocation.Invocation) args[0]; // Authenticate the caller based on the security association Principal caller = inv.getPrincipal(); Object credential = inv.getCredential(); subject = new Subject(); boolean isValid = securityMgr.isValid(caller, credential, subject); if (isValid == false) { String msg = "Failed to authenticate principal=" + caller + ", securityDomain=" + securityMgr.getSecurityDomain(); throw new SecurityException(msg); } String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if (securityMgr != null) securityDomain = securityMgr.getSecurityDomain(); // store current security context previousSC = SecurityActions.getSecurityContext(); SecurityContext sc = SecurityActions.createSecurityContext(securityDomain); SecurityActions.setSecurityContext(sc); // Push the caller security context SecurityActions.pushSubjectContext(caller, credential, subject); } } try { Interceptor i = invocation.nextInterceptor(); return i.invoke(invocation); } finally { // restore previous security context if (subject != null) SecurityActions.setSecurityContext(previousSC); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private void checkSecurityContext(Invocation mi, RunAs callerRunAsIdentity) throws Exception { Principal principal = mi.getPrincipal(); Object credential = mi.getCredential(); boolean trace = log.isTraceEnabled(); // If there is not a security manager then there is no authentication required Method m = mi.getMethod(); boolean containerMethod = m == null || m.equals(ejbTimeout); if (containerMethod == true || securityManager == null || container == null) { // Allow for the propagation of caller info to other beans SecurityActions.pushSubjectContext(principal, credential, null); return; } if (realmMapping == null) { throw new SecurityException("Role mapping manager has not been set"); } SecurityContext sc = SecurityActions.getSecurityContext(); EJBAuthenticationHelper helper = SecurityHelperFactory.getEJBAuthenticationHelper(sc); boolean isTrusted = containsTrustableRunAs(sc) || helper.isTrusted(); if (!isTrusted) { // Check the security info from the method invocation Subject subject = new Subject(); if (SecurityActions.isValid(helper, subject, m.getName()) == false) { // Notify authentication observer if (authenticationObserver != null) authenticationObserver.authenticationFailed(); // Else throw a generic SecurityException String msg = "Authentication exception, principal=" + principal; throw new SecurityException(msg); } else { SecurityActions.pushSubjectContext(principal, credential, subject); if (trace) { log.trace("Authenticated principal=" + principal + " in security domain=" + sc.getSecurityDomain()); } } } else { // Duplicate the current subject context on the stack since //SecurityActions.dupSubjectContext(); SecurityActions.pushRunAsIdentity(callerRunAsIdentity); } Method ejbMethod = mi.getMethod(); // Ignore internal container calls if (ejbMethod == null) return; // Get the caller Subject caller = SecurityActions.getContextSubject(); if (caller == null) throw new IllegalStateException("Authenticated User. But caller subject is null"); //Establish the deployment rolename-principalset custom mapping(if available) SecurityRolesAssociation.setSecurityRoles(this.deploymentRoles); boolean isAuthorized = false; Set<Principal> methodRoles = container.getMethodPermissions(ejbMethod, mi.getType()); SecurityContext currentSC = SecurityActions.getSecurityContext(); if (SecurityActions.getSecurityManagement(currentSC) == null) SecurityActions.setSecurityManagement(currentSC, securityManagement); AbstractEJBAuthorizationHelper authorizationHelper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); authorizationHelper.setPolicyRegistration(container.getPolicyRegistration()); isAuthorized = SecurityActions.authorize(authorizationHelper, ejbName, ejbMethod, mi.getPrincipal(), mi.getType().toInterfaceString(), ejbCS, caller, callerRunAsIdentity, container.getJaccContextID(), new SimpleRoleGroup(methodRoles)); if (!isAuthorized) { String msg = "Denied: caller with subject=" + caller + " and security context post-mapping roles=" + SecurityActions.getRolesFromSecurityContext(currentSC) + ": ejbMethod=" + ejbMethod; throw new SecurityException(msg); } }
0 8
              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void rollback() throws SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.rollback(" + tpc + ")"); } try { getSession().rollback(tpc); } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx commit: " + tx); int status = tm.getStatus(); tm.commit(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx rollback: " + tx); tm.rollback(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
(Lib) Exception 6
              
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { Object response = null; // Earlier versions of InvokerLocator don't have a findSerializationType() method. try { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE",locator.findSerializationType()); } catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); } try { response = client.invoke(invocation, null); if(response instanceof Exception) { throw ((Exception) response); } if(response instanceof MarshalledObject) { return ((MarshalledObject) response).get(); } if (response instanceof IMarshalledValue) { return ((IMarshalledValue)response).get(); } return response; } catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } } catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private DataSource lookupDataSource(ObjectName dataSource) throws Exception { try { String dsJndi = (String) server.getAttribute(dataSource, "BindName"); return (DataSource)new InitialContext().lookup(dsJndi); } catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void lockForUpdate(Transaction tx, Object pk) throws Exception { CachedRow row = (CachedRow) rowsById.get(pk); if(row != null) { if(row.locker != null && !tx.equals(row.locker)) { throw new Exception("lock acquisition rejected for " + tx + ", the entry is locked for update by " + row.locker + ", id=" + pk); } row.locker = tx; } // else?! }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void releaseLock(Transaction tx, Object pk) throws Exception { CachedRow row = (CachedRow) rowsById.get(pk); if(row != null) { if(!tx.equals(row.locker)) { throw new Exception("rejected to release lock for " + tx + ", the entry is locked for update by " + row.locker + ", id=" + pk); } row.locker = null; } // else?! }
// in src/main/java/org/jboss/web/WebServer.java
public void start() throws Exception { if (executor == null) throw new IllegalArgumentException("Required property 'executor' not specified"); try { server = new ServerSocket(port, backlog, bindAddress); log.debug("Started server: " + server); listen(); } catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); } catch (IOException e) { throw e; } }
// in src/main/java/org/jboss/web/WebServer.java
public void run() { // Return if the server has been stopped if (server == null) return; // Accept a connection Socket socket = null; try { socket = server.accept(); } catch (IOException e) { // If the server is not null meaning we were not stopped report the err if (server != null) log.error("Failed to accept connection", e); return; } // Create a new thread to accept the next connection listen(); try { // Get the request socket output stream DataOutputStream out = new DataOutputStream(socket.getOutputStream()); try { String httpCode = "200 OK"; // Get the requested item from the HTTP header BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String rawPath = getPath(in); // Parse the path into the class loader key and file path. // // The class loader key is a string whose format is // "ClassName[oid]", where the oid substring may contain '/' // chars. The expected form of the raw path is: // // "SomeClassName[some/object/id]/some/file/path" // // The class loader key is "SomeClassName[some/object/id]" // and the file path is "some/file/path" int endOfKey = rawPath.indexOf(']'); String filePath = rawPath.substring(endOfKey + 2); String loaderKey = rawPath.substring(0, endOfKey + 1); log.trace("loaderKey = " + loaderKey); log.trace("filePath = " + filePath); ClassLoader loader = (ClassLoader) loaderMap.get(loaderKey); /* If we did not find a class loader check to see if the raw path begins with className + '[' + class loader key + ']' by looking for an '[' char. If it does not and downloadServerClasses is true use the thread context class loader and set filePath to the rawPath */ if (loader == null && rawPath.indexOf('[') < 0 && downloadServerClasses) { filePath = rawPath; log.trace("No loader, reset filePath = " + filePath); loader = Thread.currentThread().getContextClassLoader(); } log.trace("loader = " + loader); byte[] bytes = {}; SwitchContext tclSwitchContext = null; try { tclSwitchContext = this.tclSwitcher.getSwitchContext(this.getClass().getClassLoader()); if (loader != null && filePath.endsWith(".class")) { // A request for a class file String className = filePath.substring(0, filePath.length() - 6).replace('/', '.'); log.trace("loading className = " + className); Class<?> clazz = loader.loadClass(className); URL clazzUrl = clazz.getProtectionDomain().getCodeSource().getLocation(); log.trace("clazzUrl = " + clazzUrl); if (clazzUrl == null) { // Does the WebClassLoader of clazz // have the ability to obtain the bytecodes of clazz? bytes = ((WebClassLoader) clazz.getClassLoader()).getBytes(clazz); if (bytes == null) throw new Exception("Class not found: " + className); } else { if (clazzUrl.getFile().endsWith("/") == false) { clazzUrl = new URL("jar:" + clazzUrl + "!/" + filePath); } // this is a hack for the AOP ClassProxyFactory else if (clazzUrl.getFile().indexOf("/org_jboss_aop_proxy$") < 0) { clazzUrl = new URL(clazzUrl, filePath); } // Retrieve bytecodes log.trace("new clazzUrl: " + clazzUrl); bytes = getBytes(clazzUrl); } } else if (loader != null && filePath.length() > 0 && downloadServerClasses && downloadResources) { // Try getting resource log.trace("loading resource = " + filePath); URL resourceURL = loader.getResource(filePath); if (resourceURL == null) httpCode = "404 Resource not found:" + filePath; else { // Retrieve bytes log.trace("resourceURL = " + resourceURL); bytes = getBytes(resourceURL); } } else { httpCode = "404 Not Found"; } } finally { if (tclSwitchContext != null) { tclSwitchContext.reset(); } } // Send bytecodes/resource data in response (assumes HTTP/1.0 or later) try { log.trace("HTTP code=" + httpCode + ", Content-Length: " + bytes.length); // The HTTP 1.0 header out.writeBytes("HTTP/1.0 " + httpCode + "\r\n"); out.writeBytes("Content-Length: " + bytes.length + "\r\n"); out.writeBytes("Content-Type: " + getMimeType(filePath)); out.writeBytes("\r\n\r\n"); // The response body out.write(bytes); out.flush(); } catch (IOException ie) { return; } } catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } } finally { } } catch (IOException ex) { log.error("error writting response", ex); } finally { // Close the client request socket try { socket.close(); } catch (IOException e) { } } }
3
              
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); }
// in src/main/java/org/jboss/web/WebServer.java
catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); }
464
              
// in src/main/java/org/jboss/invocation/MarshallingInvokerInterceptor.java
public Object invoke(Invocation invocation) throws Exception { /* if(isLocal(invocation)) return invokeLocalMarshalled(invocation); else return invokeInvoker(invocation); invokeLocalMarshalled is an optimized method for call-by-values. we don't need to serialize the entire Invocation for having call-by-value. */ if(isLocal(invocation)) return invokeLocalMarshalled(invocation); else return invokeInvoker(invocation); }
// in src/main/java/org/jboss/invocation/Invocation.java
public Object performCall(Object instance, Method m, Object[] arguments) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Exception { return m.invoke(instance,arguments); }
// in src/main/java/org/jboss/invocation/ByValueInvokerInterceptor.java
public Object invoke(Invocation invocation) throws Exception { // local interface if (isLocal(invocation)) // The payload as is is good return localInvoker.invoke(invocation); else // through the invoker return invocation.getInvocationContext().getInvoker().invoke(invocation); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
public static Object invoke(URL externalURL, Invocation mi) throws Exception { if( log.isTraceEnabled() ) log.trace("invoke, externalURL="+externalURL); /* Post the MarshalledInvocation data. This is using the URL class for now but this should be improved to a cluster aware layer with full usage of HTTP 1.1 features, pooling, etc. */ HttpURLConnection conn = (HttpURLConnection) externalURL.openConnection(); configureHttpsHostVerifier(conn); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestProperty("ContentType", REQUEST_CONTENT_TYPE); conn.setRequestMethod("POST"); // @todo this should be configurable conn.setRequestProperty("Accept-Encoding", "x-gzip,x-deflate,gzip,deflate"); OutputStream os = conn.getOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(os); try { oos.writeObject(mi); oos.flush(); } catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); } // Get the response MarshalledValue object InputStream is = conn.getInputStream(); // Check the headers for gzip Content-Encoding String encoding = conn.getHeaderField("Content-Encoding"); if( encoding != null && encoding.indexOf("gzip") >= 0 ) is = new GZIPInputStream(is); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); // A hack for jsse connection pooling (see patch ). ois.read(); ois.close(); oos.close(); // If the encoded value is an exception throw it Object value = mv.get(); if( value instanceof Exception ) { throw (Exception) value; } return value; }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public String getServerHostName() throws Exception { if( externalURL == null ) externalURL = Util.resolveURL(externalURLValue); return externalURL.getHost(); }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { // We are going to go through a Remote invocation, switch to a Marshalled Invocation MarshalledInvocation mi = new MarshalledInvocation(invocation); if( externalURL == null ) externalURL = Util.resolveURL(externalURLValue); try { Object value = Util.invoke(externalURL, mi); return value; } catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); } catch (IOException e) { throw new ServerException("IOE", e); } }
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
protected void startService() throws Exception { checkInvokerURL(); Invoker delegateInvoker = new HttpInvokerProxy(invokerURL); // Export the Invoker interface ObjectName name = super.getServiceName(); Registry.bind(name, delegateInvoker); log.debug("Bound Http invoker for JMX node"); }
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
public Object invoke(Invocation invocation) throws Exception { ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); try { // Deserialize the transaction if it is there MarshalledInvocation mi = (MarshalledInvocation) invocation; Object tpc = mi.getTransactionPropagationContext(); Transaction tx = importTPC(tpc); invocation.setTransaction(tx); Integer nameHash = (Integer) invocation.getObjectName(); ObjectName mbean = (ObjectName) Registry.lookup(nameHash); // The cl on the thread should be set in another interceptor Object[] args = {invocation}; String[] sig = {"org.jboss.invocation.Invocation"}; Object obj = super.getServer().invoke(mbean, "invoke", args, sig); // Return the raw object and let the http layer marshall it return obj; } catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; } finally { Thread.currentThread().setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/invocation/http/server/HttpProxyFactory.java
public void setClientInterceptors(Element config) throws Exception { this.interceptorConfig = config; Iterator interceptorElements = MetaData.getChildrenByTagName(interceptorConfig, "interceptor"); ClassLoader loader = Thread.currentThread().getContextClassLoader(); if( interceptorClasses != null ) interceptorClasses.clear(); else interceptorClasses = new ArrayList(); while( interceptorElements != null && interceptorElements.hasNext() ) { Element ielement = (Element) interceptorElements.next(); String className = null; className = MetaData.getElementContent(ielement); Class clazz = loader.loadClass(className); interceptorClasses.add(clazz); } }
// in src/main/java/org/jboss/invocation/http/server/HttpProxyFactory.java
protected void startService() throws Exception { /** Create an HttpInvokerProxy that posts invocations to the externalURL. This proxy will be associated with a naming JMX invoker given by the jmxInvokerName. */ Invoker delegateInvoker = createInvoker(); Integer nameHash = new Integer(jmxInvokerName.hashCode()); log.debug("Bound delegate: "+delegateInvoker +" for invoker="+jmxInvokerName); /* Create a binding betweeh the invoker name hash and the jmx name This is used by the HttpInvoker to map from the Invocation ObjectName hash value to the target JMX ObjectName. */ Registry.bind(nameHash, jmxInvokerName); Object cacheID = null; String proxyBindingName = null; Class[] ifaces = {exportedInterface}; /* Initialize interceptorClasses with default client interceptor list if no client interceptor configuration was provided */ if( interceptorClasses == null ) interceptorClasses = defineDefaultInterceptors(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); GenericProxyFactory proxyFactory = new GenericProxyFactory(); theProxy = proxyFactory.createProxy(cacheID, jmxInvokerName, delegateInvoker, jndiName, proxyBindingName, interceptorClasses, loader, ifaces); log.debug("Created HttpInvokerProxy for invoker="+jmxInvokerName +", nameHash="+nameHash); if( jndiName != null ) { InitialContext iniCtx = new InitialContext(); Util.bind(iniCtx, jndiName, theProxy); log.debug("Bound proxy under jndiName="+jndiName); } }
// in src/main/java/org/jboss/invocation/http/server/HttpProxyFactory.java
protected void stopService() throws Exception { Integer nameHash = new Integer(jmxInvokerName.hashCode()); Registry.unbind(jmxInvokerName); Registry.unbind(nameHash); if( jndiName != null ) { InitialContext iniCtx = new InitialContext(); Util.unbind(iniCtx, jndiName); } }
// in src/main/java/org/jboss/invocation/http/server/HttpProxyFactory.java
protected Invoker createInvoker() throws Exception { checkInvokerURL(); HttpInvokerProxy delegateInvoker = new HttpInvokerProxy(invokerURL); return delegateInvoker; }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
public void setClientInterceptors(Element config) throws Exception { this.interceptorConfig = config; Iterator interceptorElements = MetaData.getChildrenByTagName(interceptorConfig, "interceptor"); ClassLoader loader = Thread.currentThread().getContextClassLoader(); interceptorClasses.clear(); while( interceptorElements != null && interceptorElements.hasNext() ) { Element ielement = (Element) interceptorElements.next(); String className = null; className = MetaData.getElementContent(ielement); Class clazz = loader.loadClass(className); interceptorClasses.add(clazz); log.debug("added interceptor type: "+clazz); } }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
public Object invoke(Invocation mi) throws Exception { final boolean remoteInvocation = mi instanceof MarshalledInvocation; if(remoteInvocation) { ((MarshalledInvocation)mi).setMethodMap(methodMap); } final Object result; if(invokeTargetMethod) { String signature[] = (String[])signatureMap.get(mi.getMethod()); result = server.invoke(targetName, mi.getMethod().getName(), mi.getArguments(), signature); } else { result = server.invoke(targetName, "invoke", new Object[]{mi}, Invocation.INVOKE_SIGNATURE); } return result; }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
protected void startService() throws Exception { /* Create a binding between the invoker name hash and the jmx name This is used by the Invoker to map from the Invocation ObjectName hash value to the target JMX ObjectName. */ Integer nameHash = new Integer(getServiceName().hashCode()); Registry.bind(nameHash, getServiceName()); // Create the service proxy Object cacheID = null; String proxyBindingName = null; Class[] ifaces = exportedInterfaces; ClassLoader loader = Thread.currentThread().getContextClassLoader(); createProxy(cacheID, proxyBindingName, loader, ifaces); log.debug("Created JRMPPRoxy for service="+targetName +", nameHash="+nameHash+", invoker="+invokerName); if( jndiName != null ) { InitialContext iniCtx = new InitialContext(); Util.rebind(iniCtx, jndiName, theProxy); log.debug("Bound proxy under jndiName="+jndiName); } for(int i = 0; i < exportedInterfaces.length; ++i) { final Method[] methods = exportedInterfaces[i].getMethods(); for(int j = 0; j < methods.length; ++j) { methodMap.put(new Long(MarshalledInvocation.calculateHash(methods[j])), methods[j]); String signature[]; final Class[] types = methods[j].getParameterTypes(); if(types == null || types.length == 0) { signature = null; } else { signature = new String[types.length]; for(int typeInd = 0; typeInd < types.length; ++typeInd) { signature[typeInd] = types[typeInd].getName(); } } signatureMap.put(methods[j], signature); } } }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
protected void stopService() throws Exception { Integer nameHash = new Integer(getServiceName().hashCode()); Registry.unbind(nameHash); if( jndiName != null ) { InitialContext iniCtx = new InitialContext(); Util.unbind(iniCtx, jndiName); } this.theProxy = null; }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
protected void destroyService() throws Exception { interceptorClasses.clear(); }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
protected void rebind() throws Exception { log.debug("(re-)Binding " + jndiName); Util.rebind(new InitialContext(), jndiName, theProxy); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
public Object invoke(Invocation invocation) throws Exception { // optimize if calling another bean in same server VM if (isLocal(invocation)) return invokeLocal(invocation); else return invokeInvoker(invocation); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeLocal(Invocation invocation) throws Exception { return localInvoker.invoke(invocation); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeMarshalled(Invocation invocation) throws Exception { MarshalledInvocation mi = new MarshalledInvocation(invocation); MarshalledValue copy = new MarshalledValue(mi); Invocation invocationCopy = (Invocation) copy.get(); // copy the Tx Transaction tx = invocation.getTransaction(); invocationCopy.setTransaction(tx); try { Object rtnValue = localInvoker.invoke(invocationCopy); MarshalledValue mv = new MarshalledValue(rtnValue); return mv.get(); } catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); } }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeLocalMarshalled(Invocation invocation) throws Exception { IMarshalledValue value = createMarshalledValueForCallByValue(invocation.getArguments()); MarshalledInvocation invocationCopy = createInvocationCopy(invocation, value); // copy the Tx Transaction tx = invocation.getTransaction(); invocationCopy.setTransaction(tx); try { Object rtnValue = localInvoker.invoke(invocationCopy); IMarshalledValue mv = createMarshalledValueForCallByValue(rtnValue); return mv.get(); } catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); } }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeInvoker(Invocation invocation) throws Exception { InvocationContext ctx = invocation.getInvocationContext(); Invoker invoker = ctx.getInvoker(); return invoker.invoke(invocation); }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
protected void createService() throws Exception { // note on design: We need to call it ourselves as opposed to // letting the client InvokerInterceptor look it // up through the use of Registry, the reason being including // the classes in the client. // If we move to a JNDI format (with local calls) for the // registry we could remove the call below InvokerInterceptor.setLocal(this); Registry.bind(serviceName, this); }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
protected void startService() throws Exception { InitialContext ctx = new InitialContext(); try { /** * FIXME marcf: what is this doing here? */ TransactionManager tm = (TransactionManager) ctx.lookup("java:/TransactionManager"); TransactionInterceptor.setTransactionManager(tm); } finally { ctx.close(); } log.debug("Local invoker for JMX node started"); }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
public Object invoke(Invocation invocation) throws Exception { ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); ObjectName mbean = (ObjectName) Registry.lookup((Integer) invocation.getObjectName()); try { Object[] args = {invocation}; Object rtnValue = serverAction.invoke(mbean, "invoke", args, Invocation.INVOKE_SIGNATURE); return rtnValue; } catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; } finally { TCLAction.UTIL.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
public Object run() throws Exception { Object rtnValue = server.invoke(target, method, args, sig); return rtnValue; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
Object invoke(ObjectName target, String method, Object[] args, String[] sig) throws Exception { SecurityManager sm = System.getSecurityManager(); Object rtnValue = null; if( sm == null ) { // Direct invocation on MBeanServer rtnValue = server.invoke(target, method, args, sig); } else { try { // Encapsulate the invocation in a PrivilegedExceptionAction MBeanServerAction action = new MBeanServerAction(target, method, args, sig); rtnValue = AccessController.doPrivileged(action); } catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; } } return rtnValue; }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public String getServerHostName() throws Exception { if(locator != null) { return locator.getHost(); } else { return null; } }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { Object response = null; // Earlier versions of InvokerLocator don't have a findSerializationType() method. try { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE",locator.findSerializationType()); } catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); } try { response = client.invoke(invocation, null); if(response instanceof Exception) { throw ((Exception) response); } if(response instanceof MarshalledObject) { return ((MarshalledObject) response).get(); } if (response instanceof IMarshalledValue) { return ((IMarshalledValue)response).get(); } return response; } catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } } catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); } }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
protected Client createClient(InvokerLocator locator, String subSystem) throws Exception { return new Client(locator, subSystem); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
protected void createService() throws Exception { if(connector != null) { try { connector.addInvocationHandler(getSubSystem(), this); } catch(Exception e) { log.error("Error adding unified invoker as handler upon connector being set.", e); } } }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
protected void startService() throws Exception { log.debug("Starting unified invoker service."); InvokerLocator locator = null; if(serverInvoker != null) { locator = serverInvoker.getLocator(); if(!serverInvoker.isStarted()) { serverInvoker.start(); } } else if(connector != null) { locator = connector.getLocator(); } else { /** * This will happen in one of two scenarios. One, the unified invoker was not declared in as * service before the connector AND was not specified as the handler within the connector config. * Two, the unified invoker service config did not use the proxy-type attribute within the depends * tag to have the container set the connector upon creating the unified invoker. */ log.error("Error referencing either remoting connector or server invoker to be used. " + "Please check configuration to make sure proper dependancies are set."); throw new RuntimeException("Error getting locator because server invoker is null."); } proxy = new UnifiedInvokerProxy(locator, strictRMIException); jmxBind(); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
public void stopService() throws Exception { // JBAS-5590 -- the serverInvoker is a shared resource and shouldn't // be stopped just because we don't want it any more // if(serverInvoker != null) // { // serverInvoker.stop(); // } }
// in src/main/java/org/jboss/client/AppClientMain.java
public static void main(String[] args) throws Exception { log.debug("System Properties"); Properties sysprops = System.getProperties(); for (Object key : sysprops.keySet()) log.debug(" " + key + "=" + sysprops.getProperty((String) key)); // read the client class from args String clientClass = null; String clientName = null; ArrayList<String> newArgs = new ArrayList<String>(); String[] launchers = DEFAULT_LAUNCHERS; for (int i = 0; i < args.length; i++) { String arg = args[i]; log.debug("arg=" + arg); if( arg.equals(JBOSS_CLIENT_PARAM) ) { clientClass = args[i+1]; i ++; } else if( arg.equals(J2EE_CLIENT_PARAM) ) { /* Set the j2ee.client system property so the AppContextFactory sees what name the client app JNDI enc is bound under */ clientName = args[i+1]; System.setProperty(javaURLContextFactory.J2EE_CLIENT_NAME_PROP, clientName); log.info(javaURLContextFactory.J2EE_CLIENT_NAME_PROP + "=" + clientName); i ++; } else if( arg.equals(LAUNCHERS_PARAM) ) { launchers = args[i+1].split(","); log.info(LAUNCHERS_PARAM + "=" + args[i+1]); i ++; } else { newArgs.add(args[i]); } } ClassLoader loader = Thread.currentThread().getContextClassLoader(); if( loader == null ) loader = AppClientMain.class.getClassLoader(); // Look for a manifest Main-Class if (clientClass == null) { clientClass = getMainClassName(loader); throw new IllegalArgumentException("Neither a Main-Class was found in the manifest, " +"nor was a " + JBOSS_CLIENT_PARAM + " specified"); } // If J2EE_CLIENT_NAME_PROP was not specified, look in the jar descriptors if (clientName == null) { clientName = getClientName(loader); } String[] mainArgs = new String [newArgs.size()]; newArgs.toArray(mainArgs); // Try each launcher in the order specified for(String launcherName : launchers) { try { Class<AppClientLauncher> launcherClass = (Class<AppClientLauncher>) loader.loadClass(launcherName); AppClientLauncher launcher = launcherClass.newInstance(); launcher.launch(clientClass, clientName, mainArgs); break; } catch(Throwable t) { log.warn("Failed to launch using: "+launcherName, t); } } }
// in src/main/java/org/jboss/client/AppClientMain.java
private static String getClientName(ClassLoader loader) throws Exception { String clientName = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); // Try META-INF/application-client.xml application-client@id first URL appXmlURL = loader.getResource("META-INF/application-client.xml"); if( appXmlURL != null ) { InputStream is = appXmlURL.openStream(); Document appXml = builder.parse(is); is.close(); Element root = appXml.getDocumentElement(); clientName = root.getAttribute("id"); if( clientName != null ) return clientName; } // Try META-INF/jboss-client.xml jndi-name URL jbossXmlURL = loader.getResource("META-INF/jboss-client.xml"); if( appXmlURL != null ) { InputStream is = jbossXmlURL.openStream(); Document jbossXml = builder.parse(is); is.close(); Element root = jbossXml.getDocumentElement(); NodeList children = root.getChildNodes(); for(int n = 0; n < children.getLength(); n ++) { Node node = children.item(n); if( node.getLocalName().equals("jndi-name") ) { clientName = node.getNodeValue(); return clientName; } } } // TODO: annotations on main class return null; }
// in src/main/java/org/jboss/client/AppClientMain.java
private static String getMainClassName(ClassLoader loader) throws Exception { URL mfURL = loader.getResource("META-INF/MANIFEST.MF"); if(mfURL == null) { return null; } InputStream is = mfURL.openStream(); Manifest mf; try { mf = new Manifest(is); } finally { is.close(); } Attributes attrs = mf.getMainAttributes(); String mainClassName = attrs.getValue(Attributes.Name.MAIN_CLASS); return mainClassName; }
// in src/main/java/org/jboss/jmx/adaptor/rmi/RMIRemoteMBeanProxy.java
protected RMIAdaptor getRmiAdaptor () throws Exception { InitialContext ctx = new InitialContext(); return (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor"); }
// in src/main/java/org/jboss/jmx/adaptor/rmi/RMIRemoteMBeanProxy.java
public static Object create (final Class intf, final String name, final javax.management.MBeanServer server) throws Exception { return create(intf, new ObjectName(name), server); }
// in src/main/java/org/jboss/jmx/adaptor/rmi/RMIRemoteMBeanProxy.java
public static Object create (final Class intf, final ObjectName name, final javax.management.MBeanServer server) throws Exception { return java.lang.reflect.Proxy.newProxyInstance(Thread.currentThread ().getContextClassLoader (), new Class[] { intf }, new RMIRemoteMBeanProxy(name, server)); }
// in src/main/java/org/jboss/jmx/connector/invoker/SecurityActions.java
static SecurityContext createSecurityContext(final String domain) throws PrivilegedActionException { return (SecurityContext)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return SecurityContextFactory.createSecurityContext(domain); }}); }
// in src/main/java/org/jboss/jmx/connector/invoker/SecurityActions.java
public Object run() throws Exception { return SecurityContextFactory.createSecurityContext(domain); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
protected void startService() throws Exception { // Build the interface method map HashMap tmpMap = new HashMap(61); for(int n = 0; n < exportedInterfaces.length; n ++) { Class iface = exportedInterfaces[n]; Method[] methods = iface.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } /* Look for a void addNotificationListener(ObjectName name, RMINotificationListener listener, NotificationFilter filter, Object handback) */ try { Class[] sig = {ObjectName.class, RMINotificationListener.class, NotificationFilter.class, Object.class}; Method addNotificationListener = iface.getMethod( "addNotificationListener", sig); addNotificationListeners.add(addNotificationListener); } catch(Exception e) { log.debug(iface+"No addNotificationListener(ObjectName, RMINotificationListener)"); } /* Look for a void removeNotificationListener(ObjectName, RMINotificationListener) */ try { Class[] sig = {ObjectName.class, RMINotificationListener.class}; Method removeNotificationListener = iface.getMethod( "removeNotificationListener", sig); removeNotificationListeners.add(removeNotificationListener); } catch(Exception e) { log.debug(iface+"No removeNotificationListener(ObjectName, RMINotificationListener)"); } } marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap); // Place our ObjectName hash into the Registry so invokers can resolve it Registry.bind(new Integer(serviceName.hashCode()), serviceName); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
protected void stopService() throws Exception { // Remove the method hashses if( exportedInterfaces != null ) { for(int n = 0; n < exportedInterfaces.length; n ++) MarshalledInvocation.removeHashes(exportedInterfaces[n]); } marshalledInvocationMapping = null; remoteListeners.clear(); Registry.unbind(new Integer(serviceName.hashCode())); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public Object invoke(Invocation invocation) throws Exception { try { // Make sure we have the correct classloader before unmarshalling ClassLoader oldCL = SecurityActions.getContextClassLoader(); ClassLoader newCL = null; // Get the MBean this operation applies to ObjectName objectName = (ObjectName) invocation.getValue("JMX_OBJECT_NAME"); if (objectName != null) { newCL = server.getClassLoaderFor(objectName); } if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(newCL); //JBAS-6449: Cache the incoming security context to be retained on exit SecurityContext previousSecurityContext = SecurityActions.getSecurityContext(); try { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the MBeanServer method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Principal principal = invocation.getPrincipal(); Object credential = invocation.getCredential(); Object value = null; SecurityContext sc = SecurityActions.createSecurityContext(SecurityConstants.DEFAULT_APPLICATION_POLICY); SecurityActions.setSecurityContext(sc); // Associate the method SecurityActions.pushSubjectContext(principal, credential, null); try { if( addNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; NotificationFilter filter = (NotificationFilter) args[2]; Object handback = args[3]; addNotificationListener(name, listener, filter, handback); } else if( removeNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; removeNotificationListener(name, listener); } else { String name = method.getName(); Class[] paramTypes = method.getParameterTypes(); Method mbeanServerMethod = MBeanServer.class.getMethod(name, paramTypes); value = mbeanServerMethod.invoke(server, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; } finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); } } catch (Throwable t) { throw new InvokerAdaptorException(t); } }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
public void setPolicyClass(String policyClass) throws Exception { try { // try to load the policy Class Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
public void setAuthorizingClass(Class clazz) throws Exception { authenticator = clazz.newInstance(); log.debug("Loaded authenticator: "+authenticator); Class[] sig = {Principal.class, Subject.class, String.class, String.class}; authorize = clazz.getMethod("authorize", sig); log.debug("Found authorize(Principal, Subject, String, String)"); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
private void checkAuthorization(Principal caller, String objname, String opname) throws Exception { // Get the active Subject Subject subject = SecurityActions.getActiveSubject(); if( subject == null ) throw new SecurityException("No active Subject found, add th AuthenticationInterceptor"); //We will try to use the authorizing class try { Object[] args = {caller, subject, objname, opname}; authorize.invoke(authenticator, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthenticationInterceptor.java
public void setSecurityDomain(String securityDomain) throws Exception { this.securityDomain = securityDomain; }
// in src/main/java/org/jboss/jmx/connector/invoker/MBeanProxyRemote.java
protected void startService() throws Exception { if (MBeanProxyExt.remote != null) throw new IllegalStateException("Remote MBeanServerConnection is already set " + MBeanProxyExt.remote); Object o = server.getAttribute(mbeanServerConnection, "Proxy"); if (o instanceof MBeanServerConnection == false) throw new DeploymentException(mbeanServerConnection + " does not define an MBeanServerConnection"); MBeanProxyExt.remote = (MBeanServerConnection) o; }
// in src/main/java/org/jboss/jmx/connector/invoker/MBeanProxyRemote.java
protected void stopService() throws Exception { MBeanProxyExt.remote = null; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public ApplicationMetaData load(URL alternativeDD) throws Exception { URL ejbjarUrl = null; if (alternativeDD != null) { log.debug("Using alternativeDD: " + alternativeDD); ejbjarUrl = alternativeDD; } else { ejbjarUrl = getClassLoader().getResource("META-INF/ejb-jar.xml"); } if (ejbjarUrl == null) { throw new DeploymentException("no ejb-jar.xml found"); } // create the metadata JBossMetaData realMetaData = new JBossMetaData(); metaData = new ApplicationMetaData(realMetaData); Document ejbjarDocument = getDocumentFromURL(ejbjarUrl); // the url may be used to report errors metaData.setUrl(ejbjarUrl); metaData.importEjbJarXml(ejbjarDocument.getDocumentElement()); // Load jbossdefault.xml from the default classLoader // we always load defaults first // we use the context classloader, because this guy has to know where // this file is URL defaultJbossUrl = Thread.currentThread().getContextClassLoader().getResource("standardjboss.xml"); if (defaultJbossUrl == null) { throw new DeploymentException("no standardjboss.xml found"); } Document defaultJbossDocument = null; try { defaultJbossDocument = getDocumentFromURL(defaultJbossUrl); metaData.setUrl(defaultJbossUrl); metaData.importJbossXml(defaultJbossDocument.getDocumentElement()); } catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; } // Load jboss.xml // if this file is provided, then we override the defaults try { URL jbossUrl = getClassLoader().getResource("META-INF/jboss.xml"); if (jbossUrl != null) { Document jbossDocument = getDocumentFromURL(jbossUrl); metaData.setUrl(jbossUrl); metaData.importJbossXml(jbossDocument.getDocumentElement()); } } catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; } return metaData; }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
protected void startService() throws Exception { // validate the configuration if (queueFactoryRef == null) throw new DeploymentException("missing required attribute: QueueFactoryRef"); if (topicFactoryRef == null) throw new DeploymentException("missing required attribute: TopicFactoryRef"); Class cls = Thread.currentThread().getContextClassLoader().loadClass(providerAdapterClass); providerAdapter = (JMSProviderAdapter) cls.newInstance(); providerAdapter.setName(providerName); providerAdapter.setProperties(properties); providerAdapter.setFactoryRef(factoryRef); providerAdapter.setQueueFactoryRef(queueFactoryRef); providerAdapter.setTopicFactoryRef(topicFactoryRef); InitialContext context = new InitialContext(); try { // Bind in JNDI if (jndiName == null) { String name = providerAdapter.getName(); jndiName = "java:/" + name; } bind(context, jndiName, providerAdapter); log.debug("Bound adapter to " + jndiName); } finally { context.close(); } }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
protected void stopService() throws Exception { InitialContext context = new InitialContext(); try { // Unbind from JNDI String name = providerAdapter.getName(); String jndiname = "java:/" + name; context.unbind(jndiname); log.debug("unbound adapter " + name + " from " + jndiname); } finally { context.close(); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected XAResource connect() throws Exception { // Do we already have a valid delegate? synchronized (lock) { if (delegate != null) return delegate; } // Create the connection XAConnection xaConnection = getConnectionFactory().createXAConnection(); synchronized (lock) { connection = xaConnection; } // Retrieve the delegate XAResource try { XASession session = connection.createXASession(); XAResource result = session.getXAResource(); synchronized (lock) { delegate = result; } return delegate; } catch (Exception e) { close(); throw e; } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected XAConnectionFactory getConnectionFactory() throws Exception { // Get the JMS Provider Adapter if (providerName == null) throw new IllegalArgumentException("Null provider name"); String providerAdapterJNDI = providerName; if (providerAdapterJNDI.startsWith("java:") == false) providerAdapterJNDI = "java:" + providerAdapterJNDI; Context ctx = new InitialContext(); JMSProviderAdapter adapter = (JMSProviderAdapter) Util.lookup(providerAdapterJNDI, JMSProviderAdapter.class); // Determine the XAConnectionFactory name String connectionFactoryRef = adapter.getFactoryRef(); if (connectionFactoryRef == null) throw new IllegalStateException("Provider '" + providerName + "' has no FactoryRef"); // Lookup the connection factory ctx = adapter.getInitialContext(); try { return (XAConnectionFactory) Util.lookup(ctx, connectionFactoryRef, XAConnectionFactory.class); } finally { ctx.close(); } }
// in src/main/java/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception { AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>(); // don't do webMetaData anymore (rev 96033) String mainClassName = getMainClassName(unit); if (mainClassName != null && mainClassName.length() > 0) processJBossClientMetaData(unit, finder, mainClassName); else processJBossMetaData(unit, finder); }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
protected void init(VFSDeploymentUnit unit, WebFragmentMetaData metaData, VirtualFile file) throws Exception { unit.addAttachment(WebFragmentMetaData.class.getName() + ":" + file.getPathNameRelativeTo(unit.getRoot()), metaData, getOutput()); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolve(ContainerDependencyMetaData cdmd, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, Environment env, DeploymentEndpointResolver resolver, List<String> unresolvedRefs) throws Exception { if(env == null) return; AnnotatedEJBReferencesMetaData annotatedRefs = env.getAnnotatedEjbReferences(); resolveEjbAnnotatedRefs(cdmd, unit, endpointMap, annotatedRefs, resolver, unresolvedRefs); EJBLocalReferencesMetaData localRefs = env.getEjbLocalReferences(); resolveEjbLocalRefs(cdmd, unit, endpointMap, localRefs, resolver, unresolvedRefs); EJBReferencesMetaData ejbRefs = env.getEjbReferences(); resolveEjbRefs(cdmd, unit, endpointMap, ejbRefs, resolver, unresolvedRefs); MessageDestinationReferencesMetaData msgRefs = env.getMessageDestinationReferences(); resolveMsgRefs(cdmd, unit, endpointMap, msgRefs, resolver, unresolvedRefs); // TODO, other references }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolve(DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, JBossEnterpriseBeansMetaData beans, DeploymentEndpointResolver resolver, List<String> unresolvedPaths) throws Exception { if(beans == null || beans.size() == 0) return; String vfsPath = unit.getRelativePath(); for(JBossEnterpriseBeanMetaData bean : beans) { // Find the container dependency metadata String ejbCompID = "ejb/" + vfsPath + "#" + bean.getEjbName(); ContainerDependencyMetaData cdmd = endpointMap.get(ejbCompID); if(cdmd == null) throw new IllegalStateException("Failed to find ContainerDependencyMetaData for: "+ejbCompID); Environment env = bean.getJndiEnvironmentRefsGroup(); resolve(cdmd, unit, endpointMap, env, resolver, unresolvedPaths); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolveEjbLocalRefs(ContainerDependencyMetaData cdmd, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, EJBLocalReferencesMetaData localRefs, DeploymentEndpointResolver resolver, List<String> unresolvedRefs) throws Exception { if(localRefs == null) return; String vfsContext = unit.getRelativePath(); ClassLoader loader = unit.getClassLoader(); for(EJBLocalReferenceMetaData ref : localRefs) { if (ref.getIgnoreDependency() != null) { log.debug("IGNORING <ejb-ref> DEPENDENCY: " + ref); return; } String link = ref.getLink(); String mappedName = ref.getMappedName(); // Use mapped name first if(mappedName == null || mappedName.length() == 0) { ContainerDependencyMetaData target = null; if(link != null) { EndpointInfo info = resolver.getEndpointInfo(link, EndpointType.EJB, vfsContext); if(info != null) { target = endpointMap.get(info.getComponentKey()); } else { /* A non-local link without a # jar target. This is allowed for java ee clients so we have to search all ejb deployments. First get the vfspaths of the ejb deploymens. */ List<String> ejbPaths = getEjbDeploymentPaths(unit); for(String path : ejbPaths) { EndpointInfo altInfo = resolver.getEndpointInfo(link, EndpointType.EJB, path); if(altInfo != null) target = endpointMap.get(altInfo.getComponentKey()); if(target != null) break; } } } if(target == null && ref.getLocal() != null) { // Try the local interface type target = resolveEjbInterface(ref.getLocal(), unit, endpointMap, resolver); } if(target == null) unresolvedRefs.add(cdmd.getComponentID()+":"+ref); else { // Need to look at the local jndi name String localInterface = ref.getLocal(); JBossEnterpriseBeanMetaData md = target.getBeanMetaData(); /* * If for a Session bean we've got a reference to an EJB2.x * Local Component interface, stop processing because these * are not bound in JNDI (only accessible via LocalHome.create() */ // Session EJB? boolean useDefaultProxy = false; if(md.isSession()) { // Cast JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData)md; // Get the name of the Component Local Interface String ejb2xLocalInterface = smd.getLocal(); // If the ejb-ref is to a EJB2.x Local Component Interface if(localInterface.equals(ejb2xLocalInterface)) { // Use the default proxy useDefaultProxy = true; } } // Get ejb-jar Metadata JBossMetaData ejbJarMd = md.getEnterpriseBeansMetaData().getEjbJarMetaData(); // Resolve a local JNDI Name based on Spec type String localJndiName = null; if (ejbJarMd.isEJB3x()) { if (md.isSession() || md.isService()) { SessionBeanJNDINameResolver sessionBeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver((JBossSessionBeanMetaData) md, this.defaultJNDIBindingPolicy); if (useDefaultProxy) { localJndiName = sessionBeanJNDINameResolver .resolveLocalBusinessDefaultJNDIName((JBossSessionBeanMetaData) md); } else { localJndiName = sessionBeanJNDINameResolver.resolveJNDIName((JBossSessionBeanMetaData) md, localInterface); } } else if (md.isEntity()) { EntityBeanJNDINameResolver entityBeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver((JBossEntityBeanMetaData) md, this.defaultJNDIBindingPolicy); localJndiName = entityBeanJNDINameResolver.resolveJNDIName((JBossEntityBeanMetaData) md, localInterface); } } else { localJndiName = md.determineLocalJndiName(); } // If we've got a resolved JNDI Name if (localJndiName != null) { // Set it and forget it! // http://en.wikipedia.org/wiki/Ron_Popeil ref.setResolvedJndiName(localJndiName); } // Add the dependency cdmd.addDependency(target); } } else { // Create a JNDI dependency ref.setResolvedJndiName(mappedName); JndiDependencyMetaData jdmd = new JndiDependencyMetaData(mappedName, loader); cdmd.addJndiDependency(jdmd); } } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolveEjbRefs(ContainerDependencyMetaData cdmd, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, EJBReferencesMetaData ejbRefs, DeploymentEndpointResolver resolver, List<String> unresolvedRefs) throws Exception { if(ejbRefs == null) return; String vfsContext = unit.getRelativePath(); ClassLoader loader = unit.getClassLoader(); for(EJBReferenceMetaData ref : ejbRefs) { if (ref.getIgnoreDependency() != null) { log.debug("IGNORING <ejb-ref> DEPENDENCY: " + ref); return; } String link = ref.getLink(); String mappedName = ref.getMappedName(); // Use mapped name first if(mappedName == null || mappedName.length() == 0) { ContainerDependencyMetaData target = null; if(link != null) { EndpointInfo info = resolver.getEndpointInfo(link, EndpointType.EJB, vfsContext); if(info != null) { target = endpointMap.get(info.getComponentKey()); } else { /* A non-local link without a # jar target. This is allowed for java ee clients so we have to search all ejb deployments. First get the vfspaths of the ejb deploymens. */ List<String> ejbPaths = getEjbDeploymentPaths(unit); for(String path : ejbPaths) { EndpointInfo altInfo = resolver.getEndpointInfo(link, EndpointType.EJB, path); if(altInfo != null) target = endpointMap.get(altInfo.getComponentKey()); if(target != null) break; } } if(target == null) { unresolvedRefs.add(cdmd.getComponentID()+":"+ref); continue; } } if(target == null && ref.getRemote() != null) { // Try the local interface type target = resolveEjbInterface(ref.getRemote(), unit, endpointMap, resolver); } if(target == null) unresolvedRefs.add(cdmd.getComponentID()+":"+ref); else { // Obtain remote interface name String remoteInterface = ref.getRemote(); // Get Metadata JBossEnterpriseBeanMetaData md = target.getBeanMetaData(); /* * If for a Session bean we've got a reference to an EJB2.x * Remote Component interface, stop processing because these * are not bound in JNDI (only accessible via Home.create() */ // Session EJB? boolean useDefaultProxy = false; if(md.isSession()) { // Cast JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData)md; // Get the name of the Component Remote Interface String ejb2xRemoteInterface = smd.getRemote(); // If the ejb-ref is to a EJB2.x Remote Component Interface if(remoteInterface.equals(ejb2xRemoteInterface)) { // Use the default proxy useDefaultProxy = true; } } // Get ejb-jar metadata JBossMetaData ejbMarMd = md.getEnterpriseBeansMetaData().getEjbJarMetaData(); // Resolve a JNDI name String remoteJNDIName = null; if (ejbMarMd.isEJB3x()) { if (md.isSession() || md.isService()) { SessionBeanJNDINameResolver sessionBeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver((JBossSessionBeanMetaData) md, this.defaultJNDIBindingPolicy); if (useDefaultProxy) { remoteJNDIName = sessionBeanJNDINameResolver.resolveRemoteBusinessDefaultJNDIName((JBossSessionBeanMetaData) md); } else { remoteJNDIName = sessionBeanJNDINameResolver.resolveJNDIName((JBossSessionBeanMetaData) md, remoteInterface); } } else if (md.isEntity()) { EntityBeanJNDINameResolver entityBeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver((JBossEntityBeanMetaData) md, this.defaultJNDIBindingPolicy); remoteJNDIName = entityBeanJNDINameResolver.resolveJNDIName((JBossEntityBeanMetaData) md, remoteInterface); } } else { remoteJNDIName = md.determineJndiName(); } // If we've got a resolved name if(remoteJNDIName != null) { // Set it ref.setResolvedJndiName(remoteJNDIName); } // Add the dependency cdmd.addDependency(target); } } else { // Create a JNDI dependency ref.setResolvedJndiName(mappedName); JndiDependencyMetaData jdmd = new JndiDependencyMetaData(mappedName, loader); cdmd.addJndiDependency(jdmd); } } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected ContainerDependencyMetaData resolveEjbInterface(String iface, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, DeploymentEndpointResolver resolver) throws Exception { ClassLoader loader = unit.getClassLoader(); Class<?> ifaceClass = loader.loadClass(iface); String vfsContext = unit.getRelativePath(); EndpointInfo info = resolver.getEndpointInfo(ifaceClass, EndpointType.EJB, vfsContext); if(info == null) throw new IllegalStateException("Failed to find ContainerDependencyMetaData for interface: "+ iface); ContainerDependencyMetaData cdmd = endpointMap.get(info.getComponentKey()); return cdmd; }
// in src/main/java/org/jboss/deployment/AppParsingDeployer.java
protected EarMetaData parse(VFSDeploymentUnit unit, VirtualFile file, EarMetaData root) throws Exception { EarMetaData ear = super.parse(unit,file, root); List<DeploymentUnit> children = unit.getChildren(); ModulesMetaData modules = ear.getModules(); if(children != null && modules != null) { for(DeploymentUnit child : children) { String moduleName = child.getSimpleName(); ModuleMetaData module = modules.get(moduleName); if(module != null && module.getAlternativeDD() != null) { VirtualFile altDDFile = unit.getRoot().getChild(module.getAlternativeDD()); if(altDDFile == null) throw new IllegalStateException("Failed to locate alternative DD '" + module.getAlternativeDD() + "' in " + unit.getRoot().getPathName()); String attachmentName; if(module.getType() == ModuleMetaData.ModuleType.Ejb) attachmentName = EjbJarMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Web) attachmentName = WebMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Client) attachmentName = ApplicationClientMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Connector) attachmentName = "org.jboss.resource.metadata.ConnectorMetaData"; else throw new IllegalStateException("Expected module types in an EAR are ejb, web, java and connector but got " + module.getType() + " for " + child.getName() + " in " + unit.getName()); child.addAttachment(attachmentName + ".altDD", altDDFile); if(log.isTraceEnabled()) log.trace("attached alt-dd " + altDDFile + " for module " + child.getSimpleName()); } } } return ear; }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception { String mainClassName = getMainClassName(unit); Collection<Class<?>> classes = new HashSet<Class<?>>(); Map<VirtualFile, Collection<Class<?>>> classesPerJar = new HashMap<VirtualFile, Collection<Class<?>>>(); for (VirtualFile path : classpath) { Collection<Class<?>> currentClasses = getClasses(unit, mainClassName, path); classesPerJar.put(path, currentClasses); classes.addAll(currentClasses); } if (classes.size() > 0) { AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>(); if (webMetaData != null) processJBossWebMetaData(unit, finder, classesPerJar); else if (clientMetaData != null || mainClassName != null) processJBossClientMetaData(unit, finder, classes); else processJBossMetaData(unit, finder, classes); } }
// in src/main/java/org/jboss/deployment/TldParsingDeployer.java
protected void init(VFSDeploymentUnit unit, TldMetaData metaData, VirtualFile file) throws Exception { unit.addAttachment(TldMetaData.class.getName() + ":" + file.getPathNameRelativeTo(unit.getRoot()), metaData, getOutput()); }
// in src/main/java/org/jboss/deployment/TldParsingDeployer.java
protected TldMetaData parse(VirtualFile file) throws Exception { if (file == null) throw new IllegalArgumentException("Null file"); // Implicit TLDs are reserved as the "implicit.tld" name if (file.getName().equals("implicit.tld")) { return new TldMetaData(); } else { return super.parse(file); } }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception { // Get the j2ee.clientName value String clientName = (String) env.get(J2EE_CLIENT_NAME_PROP); if (clientName == null) { // Look for the name as a system property clientName = (String) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { try { return System.getProperty(J2EE_CLIENT_NAME_PROP); } catch (SecurityException e) { return null; } } } ); if (clientName == null) throw new NamingException("Failed to find j2ee.clientName in jndi env"); }
// in src/main/java/org/jboss/naming/NamingAlias.java
protected void startService() throws Exception { if( fromName == null ) throw new IllegalStateException("fromName is null"); if( toName == null ) throw new IllegalStateException("toName is null"); createLinkRef(); }
// in src/main/java/org/jboss/naming/NamingAlias.java
protected void stopService() throws Exception { removeLinkRef(fromName); }
// in src/main/java/org/jboss/naming/ExternalContext.java
protected void startService() throws Exception { rebind(); }
// in src/main/java/org/jboss/naming/ExternalContext.java
protected void stopService() throws Exception { if( contextInfo.getCacheContext() ) unbind(contextInfo.getJndiName()); }
// in src/main/java/org/jboss/naming/ExternalContext.java
private void rebind() throws Exception { Context ctx = contextInfo.newContext(); Context rootCtx = (Context) new InitialContext(); log.debug("ctx="+ctx+", env="+ctx.getEnvironment()); // Get the parent context into which we are to bind String jndiName = contextInfo.getJndiName(); Name fullName = rootCtx.getNameParser("").parse(jndiName); log.debug("fullName="+fullName); Name parentName = fullName; if( fullName.size() > 1 ) parentName = fullName.getPrefix(fullName.size()-1); else parentName = new CompositeName(); log.debug("parentName="+parentName); Context parentCtx = createContext(rootCtx, parentName); log.debug("parentCtx="+parentCtx); Name atomName = fullName.getSuffix(fullName.size()-1); String atom = atomName.get(0); boolean cacheContext = contextInfo.getCacheContext(); if( remoteAccess == true ) { // Bind contextInfo as a Referenceable parentCtx.rebind(atom, contextInfo); // Cache the context using NonSerializableFactory to avoid creating // more than one context for in VM lookups if( cacheContext == true ) { // If cacheContext is true we need to wrap the Context in a // proxy that allows the user to issue close on the lookup // Context without closing the inmemory Context. ctx = CachedContext.createProxyContext(ctx); NonSerializableFactory.rebind(jndiName, ctx); } } else if( cacheContext == true ) { // Bind a reference to the extern context using // NonSerializableFactory as the ObjectFactory. The Context must // be wrapped in a proxy that allows the user to issue close on the // lookup Context without closing the inmemory Context. Context proxyCtx = CachedContext.createProxyContext(ctx); NonSerializableFactory.rebind(rootCtx, jndiName, proxyCtx); } else { // Bind the contextInfo so that each lookup results in the creation // of a new Context object. The returned Context must be closed // by the user to prevent resource leaks. parentCtx.rebind(atom, contextInfo); } }
// in src/main/java/org/jboss/naming/ExternalContext.java
Context newContext() throws Exception { // First check the NonSerializableFactory cache initialContext = (Context) NonSerializableFactory.lookup(jndiName); // Create the context from the contextClass and contextProps if( initialContext == null ) initialContext = newContext(contextClass, contextProps); return initialContext; }
// in src/main/java/org/jboss/naming/ExternalContext.java
static Context newContext(Class contextClass, Properties contextProps) throws Exception { Context ctx = null; try { ctx = newDefaultContext(contextClass, contextProps); } catch(NoSuchMethodException e) { ctx = newLdapContext(contextClass, contextProps); } return ctx; }
// in src/main/java/org/jboss/naming/ExternalContext.java
private static Context newDefaultContext(Class contextClass, Properties contextProps) throws Exception { Context ctx = null; Class[] types = {Hashtable.class}; Constructor ctor = contextClass.getConstructor(types); Object[] args = {contextProps}; ctx = (Context) ctor.newInstance(args); return ctx; }
// in src/main/java/org/jboss/naming/ExternalContext.java
private static Context newLdapContext(Class contextClass, Properties contextProps) throws Exception { Context ctx = null; Class[] types = {Hashtable.class, Control[].class}; Constructor ctor = contextClass.getConstructor(types); Object[] args = {contextProps, null}; ctx = (Context) ctor.newInstance(args); return ctx; }
// in src/main/java/org/jboss/naming/ExternalContext.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { Reference ref = (Reference) obj; SerializableInitialContext sic = (SerializableInitialContext) ref.get(0); return sic.newContext(); }
// in src/main/java/org/jboss/naming/LinkRefPairService.java
protected void startService() throws Exception { if (jndiName == null) throw new DeploymentException("The jndiName is null for LinkRefPair " + getServiceName()); if (remoteJndiName == null) throw new DeploymentException("The remoteJndiName is null for LinkRefPair " + getServiceName()); if (localJndiName == null) throw new DeploymentException("The localJndiName is null for LinkRefPair " + getServiceName()); LinkRefPair pair = new LinkRefPair(remoteJndiName, localJndiName); InitialContext ctx = new InitialContext(); try { Util.bind(ctx, jndiName, pair); } finally { ctx.close(); } }
// in src/main/java/org/jboss/naming/LinkRefPairService.java
protected void stopService() throws Exception { LinkRefPair pair = new LinkRefPair(remoteJndiName, localJndiName); InitialContext ctx = new InitialContext(); try { Util.unbind(ctx, jndiName); } finally { ctx.close(); } }
// in src/main/java/org/jboss/naming/java/javaURLContextFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { return new NamingContext(environment, name, root); }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
public void start() throws Exception { establishBootStrapURL(); if (bootstrapUrl != null) { File base = null; if (outputDir == null) { if (server != null) { base = new File(server.getConfiguration().getServerDataLocation().toURI()); outputDir = base.toURI(); } } else { base = new File(outputDir); } if (base != null) { base.mkdirs(); File file = new File(base, getOutputFileName()); if (file.exists()) { file.delete(); } PrintWriter writer = null; try { if (log.isTraceEnabled()) { log.trace("Creating file " + file); } file.createNewFile(); file.deleteOnExit(); writer = new PrintWriter(file); writer.println(bootstrapUrl); writer.flush(); } catch (Exception e) { handleOutputFileCreationException(file.toURI(), e); } finally { if (writer != null) { writer.close(); } } } else { log.warn("No directory specified for " + getOutputFileName() + " cannot write the naming service url. Please configure either " + "the 'server' property or the 'outputDir' property."); } } else { log.debug("No URLs to write"); } }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
public void stop() throws Exception { if (outputDir != null) { String outputFile = ""; try { File f = new File(new File(outputDir), getOutputFileName()); outputFile = f.getAbsolutePath(); f.delete(); } catch (Exception e) { log.warn("Failed to delete JNP URL file " + outputFile + " due to " + e); } } }
// in src/main/java/org/jboss/naming/LinkRefPairObjectFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { LinkRefPair pair = (LinkRefPair) obj; String jndiName; // Local or remote? boolean local = false; if (guid.equals(pair.getGUID())) { jndiName = pair.getLocalLinkName(); local = true; } else jndiName = pair.getRemoteLinkName(); InitialContext ctx; if (local || environment == null) ctx = new InitialContext(); else ctx = new InitialContext(environment); return ctx.lookup(jndiName); }
// in src/main/java/org/jboss/naming/JNDIBinding.java
public Object getValue() throws Exception { if( value == null && text != null ) { // If there is a property editor set, transform text to value if( editor != null ) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class editorClass = loader.loadClass(editor); PropertyEditor pe = (PropertyEditor) editorClass.newInstance(); pe.setAsText(text); value = pe.getValue(); } else if( type != null ) { PropertyEditor pe = PropertyEditors.getEditor(type); pe.setAsText(text); value = pe.getValue(); } else { value = text; } } return value; }
// in src/main/java/org/jboss/naming/JNDIBindingServiceMgr.java
protected void startService() throws Exception { service.addBindings(); }
// in src/main/java/org/jboss/naming/JNDIBindingServiceMgr.java
protected void stopService() throws Exception { service.removeBindings(); }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception { Context ctx = getInitialContext(env); Reference ref = (Reference) obj; RefAddr addr = ref.get("URL"); String path = (String) addr.getContent(); return ctx.lookup(path); }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
public void start() throws Exception { addBindings(); }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
public void stop() throws Exception { removeBindings(); }
// in src/main/java/org/jboss/naming/NamingService.java
public Object getNamingProxy() throws Exception { Object proxy = null; if(proxyFactory != null) proxy = proxyFactory.getProxy(); else proxy = namingMain.getNamingProxy(); return proxy; }
// in src/main/java/org/jboss/naming/NamingService.java
protected void startService() throws Exception { boolean debug = log.isDebugEnabled(); // Read jndi.properties into system properties ClassLoader loader = Thread.currentThread().getContextClassLoader(); InputStream is = loader.getResourceAsStream("jndi.properties"); if (is == null) throw new RuntimeException("Cannot find jndi.properties, it should be at conf/jndi.properties by default."); Properties props = new Properties(); try { props.load(is); } finally { is.close(); } for (Enumeration keys = props.propertyNames(); keys.hasMoreElements(); ) { String key = (String) keys.nextElement(); String value = props.getProperty(key); if (debug) { log.debug("System.setProperty, key="+key+", value="+value); } System.setProperty(key, value); } if( proxyFactory != null ) namingMain.setNamingProxy(proxyFactory.getProxy()); if( startNamingBean ) namingMain.start(); // Build the Naming interface method map HashMap tmpMap = new HashMap(13); Method[] methods = Naming.class.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap); }
// in src/main/java/org/jboss/naming/NamingService.java
protected void stopService() throws Exception { if(startNamingBean) { namingMain.stop(); log.debug("JNP server stopped"); } }
// in src/main/java/org/jboss/naming/NamingService.java
public void createAlias(String fromName, String toName) throws Exception { Util.createLinkRef(fromName, toName); log.info("Created alias " + fromName + "->" + toName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void removeAlias(String name) throws Exception { log.info("Removing alias " + name); Util.removeLinkRef(name); }
// in src/main/java/org/jboss/naming/NamingService.java
public Object invoke(Invocation invocation) throws Exception { Naming theServer = namingMain.getNamingInstance(); // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the Naming method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Object value = null; try { value = method.invoke(theServer, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; }
// in src/main/java/org/jboss/naming/interceptors/ProxyFactoryInterceptor.java
private void initNamingProxy() throws Exception { if( proxy != null ) return; ObjectName proxyFactory = new ObjectName(proxyName); MBeanServer server = MBeanServerLocator.locateJBoss(); proxy = (Naming) server.getAttribute(proxyFactory, "Proxy"); }
// in src/main/java/org/jboss/naming/JndiBinder.java
public void start() throws Exception { InitialContext ctx1 = null; if (properties != null) { ctx1 = new InitialContext(properties); } else ctx1 = new InitialContext(); InitialContext ctx = ctx1; try { if (serializable) { Util.rebind(ctx, bindTo, target); } else { NonSerializableFactory.rebind(ctx, bindTo, target); } } catch (NamingException e) { NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo); namingException.setRootCause(e); throw namingException; } }
// in src/main/java/org/jboss/naming/JndiBinder.java
public void stop() throws Exception { InitialContext ctx1 = null; if (properties != null) { ctx1 = new InitialContext(properties); } else ctx1 = new InitialContext(); InitialContext ctx = ctx1; if (serializable) { Util.unbind(ctx, bindTo); } else { NonSerializableFactory.unbind(bindTo); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransactionObjectFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { Reference ref = (Reference)obj; if (!ref.getClassName().equals(ClientUserTransaction.class.getName())) return null; return getUserTransaction(); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
public Object invoke(Invocation invocation) throws Exception { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Object value = null; try { if( UserTransactionSessionFactory.class.isAssignableFrom(method.getDeclaringClass()) ) { // Just return the UserTransactionSession proxy as its stateless value = txProxy; } else if( method.getName().equals("begin") ) { // Begin a new transaction Integer timeout = (Integer) args[0]; UserTransactionSession session = UserTransactionSessionImpl.getInstance(); value = session.begin(timeout.intValue()); } else if( method.getName().equals("destroy")) { /* We do nothing as the tx will timeout and the tx map is shared across all sessions as we have no association with the txs a given client has started. */ } else { UserTransactionSession session = UserTransactionSessionImpl.getInstance(); value = method.invoke(session, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
protected void startService() throws Exception { Context ctx = new InitialContext(); // Bind the in VM UserTransaction interface ctx.bind(JNDI_NAME, ClientUserTransaction.getSingleton()); // Get the UserTransactionSession proxy txProxy = getServer().getAttribute(txProxyName, "Proxy"); // Build the UserTransactionSession interface method map HashMap tmpMap = new HashMap(13); Method[] methods = UserTransactionSession.class.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } // Add the UserTransactionSessionFactory interface method map methods = UserTransactionSessionFactory.class.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap); // Place our ObjectName hash into the Registry so invokers can resolve it. // We need this for the HA Proxy case where the only the target service // is added to the registry, which is how it should be. // In the non HA Proxy case, JRMPProxyFactory acts both as a proxy factory // and proxy which is conceptually wrong, hence this is an extra step in // that case. Registry.bind(new Integer(serviceName.hashCode()), serviceName); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
static SecurityContext createSecurityContext(final String securityDomain) throws PrivilegedActionException { return (SecurityContext)AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(securityDomain); SecurityContextAssociation.setSecurityContext(sc); return sc; } }); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(securityDomain); SecurityContextAssociation.setSecurityContext(sc); return sc; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
public void startService() throws Exception { // Get the persistence plugin if (dbpPluginClassName != null) { Class dbpPolicyClass = Thread.currentThread().getContextClassLoader().loadClass(dbpPluginClassName); dbpPlugin = (DatabasePersistencePlugin)dbpPolicyClass.newInstance(); } else { dbpPlugin = new GeneralPurposeDatabasePersistencePlugin(); } // init the plugin if (dbpPlugin instanceof DatabasePersistencePluginExt) { // if using the extended plugin interface, initialize the timers table name ((DatabasePersistencePluginExt)dbpPlugin).init(server, dataSource, timersTable); } else { dbpPlugin.init(server, dataSource); } // warn if timers table cannot be set if (dbpPlugin.getTableName().equals(timersTable) == false) { log.warn("Database persistence plugin '" + dbpPluginClassName + "' uses hardcoded timers table name: '" + dbpPlugin.getTableName()); } // create the table if needed dbpPlugin.createTableIfNotExists(); }
// in src/main/java/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java
public void callTimeout(Timer timer) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(container.getClassLoader()); container.pushENC(); try { Invocation inv = new Invocation(timedObjectId.getInstancePk(), method, new Object[]{timer}, null, null, null); inv.setValue(InvocationKey.INVOKER_PROXY_BINDING, null, PayloadKey.AS_IS); inv.setType(InvocationType.LOCAL); BeanMetaData bmd = container.getBeanMetaData(); SecurityIdentityMetaData ejbTimeoutIdentity = bmd.isEntity() ? null : bmd.getEjbTimeoutIdentity(); if( ejbTimeoutIdentity != null && ejbTimeoutIdentity.getUseCallerIdentity() == false ) { ApplicationMetaData applicationMetaData = bmd.getApplicationMetaData(); AssemblyDescriptorMetaData assemblyDescriptor = applicationMetaData.getAssemblyDescriptor(); String roleName = ejbTimeoutIdentity.getRunAsRoleName(); String principalName = ejbTimeoutIdentity.getRunAsPrincipalName(); // the run-as principal might have extra roles mapped in the assembly-descriptor Set extraRoleNames = assemblyDescriptor.getSecurityRoleNamesByPrincipal(principalName); RunAs runAsIdentity = new RunAsIdentity(roleName, principalName, extraRoleNames); SecurityActions.pushRunAsIdentity(runAsIdentity); pushedRunAs = true; } container.invoke(inv); } finally { container.popENC(); if(pushedRunAs) SecurityActions.popRunAsIdentity(); SecurityActions.setContextClassLoader(callerClassLoader); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
protected void startService() throws Exception { // Setup plugins, fall back to safe defaults // Get the TransactionManager from the factory, fall-back to the locator if (transactionManagerFactory != null) transactionManager = transactionManagerFactory.getTransactionManager(); else transactionManager = TransactionManagerLocator.getInstance().locate(); // Get a proxy to the retry policy try { retryPolicy = (RetryPolicy)MBeanProxyExt.create(RetryPolicy.class, getRetryPolicy(), server); } catch (Exception e) { log.error("Cannot obtain the implementation of a RetryPolicy", e); } // Get a proxy to the persistence policy try { persistencePolicy = (PersistencePolicy)MBeanProxyExt.create(PersistencePolicy.class, persistencePolicyName, server); } catch (Exception e) { log.warn("Cannot obtain the implementation of a PersistencePolicy, using NoopPersistencePolicy: " + e.toString()); persistencePolicy = new NoopPersistencePolicy(); } // Get the timerId generator try { Class<?> timerIdGeneratorClass = getClass().getClassLoader().loadClass(timerIdGeneratorClassName); timerIdGenerator = (TimerIdGenerator)timerIdGeneratorClass.newInstance(); } catch (Exception e) { log.warn("Cannot obtain the implementation of a TimerIdGenerator, using BigIntegerTimerIdGenerator: " + e.toString()); timerIdGenerator = new BigIntegerTimerIdGenerator(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Acquire classes from CL if (metaData.getHome() != null) homeInterface = classLoader.loadClass(metaData.getHome()); if (metaData.getRemote() != null) remoteInterface = classLoader.loadClass(metaData.getRemote()); if (((SessionMetaData) metaData).getServiceEndpoint() != null) { serviceEndpoint = classLoader.loadClass(((SessionMetaData) metaData).getServiceEndpoint()); } // Call default init super.createService(); // Make some additional validity checks with regards to the container configuration checkCoherency(); // Map the bean methods setupBeanMapping(); // Map the home methods setupHomeMapping(); // Map the interfaces to Long setupMarshalledInvocationMapping(); createInvokers(); createInstanceCache(); createInstancePool(); createPersistenceManager(); createInterceptors(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void setupMarshalledInvocationMapping() throws Exception { // Create method mappings for container invoker if (homeInterface != null) { Method[] m = homeInterface.getMethods(); for (int i = 0; i < m.length; i++) { marshalledInvocationMapping.put(new Long(MarshalledInvocation.calculateHash(m[i])), m[i]); } } if (remoteInterface != null) { Method[] m = remoteInterface.getMethods(); for (int j = 0; j < m.length; j++) { marshalledInvocationMapping.put(new Long(MarshalledInvocation.calculateHash(m[j])), m[j]); } } // Get the getEJBObjectMethod Method getEJBObjectMethod = Class.forName("javax.ejb.Handle").getMethod("getEJBObject", new Class[0]); // Hash it marshalledInvocationMapping.put(new Long(MarshalledInvocation.calculateHash(getEJBObjectMethod)), getEJBObjectMethod); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void checkCoherency() throws Exception { // Check clustering cohrency wrt metadata // if (metaData.isClustered()) { boolean clusteredProxyFactoryFound = false; Iterator it = proxyFactories.keySet().iterator(); while (it.hasNext()) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); if (ci instanceof org.jboss.proxy.ejb.ClusterProxyFactory) clusteredProxyFactoryFound = true; } if (!clusteredProxyFactoryFound) { log.warn("*** EJB '" + this.metaData.getEjbName() + "' deployed as CLUSTERED but not a single clustered-invoker is bound to container ***"); } } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createInstancePool() throws Exception { // Try to register the instance pool as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instancePool, poolName); } catch (Throwable t) { log.debug("Failed to register pool as mbean", t); } // Initialize pool instancePool.setContainer(this); instancePool.create(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createInstanceCache() throws Exception { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createInvokers() throws Exception { // Init container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.create(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createInterceptors() throws Exception { Interceptor in = interceptor; while (in != null) { in.setContainer(this); in.create(); in = in.getNext(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createPersistenceManager() throws Exception { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default start super.startService(); startInvokers(); startInstanceCache(); startInstancePool(); startPersistenceManager(); startInterceptors(); // Restore persisted ejb timers restoreTimers(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startPersistenceManager() throws Exception { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startInstanceCache() throws Exception { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startInvokers() throws Exception { for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.start(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startInstancePool() throws Exception { instancePool.start(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startInterceptors() throws Exception { Interceptor in = interceptor; while (in != null) { in.start(); in = in.getNext(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void stopService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default stop super.stopService(); stopInvokers(); stopInstanceCache(); stopInstancePool(); stopPersistenceManager(); stopInterceptors(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void destroyService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { destroyInvokers(); destroyInstanceCache(); destroyInstancePool(); destroyPersistenceManager(); destroyInterceptors(); destroyMarshalledInvocationMapping(); homeInterface = null; remoteInterface = null; serviceEndpoint = null; beanMapping.clear(); // Call default destroy super.destroyService(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); ejbObject.remove(); return null; } else throw new RemoveException("EJBHome.remove(Object) not allowed for session beans"); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object internalInvoke(Invocation mi) throws Exception { // Invoke through interceptors return getInterceptor().invoke(mi); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } try { return mi.performCall(StatelessSessionContainer.this, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // wire the transaction on the context, this is how the instance remember the tx EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); // Get method and instance to invoke upon Method miMethod = mi.getMethod(); Map map = getBeanMapping(); Method m = (Method) map.get(miMethod); // The Invocation might contain the actual bean method // e.g. For an invocation based on a JSR-181 @WebMethod annotation if (m == null && map.values().contains(miMethod)) { m = miMethod; } if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } //If we have a method that needs to be done by the container (EJBObject methods) if (m.getDeclaringClass().equals(StatelessSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { try { return mi.performCall(StatelessSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else // we have a method that needs to be done by a bean instance { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Object run() throws Exception { Object proxy = MBeanProxy.get(iface, name, server); Class[] ifaces = {iface}; InvocationHandler secureHandler = new InvocationHandlerAction(proxy); Object secureProxy = Proxy.newProxyInstance(iface.getClassLoader(), ifaces, secureHandler); return secureProxy; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Object run() throws Exception { Object value = method.invoke(mbean, args); return value; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
static Object getMBeanProxy(Class iface, ObjectName name, MBeanServer server) throws Exception { Object proxy; if( System.getSecurityManager() == null ) { proxy = MBeanProxy.get(iface, name, server); } else { MBeanProxyAction action = new MBeanProxyAction(iface, name, server); proxy = AccessController.doPrivileged(action); } return proxy; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Object run() throws Exception { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
static boolean isCallerInRole(final SecurityContext sc, final String roleName, final String ejbName, final Principal principal, final Subject contextSubject, final String jaccContextID, final Set<SecurityRoleRef> securityRoleRefs) throws PrivilegedActionException { return AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() { public Boolean run() throws Exception { AbstractEJBAuthorizationHelper helper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); return helper.isCallerInRole(roleName, ejbName, principal, contextSubject, jaccContextID, securityRoleRefs); } }); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Boolean run() throws Exception { AbstractEJBAuthorizationHelper helper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); return helper.isCallerInRole(roleName, ejbName, principal, contextSubject, jaccContextID, securityRoleRefs); }
// in src/main/java/org/jboss/ejb/EjbModule.java
Override protected void createService() throws Exception { serviceController = (ServiceControllerMBean) MBeanProxyExt.create(ServiceControllerMBean.class, ServiceControllerMBean.OBJECT_NAME, server); log.debug("createService, begin"); // Set up the beans in this module. try { Iterator beans = appMetaData.getEnterpriseBeans(); String contextID = appMetaData.getJaccContextID(); if (contextID == null) contextID = deploymentUnit.getSimpleName(); // appMetaData.gsetJaccContextID(contextID); /* PolicyConfiguration pc = null; */ while (beans.hasNext()) { BeanMetaData bean = (BeanMetaData) beans.next(); log.info("Deploying " + bean.getEjbName()); Container con = createContainer(bean, deploymentUnit); addContainer(con); // @todo support overriding the context id via metadata is needed con.setJaccContextID(contextID); } // only one iteration should be necessary, but we won't sweat it. // 2 iterations are needed by cmp...jdbc/bridge/JDBCCMRFieldBridge which // assumes persistence managers are all set up for every // bean in the relationship! ListIterator iter = containerOrdering.listIterator(); while (iter.hasNext()) { Container con = (Container) iter.next(); ObjectName jmxName = con.getJmxName(); /* * Add the container mbean to the deployment mbeans so the state of the deployment can be tracked. */ server.registerMBean(con, jmxName); // deploymentUnit.mbeans.add(jmxName); BeanMetaData metaData = con.getBeanMetaData(); Collection<ObjectName> depends = new ArrayList<ObjectName>(); for (String dependsName : metaData.getDepends()) { depends.add(ObjectName.getInstance(dependsName)); } Iterator<String> invokerBindings = metaData.getInvokerBindings(); while (invokerBindings != null && invokerBindings.hasNext()) { String invokerBindingName = invokerBindings.next(); InvokerProxyBindingMetaData ipbmd = appMetaData.getInvokerProxyBindingMetaDataByName(invokerBindingName); if (ipbmd != null) { String invokerName = ipbmd.getInvokerMBean(); if (invokerName != null) { try { ObjectName invokerMBean = ObjectName.getInstance(invokerName); if (depends.contains(invokerMBean) == false) depends.add(invokerMBean); } catch (MalformedObjectNameException e) { log.trace("Ignored malformed invoker mbean '" + invokerName + "' " + e.toString()); } } } } serviceController.create(jmxName, depends); // We keep the hashCode around for fast creation of proxies int jmxHash = jmxName.hashCode(); Registry.bind(new Integer(jmxHash), jmxName); log.debug("Bound jmxName=" + jmxName + ", hash=" + jmxHash + "into Registry"); } } catch (Exception e) { destroyService(); throw e; } // end of try-catch }
// in src/main/java/org/jboss/ejb/EjbModule.java
Override protected void startService() throws Exception { // before EntityContainer returns from the startService, its PM should be usable ListIterator iter = containerOrdering.listIterator(); while (iter.hasNext()) { Container con = (Container) iter.next(); if (con.getBeanMetaData().isEntity()) { ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(con.getClassLoader()); con.pushENC(); try { ((EntityContainer) con).getPersistenceManager().start(); } finally { con.popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } } } iter = containerOrdering.listIterator(); while (iter.hasNext()) { Container con = (Container) iter.next(); log.debug("startService, starting container: " + con.getBeanMetaData().getEjbName()); serviceController.start(con.getJmxName()); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
Override protected void stopService() throws Exception { ListIterator iter = containerOrdering.listIterator(containerOrdering.size()); while (iter.hasPrevious()) { Container con = (Container) iter.previous(); try { ObjectName jmxName = con.getJmxName(); // The container may already be destroyed so validate metaData BeanMetaData metaData = con.getBeanMetaData(); String ejbName = metaData != null ? metaData.getEjbName() : "Unknown"; log.debug("stopService, stopping container: " + ejbName); serviceController.stop(jmxName); } catch (Exception e) { log.error("unexpected exception stopping Container: " + con.getJmxName(), e); } // end of try-catch } }
// in src/main/java/org/jboss/ejb/EjbModule.java
Override protected void destroyService() throws Exception { WebServiceMBean webServer = null; if (webServiceName != null) { webServer = (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName); } ListIterator iter = containerOrdering.listIterator(containerOrdering.size()); while (iter.hasPrevious()) { Container con = (Container) iter.previous(); ObjectName jmxName = con.getJmxName(); int conState = con.getState(); boolean destroyContainer = true; log.debug("Looking to destroy container: " + jmxName + ", state: " + con.getStateString() + ", destroy: " + destroyContainer); // always unregister from Registry int jmxHash = jmxName.hashCode(); Registry.unbind(new Integer(jmxHash)); // Unregister the web classloader // Removing the wcl should probably be done in stop of the container, // but I don't want to look for errors today. if (webServer != null) { ClassLoader wcl = con.getWebClassLoader(); if (wcl != null) { try { webServer.removeClassLoader(wcl); } catch (Throwable e) { log.warn("Failed to unregister webClassLoader", e); } } } // Only destroy containers that have been created or started if (destroyContainer) { try { serviceController.destroy(jmxName); serviceController.remove(jmxName); log.info("Undeployed " + con.getBeanMetaData().getEjbName()); if (server.isRegistered(jmxName)) server.unregisterMBean(jmxName); } catch (Throwable e) { log.error("unexpected exception destroying Container: " + jmxName, e); } // end of try-catch } // Destroy proxy factories if (destroyContainer) { if (con.getBeanMetaData() != null && con.getBeanMetaData().getInvokerBindings() != null) { Iterator<String> invokerBindings = con.getBeanMetaData().getInvokerBindings(); while (invokerBindings.hasNext()) { String invoker = invokerBindings.next(); EJBProxyFactory ci = con.lookupProxyFactory(invoker); if (ci != null) { ci.setContainer(null); ci.setInvokerBinding(null); ci.setInvokerMetaData(null); } } } } // cleanup container con.setBeanMetaData(null); con.setWebClassLoader(null); con.setClassLoader(null); con.setEjbModule(null); con.setTransactionManager(null); con.setSecurityManager(null); con.setRealmMapping(null); con.setSecurityProxy(null); con.setSecurityManagement(null); con.setPolicyRegistration(null); con.proxyFactories.clear(); } this.containers.clear(); this.localHomes.clear(); this.containerOrdering.clear(); this.moduleData.clear(); this.serviceController = null; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private Container createContainer(BeanMetaData bean, VFSDeploymentUnit unit) throws Exception { Container container = null; // Added message driven deployment if (bean.isMessageDriven()) { container = createMessageDrivenContainer(bean, unit); } else if (bean.isSession()) // Is session? { if (((SessionMetaData) bean).isStateless()) // Is stateless? { container = createStatelessSessionContainer((SessionMetaData) bean, unit); } else // Stateful { container = createStatefulSessionContainer((SessionMetaData) bean, unit); } } else // Entity { container = createEntityContainer(bean, unit); } container.setDeploymentUnit(unit); return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private MessageDrivenContainer createMessageDrivenContainer(BeanMetaData bean, DeploymentUnit unit) throws Exception { // get the container configuration for this bean // a default configuration is now always provided ConfigurationMetaData conf = bean.getContainerConfiguration(); // Stolen from Stateless deploy // Create container MessageDrivenContainer container = new MessageDrivenContainer(); int transType = bean.isContainerManagedTx() ? CMT : BMT; initializeContainer(container, conf, bean, transType, unit); createProxyFactories(bean, container); container.setInstancePool(createInstancePool(conf, unit.getClassLoader())); return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private StatelessSessionContainer createStatelessSessionContainer(SessionMetaData bean, DeploymentUnit unit) throws Exception { // get the container configuration for this bean // a default configuration is now always provided ConfigurationMetaData conf = bean.getContainerConfiguration(); // Create container StatelessSessionContainer container = new StatelessSessionContainer(); int transType = bean.isContainerManagedTx() ? CMT : BMT; initializeContainer(container, conf, bean, transType, unit); if (bean.getHome() != null || bean.getServiceEndpoint() != null) { createProxyFactories(bean, container); } container.setInstancePool(createInstancePool(conf, unit.getClassLoader())); return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private StatefulSessionContainer createStatefulSessionContainer(SessionMetaData bean, DeploymentUnit unit) throws Exception { // get the container configuration for this bean // a default configuration is now always provided ConfigurationMetaData conf = bean.getContainerConfiguration(); // Create container StatefulSessionContainer container = new StatefulSessionContainer(); int transType = bean.isContainerManagedTx() ? CMT : BMT; initializeContainer(container, conf, bean, transType, unit); if (bean.getHome() != null || bean.getServiceEndpoint() != null) { createProxyFactories(bean, container); } ClassLoader cl = unit.getClassLoader(); container.setInstanceCache(createInstanceCache(conf, cl)); // No real instance pool, use the shadow class StatefulSessionInstancePool ip = new StatefulSessionInstancePool(); ip.importXml(conf.getContainerPoolConf()); container.setInstancePool(ip); // Set persistence manager container.setPersistenceManager((StatefulSessionPersistenceManager) cl.loadClass(conf.getPersistenceManager()) .newInstance()); // Set the bean Lock Manager container.setLockManager(createBeanLockManager(container, false, conf.getLockClass(), cl)); return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private EntityContainer createEntityContainer(BeanMetaData bean, DeploymentUnit unit) throws Exception { // get the container configuration for this bean // a default configuration is now always provided ConfigurationMetaData conf = bean.getContainerConfiguration(); // Create container EntityContainer container = new EntityContainer(); int transType = CMT; initializeContainer(container, conf, bean, transType, unit); if (bean.getHome() != null) { createProxyFactories(bean, container); } ClassLoader cl = unit.getClassLoader(); container.setInstanceCache(createInstanceCache(conf, cl)); container.setInstancePool(createInstancePool(conf, cl)); // Set the bean Lock Manager boolean reentrant = ((EntityMetaData) bean).isReentrant(); BeanLockManager lockMgr = createBeanLockManager(container, reentrant, conf.getLockClass(), cl); container.setLockManager(lockMgr); // Set persistence manager if (((EntityMetaData) bean).isBMP()) { Class pmClass = cl.loadClass(conf.getPersistenceManager()); EntityPersistenceManager pm = (EntityPersistenceManager) pmClass.newInstance(); container.setPersistenceManager(pm); } else { // CMP takes a manager and a store org.jboss.ejb.plugins.CMPPersistenceManager persistenceManager = new org.jboss.ejb.plugins.CMPPersistenceManager(); // Load the store from configuration Class pmClass = cl.loadClass(conf.getPersistenceManager()); EntityPersistenceStore pm = (EntityPersistenceStore) pmClass.newInstance(); persistenceManager.setPersistenceStore(pm); // Set the manager on the container container.setPersistenceManager(persistenceManager); } return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static void createProxyFactories(BeanMetaData conf, Container container) throws Exception { ClassLoader cl = container.getClassLoader(); Iterator it = conf.getInvokerBindings(); boolean foundOne = false; while (it.hasNext()) { String invoker = (String) it.next(); String jndiBinding = conf.getInvokerBinding(invoker); log.debug("creating binding for " + jndiBinding + ":" + invoker); InvokerProxyBindingMetaData imd = conf.getApplicationMetaData().getInvokerProxyBindingMetaDataByName(invoker); EJBProxyFactory ci = null; // create a ProxyFactory instance try { ci = (EJBProxyFactory) cl.loadClass(imd.getProxyFactory()).newInstance(); ci.setContainer(container); ci.setInvokerMetaData(imd); ci.setInvokerBinding(jndiBinding); if (ci instanceof XmlLoadable) { // the container invoker can load its configuration from the jboss.xml element ((XmlLoadable) ci).importXml(imd.getProxyFactoryConfig()); } container.addProxyFactory(invoker, ci); foundOne = true; } catch (Exception e) { log.warn("The Container Invoker " + invoker + " (in jboss.xml or standardjboss.xml) could not be created because of " + e + " We will ignore this error, but you may miss a transport for this bean."); } } if (!foundOne) { throw new DeploymentException("Missing or invalid Container Invokers (in jboss.xml or standardjboss.xml)."); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static BeanLockManager createBeanLockManager(Container container, boolean reentrant, String beanLock, ClassLoader cl) throws Exception { // The bean lock manager BeanLockManager lockManager = new BeanLockManager(container); Class lockClass = null; try { if (beanLock == null) beanLock = "org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock"; lockClass = cl.loadClass(beanLock); } catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); } lockManager.setLockCLass(lockClass); lockManager.setReentrant(reentrant); return lockManager; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static InstancePool createInstancePool(ConfigurationMetaData conf, ClassLoader cl) throws Exception { // Set instance pool InstancePool ip = null; try { ip = (InstancePool) cl.loadClass(conf.getInstancePool()).newInstance(); } catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); } if (ip instanceof XmlLoadable) ((XmlLoadable) ip).importXml(conf.getContainerPoolConf()); return ip; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static InstanceCache createInstanceCache(ConfigurationMetaData conf, ClassLoader cl) throws Exception { // Set instance cache InstanceCache ic = null; try { ic = (InstanceCache) cl.loadClass(conf.getInstanceCache()).newInstance(); } catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); } if (ic instanceof XmlLoadable) ((XmlLoadable) ic).importXml(conf.getContainerCacheConf()); return ic; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void createService() throws Exception { super.createService(); // Get the Handle.getEJBObject method for permission checks try { getEJBObject = Handle.class.getMethod("getEJBObject", new Class[0]); } catch (Exception e) { log.warn("Failed to grant access to the Handle.getEJBObject method"); } ejbObjectRemove = EJBObject.class.getMethod("remove", null); ejbLocalObjectRemove = EJBLocalObject.class.getMethod("remove", null); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void createInstanceCache() throws Exception { // Try to register the instance cache as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "cache"); ObjectName cacheName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instanceCache, cacheName); } catch (Throwable t) { log.debug("Failed to register cache as mbean", t); } // Init instance cache instanceCache.setContainer(this); instanceCache.create(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void createPersistenceManager() throws Exception { persistenceManager.setContainer(this); persistenceManager.create(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void startPersistenceManager() throws Exception { persistenceManager.start(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void startInstanceCache() throws Exception { instanceCache.start(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
private void createSession(final Method m, final Object[] args, final StatefulSessionEnterpriseContext ctx) throws Exception { // Create a new ID and set it Object id = getPersistenceManager().createId(ctx); log.debug("Created new session ID: " + id); ctx.setId(id); // Invoke ejbCreate<METHOD>() try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); // Build the ejbCreate<METHOD> from the home create<METHOD> sig String createName = m.getName(); Object instance = ctx.getInstance(); String ejbCreateName = "ejbC" + createName.substring(1); Method createMethod = instance.getClass().getMethod(ejbCreateName, m.getParameterTypes()); log.debug("Using create method for session: " + createMethod); createMethod.invoke(instance, args); createCount++; } catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); } catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // call back to the PM to let it know that ejbCreate has been called with success getPersistenceManager().createdSession(ctx); // Insert in cache getInstanceCache().insert(ctx); // Create EJBObject if (getProxyFactory() != null) ctx.setEJBObject((EJBObject) getProxyFactory().getStatefulSessionEJBObject(id)); // Create EJBLocalObject if (getLocalHomeClass() != null) ctx.setEJBLocalObject(getLocalProxyFactory().getStatefulSessionEJBLocalObject(id)); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBObject createHome(Invocation mi) throws Exception { StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); createSession(mi.getMethod(), mi.getArguments(), ctx); return ctx.getEJBObject(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBLocalObject createLocalHome(Invocation mi) throws Exception { StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); createSession(mi.getMethod(), mi.getArguments(), ctx); return ctx.getEJBLocalObject(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void setupHomeMapping() throws Exception { // Adrian Brock: This should go away when we don't support EJB1x boolean isEJB1x = metaData.getApplicationMetaData().isEJB1x(); Map map = new HashMap(); if (homeInterface != null) { Method[] m = homeInterface.getMethods(); for (int i = 0; i < m.length; i++) { try { // Implemented by container if (isEJB1x == false && m[i].getName().startsWith("create")) { map.put(m[i], getClass().getMethod("createHome", new Class[]{Invocation.class})); } else { map.put(m[i], getClass().getMethod(m[i].getName() + "Home", new Class[]{Invocation.class})); } } catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); } } } if (localHomeInterface != null) { Method[] m = localHomeInterface.getMethods(); for (int i = 0; i < m.length; i++) { try { // Implemented by container if (isEJB1x == false && m[i].getName().startsWith("create")) { map.put(m[i], getClass().getMethod("createLocalHome", new Class[]{Invocation.class})); } else { map.put(m[i], getClass().getMethod(m[i].getName() + "LocalHome", new Class[]{Invocation.class})); } } catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); } } } try { // Get getEJBObject from on Handle, first get the class Class handleClass = Class.forName("javax.ejb.Handle"); //Get only the one called handle.getEJBObject Method getEJBObjectMethod = handleClass.getMethod("getEJBObject", new Class[0]); //Map it in the home stuff map.put(getEJBObjectMethod, getClass().getMethod("getEJBObject", new Class[]{Invocation.class})); } catch (NoSuchMethodException e) { log.debug("Couldn't find getEJBObject method on container"); } homeMapping = map; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("HOMEMETHOD coming in "); log.trace("" + mi.getMethod()); log.trace("HOMEMETHOD coming in hashcode" + mi.getMethod().hashCode()); log.trace("HOMEMETHOD coming in classloader" + mi.getMethod().getDeclaringClass().getClassLoader().hashCode()); log.trace("CONTAINS " + getHomeMapping().containsKey(mi.getMethod())); } Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // Invoke and handle exceptions if (trace) { log.trace("HOMEMETHOD m " + m); java.util.Iterator iterator = getHomeMapping().keySet().iterator(); while (iterator.hasNext()) { Method me = (Method) iterator.next(); if (me.getName().endsWith("create")) { log.trace(me.toString()); log.trace("" + me.hashCode()); log.trace("" + me.getDeclaringClass().getClassLoader().hashCode()); log.trace("equals " + me.equals(mi.getMethod()) + " " + mi.getMethod().equals(me)); } } } try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) getBeanMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // wire the transaction on the context, this is how the instance remember the tx // Unlike Entity beans we can't do that in the previous interceptors (ordering) EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); else if(ejbObjectRemove.equals(miMethod) || ejbLocalObjectRemove.equals(miMethod)) { throw new RemoveException("An attempt to remove a session " + "object while the object is in a transaction " + "(EJB2.1, 7.6.4 Restrictions for Transactions): ejb-name=" + metaData.getEjbName() + ", method=" + mi.getMethod() + ", tx=" + ctx.getTransaction()); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(StatefulSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { // Invoke and handle exceptions try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/Container.java
public Object createBeanClassInstance() throws Exception { return getBeanClass().newInstance(); }
// in src/main/java/org/jboss/ejb/Container.java
protected void createService() throws Exception { // Acquire classes from CL beanClass = classLoader.loadClass(metaData.getEjbClass()); if (metaData.getLocalHome() != null) localHomeInterface = classLoader.loadClass(metaData.getLocalHome()); if (metaData.getLocal() != null) localInterface = classLoader.loadClass(metaData.getLocal()); localProxyFactory.setContainer(this); localProxyFactory.create(); if (localHomeInterface != null) ejbModule.addLocalHome(this, localProxyFactory.getEJBLocalHome()); ejbModule.createMissingPermissions(this, metaData); // Allow the policy to incorporate the policy configs Policy.getPolicy().refresh(); }
// in src/main/java/org/jboss/ejb/Container.java
protected void startService() throws Exception { // Setup "java:comp/env" namespace setupEnvironment(); localProxyFactory.start(); }
// in src/main/java/org/jboss/ejb/Container.java
protected void stopService() throws Exception { localProxyFactory.stop(); removeTimerService(null); teardownEnvironment(); }
// in src/main/java/org/jboss/ejb/Container.java
protected void destroyService() throws Exception { cleanENC(); localProxyFactory.destroy(); ejbModule.removeLocalHome(this); beanClass = null; homeInterface = null; remoteInterface = null; localHomeInterface = null; localInterface = null; methodPermissionsCache.clear(); // InvocationStatistics holds refs to Methods from // application classes, so to avoid a classloader // leak, lets not just resetStats() but also replace // the object invokeStats.resetStats(); // in case someone else has a ref invokeStats = new InvocationStatistics(); marshalledInvocationMapping.clear(); }
// in src/main/java/org/jboss/ejb/Container.java
public Object invoke(Invocation mi) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); long start = System.currentTimeMillis(); Method m = null; Object type = null; String contextID = getJaccContextID(); try { pushENC(); // JBAS-3732 - Remove classloader.equals optimization SecurityActions.setContextClassLoader(this.classLoader); // Set the JACC context id mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID); contextID = SecurityActions.setContextID(contextID); // Set the standard JACC policy context handler data is not a SEI msg if (mi.getType() != InvocationType.SERVICE_ENDPOINT) { EJBArgsPolicyContextHandler.setArgs(mi.getArguments()); } else { SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE); SOAPMsgPolicyContextHandler.setMessage(msg); } // Set custom JACC policy handlers BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData()); // Check against home, remote, localHome, local, getHome, // getRemote, getLocalHome, getLocal type = mi.getType(); // stat gathering: concurrent calls this.invokeStats.callIn(); if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || // web service calls come in as "ordinary" application invocations type == InvocationType.SERVICE_ENDPOINT) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD REMOTE INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||"); } } m = mi.getMethod(); Object obj = internalInvoke(mi); return obj; } else if (type == InvocationType.HOME || type == InvocationType.LOCALHOME) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD HOME INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||" + mi.getArguments().toString()); } } m = mi.getMethod(); Object obj = internalInvokeHome(mi); return obj; } else { throw new MBeanException(new IllegalArgumentException("Unknown invocation type: " + type)); } } /** * Having to catch this exception here in case can not * unmarshall arguments, values, etc. Then, convert to * UnmarshalException as defined by spec (JBAS-2999) */ catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } } finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); } }
// in src/main/java/org/jboss/ejb/Container.java
private void setupEnvironment() throws Exception { BeanMetaData beanMetaData = getBeanMetaData(); // debug log.debug("Begin java:comp/env for EJB: " + beanMetaData.getEjbName()); ClassLoader tcl = SecurityActions.getContextClassLoader(); log.debug("TCL: " + tcl); ORB orb = null; HandleDelegate hd = null; try { orb = (ORB)server.getAttribute(ORB_NAME, "ORB"); hd = (HandleDelegate)server.getAttribute(ORB_NAME, "HandleDelegate"); } catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); } // Since the BCL is already associated with this thread we can start // using the java: namespace directly Context ctx = (Context)new InitialContext().lookup("java:comp"); Object id = ENCFactory.getCurrentId(); log.debug("Using java:comp using id=" + id); // Bind the orb if (orb != null) { NonSerializableFactory.rebind(ctx, "ORB", orb); log.debug("Bound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName()); NonSerializableFactory.rebind(ctx, "HandleDelegate", hd); log.debug("Bound java:comp/HandleDelegate for EJB: " + getBeanMetaData().getEjbName()); } // JTA links ctx.bind("TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry")); log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry"); Context envCtx = ctx.createSubcontext("env"); // Bind environment properties { Iterator i = beanMetaData.getEnvironmentEntries(); while (i.hasNext()) { EnvEntryMetaData entry = (EnvEntryMetaData)i.next(); log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue()); EnvEntryBinder.bindEnvEntry(envCtx, entry); } } // Bind EJB references { Iterator i = beanMetaData.getEjbReferences(); while (i.hasNext()) { EjbRefMetaData ref = (EjbRefMetaData)i.next(); log.debug("Binding an EJBReference " + ref.getName()); if (ref.getLink() != null) { // Internal link String linkName = ref.getLink(); String jndiName = ref.getJndiName(); log.debug("Binding " + ref.getName() + " to ejb-link: " + linkName + " -> " + jndiName); if (jndiName == null) { String msg = "Failed to resolve ejb-link: " + linkName + " from ejb-ref: " + ref.getName() + " in ejb: " + beanMetaData.getEjbName(); throw new DeploymentException(msg); } Util.bind(envCtx, ref.getName(), new LinkRef(jndiName)); } else { // Get the invoker specific ejb-ref mappings Iterator it = beanMetaData.getInvokerBindings(); Reference reference = null; while (it.hasNext()) { String invokerBinding = (String)it.next(); // Check for an invoker level jndi-name String name = ref.getInvokerBinding(invokerBinding); // Check for an global jndi-name if (name == null) name = ref.getJndiName(); if (name == null) { throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml or " + "jndi-name in jboss.xml"); } StringRefAddr addr = new StringRefAddr(invokerBinding, name); log.debug("adding " + invokerBinding + ":" + name + " to Reference"); if (reference == null) { reference = new Reference("javax.naming.LinkRef", ENCThreadLocalKey.class.getName(), null); } reference.add(addr); } // If there were invoker bindings create bind the reference if (reference != null) { if (ref.getJndiName() != null) { // Add default for the bean level ejb-ref/jndi-name StringRefAddr addr = new StringRefAddr("default", ref.getJndiName()); reference.add(addr); } if (reference.size() == 1 && reference.get("default") == null) { /* There is only one invoker binding and its not default so create a default binding to allow the link to have a value when accessed without an invoker active. */ StringRefAddr addr = (StringRefAddr)reference.get(0); String target = (String)addr.getContent(); StringRefAddr addr1 = new StringRefAddr("default", target); reference.add(addr1); } Util.bind(envCtx, ref.getName(), reference); } else { // Bind the bean level ejb-ref/jndi-name if (ref.getJndiName() == null) { throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or jndi-name in jboss.xml"); } Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } } // Bind Local EJB references { Iterator i = beanMetaData.getEjbLocalReferences(); while (i.hasNext()) { EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next(); String refName = ref.getName(); log.debug("Binding an EJBLocalReference " + ref.getName()); if (ref.getLink() != null) { // Internal link log.debug("Binding " + refName + " to bean source: " + ref.getLink()); String jndiName = ref.getJndiName(); Util.bind(envCtx, ref.getName(), new LinkRef(jndiName)); } else { // Bind the bean level ejb-local-ref/local-jndi-name if (ref.getJndiName() == null) { throw new DeploymentException("ejb-local-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or local-jndi-name in jboss.xml"); } Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } // Bind service references { ClassLoader loader = unit.getClassLoader(); UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot()); Iterator<ServiceReferenceMetaData> serviceReferences = beanMetaData.getServiceReferences(); if (serviceReferences != null) { while (serviceReferences.hasNext()) { ServiceReferenceMetaData sref = serviceReferences.next(); String refName = sref.getServiceRefName(); new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref); } } } // Bind resource references { Iterator i = beanMetaData.getResourceReferences(); // let's play guess the cast game ;) New metadata should fix this. ApplicationMetaData application = beanMetaData.getApplicationMetaData(); while (i.hasNext()) { ResourceRefMetaData ref = (ResourceRefMetaData)i.next(); String resourceName = ref.getResourceName(); String finalName = application.getResourceByName(resourceName); String resType = ref.getType(); // If there was no resource-manager specified then an immeadiate // jndi-name or res-url name should have been given if (finalName == null) finalName = ref.getJndiName(); if (finalName == null && resType.equals("java.net.URL") == false) { // the application assembler did not provide a resource manager // if the type is javax.sql.Datasoure use the default one if (ref.getType().equals("javax.sql.DataSource")) { // Go through JNDI and look for DataSource - use the first one Context dsCtx = new InitialContext(); try { // Check if it is available in JNDI dsCtx.lookup("java:/DefaultDS"); finalName = "java:/DefaultDS"; } catch (Exception e) { log.debug("failed to lookup DefaultDS; ignoring", e); } finally { dsCtx.close(); } } // Default failed? Warn user and move on // POTENTIALLY DANGEROUS: should this be a critical error? if (finalName == null) { log.warn("No resource manager found for " + ref.getResourceName()); continue; } } if (resType.equals("java.net.URL")) { // URL bindings if (ref.getResURL() != null) { // The URL string was given by the res-url log.debug("Binding URL: " + ref.getRefName() + " to JDNI ENC as: " + ref.getResURL()); URL resURL = new URL(ref.getResURL()); Util.bind(envCtx, ref.getRefName(), resURL); } else { log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName); Object bind = null; if (ref.getJndiName() != null) { // Was the url given as a jndi-name reference to link to it bind = new LinkRef(finalName); } else { // The url string was given via a resource-name mapping bind = new URL(finalName); } Util.bind(envCtx, ref.getRefName(), bind); } } else { // Resource Manager bindings, should validate the type... log.debug("Binding resource manager: " + ref.getRefName() + " to JDNI ENC as: " + finalName); Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName)); } } } // Bind resource env references { Iterator i = beanMetaData.getResourceEnvReferences(); while (i.hasNext()) { ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData)i.next(); String encName = resRef.getRefName(); String jndiName = resRef.getJndiName(); // Should validate the type... log.debug("Binding env resource: " + encName + " to JDNI ENC as: " + jndiName); Util.bind(envCtx, encName, new LinkRef(jndiName)); } } // Bind message destination references { Iterator i = beanMetaData.getMessageDestinationReferences(); while (i.hasNext()) { MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next(); String refName = ref.getRefName(); String jndiName = ref.getJNDIName(); String link = ref.getLink(); if (link != null) { if (jndiName == null) { MessageDestinationMetaData messageDestination = getMessageDestination(link); if (messageDestination == null) throw new DeploymentException("message-destination-ref '" + refName + "' message-destination-link '" + link + "' not found and no jndi-name in jboss.xml"); else { String linkJNDIName = messageDestination.getJndiName(); if (linkJNDIName == null) log.warn("message-destination '" + link + "' has no jndi-name in jboss.xml"); else jndiName = linkJNDIName; } } else log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss.xml"); } else if (jndiName == null) throw new DeploymentException("message-destination-ref '" + refName + "' has no message-destination-link in ejb-jar.xml and no jndi-name in jboss.xml"); Util.bind(envCtx, refName, new LinkRef(jndiName)); } } // Create a java:comp/env/security/security-domain link to the container // or application security-domain if one exists so that access to the // security manager can be made without knowing the global jndi name. String securityDomain = metaData.getContainerConfiguration().getSecurityDomain(); if (securityDomain == null) securityDomain = metaData.getApplicationMetaData().getSecurityDomain(); if (securityDomain != null) { //JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix if(securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false) securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain; log.debug("Binding securityDomain: " + securityDomain + " to JDNI ENC as: security/security-domain"); Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain)); Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject")); Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain + "/realmMapping")); Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain + "/authorizationMgr")); } log.debug("End java:comp/env for EJB: " + beanMetaData.getEjbName()); }
// in src/main/java/org/jboss/ejb/Container.java
private void teardownEnvironment() throws Exception { Context ctx = (Context)new InitialContext().lookup("java:comp"); ctx.unbind("env"); log.debug("Removed bindings from java:comp/env for EJB: " + getBeanMetaData().getEjbName()); ctx.unbind("TransactionSynchronizationRegistry"); log.debug("Unbound java:comp/TransactionSynchronizationRegistry for EJB: " + getBeanMetaData().getEjbName()); try { NonSerializableFactory.unbind("ORB"); log.debug("Unbound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName()); NonSerializableFactory.unbind("HandleDelegate"); log.debug("Unbound java:comp/HandleDelegate for EJB: " + getBeanMetaData().getEjbName()); } catch (NamingException ignored) { } }
// in src/main/java/org/jboss/ejb/Container.java
protected void rethrow(Exception e) throws Exception { if (e instanceof IllegalAccessException) { // Throw this as a bean exception...(?) throw new EJBException(e); } else if (e instanceof InvocationTargetException) { Throwable t = ((InvocationTargetException)e).getTargetException(); if (t instanceof EJBException) { throw (EJBException)t; } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new NestedError("Unexpected Throwable", t); } } throw e; }
// in src/main/java/org/jboss/ejb/Container.java
public Object run() throws Exception { Object rtnValue = server.invoke(target, method, args, sig); return rtnValue; }
// in src/main/java/org/jboss/ejb/Container.java
Object invoke(ObjectName target, String method, Object[] args, String[] sig) throws Exception { SecurityManager sm = System.getSecurityManager(); Object rtnValue = null; if (sm == null) { // Direct invocation on MBeanServer rtnValue = server.invoke(target, method, args, sig); } else { try { // Encapsulate the invocation in a PrivilegedExceptionAction MBeanServerAction action = new MBeanServerAction(target, method, args, sig); rtnValue = AccessController.doPrivileged(action); } catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; } } return rtnValue; }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
private BeanLock createLock(Object id) throws Exception { BeanLock lock = (BeanLock) lockClass.newInstance(); lock.setId(id); lock.setTimeout(txTimeout); lock.setContainer(container); return lock; }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
protected void createService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default init super.createService(); // Map the bean methods Map map = new HashMap(); MessageDrivenMetaData mdMetaData = (MessageDrivenMetaData)metaData; String type = mdMetaData.getMessagingType(); if(type == null || type.length() == 0) type = MessageDrivenMetaData.DEFAULT_MESSAGING_TYPE; Class clazz = getClassLoader().loadClass(type); Method[] methods = clazz.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { Method m = methods[i]; map.put(m, beanClass.getMethod(m.getName(), m.getParameterTypes())); log.debug("Mapped " + m.getName() + " " + m.hashCode() + " to " + map.get(m)); } if( TimedObject.class.isAssignableFrom( beanClass ) ) { // Map ejbTimeout map.put( TimedObject.class.getMethod( "ejbTimeout", new Class[] { Timer.class } ), beanClass.getMethod( "ejbTimeout", new Class[] { Timer.class } ) ); } beanMapping = map; // Try to register the instance pool as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instancePool, poolName); } catch(Throwable t) { log.debug("Failed to register pool as mbean", t); } // Initialize pool instancePool.setContainer(this); instancePool.create(); for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); // Try to register the container invoker as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "invoker"); props.put("binding", invokerBinding); ObjectName invokerName = new ObjectName(containerName.getDomain(), props); server.registerMBean(ci, invokerName); } catch(Throwable t) { log.debug("Failed to register invoker binding as mbean", t); } ci.create(); } // Initialize the interceptor by calling the chain Interceptor in = interceptor; while (in != null) { in.setContainer(this); in.create(); in = in.getNext(); } } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
protected void startService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default start super.startService(); // Start the instance pool instancePool.start(); // Start all interceptors in the chain Interceptor in = interceptor; while (in != null) { in.start(); in = in.getNext(); } // Start container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.start(); } // Restore persisted ejb timers restoreTimers(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
protected void stopService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default stop super.stopService(); // Stop container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.stop(); } // Stop the instance pool instancePool.stop(); // Stop all interceptors in the chain Interceptor in = interceptor; while (in != null) { in.stop(); in = in.getNext(); } } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
protected void destroyService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Destroy container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.destroy(); try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "invoker"); props.put("binding", invokerBinding); ObjectName invokerName = new ObjectName(containerName.getDomain(), props); server.unregisterMBean(invokerName); } catch(Throwable ignore) { } } // Destroy the pool instancePool.destroy(); instancePool.setContainer(null); try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.unregisterMBean(poolName); } catch(Throwable ignore) { } // Destroy all the interceptors in the chain Interceptor in = interceptor; while (in != null) { in.destroy(); in.setContainer(null); in = in.getNext(); } // Call default destroy super.destroyService(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { throw new Error("invokeHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object internalInvoke(Invocation mi) throws Exception { SecurityContext cachedContext = null; try { cachedContext = SecurityActions.getSecurityContext(); //For message driven beans, there is no security context SecurityActions.setSecurityContext(null); // Invoke through interceptors return getInterceptor().invoke(mi); } finally { SecurityActions.setSecurityContext(cachedContext); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invokeHome(Invocation mi) throws Exception { throw new Error("invokeHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); // wire the transaction on the context, // this is how the instance remember the tx if (ctx.getTransaction() == null) { ctx.setTransaction(mi.getTransaction()); } // Get method and instance to invoke upon Method m = (Method) beanMapping.get(mi.getMethod()); if( m == null ) { // This is a configuration error that should have been caught earlier String msg = MessageDrivenContainer.this.getBeanMetaData().getEjbName() + " Invalid invocation, check your deployment packaging, interfaces, method=" + mi.getMethod(); throw new EJBException(msg); } // we have a method that needs to be done by a bean instance try { messageCount++; return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Get context EntityContainer container = (EntityContainer) getContainer(); EntityEnterpriseContext ctx = (EntityEnterpriseContext) container.getInstancePool().get(); ctx.setTxAssociation(GlobalTxEntityMap.NOT_READY); InstancePool pool = container.getInstancePool(); // Pass it to the method invocation mi.setEnterpriseContext(ctx); // Give it the transaction ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME); // Invoke through interceptors Object obj = null; Exception exception = null; try { obj = getNext().invokeHome(mi); // Is the context now with an identity? in which case we need to insert if (ctx.getId() != null) { BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey()); lock.sync(); // lock all access to BeanLock try { // Check there isn't a context already in the cache // e.g. commit-option B where the entity was // created then removed externally InstanceCache cache = container.getInstanceCache(); cache.remove(ctx.getCacheKey()); // marcf: possible race on creation and usage // insert instance in cache, cache.insert(ctx); } finally { lock.releaseSync(); container.getLockManager().removeLockRef(ctx.getCacheKey()); } // we are all done return obj; } } catch (Exception e) { exception = e; } finally { AllowedOperationsAssociation.popInMethodFlag(); } ctx.setTransaction(null); // EntityCreateInterceptor will access ctx if it is not null and call postCreate mi.setEnterpriseContext(null); // if we get to here with a null exception then our invocation is // just a home invocation. Return our instance to the instance pool if (exception == null) { container.getInstancePool().free(ctx); return obj; } if (exception instanceof RuntimeException) { // if we get to here with a RuntimeException, we have a system exception. // EJB 2.1 section 18.3.1 says we need to discard our instance. pool.discard(ctx); } else { // if we get to here with an Exception, we have an application exception. // EJB 2.1 section 18.3.1 says we can keep the instance. We need to return // our instance to the instance pool so we dont get a memory leak. pool.free(ctx); } throw exception; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected void createService() throws Exception { this.beans = new HashMap(1000); String ejbName = con.getBeanMetaData ().getEjbName (); idField = con.getBeanClass ().getField ("id"); log.debug("Using id field: " + idField); // Lookup the isModified method if it exists try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) { isModified = null; // Has to have "boolean" as return type! log.warn("Found isModified method, but return type is not boolean; ignoring"); } else { log.debug("Using isModified method: " + isModified); } } catch (NoSuchMethodException ignored) {} }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected void stopService() throws Exception { this.beans.clear(); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object createBeanClassInstance () throws Exception { return con.getBeanClass ().newInstance (); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object createEntity (Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get (ctx.getInstance ()); // Check exist if (this.beans.containsKey (id)) throw new javax.ejb.DuplicateKeyException ("Already exists: "+id); // Store to file storeEntity (id, ctx.getInstance ()); return id; } catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object postCreateEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { return null; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object findEntity (Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if (finderMethod.getName ().equals ("findByPrimaryKey")) { if (!this.beans.containsKey (args[0])) throw new javax.ejb.FinderException (args[0]+" does not exist"); return factory.getEntityEJBObject(args[0]); } return null; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Collection findEntities(final Method finderMethod, final Object[] args, final EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if (finderMethod.getName ().equals ("findAll")) { return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, this.beans.keySet()); } else { // we only support find all return Collections.EMPTY_LIST; } }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public boolean isStoreRequired (EntityEnterpriseContext ctx) throws Exception { if(isModified == null) { return true; } Boolean modified = (Boolean) isModified.invoke (ctx.getInstance (), new Object[0]); return modified.booleanValue (); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public boolean isModified(EntityEnterpriseContext ctx) throws Exception { return isStoreRequired(ctx); }
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke through interceptors return getNext().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
public Object invoke(Invocation mi) throws Exception { // The key. Object key = mi.getId(); // The lock. BeanLock lock ; boolean threadIsScheduled = false; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Begin invoke, key="+key); lock = container.getLockManager().getLock(key); try { lock.schedule(mi); try { return getNext().invoke(mi); } finally { // we are done with the method, decrease the count, if it reaches 0 it will wake up // the next thread lock.sync(); lock.endInvocation(mi); lock.releaseSync(); } } finally { // We are done with the lock in general container.getLockManager().removeLockRef(key); if( trace ) log.trace("End invoke, key="+key); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
public void start() throws Exception { super.start(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Apply any custom security checks if( securityProxy != null ) { EJBContext ctx = null; EnterpriseContext ectx = (EnterpriseContext)mi.getEnterpriseContext(); if( ectx != null ) ctx = ectx.getEJBContext(); Object[] args = mi.getArguments(); securityProxy.setEJBContext(ctx); try { securityProxy.invokeHome(mi.getMethod(), args); } catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; } } return getNext().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
public Object invoke(Invocation mi) throws Exception { // Apply any custom security checks if( securityProxy != null ) { EnterpriseContext ectx = (EnterpriseContext)mi.getEnterpriseContext(); Object bean = ectx.getInstance(); EJBContext ctx = ectx.getEJBContext(); Object[] args = mi.getArguments(); securityProxy.setEJBContext(ctx); try { securityProxy.invoke(mi.getMethod(), args, bean); } catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; } } return getNext().invoke(mi); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void startService() throws Exception { // Lets take a reference to our metadata metaData = (MessageDrivenMetaData) container.getBeanMetaData(); // Resolve the message listener resolveMessageListener(); // Resolve the resource adapter resolveResourceAdapter(); // Create the activation config createActivationSpec(); // Set up proxy parameters setupProxyParameters(); // Activate activate(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void stopService() throws Exception { // Deactivate deactivate(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void startDelivery() throws Exception { if (getState() != STARTED) throw new IllegalStateException("The MDB is not started"); if (deliveryActive.getAndSet(true)) return; activate(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void stopDelivery() throws Exception { stopDelivery(false); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void stopDelivery(boolean asynch) throws Exception { if (getState() != STARTED) throw new IllegalStateException("The MDB is not started"); if (deliveryActive.getAndSet(false) == false) return; if (asynch) { new Thread("StopDelivery: " + getServiceName()) { public void run() { deactivate(); } }.start(); } else { deactivate(); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstancePool.java
protected void createService() throws Exception { super.createService(); // for SLSB, we *do* pool this.reclaim = true; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { return new StatelessSessionEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactory.java
public KeyGenerator getKeyGenerator() throws Exception { return new UUIDKeyGenerator(); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public void setDataSource(ObjectName dataSource) throws Exception { if(getState() == STARTED && !dataSource.equals(this.dataSource)) { ds = lookupDataSource(dataSource); } this.dataSource = dataSource; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public void setTableName(String tableName) throws Exception { if(getState() == STARTED && !tableName.equals(this.tableName)) { initSequence(tableName, sequenceColumn, sequenceName, idColumnName); } this.tableName = tableName; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public KeyGenerator getKeyGenerator() throws Exception { return new HiLoKeyGenerator(ds, tableName, sequenceColumn, sequenceName, idColumnName, selectHiSql, blockSize, tm); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public void startService() throws Exception { Context ctx = new InitialContext(); // bind the factory Util.rebind(ctx, getFactoryName(), this); tm = (TransactionManager)ctx.lookup("java:/TransactionManager"); ds = lookupDataSource(dataSource); initSequence(tableName, sequenceColumn, sequenceName, idColumnName); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public void stopService() throws Exception { if(dropTable) { dropTableIfExists(tableName); } ds = null; tm = null; // unbind the factory Context ctx = new InitialContext(); Util.unbind(ctx, getFactoryName()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private DataSource lookupDataSource(ObjectName dataSource) throws Exception { try { String dsJndi = (String) server.getAttribute(dataSource, "BindName"); return (DataSource)new InitialContext().lookup(dsJndi); } catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invoke(mi); } finally { } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { Method getEJBObject = Handle.class.getMethod("getEJBObject", new Class[0]); //Invocation on the handle, we don't need a bean instance if (getEJBObject.equals(mi.getMethod())) return getNext().invokeHome(mi); EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invokeHome(mi); } finally { } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void create() throws Exception { ejbLoad = EntityBean.class.getMethod("ejbLoad", new Class[0]); ejbStore = EntityBean.class.getMethod("ejbStore", new Class[0]); ejbActivate = EntityBean.class.getMethod("ejbActivate", new Class[0]); ejbPassivate = EntityBean.class.getMethod("ejbPassivate", new Class[0]); ejbRemove = EntityBean.class.getMethod("ejbRemove", new Class[0]); // Create cache of create methods if (con.getHomeClass() != null) { Method[] methods = con.getHomeClass().getMethods(); createMethodCache( methods ); } if (con.getLocalHomeClass() != null) { Method[] methods = con.getLocalHomeClass().getMethods(); createMethodCache( methods ); } try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) isModified = null; // Has to have "boolean" as return type! } catch (NoSuchMethodException ignored) {} }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public Object createBeanClassInstance() throws Exception { return con.getBeanClass().newInstance(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void createEntity( Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { Object id = null; try { // Call ejbCreate<METHOD) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); Method createMethod = (Method)createMethods.get(m); id = createMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } // set the id ctx.setId(id); // Create a new CacheKey Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id ); // Give it to the context ctx.setCacheKey(cacheKey); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void postCreateEntity( Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_POST_CREATE); Method postCreateMethod = (Method)postCreateMethods.get(m); postCreateMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); // call the finder method Object objectId = callFinderMethod(finderMethod, args, ctx); final Object cacheKey = ((EntityCache)con.getInstanceCache()).createCacheKey( objectId ); return factory.getEntityEJBObject(cacheKey); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { // call the finder method Object result; try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); result = callFinderMethod(finderMethod, args, ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } if (result == null) { // for EJB 1.0 compliance // if the bean couldn't find any matching entities // it returns null, so we return an empty collection return new ArrayList(); } if (result instanceof java.util.Enumeration) { // to preserve 1.0 spec compatiblity ArrayList array = new ArrayList(); Enumeration e = (Enumeration) result; while (e.hasMoreElements() == true) { // Wrap a cache key around the given object id/primary key final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(e.nextElement()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o); } return array; } else if (result instanceof java.util.Collection) { ArrayList array = new ArrayList(((Collection) result).size()); Iterator i = ((Collection) result).iterator(); while (i.hasNext()) { // Wrap a cache key around the given object id/primary key final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(i.next()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o); } return array; } else { // so we received something that's not valid // throw an exception reporting it throw new EJBException("result of finder method is not a valid " + "return type: " + result.getClass()); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public boolean isStoreRequired(EntityEnterpriseContext ctx) throws Exception { if(isModified == null) { return true; } Boolean modified = (Boolean) isModified.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); return modified.booleanValue(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public boolean isModified(EntityEnterpriseContext ctx) throws Exception { return isStoreRequired(ctx); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
private Object callFinderMethod(Method finderMethod, Object[] args, EntityEnterpriseContext ctx) throws Exception { // get the finder method Method callMethod = (Method)finderMethods.get(finderMethod); if (callMethod == null) { throw new EJBException("couldn't find finder method in bean class. " + finderMethod.toString()); } // invoke the finder method Object result = null; try { result = callMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } return result; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
protected void createService() throws Exception { // Initialize the dataStore String ejbName = con.getBeanMetaData().getEjbName(); // Get the system data directory File dir = new File(ServerConfigLocator.locate().getServerTempLocation().toURI()); // Setup the reference to the session data store directory dir = new File(dir, storeDirName); // ejbName is not unique across all deployments, so use a unique token dir = new File(dir, ejbName + "-" + new UID().toString()); storeDir = dir; log.debug("Storing sessions for '" + ejbName + "' in: " + storeDir); // if the directory does not exist then try to create it if( !storeDir.exists() ) { if( MkdirsFileAction.mkdirs(storeDir) == false ) { throw new IOException("Failed to create directory: " + storeDir); } } // make sure we have a directory if( !storeDir.isDirectory() ) { throw new IOException("File exists where directory expected: " + storeDir); } // make sure we can read and write to it if( !storeDir.canWrite() || !storeDir.canRead() ) { throw new IOException("Directory must be readable and writable: " + storeDir); } // Purge state session state files, should be none, due to unique directory purgeAllSessionData(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
protected void destroyService() throws Exception { // Purge data and attempt to delete directory purgeAllSessionData(); // Nuke the directory too if purge is enabled if( purgeEnabled && !storeDir.delete() ) { log.warn("Failed to delete session state storage directory: " + storeDir); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public Object createId(StatefulSessionEnterpriseContext ctx) throws Exception { return new UID(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void createdSession(StatefulSessionEnterpriseContext ctx) throws Exception { // nothing }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public Object run() throws Exception { FileInputStream fis = new FileInputStream(file); return fis; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public Object run() throws Exception { FileOutputStream fis = new FileOutputStream(file); return fis; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public void create() throws Exception { super.create(); BeanMetaData bmd = getContainer().getBeanMetaData(); exceptionRollback = bmd.getExceptionRollback(); if (exceptionRollback == false) exceptionRollback = bmd.getApplicationMetaData().getExceptionRollback(); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public Object invokeHome(Invocation invocation) throws Exception { Transaction oldTransaction = invocation.getTransaction(); for (int i = 0; i < MAX_RETRIES; i++) { try { return runWithTransactions(invocation); } catch (Exception ex) { checkRetryable(i, ex, oldTransaction); } } throw new RuntimeException("Unreachable"); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public Object invoke(Invocation invocation) throws Exception { Transaction oldTransaction = invocation.getTransaction(); for (int i = 0; i < MAX_RETRIES; i++) { try { return runWithTransactions(invocation); } catch (Exception ex) { checkRetryable(i, ex, oldTransaction); } } throw new RuntimeException("Unreachable"); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private void checkRetryable(int i, Exception ex, Transaction oldTransaction) throws Exception { // if oldTransaction != null this means tx was propagated over the wire // and we cannot retry it if (i + 1 >= MAX_RETRIES || oldTransaction != null) throw ex; // Keep ADE check for backward compatibility ApplicationDeadlockException deadlock = isADE(ex); if (deadlock != null) { if (!deadlock.retryable()) throw deadlock; log.debug(deadlock.getMessage() + " retrying tx " + (i + 1)); } else if (retryHandlers != null) { boolean retryable = false; for (int j = 0; j < retryHandlers.length; j++) { retryable = retryHandlers[j].retry(ex); if (retryable) break; } if (!retryable) throw ex; log.debug(ex.getMessage() + " retrying tx " + (i + 1)); } else { throw ex; } Thread.sleep(random.nextInt(1 + i), random.nextInt(1000)); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private Object runWithTransactions(Invocation invocation) throws Exception { // Old transaction is the transaction that comes with the MI Transaction oldTransaction = invocation.getTransaction(); // New transaction is the new transaction this might start Transaction newTransaction = null; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Current transaction in MI is " + oldTransaction); InvocationType type = invocation.getType(); byte transType = container.getBeanMetaData().getTransactionMethod(invocation.getMethod(), type); if ( trace ) printMethod(invocation.getMethod(), transType); // Thread arriving must be clean (jboss doesn't set the thread // previously). However optimized calls come with associated // thread for example. We suspend the thread association here, and // resume in the finally block of the following try. Transaction threadTx = tm.suspend(); if( trace ) log.trace("Thread came in with tx " + threadTx); try { switch (transType) { case MetaData.TX_NOT_SUPPORTED: { // Do not set a transaction on the thread even if in MI, just run try { invocation.setTransaction(null); return invokeNext(invocation, false); } finally { invocation.setTransaction(oldTransaction); } } case MetaData.TX_REQUIRED: { int oldTimeout = 0; Transaction theTransaction = oldTransaction; if (oldTransaction == null) { // No tx running // Create tx oldTimeout = startTransaction(invocation); // get the tx newTransaction = tm.getTransaction(); if( trace ) log.trace("Starting new tx " + newTransaction); // Let the method invocation know invocation.setTransaction(newTransaction); theTransaction = newTransaction; } else { // We have a tx propagated // Associate it with the thread tm.resume(oldTransaction); } // Continue invocation try { Object result = invokeNext(invocation, oldTransaction != null); checkTransactionStatus(theTransaction, type); return result; } finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); } } case MetaData.TX_SUPPORTS: { // Associate old transaction with the thread // Some TMs cannot resume a null transaction and will throw // an exception (e.g. Tyrex), so make sure it is not null if (oldTransaction != null) { tm.resume(oldTransaction); } try { Object result = invokeNext(invocation, oldTransaction != null); if (oldTransaction != null) checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } // Even on error we don't do anything with the tx, // we didn't start it } case MetaData.TX_REQUIRES_NEW: { // Always begin a transaction int oldTimeout = startTransaction(invocation); // get it newTransaction = tm.getTransaction(); // Set it on the method invocation invocation.setTransaction(newTransaction); // Continue invocation try { Object result = invokeNext(invocation, false); checkTransactionStatus(newTransaction, type); return result; } finally { // We started the transaction for sure so we commit or roll back endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); } } case MetaData.TX_MANDATORY: { if (oldTransaction == null) { if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new TransactionRequiredLocalException( "Transaction Required"); } else { throw new TransactionRequiredException( "Transaction Required"); } } // Associate it with the thread tm.resume(oldTransaction); try { Object result = invokeNext(invocation, true); checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } } case MetaData.TX_NEVER: { if (oldTransaction != null) { throw new EJBException("Transaction not allowed"); } return invokeNext(invocation, false); } default: log.error("Unknown TX attribute "+transType+" for method"+invocation.getMethod()); } } finally { // IN case we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } return null; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private int startTransaction(final Invocation invocation) throws Exception { // Get the old timeout and set any new timeout int oldTimeout = -1; if (tm instanceof TransactionTimeoutConfiguration) { oldTimeout = ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); int newTimeout = container.getBeanMetaData().getTransactionTimeout(invocation.getMethod()); tm.setTransactionTimeout(newTimeout); } tm.begin(); return oldTimeout; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
public void remove(String id) throws Exception { EntityMetaData metaData = (EntityMetaData) m_container.getBeanMetaData(); String primKeyClass = metaData.getPrimaryKeyClass(); Object key = PropertyEditors.convertValue(id, primKeyClass); remove(key); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
protected EnterpriseContext acquireContext() throws Exception { return m_container.getInstancePool().get(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() throws Exception { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain, final Subject subject) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { // The instance is created by the caller and is a newInstance(); return new StatefulSessionEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
public void start() throws Exception { super.start(); log.debug("Starting InvalidableEntityInstanceCache..."); EntityMetaData emd = ((EntityMetaData) this.getContainer().getBeanMetaData()); boolean participateInDistInvalidations = emd.doDistributedCacheInvalidations(); byte co = emd.getContainerConfiguration().getCommitOption(); if (participateInDistInvalidations && (co == ConfigurationMetaData.A_COMMIT_OPTION || co == ConfigurationMetaData.D_COMMIT_OPTION) ) { // we are interested in receiving cache invalidation callbacks // String groupName = emd.getDistributedCacheInvalidationConfig().getInvalidationGroupName(); String imName = emd.getDistributedCacheInvalidationConfig().getInvalidationManagerName(); this.invalMgr = (InvalidationManagerMBean) Registry.lookup(imName); this.ig = this.invalMgr.getInvalidationGroup(groupName); this.ig.register(this); this.isTraceEnabled = log.isTraceEnabled(); } }
// in src/main/java/org/jboss/ejb/plugins/lock/NoLock.java
public void schedule(Invocation mi) throws Exception { return; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean isTxExpired(Transaction miTx) throws Exception { return TxUtils.isRollback(miTx); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
public void schedule(Invocation mi) throws Exception { boolean threadScheduled = false; while (!threadScheduled) { /* loop on lock wakeup and restart trying to schedule */ threadScheduled = doSchedule(mi); } }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean doSchedule(Invocation mi) throws Exception { boolean wasThreadScheduled = false; Transaction miTx = mi.getTransaction(); boolean trace = log.isTraceEnabled(); this.sync(); try { if (trace) log.trace("Begin schedule, key=" + mi.getId()); if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } //Next test is independent of whether the context is locked or not, it is purely transactional // Is the instance involved with another transaction? if so we implement pessimistic locking long startWait = System.currentTimeMillis(); try { wasThreadScheduled = waitForTx(miTx, trace); if (wasThreadScheduled && lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } } catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; } } finally { if (miTx == null // non-transactional && wasThreadScheduled) { // if this non-transctional thread was // scheduled in txWaitQueue, we need to call nextTransaction // Otherwise, threads in txWaitQueue will never wake up. nextTransaction(); } this.releaseSync(); } //If we reach here we are properly scheduled to go through so return true return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean waitForTx(Transaction miTx, boolean trace) throws Exception { boolean intr = false; try { boolean wasScheduled = false; // Do we have a running transaction with the context? // We loop here until either until success or until transaction timeout // If we get out of the loop successfully, we can successfully // set the transaction on this puppy. TxLock txLock = null; Object deadlocker = miTx; if (deadlocker == null) deadlocker = Thread.currentThread(); while (getTransaction() != null && // And are we trying to enter with another transaction? !getTransaction().equals(miTx)) { // Check for a deadlock on every cycle try { if( deadlockDetection == true ) DeadlockDetector.singleton.deadlockDetection(deadlocker, this); } catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; } wasScheduled = true; if (lockMonitor != null) lockMonitor.contending(); // That's no good, only one transaction per context // Let's put the thread to sleep the transaction demarcation will wake them up if (trace) log.trace("Transactional contention on context" + id); // Only queue the lock on the first iteration if (txLock == null) txLock = getTxLock(miTx); if (trace) log.trace("Begin wait on Tx=" + getTransaction()); // And lock the threads on the lock corresponding to the Tx in MI synchronized (txLock) { releaseSync(); try { txLock.wait(txTimeout); } catch (InterruptedException ignored) { intr = true; } } // end synchronized(txLock) this.sync(); if (trace) log.trace("End wait on TxLock=" + getTransaction()); if (isTxExpired(miTx)) { log.error(Thread.currentThread() + "Saw rolled back tx=" + miTx + " waiting for txLock" // +" On method: " + mi.getMethod().getName() // +" txWaitQueue size: " + txWaitQueue.size() ); if (txLock.isQueued) { // Remove the TxLock from the queue because this thread is exiting. // Don't worry about notifying other threads that share the same transaction. // They will timeout and throw the below RuntimeException txLocks.remove(txLock); txWaitQueue.remove(txLock); } else if (getTransaction() != null && getTransaction().equals(miTx)) { // We're not qu nextTransaction(); } if (miTx != null) { if( deadlockDetection == true ) DeadlockDetector.singleton.removeWaiting(deadlocker); } throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } // end while(tx!=miTx) // If we get here, this means that we have the txlock if (!wasScheduled) { setTransaction(miTx); } return wasScheduled; } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void create() throws Exception { getCache().create(); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void start() throws Exception { getCache().start(); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context MessageDrivenContainer mdc = (MessageDrivenContainer) container; InstancePool pool = mdc.getInstancePool(); EnterpriseContext ctx = null; try { ctx = pool.get(); } catch (EJBException e) { throw e; } catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Use this context mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); // There is no need for synchronization since the instance is always // fresh also there should never be a tx associated with the instance. try { // Invoke through interceptors Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free((EnterpriseContext) mi.getEnterpriseContext()); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInterceptor.java
public void create() throws Exception { // empty }
// in src/main/java/org/jboss/ejb/plugins/AbstractInterceptor.java
public void start() throws Exception { // empty }
// in src/main/java/org/jboss/ejb/plugins/AbstractInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { // assert mi != null; return getNext().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // assert mi != null; return getNext().invoke(mi); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { return new EntityEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
public void create() throws Exception { try { ConfigurationMetaData configuration = container.getBeanMetaData().getContainerConfiguration(); commitOption = configuration.getCommitOption(); optionDRefreshRate = configuration.getOptionDRefreshRate(); } catch(Exception e) { log.warn(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); Transaction tx = mi.getTransaction(); Object rtn = getNext().invokeHome(mi); // An anonymous context was sent in, so if it has an id it is a real instance now if(ctx.getId() != null) { // it doesn't need to be read, but it might have been changed from the db already. ctx.setValid(true); if(tx != null) { BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey()); try { lock.schedule(mi); register(ctx, tx); // Set tx lock.endInvocation(mi); } finally { container.getLockManager().removeLockRef(lock.getId()); } } } return rtn; }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); // The Tx coming as part of the Method Invocation Transaction tx = mi.getTransaction(); if(log.isTraceEnabled()) log.trace("invoke called for ctx " + ctx + ", tx=" + tx); if(!ctx.isValid()) { container.getPersistenceManager().loadEntity(ctx); ctx.setValid(true); } // mark the context as read only if this is a readonly method and the context // was not already readonly boolean didSetReadOnly = false; if(!ctx.isReadOnly() && (container.isReadOnly() || container.getBeanMetaData().isMethodReadOnly(mi.getMethod()))) { ctx.setReadOnly(true); didSetReadOnly = true; } // So we can go on with the invocation // Invocation with a running Transaction try { if(tx != null && tx.getStatus() != Status.STATUS_NO_TRANSACTION) { // readonly does not synchronize, lock or belong with transaction. boolean isReadOnly = container.isReadOnly(); if(isReadOnly == false) { Method method = mi.getMethod(); if(method != null) isReadOnly = container.getBeanMetaData().isMethodReadOnly(method.getName()); } try { if(isReadOnly == false) { // register the wrapper with the transaction monitor (but only // register once). The transaction demarcation will trigger the // storage operations register(ctx, tx); } //Invoke down the chain Object retVal = getNext().invoke(mi); // Register again as a finder in the middle of a method // will de-register this entity, and then the rest of the method can // change fields which will never be stored if(isReadOnly == false) { // register the wrapper with the transaction monitor (but only // register once). The transaction demarcation will trigger the // storage operations register(ctx, tx); } // return the return value return retVal; } finally { // We were read-only and the context wasn't already synchronized, tidyup the cache if(isReadOnly && ctx.hasTxSynchronization() == false) { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // FIXME: We cannot passivate here, because previous // interceptors work with the context, in particular // the re-entrance interceptor is doing lock counting // Just remove it from the cache if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } } } else { // No tx try { Object result = getNext().invoke(mi); // Store after each invocation -- not on exception though, or removal // And skip reads too ("get" methods) if(ctx.getId() != null && !container.isReadOnly()) { container.invokeEjbStore(ctx); container.storeEntity(ctx); } return result; } catch(Exception e) { // Exception - force reload on next call ctx.setValid(false); throw e; } finally { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // Do not call release if getId() is null. This means that // the entity has been removed from cache. // release will schedule a passivation and this removed ctx // could be put back into the cache! // This is necessary because we have no lock, we // don't want to return an instance to the pool that is // being used if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } } } finally { // if we marked the context as read only we need to reset it if(didSetReadOnly) { ctx.setReadOnly(false); } } }
// in src/main/java/org/jboss/ejb/plugins/EntityCreationInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke through interceptors Object retVal = getNext().invokeHome(mi); // Is the context now with an identity? // This means that a create method was called, so invoke ejbPostCreate. EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); if(ctx != null && ctx.getId() != null) { // copy from the context into the mi // interceptors down the chain look in the mi for the id not the ctx. mi.setId(ctx.getId()); // invoke down the invoke chain // the final interceptor in EntityContainer will redirect this // call to postCreateEntity, which calls ejbPostCreate getNext().invoke(mi); // now it's ready and can be scheduled for the synchronization if(TxUtils.isActive(mi.getTransaction())) { GlobalTxEntityMap.NONE.scheduleSync(mi.getTransaction(), ctx); } } return retVal; }
// in src/main/java/org/jboss/ejb/plugins/EntityCreationInterceptor.java
public Object invoke(Invocation mi) throws Exception { // nothing to see here... move along return getNext().invoke(mi); }
// in src/main/java/org/jboss/ejb/plugins/CallValidationInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { validateArguments(mi); Object obj = getNext().invokeHome(mi); return validateReturnValue(mi, obj); }
// in src/main/java/org/jboss/ejb/plugins/CallValidationInterceptor.java
public Object invoke(final Invocation mi) throws Exception { validateArguments(mi); Object obj = getNext().invoke(mi); return validateReturnValue(mi, obj); }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
public void start() throws Exception { super.start(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Apply any declarative security checks checkSecurityAssociation(mi); Object returnValue = getNext().invokeHome(mi); return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
public Object invoke(Invocation mi) throws Exception { // Authenticate the subject and apply any declarative security checks checkSecurityAssociation(mi); Object returnValue = getNext().invoke(mi); return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
private void checkSecurityAssociation(Invocation mi) throws Exception { Principal principal = mi.getPrincipal(); boolean trace = log.isTraceEnabled(); if (realmMapping == null) { throw new EJBException("checkSecurityAssociation", new SecurityException("Role mapping manager has not been set")); } // Get the method permissions InvocationType iface = mi.getType(); Set methodRoles = container.getMethodPermissions(mi.getMethod(), iface); if (methodRoles == null) { String method = mi.getMethod().getName(); String msg = "No method permissions assigned to method=" + method + ", interface=" + iface; log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } else if (trace) { log.trace("method=" + mi.getMethod() + ", interface=" + iface + ", requiredRoles=" + methodRoles); } // Check if the caller is allowed to access the method RunAsIdentity callerRunAsIdentity = SecurityAssociation.peekRunAsIdentity(); if (methodRoles.contains(AnybodyPrincipal.ANYBODY_PRINCIPAL) == false) { // The caller is using a the caller identity if (callerRunAsIdentity == null) { // Now actually check if the current caller has one of the required method roles if (realmMapping.doesUserHaveRole(principal, methodRoles) == false) { Set userRoles = realmMapping.getUserRoles(principal); String method = mi.getMethod().getName(); String msg = "Insufficient method permissions, principal=" + principal + ", method=" + method + ", interface=" + iface + ", requiredRoles=" + methodRoles + ", principalRoles=" + userRoles; log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } } // The caller is using a run-as identity else { // Check that the run-as role is in the set of method roles if (callerRunAsIdentity.doesUserHaveRole(methodRoles) == false) { String method = mi.getMethod().getName(); String msg = "Insufficient method permissions, runAsPrincipal=" + callerRunAsIdentity.getName() + ", method=" + method + ", interface=" + iface + ", requiredRoles=" + methodRoles + ", runAsRoles=" + callerRunAsIdentity.getRunAsRoles(); log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } } } }
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
public void start() throws Exception { super.start(); }
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { boolean isInvokeMethod = false; return this.process(mi, isInvokeMethod); }
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean isInvokeMethod = true; return this.process(mi, isInvokeMethod); }
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
public Object process(Invocation mi, boolean isInvokeMethod) throws Exception { String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(securityManager != null) { securityDomain = securityManager.getSecurityDomain(); } if (log.isTraceEnabled()) { log.trace("Bean:"+ container.getServiceName() + " securityDomain="+securityDomain + " isInvokeMethod="+ isInvokeMethod); } //Establish a security context if one is missing for Run-As push if(SecurityActions.getSecurityContext() == null) { SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain); } /* If a run-as role was specified, push it so that any calls made by this bean will have the runAsRole available for declarative security checks. */ SecurityActions.pushRunAsIdentity(runAsIdentity); SecurityActions.pushCallerRunAsIdentity(runAsIdentity); if (log.isTraceEnabled()) { log.trace("Security Context = " + SecurityActions.trace(SecurityActions.getSecurityContext())); } try { if(isInvokeMethod) return getNext().invoke(mi); else return getNext().invokeHome(mi); } finally { SecurityActions.popRunAsIdentity(); SecurityActions.popCallerRunAsIdentity(); } }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void create() throws Exception { m_map = new HashMap(); }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void start() throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
public void create() throws Exception { super.create(); tm = getContainer().getTransactionManager(); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
protected Object invokeNext(Invocation invocation, boolean inheritedTx) throws Exception { InvocationType type = invocation.getType(); try { if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || type == InvocationType.SERVICE_ENDPOINT) { // register the Timer with the transaction if (ejbTimeout.equals(invocation.getMethod())) registerTimer(invocation); return getNext().invoke(invocation); } else { return getNext().invokeHome(invocation); } } catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
protected boolean isTxExpired(Transaction miTx) throws Exception { return TxUtils.isRollback(miTx); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); boolean nonReentrant = !(reentrant || isReentrantMethod(mi)); // Not a reentrant method like getPrimaryKey NonReentrantLock methodLock = ctx.getMethodLock(); Transaction miTx = ctx.getTransaction(); boolean locked = false; try { while (!locked) { if (methodLock.attempt(5000, miTx, nonReentrant)) { locked = true; } else { if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } } } catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } } try { ctx.lock(); return getNext().invoke(mi); } finally { ctx.unlock(); methodLock.release(nonReentrant); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void create() throws Exception { if(con.getHomeClass() != null) { Method[] methods = con.getHomeClass().getMethods(); createMethodCache(methods); } if(con.getLocalHomeClass() != null) { Method[] methods = con.getLocalHomeClass().getMethods(); createMethodCache(methods); } insertAfterEjbPostCreate = con.getBeanMetaData().getContainerConfiguration().isInsertAfterEjbPostCreate(); store.create(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public Object createBeanClassInstance() throws Exception { return store.createBeanClassInstance(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void start() throws Exception { store.start(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { // Deligate initialization of bean to persistence store store.initEntity(ctx); // Call ejbCreate on the target bean try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); Method createMethod = (Method) createMethods.get(m); createMethod.invoke(ctx.getInstance(), args); } catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // if insertAfterEjbPostCreate == true, this will INSERT entity // otherwise, primary key is extracted from the context and returned Object id; try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); id = store.createEntity(m, args, ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Set the key on the target context ctx.setId(id); // Create a new CacheKey Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id); // Give it to the context ctx.setCacheKey(cacheKey); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void postCreateEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { // this call should go first as it sets up relationships // for fk fields mapped to pk fields store.postCreateEntity(m, args, ctx); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_POST_CREATE); Method postCreateMethod = (Method) postCreateMethods.get(m); postCreateMethod.invoke(ctx.getInstance(), args); if(insertAfterEjbPostCreate) { store.createEntity(m, args, ctx); } } catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); return store.findEntity(finderMethod, args, ctx, factory); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { try { // return the finderResults so that the invoker layer can extend this back // giving the client an OO 'cursor' AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); return store.findEntities(finderMethod, args, ctx, factory); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public boolean isStoreRequired(EntityEnterpriseContext ctx) throws Exception { return store.isStoreRequired(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public boolean isModified(EntityEnterpriseContext ctx) throws Exception { return store.isModified(ctx); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
public synchronized EnterpriseContext get() throws Exception { boolean intr = false; try { // Wait while someone else is using it while(inUse && isSynchronized) { try { this.wait(); } catch (InterruptedException e) { intr = true; } } // Create if not already created (or it has been discarded) if (ctx == null) { try { ctx = create(getContainer().createBeanClassInstance()); } catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); } catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); } } else { } // Lock and return instance inUse = true; return ctx; } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
public void add() throws Exception { // Empty }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { // The instance is created by the caller and is a newInstance(); return new StatelessSessionEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { InstancePool pool = container.getInstancePool(); StatelessSessionEnterpriseContext ctx = null; try { // Acquire an instance in case the ejbCreate throws a CreateException ctx = (StatelessSessionEnterpriseContext) pool.get(); mi.setEnterpriseContext(ctx); // Dispatch the method to the container return getNext().invokeHome(mi); } finally { mi.setEnterpriseContext(null); // If an instance was created, return it to the pool if( ctx != null ) pool.free(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context InstancePool pool = container.getInstancePool(); StatelessSessionEnterpriseContext ctx = null; try { ctx = (StatelessSessionEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Use this context mi.setEnterpriseContext(ctx); // JAXRPC/JAXWS message context Object msgContext = mi.getValue(InvocationKey.SOAP_MESSAGE_CONTEXT); // Timer invocation if (ejbTimeout.equals(mi.getMethod())) { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); } // Service Endpoint invocation else if (msgContext != null) { if (msgContext instanceof javax.xml.rpc.handler.MessageContext) ctx.setMessageContext((javax.xml.rpc.handler.MessageContext)msgContext); AllowedOperationsAssociation.pushInMethodFlag(IN_SERVICE_ENDPOINT_METHOD); } // Business Method Invocation else { AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); } // There is no need for synchronization since the instance is always fresh also there should // never be a tx associated with the instance. try { Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected void createService() throws Exception { // Initialize the dataStore String ejbName = con.getBeanMetaData().getEjbName(); // Get the system data directory File dir = new File(ServerConfigLocator.locate().getServerDataLocation().toURI()); // // jason: may have to use a generated token from container config // to determine a unique name for this config for the given // entity name. it must persist through restarts though... // // Setup the reference to the entity data store directory dir = new File(dir, storeDirName); dir = new File(dir, ejbName); storeDir = dir; log.debug("Storing entity state for '" + ejbName + "' in: " + storeDir); // if the directory does not exist then try to create it if (!storeDir.exists()) { if (!storeDir.mkdirs()) { throw new IOException("Failed to create directory: " + storeDir); } } // make sure we have a directory if (!storeDir.isDirectory()) { throw new IOException("File exists where directory expected: " + storeDir); } // make sure we can read and write to it if (!storeDir.canWrite() || !storeDir.canRead()) { throw new IOException("Directory must be readable and writable: " + storeDir); } // Get the ID field idField = con.getBeanClass().getField("id"); log.debug("Using id field: " + idField); // Lookup the isModified method if it exists try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) { isModified = null; // Has to have "boolean" as return type! log.warn("Found isModified method, but return type is not boolean; ignoring"); } else { log.debug("Using isModified method: " + isModified); } } catch (NoSuchMethodException ignored) {} }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected void destroyService() throws Exception { storeDir.delete(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object createBeanClassInstance() throws Exception { return con.getBeanClass().newInstance(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object createEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get(ctx.getInstance()); // Check exist if (getFile(id).exists()) throw new DuplicateKeyException("Already exists: "+id); // Store to file storeEntity(id, ctx.getInstance()); return id; } catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object postCreateEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { return null; }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public boolean isStoreRequired(final EntityEnterpriseContext ctx) throws Exception { if (isModified == null) { return true; } Boolean modified = (Boolean) isModified.invoke(ctx.getInstance(), new Object[0]); return modified.booleanValue(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public boolean isModified(EntityEnterpriseContext ctx) throws Exception { return isStoreRequired(ctx); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
protected EnterpriseContext acquireContext() throws Exception { return m_container.getInstancePool().get(); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { long begin = System.currentTimeMillis(); try { return super.invokeHome(mi); } finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } } }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
public Object invoke(Invocation mi) throws Exception { long begin = System.currentTimeMillis(); try { return super.invoke(mi); } finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public void create() throws Exception { BeanMetaData metaData = container.getBeanMetaData(); localJndiName = metaData.getLocalJndiName(); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public void start() throws Exception { BeanMetaData metaData = container.getBeanMetaData(); EJBProxyFactoryContainer invokerContainer = (EJBProxyFactoryContainer) container; localHomeClass = invokerContainer.getLocalHomeClass(); localClass = invokerContainer.getLocalClass(); if(localHomeClass == null || localClass == null) { log.debug(metaData.getEjbName() + " cannot be Bound, doesn't " + "have local and local home interfaces"); return; } // this is faster than newProxyInstance Class[] intfs = {localClass}; Class proxyClass = Proxy.getProxyClass(ClassLoaderAction.UTIL.get(localClass), intfs); final Class[] constructorParams = {InvocationHandler.class}; proxyClassConstructor = proxyClass.getConstructor(constructorParams); Context iniCtx = new InitialContext(); String beanName = metaData.getEjbName(); // Set the transaction manager and transaction propagation // context factory of the GenericProxy class transactionManager = (TransactionManager) iniCtx.lookup("java:/TransactionManager"); // Create method mappings for container invoker Method[] methods = localClass.getMethods(); beanMethodInvokerMap = new HashMap(); for(int i = 0; i < methods.length; i++) { long hash = MarshalledInvocation.calculateHash(methods[i]); beanMethodInvokerMap.put(new Long(hash), methods[i]); } methods = localHomeClass.getMethods(); homeMethodInvokerMap = new HashMap(); for(int i = 0; i < methods.length; i++) { long hash = MarshalledInvocation.calculateHash(methods[i]); homeMethodInvokerMap.put(new Long(hash), methods[i]); } // bind that referance to my name Util.rebind(iniCtx, localJndiName, getEJBLocalHome()); invokerMap.put(localJndiName, this); log.info("Bound EJB LocalHome '" + beanName + "' to jndi '" + localJndiName + "'"); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/RelationInterceptor.java
public Object invoke(Invocation mi) throws Exception { if(!(mi instanceof CMRInvocation)) { return getNext().invoke(mi); } org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage msg = ((CMRInvocation)mi).getCmrMessage(); // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); JDBCCMRFieldBridge2 cmrField = (JDBCCMRFieldBridge2)mi.getArguments()[0]; if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.ADD_RELATION == msg) { Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Add relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.addRelatedId(ctx, relatedId); } else if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.REMOVE_RELATION == msg) { // call removeRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Remove relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.removeRelatedId(ctx, relatedId); } else { // this should not be possible we are using a type safe enum throw new EJBException("Unknown cmp2.0-relationship-message=" + msg); } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
public void lockForUpdate(Transaction tx, Object pk) throws Exception { final int i = getPartitionIndex(pk); partitions[i].lockForUpdate(tx, pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
public void releaseLock(Transaction tx, Object pk) throws Exception { final int i = getPartitionIndex(pk); partitions[i].releaseLock(tx, pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void stop() throws Exception { if(cacheInvalidator != null) { cacheInvalidator.unregister(); } if(cacheName != null) { serviceController.stop(cacheName); serviceController.destroy(cacheName); serviceController.remove(cacheName); } serviceController = null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Cache.java
public void lockForUpdate(Transaction tx, Object pk) throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Cache.java
public void releaseLock(Transaction tx, Object pk) throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void lockForUpdate(Transaction tx, Object pk) throws Exception { CachedRow row = (CachedRow) rowsById.get(pk); if(row != null) { if(row.locker != null && !tx.equals(row.locker)) { throw new Exception("lock acquisition rejected for " + tx + ", the entry is locked for update by " + row.locker + ", id=" + pk); } row.locker = tx; } // else?! }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void releaseLock(Transaction tx, Object pk) throws Exception { CachedRow row = (CachedRow) rowsById.get(pk); if(row != null) { if(!tx.equals(row.locker)) { throw new Exception("rejected to release lock for " + tx + ", the entry is locked for update by " + row.locker + ", id=" + pk); } row.locker = null; } // else?! }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public void create() throws Exception { HashMap managersMap = (HashMap)getApplicationData(CREATED_MANAGERS); if(managersMap == null) { managersMap = new HashMap(); putApplicationData(CREATED_MANAGERS, managersMap); } managersMap.put(container.getBeanMetaData().getEjbName(), this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public void start() throws Exception { initStoreManager(); HashMap managersMap = (HashMap)getApplicationData(CREATED_MANAGERS); Catalog catalog = getCatalog(); if(catalog.getEntityCount() == managersMap.size() && catalog.getEJBNames().equals(managersMap.keySet())) { // Make a copy of the managers (for safty) List managers = new ArrayList(managersMap.values()); // Start Phase 2: resolve relationships for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager2 manager = (JDBCStoreManager2)managers.get(i); manager.resolveRelationships(); } // Start Phase 3: init cmr loaders for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager2 manager = (JDBCStoreManager2)managers.get(i); manager.startEntity(); } // Start Phase 4: create tables and compile queries for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager2 manager = (JDBCStoreManager2)managers.get(i); manager.startStoreManager(); } // add foreign key constraints for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager2 manager = (JDBCStoreManager2)managers.get(i); manager.startCmd.addForeignKeyConstraints(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Object createBeanClassInstance() throws Exception { return instanceFactory.newInstance(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public boolean isModified(EntityEnterpriseContext instance) throws Exception { return entityBridge.isModified(instance); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
protected void initStoreManager() throws Exception { if(log.isDebugEnabled()) { log.debug("Initializing CMP plugin for " + container.getBeanMetaData().getEjbName()); } metaData = loadJDBCEntityMetaData(); // setup the type factory, which is used to map java types to sql types. typeFactory = new JDBCTypeFactory(metaData.getTypeMapping(), metaData.getJDBCApplication().getValueClasses(), metaData.getJDBCApplication().getUserTypeMappings() ); entityBridge = new JDBCEntityBridge2(this, metaData); entityBridge.init(); Catalog catalog = getCatalog(); catalog.addEntity(entityBridge); stop = new JDBCStopCommand(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
private void resolveRelationships() throws Exception { entityBridge.resolveRelationships(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
protected void startStoreManager() throws Exception { queryFactory = new QueryFactory(entityBridge); queryFactory.init(); instanceFactory = new InstanceFactory(this, entityBridge); startCmd = new JDBCStartCommand(this); startCmd.execute(); final JDBCEntityCommandMetaData entityCommand = getMetaData().getEntityCommand(); if(entityCommand == null || "default".equals(entityCommand.getCommandName())) { createCmd = new ApplicationPkCreateCommand(); } else { final Class cmdClass = entityCommand.getCommandClass(); if(cmdClass == null) { throw new DeploymentException( "entity-command class name is not specified for entity " + entityBridge.getEntityName() ); } try { createCmd = (CreateCommand)cmdClass.newInstance(); } catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); } } createCmd.init(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
public Object newInstance() throws Exception { EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(fieldMap, selectorMap, beanClass); return beanProxyConstructor.newInstance(new Object[]{handler}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/EJBSelectBridge.java
public Object invoke(EntityEnterpriseContext instance, Method method, Object[] args) throws Exception { Transaction tx = (instance != null ? instance.getTransaction() : tm.getTransaction()); if(syncBeforeSelect) { EntityContainer.synchronizeEntitiesWithinTransaction(tx); } return execute(args); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void stop() throws Exception { table.stop(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRelationInterceptor.java
public Object invoke(Invocation mi) throws Exception { if(!(mi instanceof CMRInvocation)) return getNext().invoke(mi); CMRMessage relationshipMessage = ((CMRInvocation)mi).getCmrMessage(); if(relationshipMessage == null) { // Not a relationship message. Invoke down the chain return getNext().invoke(mi); } // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)mi.getArguments()[0]; if(CMRMessage.GET_RELATED_ID == relationshipMessage) { // call getRelateId if(log.isTraceEnabled()) { log.trace("Getting related id: field=" + cmrField.getFieldName() + " id=" + ctx.getId()); } return cmrField.getRelatedId(ctx); } else if(CMRMessage.ADD_RELATION == relationshipMessage) { // call addRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Add relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.addRelation(ctx, relatedId); return null; } else if(CMRMessage.REMOVE_RELATION == relationshipMessage) { // call removeRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Remove relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.removeRelation(ctx, relatedId); return null; } else if(CMRMessage.SCHEDULE_FOR_CASCADE_DELETE == relationshipMessage) { JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity(); entity.scheduleForCascadeDelete(ctx); return null; } else if(CMRMessage.SCHEDULE_FOR_BATCH_CASCADE_DELETE == relationshipMessage) { JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity(); entity.scheduleForBatchCascadeDelete(ctx); return null; } else { // this should not be possible we are using a type safe enum throw new EJBException("Unknown cmp2.0-relationship-message=" + relationshipMessage); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/MetaDataLibrary.java
public void startService() throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL stdJDBCUrl = classLoader.getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if(debug) { log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); } Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); Element typeMaps = MetaData.getOptionalChild(stdJDBCElement, "type-mappings"); if(typeMaps != null) { for(Iterator i = MetaData.getChildrenByTagName(typeMaps, "type-mapping"); i.hasNext();) { Element typeMappingElement = (Element)i.next(); JDBCTypeMappingMetaData typeMapping = new JDBCTypeMappingMetaData(typeMappingElement); typeMappings.put(typeMapping.getName(), typeMapping); log.debug("added type-mapping: " + typeMapping.getName()); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/MetaDataLibrary.java
public void stopService() throws Exception { typeMappings.clear(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/DataSourceMetaData.java
public JDBCTypeMappingMetaData getTypeMappingMetaData() throws Exception { return (JDBCTypeMappingMetaData)server.invoke( metadataLibrary, "findTypeMappingMetaData", new Object[]{typeMapping}, new String[]{String.class.getName()} ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public void compileEJBQL(String ejbql, Class returnType, Class[] parameterTypes, JDBCQueryMetaData metadata) throws Exception { // reset all state variables reset(); // set input arguemts this.returnType = returnType; this.parameterTypes = parameterTypes; this.readAhead = metadata.getReadAhead(); // get the parser EJBQLParser parser = new EJBQLParser(new StringReader("")); try { // parse the ejbql into an abstract sytax tree ASTEJBQL ejbqlNode = parser.parse(catalog, parameterTypes, ejbql); // translate to sql sql = ejbqlNode.jjtAccept(this, new StringBuffer()).toString(); } catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; } catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public void compileJBossQL(String ejbql, Class returnType, Class[] parameterTypes, JDBCQueryMetaData metadata) throws Exception { // reset all state variables reset(); // set input arguemts this.returnType = returnType; this.parameterTypes = parameterTypes; this.readAhead = metadata.getReadAhead(); // get the parser JBossQLParser parser = new JBossQLParser(new StringReader("")); try { // parse the ejbql into an abstract sytax tree ASTEJBQL ejbqlNode = parser.parse(catalog, parameterTypes, ejbql); // translate to sql sql = ejbqlNode.jjtAccept(this, new StringBuffer()).toString(); if(log.isTraceEnabled()) { log.trace("ejbql: " + ejbql); log.trace("sql: " + sql); } } catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; } catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCreateBeanClassInstanceCommand.java
public Object execute() throws Exception { EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(fieldMap, selectorMap, beanClass); return beanProxyConstructor.newInstance(new Object[]{handler}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public void create() throws Exception { // Store a reference to this manager in an application level hashtable. // This way in the start method other managers will be able to know // the other managers. HashMap managersMap = (HashMap)getApplicationData(CREATED_MANAGERS); if(managersMap == null) { managersMap = new HashMap(); putApplicationData(CREATED_MANAGERS, managersMap); } managersMap.put(container.getBeanMetaData().getEjbName(), this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public void start() throws Exception { // // // Start Phase 1: create bridge and commands but // don't access other entities initStoreManager(); // If all managers have been started (this is the last manager), // complete the other two phases of startup. Catalog catalog = getCatalog(); HashMap managersMap = (HashMap)getApplicationData(CREATED_MANAGERS); if(catalog.getEntityCount() == managersMap.size() && catalog.getEJBNames().equals(managersMap.keySet())) { // Make a copy of the managers (for safty) ArrayList managers = new ArrayList(managersMap.values()); // // // Start Phase 2: resolve relationships for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager manager = (JDBCStoreManager)managers.get(i); manager.resolveRelationships(); } // // // Start Phase 3: create tables and compile queries for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager manager = (JDBCStoreManager)managers.get(i); manager.startStoreManager(); } // add foreign key constraints for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager manager = (JDBCStoreManager)managers.get(i); manager.startCommand.addForeignKeyConstraints(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private void initStoreManager() throws Exception { if(log.isDebugEnabled()) log.debug("Initializing CMP plugin for " + container.getBeanMetaData().getEjbName()); // get the transaction manager tm = container.getTransactionManager(); // initializes the generic data containers initApplicationDataMap(); // load the metadata for this entity metaData = loadJDBCEntityMetaData(); // setup the type factory, which is used to map java types to sql types. typeFactory = new JDBCTypeFactory( metaData.getTypeMapping(), metaData.getJDBCApplication().getValueClasses(), metaData.getJDBCApplication().getUserTypeMappings() ); // create the bridge between java land and this engine (sql land) entityBridge = new JDBCEntityBridge(metaData, this); entityBridge.init(); // add the entity bridge to the catalog Catalog catalog = getCatalog(); if(catalog == null) { catalog = new Catalog(); putApplicationData(CATALOG, catalog); } catalog.addEntity(entityBridge); // create the read ahead cache readAheadCache = new ReadAheadCache(this); readAheadCache.create(); // Set up Commands commandFactory = new JDBCCommandFactory(this); // Execute the init command initCommand = commandFactory.createInitCommand(); initCommand.execute(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private void resolveRelationships() throws Exception { entityBridge.resolveRelationships(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private void startStoreManager() throws Exception { entityBridge.start(); // Store manager life cycle commands startCommand = commandFactory.createStartCommand(); stopCommand = commandFactory.createStopCommand(); destroyCommand = commandFactory.createDestroyCommand(); // Entity commands initEntityCommand = commandFactory.createInitEntityCommand(); createBeanClassInstanceCommand = commandFactory.createCreateBeanClassInstanceCommand(); findEntityCommand = commandFactory.createFindEntityCommand(); findEntitiesCommand = commandFactory.createFindEntitiesCommand(); createEntityCommand = commandFactory.createCreateEntityCommand(); postCreateEntityCommand = commandFactory.createPostCreateEntityCommand(); removeEntityCommand = commandFactory.createRemoveEntityCommand(); loadEntityCommand = commandFactory.createLoadEntityCommand(); isModifiedCommand = commandFactory.createIsModifiedCommand(); storeEntityCommand = commandFactory.createStoreEntityCommand(); activateEntityCommand = commandFactory.createActivateEntityCommand(); passivateEntityCommand = commandFactory.createPassivateEntityCommand(); // Relation commands loadRelationCommand = commandFactory.createLoadRelationCommand(); deleteRelationsCommand = commandFactory.createDeleteRelationsCommand(); insertRelationsCommand = commandFactory.createInsertRelationsCommand(); // Create the query manager queryManager = new JDBCQueryManager(this); // Execute the start command, creates the tables startCommand.execute(); // Start the query manager. At this point is creates all of the // query commands. The must occure in the start phase, as // queries can opperate on other entities in the application, and // all entities are gaurenteed to be createed until the start phase. queryManager.start(); readAheadCache.start(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object createBeanClassInstance() throws Exception { if(createBeanClassInstanceCommand == null) throw new IllegalStateException("createBeanClassInstanceCommand == null"); return createBeanClassInstanceCommand.execute(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public void compileEJBQL(String ejbql, Class returnType, Class[] parameterTypes, JDBCQueryMetaData metadata) throws Exception { // reset all state variables reset(); // set input arguemts this.returnType = returnType; this.parameterTypes = parameterTypes; this.readAhead = metadata.getReadAhead(); this.lazyResultSetLoading = metadata.isLazyResultSetLoading(); // get the parser EJBQLParser parser = new EJBQLParser(new StringReader(SQLUtil.EMPTY_STRING)); try { // parse the ejbql into an abstract sytax tree ASTEJBQL ejbqlNode; ejbqlNode = parser.parse(catalog, parameterTypes, ejbql); // translate to sql sql = ejbqlNode.jjtAccept(this, new StringBuffer()).toString(); } catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; } catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public void compileJBossQL(String ejbql, Class returnType, Class[] parameterTypes, JDBCQueryMetaData metadata) throws Exception { // reset all state variables reset(); // set input arguemts this.returnType = returnType; this.parameterTypes = parameterTypes; this.readAhead = metadata.getReadAhead(); this.lazyResultSetLoading = metadata.isLazyResultSetLoading(); // get the parser JBossQLParser parser = new JBossQLParser(new StringReader(SQLUtil.EMPTY_STRING)); try { // parse the ejbql into an abstract sytax tree ASTEJBQL ejbqlNode; ejbqlNode = parser.parse(catalog, parameterTypes, ejbql); // translate to sql sql = ejbqlNode.jjtAccept(this, new StringBuffer()).toString(); } catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; } catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
private void setParameters(PreparedStatement ps, RelationData relationData, Iterator pairs) throws Exception { int index = 1; JDBCCMPFieldBridge[] leftFields = (JDBCCMPFieldBridge[])relationData.getLeftCMRField().getTableKeyFields(); JDBCCMPFieldBridge[] rightFields = (JDBCCMPFieldBridge[])relationData.getRightCMRField().getTableKeyFields(); int keyIndex = 0; while(pairs.hasNext()) { RelationPair pair = (RelationPair)pairs.next(); // left keys Object leftId = pair.getLeftId(); for(int i = 0; i < leftFields.length; ++i) { index = leftFields[i].setPrimaryKeyParameters(ps, index, leftId); } // right keys Object rightId = pair.getRightId(); for(int i = 0; i < rightFields.length; ++i) { index = rightFields[i].setPrimaryKeyParameters(ps, index, rightId); } if(maxKeysInDelete > 0) { ++keyIndex; if(keyIndex == maxKeysInDelete) { break; } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCCreateBeanClassInstanceCommand createCreateBeanClassInstanceCommand() throws Exception { return new JDBCCreateBeanClassInstanceCommand(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
public void set(Logger log, PreparedStatement ps, int index, Object[] args) throws Exception { Object arg = args[argNum]; JDBCParameterSetter param; if(field != null) { if(!isPrimaryKeyParameter) { if(arg instanceof EJBObject) { arg = ((EJBObject)arg).getPrimaryKey(); } else if(arg instanceof EJBLocalObject) { arg = ((EJBLocalObject)arg).getPrimaryKey(); } else { throw new IllegalArgumentException("Expected an instanc of " + "EJBObject or EJBLocalObject, but got an instance of " + arg.getClass().getName()); } } arg = field.getPrimaryKeyValue(arg); // use mapper final JDBCType jdbcType = field.getJDBCType(); arg = jdbcType.getColumnValue(0, arg); param = jdbcType.getParameterSetter()[0]; } else if(property != null) { arg = property.getColumnValue(arg); param = property.getParameterSetter(); } else { if(type != null) { arg = type.getColumnValue(0, arg); param = type.getParameterSetter()[0]; } else { param = JDBCUtil.getParameterSetter(jdbcType, arg == null ? null : arg.getClass()); } } param.set(ps, index, jdbcType, arg, log); //JDBCUtil.setParameter(log, ps, index, jdbcType, arg); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() throws Exception { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain, final Subject subject) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object invoke(EntityEnterpriseContext ctx, Method method, Object[] args) throws Exception { Transaction tx = (ctx != null ? ctx.getTransaction() : tm.getTransaction()); if(syncBeforeSelect) { EntityContainer.synchronizeEntitiesWithinTransaction(tx); } return execute(args); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplexProperty.java
public Object getColumnValue(Object value) throws Exception { Object[] noArgs = new Object[0]; for(int i = 0; i < getters.length; i++) { if(value == null) { return null; } value = getters[i].invoke(value, noArgs); } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplexProperty.java
public Object setColumnValue( Object value, Object columnValue) throws Exception { // Used for invocation of get and set Object[] noArgs = new Object[0]; Object[] singleArg = new Object[1]; // save the first value to return Object returnValue = value; // get the second to last object in the chain for(int i = 0; i < getters.length - 1; i++) { // get the next object in chain Object next = getters[i].invoke(value, noArgs); // the next object is null creat it if(next == null) { // new type based on getter next = getters[i].getReturnType().newInstance(); // and set it into the current value singleArg[0] = next; setters[i].invoke(value, singleArg); } // update value to the next in chain value = next; } // value is now the object on which we need to set the column value singleArg[0] = columnValue; setters[setters.length - 1].invoke(value, singleArg); // return the first object in call chain return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
public EnterpriseContext get() throws Exception { boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Get instance "+this+"#"+pool.size()+"#"+getContainer().getBeanClass()); if( strictMaxSize != null ) { // Block until an instance is available boolean acquired = strictMaxSize.attempt(strictTimeout); if( trace ) log.trace("Acquired("+acquired+") strictMaxSize semaphore, remaining="+strictMaxSize.permits()); if( acquired == false ) throw new EJBException("Failed to acquire the pool semaphore, strictTimeout="+strictTimeout); } synchronized (pool) { if ( pool.isEmpty() == false ) { return (EnterpriseContext) pool.removeFirst(); } } // Pool is empty, create an instance try { Object instance = container.createBeanClassInstance(); return create(instance); } catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
protected void createService() throws Exception { if( this.isStrict == Boolean.TRUE ) this.strictMaxSize = new FIFOSemaphore(this.maxSize); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
protected void destroyService() throws Exception { freeAll(); this.strictMaxSize = null; }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public void create() throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public void start() throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Get context EntityContainer ec = (EntityContainer) getContainer(); EntityEnterpriseContext ctx = (EntityEnterpriseContext) ec.getInstancePool().get(); // Pass it to the method invocation mi.setEnterpriseContext(ctx); // Give it the transaction ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME); Object result; try { // Invoke through interceptors result = getNext().invokeHome(mi); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // No id, means we can put the context back in the pool if (ctx.getId() == null) { ctx.setTransaction(null); ec.getInstancePool().free(ctx); } // We are done return result; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // The key Object key = mi.getId(); EntityEnterpriseContext ctx = null; EntityContainer ec = (EntityContainer) container; if (mi.getTransaction() != null) { //ctx = ec.getTxEntityMap().getCtx(mi.getTransaction(), key); } if (ctx == null) { InstancePool pool = ec.getInstancePool(); try { ctx = (EntityEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } ctx.setCacheKey(key); ctx.setId(key); EntityPersistenceManager pm = ec.getPersistenceManager(); pm.activateEntity(ctx); } boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Begin invoke, key="+key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); try { Object ret = getNext().invoke(mi); return ret; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
public void create() throws Exception { super.start(); BeanMetaData md = getContainer().getBeanMetaData(); ejbName = md.getEjbName(); // Should we log call details callLogging = md.getContainerConfiguration().getCallLogging(); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
public Object invokeHome(Invocation invocation) throws Exception { String methodName; if (invocation.getMethod() != null) { methodName = invocation.getMethod().getName(); } else { methodName = "<no method>"; } boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Start method=" + methodName); } // Log call details if (callLogging) { StringBuffer str = new StringBuffer("InvokeHome: "); str.append(methodName); str.append("("); Object[] args = invocation.getArguments(); if (args != null) { for (int i = 0; i < args.length; i++) { if (i > 0) { str.append(","); } str.append(args[i]); } } str.append(")"); log.debug(str.toString()); } try { return getNext().invokeHome(invocation); } catch(Throwable e) { throw handleException(e, invocation); } finally { if (trace) { log.trace("End method=" + methodName); } } }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
public Object invoke(Invocation invocation) throws Exception { String methodName; if (invocation.getMethod() != null) { methodName = invocation.getMethod().getName(); } else { methodName = "<no method>"; } boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Start method=" + methodName); } // Log call details if (callLogging) { StringBuffer str = new StringBuffer("Invoke: "); if (invocation.getId() != null) { str.append("["); str.append(invocation.getId().toString()); str.append("] "); } str.append(methodName); str.append("("); Object[] args = invocation.getArguments(); if (args != null) { for (int i = 0; i < args.length; i++) { if (i > 0) { str.append(","); } str.append(args[i]); } } str.append(")"); log.debug(str.toString()); } try { return getNext().invoke(invocation); } catch(Throwable e) { throw handleException(e, invocation); } finally { if (trace) { log.trace("End method=" + methodName); } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
public void create() throws Exception { // Do initialization in superclass. super.create(); // bind java:comp/UserTransaction RefAddr refAddr = new RefAddr("userTransaction") { /** This is never really serialized */ private static final long serialVersionUID = -8228448967597474960L; public Object getContent() { return userTransaction; } }; Reference ref = new Reference("javax.transaction.UserTransaction", refAddr, new UserTxFactory().getClass() .getName(), null); ((Context) new InitialContext().lookup("java:comp/")).bind("UserTransaction", ref); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
protected Object invokeNext(Invocation mi) throws Exception { // Save the transaction that comes with the MI Transaction oldTransaction = mi.getTransaction(); // Get old threadlocal: It may be non-null if one BMT bean does a local // call to another. Object oldUserTx = userTransaction.get(); // Suspend any transaction associated with the thread: It may be // non-null on optimized local calls. Transaction threadTx = tm.suspend(); try { EnterpriseContext ctx = ((EnterpriseContext) mi.getEnterpriseContext()); // Set the threadlocal to the userTransaction of the instance try { AllowedOperationsAssociation.pushInMethodFlag(IN_INTERCEPTOR_METHOD); userTransaction.set(ctx.getEJBContext().getUserTransaction()); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Get the bean instance transaction Transaction beanTx = ctx.getTransaction(); // Resume the bean instance transaction // only if it not null, some TMs can't resume(null), e.g. Tyrex if (beanTx != null) tm.resume(beanTx); // Let the MI know about our new transaction mi.setTransaction(beanTx); try { // Let the superclass call next interceptor and do the exception // handling return super.invokeNext(mi, false); } finally { try { if (stateless) checkStatelessDone(); else checkBadStateful(); } finally { tm.suspend(); } } } finally { // Reset threadlocal to its old value userTransaction.set(oldUserTx); // Restore old MI transaction // OSH: Why ??? mi.setTransaction(oldTransaction); // If we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
public Object getObjectInstance(Object ref, Name name, Context nameCtx, Hashtable environment) throws Exception { // The ref is a list with only one RefAddr ... RefAddr refAddr = ((Reference) ref).get(0); // ... whose content is the threadlocal ThreadLocal threadLocal = (ThreadLocal) refAddr.getContent(); // The threadlocal holds the right UserTransaction return threadLocal.get(); }
// in src/main/java/org/jboss/ejb/plugins/SSLSessionInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { extractSessionPrincipal(mi); Object returnValue = getNext().invokeHome(mi); return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/SSLSessionInterceptor.java
public Object invoke(Invocation mi) throws Exception { extractSessionPrincipal(mi); Object returnValue = getNext().invoke(mi); return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstancePool.java
protected void createService() throws Exception { super.createService(); // for MDB, we *do* pool this.reclaim = true; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { return new MessageDrivenEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenTxInterceptorBMT.java
public Object invoke(Invocation mi) throws Exception { return invokeNext(mi); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Invocation on the handle, we don't need a bean instance if (getEJBObject.equals(mi.getMethod())) return getNext().invokeHome(mi); // get a new context from the pool (this is a home method call) InstancePool pool = container.getInstancePool(); EnterpriseContext ctx = pool.get(); // set the context on the Invocation mi.setEnterpriseContext(ctx); // It is a new context for sure so we can lock it ctx.lock(); // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME); try { // Invoke through interceptors return getNext().invokeHome(mi); } finally { synchronized (ctx) { AllowedOperationsAssociation.popInMethodFlag(); // Release the lock ctx.unlock(); // Still free? Not free if create() was called successfully if (ctx.getId() == null) { pool.free(ctx); } } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { InstanceCache cache = container.getInstanceCache(); InstancePool pool = container.getInstancePool(); Object methodID = mi.getId(); EnterpriseContext ctx = null; BeanLock lock = container.getLockManager().getLock(methodID); boolean callerRunAsIdentityPresent = SecurityActions.peekRunAsIdentity() != null; boolean pushSecurityContext = SecurityActions.getSecurityContext() == null; try { /* The security context must be established before the cache lookup because the activation of a session should have the caller's security context as ejbActivate is allowed to call other secured resources. Since the pm makes the ejbActivate call, we need to set the caller's security context. The only reason this shows up for stateful session is that we moved the SecurityInterceptor to after the instance interceptor to allow security exceptions to result in invalidation of the session. This may be too literal an interpretation of the ejb spec requirement that runtime exceptions should invalidate the session. */ if(!callerRunAsIdentityPresent && pushSecurityContext) { AuthenticationManager am = container.getSecurityManager(); String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(am != null) securityDomain = am.getSecurityDomain(); SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain , null); //SecurityActions.pushSubjectContext(mi.getPrincipal(), mi.getCredential(), null); } lock.sync(); try { // Get context try { ctx = cache.get(methodID); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } // Associate it with the method invocation mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // BMT beans will lock and replace tx no matter what, CMT do work on transaction boolean isBMT = ((SessionMetaData)container.getBeanMetaData()).isBeanManagedTx(); if (isBMT == false) { // Do we have a running transaction with the context if (ctx.getTransaction() != null && // And are we trying to enter with another transaction !ctx.getTransaction().equals(mi.getTransaction())) { // Calls must be in the same transaction StringBuffer msg = new StringBuffer("Application Error: " + "tried to enter Stateful bean with different tx context"); msg.append(", contextTx: " + ctx.getTransaction()); msg.append(", methodTx: " + mi.getTransaction()); throw new EJBException(msg.toString()); } //If the instance will participate in a new transaction we register a sync for it if (ctx.getTransaction() == null && mi.getTransaction() != null) { register(ctx, mi.getTransaction(), lock); } } if (!ctx.isLocked()) { //take it! ctx.lock(); } else { if (!isCallAllowed(mi)) { // Concurent calls are not allowed throw new EJBException("Application Error: no concurrent " + "calls on stateful beans"); } else { ctx.lock(); } } } finally { lock.releaseSync(); } // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); boolean validContext = true; try { // Invoke through interceptors Object ret = getNext().invoke(mi); return ret; } catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } } } finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
public void start() throws Exception { super.start(); authenticationObserver = (AuthenticationObserver) Registry.lookup(AuthenticationObserver.KEY); //Take care of hot deployed security domains if (container != null) { securityManager = container.getSecurityManager(); if (securityManager != null) { appSecurityDomain = securityManager.getSecurityDomain(); appSecurityDomain = SecurityUtil.unprefixSecurityDomain(appSecurityDomain); } } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { boolean isInvoke = false; return process(mi, isInvoke); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean isInvoke = true; return process(mi, isInvoke); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private Object process(Invocation mi, boolean isInvoke) throws Exception { if (this.shouldBypassSecurity(mi)) { if (log.isTraceEnabled()) log.trace("Bypass security for invoke or invokeHome"); if (isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } SecurityContext sc = SecurityActions.getSecurityContext(); if (sc == null) throw new IllegalStateException("Security Context is null"); RunAs callerRunAsIdentity = sc.getIncomingRunAs(); if (log.isTraceEnabled()) log.trace("Caller RunAs=" + callerRunAsIdentity + ": useCallerIdentity=" + this.isUseCallerIdentity); // Authenticate the subject and apply any declarative security checks try { checkSecurityContext(mi, callerRunAsIdentity); } catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; } RunAs runAsIdentityToPush = runAsIdentity; /** * Special case: if <use-caller-identity> configured and * the caller is arriving with a run-as, we need to push that run-as */ if (callerRunAsIdentity != null && this.isUseCallerIdentity) runAsIdentityToPush = callerRunAsIdentity; /* If a run-as role was specified, push it so that any calls made by this bean will have the runAsRole available for declarative security checks. */ SecurityActions.pushRunAsIdentity(runAsIdentityToPush); try { if (isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } finally { SecurityActions.popRunAsIdentity(); SecurityActions.popSubjectContext(); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private void checkSecurityContext(Invocation mi, RunAs callerRunAsIdentity) throws Exception { Principal principal = mi.getPrincipal(); Object credential = mi.getCredential(); boolean trace = log.isTraceEnabled(); // If there is not a security manager then there is no authentication required Method m = mi.getMethod(); boolean containerMethod = m == null || m.equals(ejbTimeout); if (containerMethod == true || securityManager == null || container == null) { // Allow for the propagation of caller info to other beans SecurityActions.pushSubjectContext(principal, credential, null); return; } if (realmMapping == null) { throw new SecurityException("Role mapping manager has not been set"); } SecurityContext sc = SecurityActions.getSecurityContext(); EJBAuthenticationHelper helper = SecurityHelperFactory.getEJBAuthenticationHelper(sc); boolean isTrusted = containsTrustableRunAs(sc) || helper.isTrusted(); if (!isTrusted) { // Check the security info from the method invocation Subject subject = new Subject(); if (SecurityActions.isValid(helper, subject, m.getName()) == false) { // Notify authentication observer if (authenticationObserver != null) authenticationObserver.authenticationFailed(); // Else throw a generic SecurityException String msg = "Authentication exception, principal=" + principal; throw new SecurityException(msg); } else { SecurityActions.pushSubjectContext(principal, credential, subject); if (trace) { log.trace("Authenticated principal=" + principal + " in security domain=" + sc.getSecurityDomain()); } } } else { // Duplicate the current subject context on the stack since //SecurityActions.dupSubjectContext(); SecurityActions.pushRunAsIdentity(callerRunAsIdentity); } Method ejbMethod = mi.getMethod(); // Ignore internal container calls if (ejbMethod == null) return; // Get the caller Subject caller = SecurityActions.getContextSubject(); if (caller == null) throw new IllegalStateException("Authenticated User. But caller subject is null"); //Establish the deployment rolename-principalset custom mapping(if available) SecurityRolesAssociation.setSecurityRoles(this.deploymentRoles); boolean isAuthorized = false; Set<Principal> methodRoles = container.getMethodPermissions(ejbMethod, mi.getType()); SecurityContext currentSC = SecurityActions.getSecurityContext(); if (SecurityActions.getSecurityManagement(currentSC) == null) SecurityActions.setSecurityManagement(currentSC, securityManagement); AbstractEJBAuthorizationHelper authorizationHelper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); authorizationHelper.setPolicyRegistration(container.getPolicyRegistration()); isAuthorized = SecurityActions.authorize(authorizationHelper, ejbName, ejbMethod, mi.getPrincipal(), mi.getType().toInterfaceString(), ejbCS, caller, callerRunAsIdentity, container.getJaccContextID(), new SimpleRoleGroup(methodRoles)); if (!isAuthorized) { String msg = "Denied: caller with subject=" + caller + " and security context post-mapping roles=" + SecurityActions.getRolesFromSecurityContext(currentSC) + ": ejbMethod=" + ejbMethod; throw new SecurityException(msg); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private boolean shouldBypassSecurity(Invocation mi) throws Exception { // If there is not a security manager then there is no authentication required Method m = mi.getMethod(); boolean containerMethod = m == null || m.equals(ejbTimeout); if (containerMethod == true || securityManager == null || container == null) { // Allow for the propagation of caller info to other beans SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), "BYPASSED-SECURITY"); if (this.runAsIdentity != null) SecurityActions.pushRunAsIdentity(runAsIdentity); return true; } return false; }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
public void create() throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
protected void setProxyFactory(String invokerBinding, Invocation mi) throws Exception { // if (BeanMetaData.LOCAL_INVOKER_PROXY_BINDING.equals(invokerBinding)) return; if (invokerBinding == null) { log.trace("invokerBInding is null in ProxyFactoryFinder"); return; } /* if (invokerBinding == null) { log.error("***************** invokerBinding is null ********"); log.error("Method name: " + mi.getMethod().getName()); log.error("jmx name: " + container.getJmxName().toString()); new Throwable().printStackTrace(); log.error("*************************"); throw new EJBException("Couldn't insert proxy factory, " + "invokerBinding was null"); } */ Object proxyFactory = container.lookupProxyFactory(invokerBinding); if (proxyFactory == null) { String methodName; if(mi.getMethod() != null) { methodName = mi.getMethod().getName(); } else { methodName ="<no method>"; } log.error("***************** proxyFactory is null ********"); log.error("Method name: " + methodName); log.error("jmx name: " + container.getJmxName().toString()); log.error("invokerBinding: " + invokerBinding); log.error("Stack trace", new Throwable()); log.error("*************************"); throw new EJBException("Couldn't find proxy factory"); } container.setProxyFactory(proxyFactory); }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { String invokerBinding = (String)mi.getAsIsValue(InvocationKey.INVOKER_PROXY_BINDING); setProxyFactory(invokerBinding, mi); String oldInvokerBinding = ENCThreadLocalKey.getKey(); // Only override current ENC binding if we're not local // if ((!BeanMetaData.LOCAL_INVOKER_PROXY_BINDING.equals(invokerBinding)) || oldInvokerBinding == null) if (invokerBinding != null || oldInvokerBinding == null) { ENCThreadLocalKey.setKey(invokerBinding); } Interceptor next = getNext(); Object value = null; try { value = next.invokeHome(mi); } finally { ENCThreadLocalKey.setKey(oldInvokerBinding); // JBAS-4192 clear the container's thread local container.setProxyFactory(null); } return value; }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
public Object invoke(Invocation mi) throws Exception { String invokerBinding = (String)mi.getAsIsValue(InvocationKey.INVOKER_PROXY_BINDING); setProxyFactory(invokerBinding, mi); String oldInvokerBinding = ENCThreadLocalKey.getKey(); // Only override current ENC binding if we're not local or there has not been a previous call // if ((!BeanMetaData.LOCAL_INVOKER_PROXY_BINDING.equals(invokerBinding)) || oldInvokerBinding == null) if (invokerBinding != null || oldInvokerBinding == null) { ENCThreadLocalKey.setKey(invokerBinding); } Interceptor next = getNext(); Object value = null; try { value = next.invoke(mi); } finally { ENCThreadLocalKey.setKey(oldInvokerBinding); // JBAS-4192 clear the container's thread local container.setProxyFactory(null); } return value; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorBMT.java
public void create() throws Exception { // Do initialization in superclass. super.create(); // Set the atateless attribute stateless = ((SessionMetaData)container.getBeanMetaData()).isStateless(); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorBMT.java
public Object invokeHome(Invocation mi) throws Exception { // stateless: no context, no transaction, no call to the instance if (stateless || mi.getEnterpriseContext() == null) return getNext().invokeHome(mi); else return invokeNext(mi); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorBMT.java
public Object invoke(Invocation mi) throws Exception { return invokeNext(mi); }
// in src/main/java/org/jboss/ejb/plugins/security/SecurityActions.java
static SecurityContext createAndSetSecurityContext(final String domain, final String fqnClassName) throws PrivilegedActionException { return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>() { public SecurityContext run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain, fqnClassName); setSecurityContext(sc); return sc; }} ); }
// in src/main/java/org/jboss/ejb/plugins/security/SecurityActions.java
public SecurityContext run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain, fqnClassName); setSecurityContext(sc); return sc; }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
Override public Object invoke(Invocation mi) throws Exception { boolean isInvoke = true; return this.process(mi, isInvoke); }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
Override public Object invokeHome(Invocation mi) throws Exception { boolean isInvoke = false; return this.process(mi, isInvoke); }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
private Object process(Invocation mi, boolean isInvoke) throws Exception { //No Security in the absence of SecurityDomain if(securityDomain == null) { if(isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } if (log.isTraceEnabled()) { log.trace("process:isInvoke="+isInvoke + " bean="+ container.getServiceName()); } SecurityIdentity si = null; String incomingDomain = null; Method m = mi.getMethod(); boolean isEjbTimeOutMethod = m!= null && m.getName().equals(timedObjectMethod); //For local ejb invocations if(mi.isLocal() && !isEjbTimeOutMethod) { if (log.isTraceEnabled()) { log.trace("True mi.isLocal() && !isEjbTimeOutMethod"); } //Cache the security context SecurityContext sc = SecurityActions.getSecurityContext(); if(sc != null) { si = SecurityActions.getSecurityIdentity(sc); incomingDomain = sc.getSecurityDomain(); } SecurityActions.setSecurityManagement(sc, container.getSecurityManagement()); // set the container's security domain in the security context SecurityActions.setSecurityDomain(sc, this.securityDomain); if (log.isTraceEnabled()) { log.trace("SecurityIdentity="+SecurityActions.trace(si)); } //Set the security context on the invocation mi.setSecurityContext(sc); } else { if (log.isTraceEnabled()) { log.trace("False mi.isLocal() && !isEjbTimeOutMethod"); } establishSecurityContext(mi); } try { //Establish the run-as on the SC as the caller SC SecurityContext currentSC = SecurityActions.getSecurityContext(); SecurityActions.pushCallerRunAsIdentity(currentSC.getOutgoingRunAs()); if (log.isTraceEnabled()) { log.trace("Going to the SecurityInterceptor with SC="+SecurityActions.trace(currentSC)); } if(isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } finally { SecurityActions.popCallerRunAsIdentity(); if(mi.isLocal() && si != null) SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si); if(mi.isLocal() && incomingDomain != null) SecurityActions.setSecurityDomain(SecurityActions.getSecurityContext(), incomingDomain); if (log.isTraceEnabled()) { log.trace("Exit process():isInvoke="+isInvoke); } } }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
private void establishSecurityContext(Invocation mi) throws Exception { //For Local EJB invocations, the security context needs //to be obtained from the thread local. For remote ejb //invocations, the SC is obtained in the invocation SecurityContext sc = mi.getSecurityContext(); SecurityContext newSC = SecurityActions.createAndSetSecurityContext(securityDomain, container.getSecurityContextClassName()); if(sc != null) { //Get the run-as, principal, cred etc from the invocation and set it on the context SecurityActions.setSecurityIdentity(newSC, SecurityActions.getSecurityIdentity(sc)); } else { //Local EJB Invocation or some one created the Invocation object on the server side mi.setSecurityContext(newSC); } //Set the SecurityManagement on the context SecurityActions.setSecurityManagement(newSC, container.getSecurityManagement()); if (log.isTraceEnabled()) { log.trace("establishSecurityIdentity:SecCtx="+SecurityActions.trace(newSC)); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
public void create() throws Exception { super.create(); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void invokeEjbStore(Thread thread, EntityEnterpriseContext instance) throws Exception { if(instance.getId() != null) { EntityContainer container = (EntityContainer) instance.getContainer(); // set the context class loader before calling the store method SecurityActions.setContextClassLoader(thread, container.getClassLoader()); container.pushENC(); try { // store it container.invokeEjbStore(instance); } finally { container.popENC(); } } }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { // only synchronize if the id is not null. A null id means // that the entity has been removed. if(instance.getId() != null) { EntityContainer container = (EntityContainer) instance.getContainer(); // set the context class loader before calling the store method SecurityActions.setContextClassLoader(thread, container.getClassLoader()); container.pushENC(); try { // store it container.storeEntity(instance); instance.setTxAssociation(SYNCHRONIZED); } finally { container.popENC(); } } }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { EntityContainer container = (EntityContainer)instance.getContainer(); if(container.getPersistenceManager().isStoreRequired(instance)) { throw new EJBException("The instance of " + container.getBeanMetaData().getEjbName() + " with pk=" + instance.getId() + " was not stored to prevent potential inconsistency of data in the database:" + " the instance was evicted from the cache during the transaction" + " and the database was possibly updated by another process."); } }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void invokeEjbStore(Thread thread, EntityEnterpriseContext instance) throws Exception { GlobalTxEntityMap.SYNC_SCHEDULED.invokeEjbStore(thread, instance); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void invokeEjbStore(Thread thread, EntityEnterpriseContext instance) throws Exception { }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object createBeanClassInstance() throws Exception { return persistenceManager.createBeanClassInstance(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void createService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Acquire classes from CL if (metaData.getHome() != null) homeInterface = classLoader.loadClass(metaData.getHome()); if (metaData.getRemote() != null) remoteInterface = classLoader.loadClass(metaData.getRemote()); // Call default init super.createService(); // Make some additional validity checks with regards to the container configuration checkCoherency (); // Map the bean methods setupBeanMapping(); // Map the home methods setupHomeMapping(); // Map the interfaces to Long setupMarshalledInvocationMapping(); // Try to register the instance pool as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instancePool, poolName); } catch(Throwable t) { log.debug("Failed to register cache as mbean", t); } // Initialize pool instancePool.setContainer(this); instancePool.create(); for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); ci.create(); } // Try to register the instance cache as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "cache"); ObjectName cacheName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instanceCache, cacheName); } catch(Throwable t) { log.debug("Failed to register cache as mbean", t); } // Init instance cache instanceCache.setContainer(this); instanceCache.create(); // Init persistence persistenceManager.setContainer(this); persistenceManager.create(); // Initialize the interceptor by calling the chain Interceptor in = interceptor; while (in != null) { in.setContainer(this); in.create(); in = in.getNext(); } readOnly = ((EntityMetaData)metaData).isReadOnly(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void startService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default start super.startService(); // Start container invokers for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); ci.start(); } // Start instance cache instanceCache.start(); // Start the instance pool instancePool.start(); Interceptor i = interceptor; while(i != null) { i.start(); i = i.getNext(); } // Restore persisted ejb timers restoreTimers(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void stopService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { //Stop items in reverse order from start //This assures that CachedConnectionInterceptor will get removed //from in between this and the pm before the pm is stopped. // Stop all interceptors in the chain Interceptor in = interceptor; while (in != null) { in.stop(); in = in.getNext(); } // Stop the instance pool instancePool.stop(); // Stop persistence persistenceManager.stop(); // Stop instance cache instanceCache.stop(); // Stop container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); ci.stop(); } // Call default stop super.stopService(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void destroyService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Destroy container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); ci.destroy(); } // Destroy instance cache instanceCache.destroy(); instanceCache.setContainer(null); try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "cache"); ObjectName cacheName = new ObjectName(containerName.getDomain(), props); server.unregisterMBean(cacheName); } catch(Throwable ignore) { } // Destroy persistence persistenceManager.destroy(); persistenceManager.setContainer(null); // Destroy the pool instancePool.destroy(); instancePool.setContainer(null); try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.unregisterMBean(poolName); } catch(Throwable ignore) { } // Destroy all the interceptors in the chain Interceptor in = interceptor; while (in != null) { in.destroy(); in.setContainer(null); in = in.getNext(); } MarshalledInvocation.removeHashes(homeInterface); MarshalledInvocation.removeHashes(remoteInterface); // Call default destroy super.destroyService(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Map to EJBHome.remove(Object) to EJBObject.remove() InvocationType type = mi.getType(); if (type == InvocationType.HOME) mi.setType(InvocationType.REMOTE); else if (type == InvocationType.LOCALHOME) mi.setType(InvocationType.LOCAL); mi.setMethod(EJBOBJECT_REMOVE); // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); mi.setId(ejbObject.getPrimaryKey()); } else mi.setId(arg); mi.setArguments(new Object[0]); return getInterceptor().invoke(mi); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object internalInvoke(Invocation mi) throws Exception { // Invoke through interceptors return getInterceptor().invoke(mi); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBLocalObject createLocalHome(Invocation mi) throws Exception { // The persistence manager takes care of the wiring and creating the EJBLocalObject final EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().createEntity(mi.getMethod(), mi.getArguments(), ctx); // The context implicitely carries the EJBObject createCount++; return localProxyFactory.getEntityEJBLocalObject(ctx.getId(), true); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void postCreateLocalHome(Invocation mi) throws Exception { // The persistence manager takes care of the post create step getPersistenceManager().postCreateEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object findLocal(Invocation mi) throws Exception { Method method = mi.getMethod(); Object[] args = mi.getArguments(); EntityEnterpriseContext instance = (EntityEnterpriseContext)mi.getEnterpriseContext(); boolean syncOnCommitOnly = metaData.getContainerConfiguration().getSyncOnCommitOnly(); Transaction tx = mi.getTransaction(); Class returnType = method.getReturnType(); if (Collection.class.isAssignableFrom(returnType) || returnType == Enumeration.class) { // as per the spec 9.6.4, entities must be synchronized with the datastore when an ejbFind<METHOD> is called. if (!syncOnCommitOnly) { synchronizeEntitiesWithinTransaction(tx); } // Iterator finder Collection c = getPersistenceManager().findEntities(method, args, instance, localProxyFactory); // BMP entity finder methods are allowed to return java.util.Enumeration. if (returnType == Enumeration.class) { return java.util.Collections.enumeration(c); } else { return c; } } else { return findSingleObject(tx, method, args, instance, localProxyFactory); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object find(Invocation mi) throws Exception { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Method method = mi.getMethod(); Object[] args = mi.getArguments(); EntityEnterpriseContext instance = (EntityEnterpriseContext)mi.getEnterpriseContext(); boolean syncOnCommitOnly = metaData.getContainerConfiguration().getSyncOnCommitOnly(); Transaction tx = mi.getTransaction(); Class returnType = method.getReturnType(); if (Collection.class.isAssignableFrom(returnType) || returnType == Enumeration.class) { // as per the spec 9.6.4, entities must be synchronized with the datastore when an ejbFind<METHOD> is called. if (!syncOnCommitOnly) { synchronizeEntitiesWithinTransaction(tx); } // Iterator finder Collection c = getPersistenceManager().findEntities(method, args, instance, ci); // BMP entity finder methods are allowed to return java.util.Enumeration. // We need a serializable Enumeration, so we can't use Collections.enumeration() if (returnType == Enumeration.class) { return new SerializableEnumeration(c); } else { return c; } } else { return findSingleObject(tx, method, args, instance, ci); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void invokeEjbStore(EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() != null) { final EntityPersistenceManager pm = getPersistenceManager(); pm.invokeEjbStore(ctx); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void storeEntity(EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() != null) { final EntityPersistenceManager pm = getPersistenceManager(); if(pm.isStoreRequired(ctx)) { pm.storeEntity(ctx); } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void postCreateHome(Invocation mi) throws Exception { // The persistence manager takes care of the post create step getPersistenceManager().postCreateEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBObject createHome(Invocation mi) throws Exception { // The persistence manager takes care of the wiring and creating the EJBObject getPersistenceManager().createEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); // The context implicitely carries the EJBObject createCount++; return ((EntityEnterpriseContext)mi.getEnterpriseContext()).getEJBObject(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private void setupHomeMappingImpl(Method[] m, String finderName, String append) throws Exception { // Adrian Brock: This should go away when we don't support EJB1x boolean isEJB1x = metaData.getApplicationMetaData().isEJB1x(); for (int i = 0; i < m.length; i++) { String methodName = m[i].getName(); try { try // Try home method { String ejbHomeMethodName = "ejbHome" + methodName.substring(0,1).toUpperCase() + methodName.substring(1); homeMapping.put(m[i], beanClass.getMethod(ejbHomeMethodName, m[i].getParameterTypes())); continue; } catch (NoSuchMethodException ignore) {} // just go on with other types of methods // Implemented by container (in both cases) if (methodName.startsWith("find")) { homeMapping.put(m[i], this.getClass().getMethod(finderName, new Class[] { Invocation.class })); } else if (methodName.equals("create") || (isEJB1x == false && methodName.startsWith("create"))) { homeMapping.put(m[i], this.getClass().getMethod("create"+append, new Class[] { Invocation.class })); beanMapping.put(m[i], this.getClass().getMethod("postCreate"+append, new Class[] { Invocation.class })); } else { homeMapping.put(m[i], this.getClass().getMethod(methodName+append, new Class[] { Invocation.class })); } } catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void setupHomeMapping() throws Exception { try { if (homeInterface != null) { Method[] m = homeInterface.getMethods(); setupHomeMappingImpl( m, "find", "Home" ); } if (localHomeInterface != null) { Method[] m = localHomeInterface.getMethods(); setupHomeMappingImpl( m, "findLocal", "LocalHome" ); } // Special methods // Get the One on Handle (getEJBObject), get the class Class handleClass = Class.forName("javax.ejb.Handle"); // Get the methods (there is only one) Method[] handleMethods = handleClass.getMethods(); //Just to make sure let's iterate for (int j=0; j<handleMethods.length ;j++) { //Get only the one called handle.getEJBObject if (handleMethods[j].getName().equals("getEJBObject")) { //Map it in the home stuff homeMapping.put(handleMethods[j], this.getClass().getMethod("getEJBObject", new Class[] {Invocation.class})); } } } catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private void setupBeanMappingImpl( Method[] m, String intfName ) throws Exception { for (int i = 0; i < m.length; i++) { if (!m[i].getDeclaringClass().getName().equals(intfName)) { // Implemented by bean beanMapping.put(m[i], beanClass.getMethod(m[i].getName(), m[i].getParameterTypes())); } else { // Implemented by container beanMapping.put(m[i], getClass().getMethod(m[i].getName(), new Class[] { Invocation.class })); } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void setupBeanMapping() throws Exception { try { if (remoteInterface != null) { Method[] m = remoteInterface.getMethods(); setupBeanMappingImpl( m, "javax.ejb.EJBObject" ); } if (localInterface != null) { Method[] m = localInterface.getMethods(); setupBeanMappingImpl( m, "javax.ejb.EJBLocalObject" ); } if( TimedObject.class.isAssignableFrom( beanClass ) ) { // Map ejbTimeout beanMapping.put( TimedObject.class.getMethod( "ejbTimeout", new Class[] { Timer.class } ), beanClass.getMethod( "ejbTimeout", new Class[] { Timer.class } ) ); } } catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void setupMarshalledInvocationMapping() throws Exception { // Create method mappings for container invoker if (homeInterface != null) { Method [] m = homeInterface.getMethods(); for (int i = 0 ; i<m.length ; i++) { marshalledInvocationMapping.put( new Long(MarshalledInvocation.calculateHash(m[i])), m[i]); } } if (remoteInterface != null) { Method [] m = remoteInterface.getMethods(); for (int j = 0 ; j<m.length ; j++) { marshalledInvocationMapping.put( new Long(MarshalledInvocation.calculateHash(m[j])), m[j]); } } // Get the getEJBObjectMethod Method getEJBObjectMethod = Class.forName("javax.ejb.Handle").getMethod("getEJBObject", new Class[0]); // Hash it marshalledInvocationMapping.put(new Long(MarshalledInvocation.calculateHash(getEJBObjectMethod)),getEJBObjectMethod); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void checkCoherency () throws Exception { // Check clustering cohrency wrt metadata // if (metaData.isClustered()) { boolean clusteredProxyFactoryFound = false; for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); if (ci instanceof org.jboss.proxy.ejb.ClusterProxyFactory) clusteredProxyFactoryFound = true; } if (!clusteredProxyFactoryFound) { log.warn("*** EJB '" + this.metaData.getEjbName() + "' deployed as CLUSTERED but not a single clustered-invoker is bound to container ***"); } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private Object findSingleObject(Transaction tx, Method method, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if(method.getName().equals("findByPrimaryKey")) { if(args[0] == null) throw new IllegalArgumentException("findByPrimaryKey called with null argument."); if(metaData.getContainerConfiguration().getCommitOption() != ConfigurationMetaData.B_COMMIT_OPTION) { Object key = instance.getCacheKey(); if(key == null) { key = ((EntityCache)instanceCache).createCacheKey(args[0]); } if(instanceCache.isActive(key)) { return factory.getEntityEJBObject(key); } } } else if(!metaData.getContainerConfiguration().getSyncOnCommitOnly()) { EntityContainer.synchronizeEntitiesWithinTransaction(tx); } return getPersistenceManager().findEntity(method, args, instance, factory); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke and handle exceptions Method miMethod = mi.getMethod(); Method m = (Method) homeMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } if (m.getDeclaringClass().equals(EntityContainer.class)) { try { return mi.performCall(EntityContainer.this, m, new Object[] { mi }); } catch (Exception e) { rethrow(e); } } else // Home method { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); try { AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_EJB_HOME); return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } finally{ AllowedOperationsAssociation.popInMethodFlag(); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) beanMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(EntityContainer.class)) { // Invoke container try { return mi.performCall(EntityContainer.this, m, new Object[]{ mi }); } catch (Exception e) { rethrow(e); } } else { // Invoke bean instance try { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); Object instance = ctx.getInstance(); return mi.performCall(instance, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/Shutdown.java
public static void main(final String[] args) throws Exception { if (args.length == 0) { displayUsage(); System.exit(0); } String sopts = "-:hD:s:n:a:u:p:S::v::o:r:"; LongOpt[] lopts = { new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'), new LongOpt("server", LongOpt.REQUIRED_ARGUMENT, null, 's'), new LongOpt("adapter", LongOpt.REQUIRED_ARGUMENT, null, 'a'), new LongOpt("serverName", LongOpt.REQUIRED_ARGUMENT, null, 'n'), new LongOpt("shutdown", LongOpt.NO_ARGUMENT, null, 'S'), new LongOpt("user", LongOpt.REQUIRED_ARGUMENT, null, 'u'), new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'), new LongOpt("password", LongOpt.REQUIRED_ARGUMENT, null, 'p'), new LongOpt("host", LongOpt.REQUIRED_ARGUMENT, null, 'o'), new LongOpt("port", LongOpt.REQUIRED_ARGUMENT, null, 'r'), }; Getopt getopt = new Getopt(PROGRAM_NAME, args, sopts, lopts); int code; String arg; String serverURL = null; String username = null; String password = null; ObjectName serverJMXName = new ObjectName("jboss.system:type=Server"); String hostname=null; String port=null; boolean verbose = false; while ((code = getopt.getopt()) != -1) { switch (code) { case ':': case '?': // for now both of these should exit with error status System.exit(1); break; case 1: // this will catch non-option arguments // (which we don't currently care about) System.err.println(PROGRAM_NAME + ": unused non-option argument: " + getopt.getOptarg()); break; case 'h': displayUsage(); System.exit(0); break; case 'D': { // set a system property arg = getopt.getOptarg(); String name, value; int i = arg.indexOf("="); if (i == -1) { name = arg; value = "true"; } else { name = arg.substring(0, i); value = arg.substring(i + 1, arg.length()); } System.setProperty(name, value); break; } case 's': serverURL = getopt.getOptarg(); break; case 'n': serverJMXName = new ObjectName(getopt.getOptarg()); break; case 'S': // nothing... break; case 'a': String adapterName = getopt.getOptarg(); System.out.println("adapter name is ignored " + adapterName); break; case 'u': username = getopt.getOptarg(); break; case 'p': password = getopt.getOptarg(); break; // host name case 'o': hostname = getopt.getOptarg(); break; // host port case 'r': port = getopt.getOptarg(); break; // be noisy case 'v': verbose = true; break; } } // If there was a username specified, but no password prompt for it if( username != null && password == null ) { System.out.print("Enter password for "+username+": "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); password = br.readLine(); } if( serverURL == null) { serverURL = DEFAULT_BASEURL + (hostname != null ? hostname : DEFAULT_HOSTNAME) + ":" + (port != null ? port : DEFAULT_PORT) + DEFAULT_RMIOBJECTNAME; } if( verbose ) { System.out.println("JMX server url=" + serverURL); } HashMap env = new HashMap(); if (username != null && password != null) { if (verbose ) { System.out.println("will connect with username=" + username); } String[] creds = new String[2]; creds[0] = username; creds[1] = password; env.put(JMXConnector.CREDENTIALS, creds); } JMXServiceURL url = new JMXServiceURL(serverURL); JMXConnector jmxc = JMXConnectorFactory.connect(url, env); MBeanServerConnection adaptor = jmxc.getMBeanServerConnection(); ServerProxyHandler handler = new ServerProxyHandler(adaptor, serverJMXName); Class<?>[] ifaces = {JBossASServer.class}; ClassLoader tcl = Thread.currentThread().getContextClassLoader(); JBossASServer server = (JBossASServer) Proxy.newProxyInstance(tcl, ifaces, handler); server.shutdown(); System.out.println("Shutdown message has been posted to the server."); System.out.println("Server shutdown may take a while - check logfiles for completion"); jmxc.close(); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationsTxGrouper.java
public static void registerInvalidationSynchronization(Transaction tx, InvalidationGroup group, Serializable key) throws Exception { InvalidatorSynchronization synch = (InvalidatorSynchronization) synchLocal.get(tx); if(synch == null) { synch = new InvalidatorSynchronization(tx); synchLocal.set(tx, synch); // If there is no tx don't try to use it if( tx != null ) tx.registerSynchronization(synch); } synch.addInvalidation(group, key); // If there is no tx call afterCompletion if( tx == null ) synch.afterCompletion(javax.transaction.Status.STATUS_NO_TRANSACTION); }
// in src/main/java/org/jboss/cache/invalidation/triggers/EntityBeanCacheBatchInvalidatorInterceptor.java
public void start() throws Exception { org.jboss.metadata.EntityMetaData emd = ((org.jboss.metadata.EntityMetaData)this.getContainer ().getBeanMetaData ()); doCacheInvalidations = emd.doDistributedCacheInvalidations (); if (doCacheInvalidations) { // we are interested in receiving cache invalidation callbacks // String groupName = emd.getDistributedCacheInvalidationConfig ().getInvalidationGroupName (); String imName = emd.getDistributedCacheInvalidationConfig ().getInvalidationManagerName (); this.invalMgr = (org.jboss.cache.invalidation.InvalidationManagerMBean)org.jboss.system.Registry.lookup (imName); this.ig = this.invalMgr.getInvalidationGroup (groupName); } }
// in src/main/java/org/jboss/cache/invalidation/triggers/EntityBeanCacheBatchInvalidatorInterceptor.java
protected boolean changed (org.jboss.invocation.Invocation mi, org.jboss.ejb.EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() == null) return true; if(!container.isReadOnly()) { java.lang.reflect.Method method = mi.getMethod(); if(method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { return invalidateRelated ? container.getPersistenceManager().isModified(ctx) : container.getPersistenceManager().isStoreRequired(ctx); } } return false; }
// in src/main/java/org/jboss/cache/invalidation/triggers/EntityBeanCacheBatchInvalidatorInterceptor.java
public Object invoke(org.jboss.invocation.Invocation mi) throws Exception { if (doCacheInvalidations) { // We are going to work with the context a lot org.jboss.ejb.EntityEnterpriseContext ctx = (org.jboss.ejb.EntityEnterpriseContext)mi.getEnterpriseContext(); Object id = ctx.getId(); // The Tx coming as part of the Method Invocation javax.transaction.Transaction tx = mi.getTransaction(); // Invocation with a running Transaction if (tx != null && tx.getStatus() != javax.transaction.Status.STATUS_NO_TRANSACTION) { //Invoke down the chain Object retVal = getNext().invoke(mi); if (changed(mi, ctx)) { org.jboss.cache.invalidation.InvalidationsTxGrouper.registerInvalidationSynchronization (tx, this.ig, (java.io.Serializable)id); } // return the return value return retVal; } // else { // No tx Object result = getNext().invoke(mi); if (changed(mi, ctx)) { org.jboss.cache.invalidation.InvalidationsTxGrouper.registerInvalidationSynchronization (tx, this.ig, (java.io.Serializable)id); } return result; } } else { return getNext().invoke(mi); } }
// in src/main/java/org/jboss/cache/invalidation/triggers/EntityBeanCacheBatchInvalidatorInterceptor.java
public void importXml(Element element) throws Exception { String str = MetaData.getElementAttribute(element, "invalidate-related"); invalidateRelated = (str == null ? true : Boolean.valueOf(str).booleanValue()); if(log.isTraceEnabled()) { log.trace("invalidate-related: " + invalidateRelated); } }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
protected void startService () throws Exception { log.info("Starting JMS cache invalidation bridge"); // Deal with the InvalidationManager first.. // this.invalMgr = (org.jboss.cache.invalidation.InvalidationManagerMBean) org.jboss.system.Registry.lookup (this.invalidationManagerName); this.invalidationSubscription = invalMgr.registerBridgeListener (this); // deal with JMS next // InitialContext iniCtx = getInitialContext (); Object tmp = iniCtx.lookup(this.connectionFactoryName); TopicConnectionFactory tcf = (TopicConnectionFactory) tmp; conn = tcf.createTopicConnection(); topic = (Topic) iniCtx.lookup(this.topicName); session = conn.createTopicSession(this.transacted, this.acknowledgeMode); conn.start(); // Are we publisher, subscriber, or both? // if (this.propagationMode == JMSCacheInvalidationBridgeMBean.IN_OUT_BRIDGE_PROPAGATION || this.propagationMode == JMSCacheInvalidationBridgeMBean.IN_ONLY_BRIDGE_PROPAGATION) { this.subscriber = session.createSubscriber(topic); this.subscriber.setMessageListener(this); } if (this.propagationMode == JMSCacheInvalidationBridgeMBean.IN_OUT_BRIDGE_PROPAGATION || this.propagationMode == JMSCacheInvalidationBridgeMBean.OUT_ONLY_BRIDGE_PROPAGATION) { this.pub = session.createPublisher(topic); this.publishingAuthorized = true; } }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public void startService () throws Exception { // bind us in system registry // log.debug ("Starting Invalidation Manager " + this.getServiceName ().toString ()); org.jboss.system.Registry.bind (this.getServiceName ().toString (), this); this.hashcode = this.getServiceName ().hashCode (); }
// in src/main/java/org/jboss/monitor/BeanCacheMonitor.java
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { m_mbeanServer = server; return name; }
// in src/main/java/org/jboss/monitor/BeanCacheMonitor.java
public void preDeregister() throws Exception {}
// in src/main/java/org/jboss/monitor/EntityLockMonitor.java
protected void startService() throws Exception { bind(); log.info("EntityLockMonitor started"); }
// in src/main/java/org/jboss/web/WebServer.java
public void start() throws Exception { if (executor == null) throw new IllegalArgumentException("Required property 'executor' not specified"); try { server = new ServerSocket(port, backlog, bindAddress); log.debug("Started server: " + server); listen(); } catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); } catch (IOException e) { throw e; } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public synchronized WebApplication start(DeploymentUnit unit, JBossWebMetaData metaData) throws Exception { Thread thread = Thread.currentThread(); ClassLoader appClassLoader = thread.getContextClassLoader(); WebApplication webApp = null; try { // Create a classloader for the war to ensure a unique ENC ClassLoader warLoader = unit.getClassLoader(); thread.setContextClassLoader(warLoader); String webContext = metaData.getContextRoot(); // Get the war URL URL warUrl = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class); if (warUrl == null && unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vdu = VFSDeploymentUnit.class.cast(unit); warUrl = VFSUtils.getPhysicalURL(vdu.getRoot()); } // Dynamic WebMetaData deployments might not provide an URL // We use the DEploymentUnit name as identifier instead. // The JAXWS Endpoint API for example does this. String warURLString = (warUrl != null ? warUrl.toExternalForm() : unit.getName()); // Strip any jar: url syntax. This should be be handled by the vfs if (warURLString.startsWith("jar:")) warURLString = warURLString.substring(4, warURLString.length() - 2); log.debug("webContext: " + webContext); log.debug("warURL: " + warURLString); // Register the permissions with the JACC layer String contextID = metaData.getJaccContextID(); if (contextID == null) contextID = unit.getSimpleName(); metaData.setJaccContextID(contextID); webApp = new WebApplication(metaData); webApp.setClassLoader(warLoader); webApp.setDeploymentUnit(unit); performDeploy(webApp, warURLString); } finally { thread.setContextClassLoader(appClassLoader); } return webApp; }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public synchronized void stop(DeploymentUnit di, WebApplication webApp) throws Exception { URL warURL = webApp.getURL(); String warUrl = warURL.toString(); performUndeploy(webApp, warUrl); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void processEnc(ClassLoader loader, WebApplication webApp) throws Exception { if (loader == null) throw new IllegalArgumentException("Classloader passed to process ENC refs is null"); log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin"); InitialContext iniCtx = new InitialContext(); Context envCtx = null; Thread currentThread = Thread.currentThread(); ClassLoader currentLoader = currentThread.getContextClassLoader(); JBossWebMetaData metaData = webApp.getMetaData(); try { // Create a java:comp/env environment unique for the web application log.debug("Creating ENC using ClassLoader: " + loader); ClassLoader parent = loader.getParent(); while (parent != null) { log.debug(".." + parent); parent = parent.getParent(); } // TODO: The enc should be an input? currentThread.setContextClassLoader(loader); // webApp.setENCLoader(loader); envCtx = (Context)iniCtx.lookup("java:comp"); // TODO: inject the ORB try { ObjectName ORB_NAME = new ObjectName("jboss:service=CorbaORB"); org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB)server.getAttribute(ORB_NAME, "ORB"); // Bind the orb if (orb != null) { NonSerializableFactory.rebind(envCtx, "ORB", orb); log.debug("Bound java:comp/ORB"); } } catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); } // TODO: injection, Add a link to the global transaction manager envCtx.bind("UserTransaction", new LinkRef("UserTransaction")); log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction"); envCtx = envCtx.createSubcontext("env"); processEncReferences(webApp, envCtx); } finally { currentThread.setContextClassLoader(currentLoader); } String securityDomain = metaData.getSecurityDomain(); log.debug("linkSecurityDomain"); linkSecurityDomain(securityDomain, envCtx); log.debug("AbstractWebContainer.parseWebAppDescriptors, End"); }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingDeployer.java
Override protected JSFDeployment parse(DeploymentUnit unit, String name, JSFDeployment output) throws Exception { if (unit instanceof VFSDeploymentUnit == false) { return null; } if (ignoreName(unit, name)) { return null; } VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; List<VirtualFile> facesConfigXmlFiles = vfsDeploymentUnit.getMetaDataFiles(new FacesConfigXmlFileNameMatchFilter(), MetaDataTypeFilter.ALL); if (facesConfigXmlFiles == null || facesConfigXmlFiles.isEmpty()) { return null; } JSFDeployment jsfDeployment = vfsDeploymentUnit.getAttachment(JSFDeployment.class); for (VirtualFile facesConfigXmlFile : facesConfigXmlFiles) { if (this.ignoreFile(vfsDeploymentUnit, facesConfigXmlFile)) { continue; } jsfDeployment = this.parse(vfsDeploymentUnit, facesConfigXmlFile, jsfDeployment); } return jsfDeployment; }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingDeployer.java
Override protected JSFDeployment parse(VFSDeploymentUnit unit, VirtualFile file, JSFDeployment jsfDeployment) throws Exception { URL facesConfigURL = file.toURL(); if (jsfDeployment == null) { // create the jsf deployment. Note that we don't have to attach it to the deployment unit, since that part // will be done by the AbstractVFSParsingDeployer which will attach the return value of this method to the unit. jsfDeployment = new JSFDeployment(); } // parse the xml file and update the jsf deployment FacesConfigParsingUtil.parse(unit, facesConfigURL, jsfDeployment); // return the updated jsf deployment return jsfDeployment; }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public void start() throws Exception { startModule(); }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public void stop() throws Exception { stopModule(); }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public synchronized void startModule() throws Exception { if (this.unit == null || this.container == null || this.deployment == null) throw new IllegalStateException("WebModules cannot be restarted, and must be redeployed"); // Get the war URL JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); WebApplication webApp = deployment.start(unit, metaData); String warURL = unit.getName(); container.addDeployedApp(warURL, webApp); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
public void start() throws Exception { // TODO: remove dependency on jmx this.server = MBeanServerLocator.locateJBoss(); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
public void stop() throws Exception { }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
protected void deployWebModule(DeploymentUnit unit, JBossWebMetaData metaData, AbstractWarDeployment deployment) throws Exception { log.debug("deployWebModule: " + unit.getName()); try { ServiceMetaData webModule = new ServiceMetaData(); String name = getObjectName(metaData); ObjectName objectName = new ObjectName(name); webModule.setObjectName(objectName); webModule.setCode(WebModule.class.getName()); // WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment) ServiceConstructorMetaData constructor = new ServiceConstructorMetaData(); constructor.setSignature(new String[] { DeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() }); constructor.setParameters(new Object[] { unit, this, deployment }); webModule.setConstructor(constructor); List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>(); ServiceAttributeMetaData attr = new ServiceAttributeMetaData(); attr.setName("SecurityManagement"); ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(deployment.getSecurityManagementName()); attr.setValue(injectionValue); attrs.add(attr); ServiceAttributeMetaData attrPR = new ServiceAttributeMetaData(); attrPR.setName("PolicyRegistration"); ServiceInjectionValueMetaData injectionValuePR = new ServiceInjectionValueMetaData(deployment.getPolicyRegistrationName()); attrPR.setValue(injectionValuePR); attrs.add(attrPR); ServiceAttributeMetaData attrKernel = new ServiceAttributeMetaData(); attrKernel.setName("Kernel"); ServiceInjectionValueMetaData injectionValueKernel = new ServiceInjectionValueMetaData(KernelConstants.KERNEL_NAME); attrKernel.setValue(injectionValueKernel); attrs.add(attrKernel); webModule.setAttributes(attrs); // Dependencies...Still have old jmx names here Collection<String> depends = metaData.getDepends(); List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>(); if (depends != null && depends.isEmpty() == false) { if (log.isTraceEnabled()) log.trace(name + " has dependencies: " + depends); for (String iDependOn : depends) { ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData(); sdmd.setIDependOn(iDependOn); dependencies.add(sdmd); } } // SwitchBoard Barrier switchBoard = unit.getAttachment(Barrier.class); if (switchBoard != null) { // Setup switchboard dependency on the deployment ServiceDependencyMetaData switchBoardDependency = new AnyStateServiceDependencyMetaData(switchBoard.getId(), ControllerState.START, ControllerState.INSTALLED); dependencies.add(switchBoardDependency); log.debug("Added switchboard dependency: " + switchBoard.getId() + " for web module: " + name); } // Injection Manager InjectionManager injectionManager = unit.getAttachment(InjectionManager.class); if (injectionManager != null) { // set the InjectionManager on the deployment deployment.setInjectionManager(injectionManager); // Setup the Injector Environment webEnvironment = metaData.getJndiEnvironmentRefsGroup(); if (webEnvironment != null) { // convert JBMETA metadata to jboss-injection specific metadata JndiEnvironmentRefsGroup jndiEnvironment = new JndiEnvironmentImpl(webEnvironment, unit.getClassLoader()); // For optimization, we'll create an Injector only if there's atleast one InjectionTarget if (this.hasInjectionTargets(jndiEnvironment)) { // create the injector EEInjector eeInjector = new EEInjector(jndiEnvironment); // add the injector the injection manager injectionManager.addInjector(eeInjector); // Deploy the Injector as a MC bean (so that the fully populated naming context (obtained via the SwitchBoard // Barrier) gets injected. String injectorMCBeanName = this.getInjectorMCBeanName(unit); BeanMetaData injectorBMD = this.createInjectorBMD(injectorMCBeanName, eeInjector, switchBoard); unit.addAttachment(BeanMetaData.class + ":" + injectorMCBeanName, injectorBMD); // Add the Injector dependency on the deployment (so that the DU doesn't // get started till the Injector is available) ServiceDependencyMetaData injectorDepdendency = new ServiceDependencyMetaData(); injectorDepdendency.setIDependOn(injectorMCBeanName); dependencies.add(injectorDepdendency); log.debug("Added Injector dependency: " + injectorMCBeanName + " for web module: " + name); } } } // TODO: We haven't yet integrated PC and EJB reference providers in SwitchBoard. // The following sections will be removed after the RPs are made available // JBAS-6795 Add dependency on PersistenceContext references PersistenceContextReferencesMetaData pcRefs = metaData.getPersistenceContextRefs(); if (pcRefs != null) { for (PersistenceContextReferenceMetaData pcRef : metaData.getPersistenceContextRefs()) { // TODO: this is a duplication of the logic in PersistenceContextHandler String persistenceUnitName = pcRef.getPersistenceUnitName(); String beanName = persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(unit, persistenceUnitName); ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData(); sdmd.setIDependOn(beanName); dependencies.add(sdmd); } } webModule.setDependencies(dependencies); // Here's where a bit of magic happens. By attaching the ServiceMetaData // to the deployment, we now make the deployment "relevant" to // deployers that use ServiceMetaData as an input (e.g. the // org.jboss.system.deployers.ServiceDeployer). Those deployers // can now take over deploying the web module. unit.addAttachment("WarServiceMetaData", webModule, ServiceMetaData.class); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e); } }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
protected void processMetaData(VFSDeploymentUnit unit, List<VirtualFile> classpath) throws Exception { ResourcesIndex ri = unit.getAttachment(ResourcesIndex.class); if (ri == null) { return; } AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>(); Web30MetaDataCreator creator = new Web30MetaDataCreator(finder); // Merge processed annotations from all scopes Set<Class<? extends Annotation>> annotations = new HashSet<Class<? extends Annotation>>(); AnnotationContext annotationContext = creator.getAnnotationContext(); if (annotationContext.getTypeAnnotations() != null) annotations.addAll(annotationContext.getTypeAnnotations()); if (annotationContext.getMethodAnnotations() != null) annotations.addAll(annotationContext.getMethodAnnotations()); if (annotationContext.getFieldAnnotations() != null) annotations.addAll(annotationContext.getFieldAnnotations()); boolean metaData = false; for (VirtualFile path : classpath) { Set<Class<?>> annotatedClasses = new HashSet<Class<?>>(); for (Class<? extends Annotation> annotation : annotations) { annotatedClasses.addAll(ri.getAnnotatedClasses(path, annotation)); } WebMetaData annotationMetaData = creator.create(annotatedClasses); if (annotationMetaData != null) { unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME + ":" + path.getName(), annotationMetaData, WebMetaData.class); metaData = true; } } if (metaData) unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, Boolean.TRUE); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
private void processConfigFilesContextParamValue(final VFSDeploymentUnit vfsDeploymentUnit, final JSFDeployment jsfDeployment, final String configFilesContextParamValue) throws Exception { if (configFilesContextParamValue == null) { return; } // trim the context param value String trimmedConfigParamValues = configFilesContextParamValue.trim(); // split the paths which are separated by "," delimiter String[] paths = trimmedConfigParamValues.split(","); for (String path : paths) { // trim each path path = path.trim(); if (path.isEmpty()) { continue; } // skip this path, since .war/WEB-INF/faces-config.xml is by default parsed // (by a separate deployer) if (WEB_INF_FACES_CONFIG_XML.equals(path)) { continue; } // get hold of the file relative to the deployment unit root VirtualFile facesConfigXml = vfsDeploymentUnit.getRoot().getChild(path); // for a file which wasn't found, just log a WARN and move on to the next if (facesConfigXml == null) { logger.warn("Faces config xml not found at relative path: " + path + " in unit " + vfsDeploymentUnit.getRoot()); continue; } logger.debug("Found faces config xml with relative path: " + path + " in unit " + vfsDeploymentUnit.getRoot()); // parse the faces config file FacesConfigParsingUtil.parse(vfsDeploymentUnit, facesConfigXml.toURL(), jsfDeployment); } }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
public static void parse(final DeploymentUnit unit, final URL facesConfigXmlURL, final JSFDeployment jsfDeployment) throws Exception { logger.debug("Checking for the presence of JSF managed-bean(s) in JSF config file: " + facesConfigXmlURL + " in deployment unit: " + unit); // get the parser factory SAXParserFactory parserFactory = getParserFactory(); // create a parser SAXParser saxParser = parserFactory.newSAXParser(); InputStream inputStream = null; try { // get the input stream and the input source for the faces config file inputStream = getInputStream(facesConfigXmlURL); InputSource inputSource = new InputSource(getInputStream(facesConfigXmlURL)); inputSource.setSystemId(facesConfigXmlURL.toExternalForm()); // parse it! saxParser.parse(inputSource, new DefaultHandler() { /** * Flag to keep track of managed-bean-class element being processed */ private boolean managedBeanClassElementProcessingInProgress; /** * Uses the {@link JBossEntityResolver} to resolve the entity. If it cannot be resolved by the {@link JBossEntityResolver} * then this method lets the {@link DefaultHandler} to resolve it. * * @param publicId * @param systemId * @return * @throws IOException * @throws SAXException */ @Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { // try resolving it with the JBossEntityResolver InputSource source = jBossJSFEntityResolver.resolveEntity(publicId, systemId); if (source != null) { return source; } // we couldn't resolve, so let the default handler try to resolve it return super.resolveEntity(publicId, systemId); } @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // we are only interested in managed-bean-class element. if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = true; } // let the super do its job super.startElement(uri, localName, qName, attributes); } @Override public void endElement(String uri, String localName, String qName) throws SAXException { // reset the flag when the managed-bean-class element ends if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = false; } // let super do its job super.endElement(uri, localName, qName); } @Override public void characters(char[] ch, int start, int length) throws SAXException { // if we are currently processing the managed-bean-class element, then fetch the managed bean // class name text if (this.managedBeanClassElementProcessingInProgress) { // get the managed bean class name String managedBeanClassName = new String(ch, start, length); if (!managedBeanClassName.trim().isEmpty()) { logger.debug("Found JSF managed bean class: " + managedBeanClassName + " in unit " + unit); // add it to the jsf deployment jsfDeployment.addManagedBean(managedBeanClassName); } } // let super do its job now super.characters(ch, start, length); } }); } finally { if (inputStream != null) { inputStream.close(); } } return; }
// in src/main/java/org/jboss/web/deployers/SpecCompliantWarAnnotationDeployer.java
Override protected void processMetaData(VFSDeploymentUnit unit, List<VirtualFile> classpath) throws Exception { ResourcesIndex resourceIndex = unit.getAttachment(ResourcesIndex.class); if (resourceIndex == null) { return; } AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>(); Web30MetaDataCreator creator = new Web30MetaDataCreator(finder); // Merge processed annotations from all scopes Set<Class<? extends Annotation>> annotations = new HashSet<Class<? extends Annotation>>(); AnnotationContext annotationContext = creator.getAnnotationContext(); if (annotationContext.getTypeAnnotations() != null) annotations.addAll(annotationContext.getTypeAnnotations()); if (annotationContext.getMethodAnnotations() != null) annotations.addAll(annotationContext.getMethodAnnotations()); if (annotationContext.getFieldAnnotations() != null) annotations.addAll(annotationContext.getFieldAnnotations()); Collection<Class<?>> specEligibleResourceInjectionClasses = this.getResourceInjectionEligibleWebAppClasses(resourceIndex, classpath); boolean metaData = false; final JSFDeployment jsfDeployment = unit.getAttachment(JSFDeployment.class); final ManagedBeanDeploymentMetaData managedBeanDeployment = unit.getAttachment(ManagedBeanDeploymentMetaData.class); for (VirtualFile path : classpath) { Collection<Class<?>> eligibleAnnotatedClasses = new HashSet<Class<?>>(); for (Class<? extends Annotation> annotation : annotations) { Collection<Class<?>> annotatedClasses = resourceIndex.getAnnotatedClasses(path, annotation); // include the jsf and Java EE6 managed beans as eligible for resource injection specEligibleResourceInjectionClasses.addAll(this.getManagedBeansRelatedClasses(jsfDeployment, managedBeanDeployment, annotatedClasses)); // filter out any extra non-spec classes which shouldn't be picked up for resource injection processing eligibleAnnotatedClasses.addAll(this.retainResourceInjectionEligibleWebAppClasses(specEligibleResourceInjectionClasses, annotatedClasses)); } WebMetaData annotationMetaData = creator.create(eligibleAnnotatedClasses); if (annotationMetaData != null) { unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME + ":" + path.getName(), annotationMetaData, WebMetaData.class); metaData = true; } } if (metaData) { unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, Boolean.TRUE); } }
// in src/main/java/org/jboss/web/WebService.java
protected void createService() throws Exception { // Load the file mime.types into the mapping list Properties mimeTypes = new Properties(); try { mimeTypes.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("org/jboss/web/mime.types")); Enumeration keys = mimeTypes.keys(); while (keys.hasMoreElements()) { String extension = (String) keys.nextElement(); String type = mimeTypes.getProperty(extension); server.addMimeType(extension, type); } } catch (Exception e) { log.error("Failed to load org/jboss/web/mime.types; ignoring", e); } // if no override has been specified, default to the jboss bind address if (getBindAddress() == null) setBindAddress(System.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS)); // if no host specified, default to the java.rmi.server.hostname property value if (getHost() == null) setHost(System.getProperty("java.rmi.server.hostname")); // Set the rmi codebase if it is not already set String codebase = getCodebase(); if (codebase == null) { // JBAS-8540 codebase = "http://" + ServerConfigUtil.fixHostnameForURL(getHost()) + ":" + getPort() + "/"; System.setProperty("java.rmi.server.codebase", codebase); } log.info("Using RMI server codebase: " + codebase); }
// in src/main/java/org/jboss/web/WebService.java
protected void startService() throws Exception { // Start the WebServer running server.start(); // JBAS-8540 log.debug("Started WebServer with address: " + ServerConfigUtil.fixHostnameForURL(getBindAddress()) + ":" + getPort()); }
// in src/main/java/org/jboss/web/WebService.java
protected void stopService() throws Exception { server.stop(); // JBAS-8540 log.debug("Stopped WebServer with address: " + ServerConfigUtil.fixHostnameForURL(getBindAddress()) + ":" + getPort()); }
// in src/main/java/org/jboss/web/WebClassLoaderFactory.java
public static WebClassLoader createWebClassLoader(Class<?> webClassLoaderClass, ObjectName containerName, RealClassLoader parent) throws Exception { Constructor constructor = webClassLoaderClass.getConstructor(new Class[]{ObjectName.class, RealClassLoader.class}); return (WebClassLoader) constructor.newInstance(new Object[]{containerName, parent}); }
// in src/main/java/org/jboss/web/RMICodebaseConfigurer.java
Override protected void startService() throws Exception { // Set the rmi codebase if it is not already set String codebase = System.getProperty("java.rmi.server.codebase"); if (codebase == null) { if (host != null) { codebase = "http://" + getHostPortion() + getPortPortion() + "/"; System.setProperty("java.rmi.server.codebase", codebase); } else { getLog().warn("Property codebaseHost has not been set; cannot set java.rmi.server.codebase"); } } }
// in src/main/java/org/jboss/proxy/compiler/Runtime.java
void makeProxyType(ProxyCompiler compiler) throws Exception { this.compiler = compiler; // temporary, for use during loading byte code[] = compiler.getCode(); compiler.proxyType = super.defineClass(compiler.getProxyClassName(), code, 0, code.length); super.resolveClass(compiler.proxyType); // set the Foo$Impl.info pointer to myself Field field = compiler.proxyType.getField(RUNTIME_FN); field.set(null, this); compiler = null; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
public static ProxyTarget newTarget(ClassLoader parent, InvocationHandler invocationHandler, Class targetTypes[]) throws Exception { return Impl.getImpl(targetTypes).newTarget(invocationHandler, parent); }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
ProxyTarget newTarget(InvocationHandler invocationHandler, ClassLoader parent) throws Exception { if (proxyConstructor == null) { // make the proxy constructor ProxyCompiler pc = new ProxyCompiler(parent, superclass, targetTypes, methods); Class type[] = { InvocationHandler.class }; proxyConstructor = pc.getProxyType().getConstructor(type); } Object args[] = { invocationHandler }; return (ProxyTarget)proxyConstructor.newInstance(args); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
protected EJBObject getEjbObjectViaInvoker() throws Exception { if (log.isTraceEnabled()) { log.trace("Using legacy invoker method for getEJBObject() invocation."); } SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); Invocation invocation = new Invocation( null, GET_EJB_OBJECT, new Object[]{id}, //No transaction set up in here? it will get picked up in the proxy null, // fix for bug 474134 from Luke Taylor sa.getPrincipal(), sa.getCredential()); invocation.setObjectName(new Integer(objectName)); invocation.setValue(InvocationKey.INVOKER_PROXY_BINDING, invokerProxyBinding, PayloadKey.AS_IS); // It is a home invocation invocation.setType(InvocationType.HOME); // Create an invocation context for the invocation InvocationContext ctx = new InvocationContext(); invocation.setInvocationContext(ctx); // Get the invoker to the target server (cluster or node) // Ship it if (isLocal()) return (EJBObject) InvokerInterceptor.getLocal().invoke(invocation); else return (EJBObject) invoker.invoke(invocation); }
// in src/main/java/org/jboss/proxy/ejb/SecurityActions.java
static SecurityContext createSecurityContext(final Principal p, final Object cred, final String sdomain) throws Exception { return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>() { public SecurityContext run() throws Exception { return SecurityContextFactory.createSecurityContext(p,cred, null, sdomain); } }); }
// in src/main/java/org/jboss/proxy/ejb/SecurityActions.java
public SecurityContext run() throws Exception { return SecurityContextFactory.createSecurityContext(p,cred, null, sdomain); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public void create() throws Exception { jmxName = container.getJmxName(); jmxNameHash = jmxName.hashCode(); jmxNameHashInteger = new Integer(jmxNameHash); // Create metadata BeanMetaData bmd = container.getBeanMetaData(); boolean isSession = !(bmd instanceof EntityMetaData); boolean isStatelessSession = false; if(isSession) { SessionMetaData smd = (SessionMetaData) bmd; if(bmd.getRemote() == null) { isServiceEndpointOnly = true; // nothing more to do return; } isStatelessSession = smd.isStateless(); } Class pkClass = null; if(!isSession) { EntityMetaData metaData = (EntityMetaData) bmd; String pkClassName = metaData.getPrimaryKeyClass(); try { if(pkClassName != null) { pkClass = container.getClassLoader().loadClass(pkClassName); } else { pkClass = container.getClassLoader() .loadClass(metaData.getEjbClass()) .getField(metaData.getPrimKeyField()) .getClass(); } } catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); } catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); } } ejbMetaData = new EJBMetaDataImpl( ((EJBProxyFactoryContainer) container).getRemoteClass(), ((EJBProxyFactoryContainer) container).getHomeClass(), pkClass, //null if not entity isSession, //Session isStatelessSession, //Stateless new HomeHandleImpl(jndiBinding) ); log.debug("Proxy Factory for " + jndiBinding + " initialized"); initInterceptorClasses(); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public void start() throws Exception { if(!isServiceEndpointOnly) { setupInvokers(); bindProxy(); } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void setupInvokers() throws Exception { ObjectName oname = new ObjectName(invokerMetaData.getInvokerMBean()); Invoker invoker = (Invoker) Registry.lookup(oname); if(invoker == null) { throw new RuntimeException("invoker is null: " + oname); } homeInvoker = beanInvoker = invoker; }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void initInterceptorClasses() throws Exception { HashMap interceptors = new HashMap(); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element clientInterceptors = MetaData.getOptionalChild( proxyConfig, "client-interceptors", null ); if(clientInterceptors != null) { String value = MetaData.getElementAttribute(clientInterceptors, "exposeContainer"); this.includeIClientIface = Boolean.valueOf(value).booleanValue(); NodeList children = clientInterceptors.getChildNodes(); for(int i = 0; i < children.getLength(); i++) { Node currentChild = children.item(i); if(currentChild.getNodeType() == Node.ELEMENT_NODE) { Element interceptor = (Element) children.item(i); interceptors.put(interceptor.getTagName(), interceptor); } } } else { log.debug("client interceptors element is null"); } Element homeInterceptorConf = (Element) interceptors.get(HOME_INTERCEPTOR); loadInterceptorClasses(homeInterceptorClasses, homeInterceptorConf); if(homeInterceptorClasses.size() == 0) { throw new DeploymentException("There are no home interface interceptors configured"); } Element beanInterceptorConf = (Element) interceptors.get(BEAN_INTERCEPTOR); loadInterceptorClasses(beanInterceptorClasses, beanInterceptorConf); if(beanInterceptorClasses.size() == 0) { throw new DeploymentException("There are no bean interface interceptors configured"); } Element listEntityInterceptorConf = (Element) interceptors.get(LIST_ENTITY_INTERCEPTOR); loadInterceptorClasses(listEntityInterceptorClasses, listEntityInterceptorConf); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void loadInterceptorClasses(ArrayList classes, Element interceptors) throws Exception { Iterator interceptorElements = MetaData.getChildrenByTagName(interceptors, "interceptor"); ClassLoader loader = container.getClassLoader(); while(interceptorElements != null && interceptorElements.hasNext()) { Element ielement = (Element) interceptorElements.next(); String className = null; className = MetaData.getElementContent(ielement); // load the invoker interceptor that corresponds to the beans call semantic String byValueAttr = MetaData.getElementAttribute(ielement, "call-by-value"); if(byValueAttr != null) { if (container.isCallByValue() == new Boolean(byValueAttr).booleanValue()) { Class clazz = loader.loadClass(className); classes.add(clazz); } } else { Class clazz = loader.loadClass(className); classes.add(clazz); } } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void loadInterceptorChain(ArrayList chain, ClientContainer client) throws Exception { Interceptor last = null; for(int i = 0; i < chain.size(); i++) { Class clazz = (Class) chain.get(i); Interceptor interceptor = (Interceptor) clazz.newInstance(); if(last == null) { last = interceptor; client.setNext(interceptor); } else { last.setNext(interceptor); last = interceptor; } } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void bindProxy() throws Exception { try { // Create a stack from the description (in the future) for now we hardcode it InvocationContext context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); // The behavior for home proxying should be isolated in an interceptor FIXME context.setInvoker(homeInvoker); context.setValue(InvocationKey.EJB_METADATA, ejbMetaData); context.setInvokerProxyBinding(invokerMetaData.getName()); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } ClientContainer client = null; EJBProxyFactoryContainer pfc = (EJBProxyFactoryContainer) container; Class[] ifaces = {pfc.getHomeClass(), Class.forName("javax.ejb.Handle")}; if( includeIClientIface ) { ifaces = new Class[] {IClientContainer.class, pfc.getHomeClass(), Class.forName("javax.ejb.Handle")}; client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } loadInterceptorChain(homeInterceptorClasses, client); // Create the EJBHome this.home = (EJBHome) Proxy.newProxyInstance( // Class loader pointing to the right classes from deployment pfc.getHomeClass().getClassLoader(), // The classes we want to implement home and handle ifaces, // The home proxy as invocation handler client); // Create stateless session object // Same instance is used for all objects if(ejbMetaData.isStatelessSession() == true) { // Create a stack from the description (in the future) for now we hardcode it context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); // The behavior for home proxying should be isolated in an interceptor FIXME context.setInvoker(beanInvoker); context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } Class[] ssifaces = {pfc.getRemoteClass()}; if( includeIClientIface ) { ssifaces = new Class[] {IClientContainer.class, pfc.getRemoteClass()}; client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } loadInterceptorChain(beanInterceptorClasses, client); this.statelessObject = (EJBObject)Proxy.newProxyInstance( // Correct CL pfc.getRemoteClass().getClassLoader(), // Interfaces ssifaces, // SLSB proxy as invocation handler client ); } else { // this is faster than newProxyInstance Class[] intfs = {pfc.getRemoteClass()}; if( this.includeIClientIface ) { intfs = new Class[]{IClientContainer.class, pfc.getRemoteClass()}; } Class proxyClass = Proxy.getProxyClass(pfc.getRemoteClass().getClassLoader(), intfs); final Class[] constructorParams = {InvocationHandler.class}; proxyClassConstructor = proxyClass.getConstructor(constructorParams); } // Bind the home in the JNDI naming space rebindHomeProxy(); } catch(Exception e) { throw new ServerException("Could not bind home", e); } }
// in src/main/java/org/jboss/proxy/ejb/SecurityContextInterceptor.java
private SecurityContext createSecurityContext(Invocation invocation) throws Exception { //There may be principal set on the invocation Principal p = invocation.getPrincipal(); Object cred = invocation.getCredential(); //Create a new SecurityContext String domain = (String) invocation.getInvocationContext().getValue(InvocationKey.SECURITY_DOMAIN); if(domain == null) domain = "CLIENT_PROXY"; return SecurityActions.createSecurityContext(p,cred, domain); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
protected void loadInterceptorChain(ArrayList chain, ClientContainer client) throws Exception { Interceptor last = null; for (int i = 0; i < chain.size(); i++) { Class clazz = (Class)chain.get(i); Interceptor interceptor = (Interceptor) clazz.newInstance(); if (last == null) { last = interceptor; client.setNext(interceptor); } else { last.setNext(interceptor); last = interceptor; } } }
// in src/etc/class.java
public void startService() throws Exception { // Use the newline for the opening bracket so we can match top and bottom bracket visually Class cls = Class.forName(dataSourceClass); vendorSource = (XADataSource)cls.newInstance(); // JUMP A LINE BETWEEN LOGICALLY DISCTINT **STEPS** AND ADD A LINE OF COMMENT TO IT cls = vendorSource.getClass(); if(properties != null && properties.length() > 0) { try { } catch (IOException ioe) { } for (Iterator i = props.entrySet().iterator(); i.hasNext();) { // Get the name and value for the attributes Map.Entry entry = (Map.Entry) i.next(); String attributeName = (String) entry.getKey(); String attributeValue = (String) entry.getValue(); // Print the debug message log.debug("Setting attribute '" + attributeName + "' to '" + attributeValue + "'"); // get the attribute Method setAttribute = cls.getMethod("set" + attributeName, new Class[] { String.class }); // And set the value setAttribute.invoke(vendorSource, new Object[] { attributeValue }); } } // Test database vendorSource.getXAConnection().close(); // Bind in JNDI bind(new InitialContext(), "java:/"+getPoolName(), new Reference(vendorSource.getClass().getName(), getClass().getName(), null)); }
(Lib) ServerException 6
              
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { // We are going to go through a Remote invocation, switch to a Marshalled Invocation MarshalledInvocation mi = new MarshalledInvocation(invocation); if( externalURL == null ) externalURL = Util.resolveURL(externalURLValue); try { Object value = Util.invoke(externalURL, mi); return value; } catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); } catch (IOException e) { throw new ServerException("IOE", e); } }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { Object response = null; // Earlier versions of InvokerLocator don't have a findSerializationType() method. try { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE",locator.findSerializationType()); } catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); } try { response = client.invoke(invocation, null); if(response instanceof Exception) { throw ((Exception) response); } if(response instanceof MarshalledObject) { return ((MarshalledObject) response).get(); } if (response instanceof IMarshalledValue) { return ((IMarshalledValue)response).get(); } return response; } catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } } catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); } }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
public EJBObject getEJBObject() throws ServerException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); Class type = home.getClass(); Method method = type.getMethod("create", new Class[0]); return (EJBObject) method.invoke(home, new Object[0]); } catch (Exception e) { throw new ServerException("Could not get EJBObject", e); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
public EJBHome getEJBHome() throws RemoteException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); return home; } catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); } }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
public EJBObject getEJBObject() throws RemoteException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); Class type = home.getClass(); Method method = type.getMethod("findByPrimaryKey", new Class[]{home.getEJBMetaData().getPrimaryKeyClass()}); // call findByPrimary on the target return (EJBObject) method.invoke(home, new Object[]{id}); } catch (Exception e) { throw new ServerException("Could not get EJBObject", e); } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void bindProxy() throws Exception { try { // Create a stack from the description (in the future) for now we hardcode it InvocationContext context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); // The behavior for home proxying should be isolated in an interceptor FIXME context.setInvoker(homeInvoker); context.setValue(InvocationKey.EJB_METADATA, ejbMetaData); context.setInvokerProxyBinding(invokerMetaData.getName()); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } ClientContainer client = null; EJBProxyFactoryContainer pfc = (EJBProxyFactoryContainer) container; Class[] ifaces = {pfc.getHomeClass(), Class.forName("javax.ejb.Handle")}; if( includeIClientIface ) { ifaces = new Class[] {IClientContainer.class, pfc.getHomeClass(), Class.forName("javax.ejb.Handle")}; client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } loadInterceptorChain(homeInterceptorClasses, client); // Create the EJBHome this.home = (EJBHome) Proxy.newProxyInstance( // Class loader pointing to the right classes from deployment pfc.getHomeClass().getClassLoader(), // The classes we want to implement home and handle ifaces, // The home proxy as invocation handler client); // Create stateless session object // Same instance is used for all objects if(ejbMetaData.isStatelessSession() == true) { // Create a stack from the description (in the future) for now we hardcode it context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); // The behavior for home proxying should be isolated in an interceptor FIXME context.setInvoker(beanInvoker); context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } Class[] ssifaces = {pfc.getRemoteClass()}; if( includeIClientIface ) { ssifaces = new Class[] {IClientContainer.class, pfc.getRemoteClass()}; client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } loadInterceptorChain(beanInterceptorClasses, client); this.statelessObject = (EJBObject)Proxy.newProxyInstance( // Correct CL pfc.getRemoteClass().getClassLoader(), // Interfaces ssifaces, // SLSB proxy as invocation handler client ); } else { // this is faster than newProxyInstance Class[] intfs = {pfc.getRemoteClass()}; if( this.includeIClientIface ) { intfs = new Class[]{IClientContainer.class, pfc.getRemoteClass()}; } Class proxyClass = Proxy.getProxyClass(pfc.getRemoteClass().getClassLoader(), intfs); final Class[] constructorParams = {InvocationHandler.class}; proxyClassConstructor = proxyClass.getConstructor(constructorParams); } // Bind the home in the JNDI naming space rebindHomeProxy(); } catch(Exception e) { throw new ServerException("Could not bind home", e); } }
6
              
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (IOException e) { throw new ServerException("IOE", e); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new ServerException("Could not bind home", e); }
1
              
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
public EJBObject getEJBObject() throws ServerException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); Class type = home.getClass(); Method method = type.getMethod("create", new Class[0]); return (EJBObject) method.invoke(home, new Object[0]); } catch (Exception e) { throw new ServerException("Could not get EJBObject", e); } }
(Lib) DuplicateKeyException 6
              
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object createEntity (Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get (ctx.getInstance ()); // Check exist if (this.beans.containsKey (id)) throw new javax.ejb.DuplicateKeyException ("Already exists: "+id); // Store to file storeEntity (id, ctx.getInstance ()); return id; } catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object createEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get(ctx.getInstance()); // Check exist if (getFile(id).exists()) throw new DuplicateKeyException("Already exists: "+id); // Store to file storeEntity(id, ctx.getInstance()); return id; } catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { pk = entityBridge.extractPrimaryKeyFromInstance(ctx); if(pk == null) { throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
protected void beforeInsert(EntityEnterpriseContext ctx) throws CreateException { // are we checking existance by query? if(existsSQL != null) { Connection c = null; PreparedStatement ps = null; ResultSet rs = null; try { if(debug) log.debug("Executing SQL: " + existsSQL); c = entity.getDataSource().getConnection(); ps = c.prepareStatement(existsSQL); // bind PK // @todo add a method to EntityBridge that binds pk fields directly Object pk = entity.extractPrimaryKeyFromInstance(ctx); entity.setPrimaryKeyParameters(ps, 1, pk); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("Error checking if entity with primary pk " + pk + "exists: SQL returned no rows"); } if(rs.getInt(1) > 0) { throw new DuplicateKeyException("Entity with primary key " + pk + " already exists"); } } catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } } }
3
              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
5
              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void addCreated(Row row) throws DuplicateKeyException { //if(getRowByPk(row.pk, false) != null) //{ // throw new DuplicateKeyException("Table " + tableName + ", key=" + row.pk); //} if(created != null) { row.next = created; created.prev = row; } created = row; row.state = CREATED; rowByPk.put(row.pk, row); JDBCCMPFieldBridge2 versionField = entity.getVersionField(); if(versionField != null) { row.fields[versionField.getVersionIndex()] = row.fields[versionField.getRowIndex()]; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void insert(Object pk) throws DuplicateKeyException { this.pk = pk; view.addCreated(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flush() throws SQLException, DuplicateKeyException { // todo needs refactoring if(state != CREATED) { if(log.isTraceEnabled()) { log.trace("The row is already inserted: pk=" + pk); } return; } Connection con = null; PreparedStatement duplicatePkPs = null; PreparedStatement insertPs = null; ResultSet rs = null; try { int paramInd; con = dataSource.getConnection(); // check for duplicate key /* if(log.isDebugEnabled()) { log.debug("executing : " + duplicatePkSql); } duplicatePkPs = con.prepareStatement(duplicatePkSql); paramInd = 1; JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object fieldValue = fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(duplicatePkPs, paramInd, fieldValue); } rs = duplicatePkPs.executeQuery(); if(rs.next()) { throw new DuplicateKeyException("Table " + tableName + ", pk=" + pk); } */ // insert if(log.isDebugEnabled()) { log.debug("executing : " + insertSql); } insertPs = con.prepareStatement(insertSql); paramInd = 1; JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); for(int fInd = 0; fInd < tableFields.length; ++fInd) { JDBCCMPFieldBridge2 field = tableFields[fInd]; Object fieldValue = fields[field.getRowIndex()]; paramInd = field.setArgumentParameters(insertPs, paramInd, fieldValue); } insertPs.executeUpdate(); flushStatus(); } catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(duplicatePkPs); JDBCUtil.safeClose(insertPs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PersistentContext.java
public void setPk(Object pk) throws DuplicateKeyException { if(pk == null) { throw new IllegalArgumentException("Primary key is null!"); } row.insert(pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PersistentContext.java
public void flush() throws SQLException, DuplicateKeyException { row.flush(); }
(Lib) NoSuchMethodException 4
              
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void setUpBeanMappingImpl(Map map, Method[] methods, String declaringClass) throws NoSuchMethodException { for (int i = 0; i < methods.length; i++) { Method m = methods[i]; if (m.getDeclaringClass().getName().equals(declaringClass) == false) { // Implemented by bean try { Method beanMethod = beanClass.getMethod(m.getName(), m.getParameterTypes()); map.put(m, beanMethod); } catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); } log.debug("Mapped " + m.getName() + " HASH " + m.hashCode() + "to " + map.get(m)); } else { // Implemented by container try { Method containerMethod = getClass().getMethod(m.getName(), new Class[]{Invocation.class}); map.put(m, containerMethod); } catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); } log.debug("Mapped Container method " + m.getName() + " HASH " + m.hashCode()); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void createMethodCache(Method[] methods) throws NoSuchMethodException { // Create cache of create methods Class beanClass = con.getBeanClass(); for(int i = 0; i < methods.length; i++) { String name = methods[i].getName(); if(name.startsWith("create")) { Class[] types = methods[i].getParameterTypes(); try { String nameSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); Method beanMethod = beanClass.getMethod("ejb" + nameSuffix, types); createMethods.put(methods[i], beanMethod); beanMethod = beanClass.getMethod("ejbPost" + nameSuffix, types); postCreateMethods.put(methods[i], beanMethod); } catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); } } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private void setupHomeMappingImpl(Method[] m, String finderName, String append) throws Exception { // Adrian Brock: This should go away when we don't support EJB1x boolean isEJB1x = metaData.getApplicationMetaData().isEJB1x(); for (int i = 0; i < m.length; i++) { String methodName = m[i].getName(); try { try // Try home method { String ejbHomeMethodName = "ejbHome" + methodName.substring(0,1).toUpperCase() + methodName.substring(1); homeMapping.put(m[i], beanClass.getMethod(ejbHomeMethodName, m[i].getParameterTypes())); continue; } catch (NoSuchMethodException ignore) {} // just go on with other types of methods // Implemented by container (in both cases) if (methodName.startsWith("find")) { homeMapping.put(m[i], this.getClass().getMethod(finderName, new Class[] { Invocation.class })); } else if (methodName.equals("create") || (isEJB1x == false && methodName.startsWith("create"))) { homeMapping.put(m[i], this.getClass().getMethod("create"+append, new Class[] { Invocation.class })); beanMapping.put(m[i], this.getClass().getMethod("postCreate"+append, new Class[] { Invocation.class })); } else { homeMapping.put(m[i], this.getClass().getMethod(methodName+append, new Class[] { Invocation.class })); } } catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); } } }
4
              
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); }
6
              
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void setUpBeanMappingImpl(Map map, Method[] methods, String declaringClass) throws NoSuchMethodException { for (int i = 0; i < methods.length; i++) { Method m = methods[i]; if (m.getDeclaringClass().getName().equals(declaringClass) == false) { // Implemented by bean try { Method beanMethod = beanClass.getMethod(m.getName(), m.getParameterTypes()); map.put(m, beanMethod); } catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); } log.debug("Mapped " + m.getName() + " HASH " + m.hashCode() + "to " + map.get(m)); } else { // Implemented by container try { Method containerMethod = getClass().getMethod(m.getName(), new Class[]{Invocation.class}); map.put(m, containerMethod); } catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); } log.debug("Mapped Container method " + m.getName() + " HASH " + m.hashCode()); } } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void setupBeanMapping() throws NoSuchMethodException { Map map = new HashMap(); if (remoteInterface != null) { Method[] m = remoteInterface.getMethods(); setUpBeanMappingImpl(map, m, "javax.ejb.EJBObject"); } if (localInterface != null) { Method[] m = localInterface.getMethods(); setUpBeanMappingImpl(map, m, "javax.ejb.EJBLocalObject"); } if (TimedObject.class.isAssignableFrom(beanClass)) { Method[] m = new Method[]{TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class})}; setUpBeanMappingImpl(map, m, "javax.ejb.Timer"); } if (serviceEndpoint != null) { Method[] m = serviceEndpoint.getMethods(); setUpBeanMappingImpl(map, m, "java.rmi.Remote"); } beanMapping = map; }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
protected void setupHomeMapping() throws NoSuchMethodException { Map map = new HashMap(); if (homeInterface != null) { Method[] m = homeInterface.getMethods(); for (int i = 0; i < m.length; i++) { // Implemented by container log.debug("Mapping " + m[i].getName()); map.put(m[i], getClass().getMethod(m[i].getName() + "Home", m[i].getParameterTypes())); } } if (localHomeInterface != null) { Method[] m = localHomeInterface.getMethods(); for (int i = 0; i < m.length; i++) { // Implemented by container log.debug("Mapping " + m[i].getName()); map.put(m[i], getClass().getMethod(m[i].getName() + "LocalHome", m[i].getParameterTypes())); } } homeMapping = map; }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException { boolean result = false; int transType = metaData.getMethodTransactionType(method.getName(), method.getParameterTypes(), InvocationType.LOCAL); if (transType == MetaData.TX_REQUIRED) result = true; if (trace) log.trace("isDeliveryTransacted " + container.getBeanMetaData().getContainerObjectNameJndiName() + " method=" + method + " result=" + result); return result; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
private void createMethodCache( Method[] methods ) throws NoSuchMethodException { for (int i = 0; i < methods.length; i++) { String name = methods[i].getName(); if (name.startsWith("create")) { String nameSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); try { createMethods.put(methods[i], con.getBeanClass().getMethod("ejb" + nameSuffix, methods[i].getParameterTypes())); } catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); throw e; } try { postCreateMethods.put(methods[i], con.getBeanClass().getMethod("ejbPost" + nameSuffix, methods[i].getParameterTypes())); } catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; } } } // Create cache of finder methods for (int i = 0; i < methods.length; i++) { if (methods[i].getName().startsWith("find")) { try { finderMethods.put(methods[i], con.getBeanClass().getMethod("ejbF" + methods[i].getName().substring(1), methods[i].getParameterTypes())); } catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class"); throw e; } } } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void createMethodCache(Method[] methods) throws NoSuchMethodException { // Create cache of create methods Class beanClass = con.getBeanClass(); for(int i = 0; i < methods.length; i++) { String name = methods[i].getName(); if(name.startsWith("create")) { Class[] types = methods[i].getParameterTypes(); try { String nameSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); Method beanMethod = beanClass.getMethod("ejb" + nameSuffix, types); createMethods.put(methods[i], beanMethod); beanMethod = beanClass.getMethod("ejbPost" + nameSuffix, types); postCreateMethods.put(methods[i], beanMethod); } catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); } } } }
(Lib) ObjectNotFoundException 4
              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/FindByPrimaryKeyCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { Object pk = args[0]; if(pk == null) { throw new IllegalArgumentException("Null argument for findByPrimaryKey"); } Object instance; boolean cached = entity.getTable().hasRow(pk); if(!cached) { instance = super.executeFetchOne(args, factory); if(instance == null) { throw new ObjectNotFoundException("Instance not find: entity=" + entity.getEntityName() + ", pk=" + pk); } } else { instance = factory.getEntityEJBObject(pk); } return instance; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
static Object fetchOne(JDBCEntityBridge2 entity, String sql, QueryParameter[] params, ResultReader resultReader, Object[] args, GenericEntityObjectFactory factory, Logger log) throws FinderException { Object pk; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; } } try { if(log.isDebugEnabled()) { log.debug("executing: " + sql); } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entity.getDataSource().getConnection(); } ps = con.prepareStatement(sql); if(params != null) { for(int i = 0; i < params.length; i++) { params[i].set(log, ps, i + 1, args); } } rs = ps.executeQuery(); if(rs.next()) { pk = resultReader.readRow(rs, factory); if(rs.next()) { List list = new ArrayList(); list.add(pk); list.add(resultReader.readRow(rs, factory)); while(rs.next()) { list.add(resultReader.readRow(rs, factory)); } throw new FinderException("More than one instance matches the single-object finder criteria: " + list); } } else { throw new ObjectNotFoundException(); } } catch(FinderException e) { throw e; } catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntityCommand.java
public Object execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(finderMethod); Collection result = query.execute(finderMethod, args, ctx, factory); if(result.isEmpty()) { throw new ObjectNotFoundException(NO_SUCH_ENTITY); } else if(result.size() == 1) { return result.iterator().next(); } else { throw new FinderException("More than one entity matches the finder criteria: " + result); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object execute(Object[] args) throws FinderException { Collection retVal; Method method = getMethod(); try { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(method); EntityContainer selectedContainer = query.getSelectManager().getContainer(); GenericEntityObjectFactory factory; if(queryMetaData.isResultTypeMappingLocal() && selectedContainer.getLocalHomeClass() != null) { factory = selectedContainer.getLocalProxyFactory(); } else { factory = selectedContainer.getProxyFactory(); } retVal = query.execute(method, args, null, factory); } catch(FinderException e) { throw e; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); } if(!Collection.class.isAssignableFrom(getReturnType())) { // single object if(retVal.size() == 0) { throw new ObjectNotFoundException(); } if(retVal.size() > 1) { throw new FinderException(getSelectorName() + " returned " + retVal.size() + " objects"); } Object o = retVal.iterator().next(); if(o == null && method.getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + method.getReturnType().getName() ); } return o; } else { // collection or set if(Set.class.isAssignableFrom(getReturnType())) { return new HashSet(retVal); } else { return retVal; } } }
0 0
(Lib) UnreachableStatementException 11
              
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Handle handle) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Object primaryKey) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } try { return mi.performCall(StatelessSessionContainer.this, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // wire the transaction on the context, this is how the instance remember the tx EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); // Get method and instance to invoke upon Method miMethod = mi.getMethod(); Map map = getBeanMapping(); Method m = (Method) map.get(miMethod); // The Invocation might contain the actual bean method // e.g. For an invocation based on a JSR-181 @WebMethod annotation if (m == null && map.values().contains(miMethod)) { m = miMethod; } if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } //If we have a method that needs to be done by the container (EJBObject methods) if (m.getDeclaringClass().equals(StatelessSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { try { return mi.performCall(StatelessSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else // we have a method that needs to be done by a bean instance { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("HOMEMETHOD coming in "); log.trace("" + mi.getMethod()); log.trace("HOMEMETHOD coming in hashcode" + mi.getMethod().hashCode()); log.trace("HOMEMETHOD coming in classloader" + mi.getMethod().getDeclaringClass().getClassLoader().hashCode()); log.trace("CONTAINS " + getHomeMapping().containsKey(mi.getMethod())); } Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // Invoke and handle exceptions if (trace) { log.trace("HOMEMETHOD m " + m); java.util.Iterator iterator = getHomeMapping().keySet().iterator(); while (iterator.hasNext()) { Method me = (Method) iterator.next(); if (me.getName().endsWith("create")) { log.trace(me.toString()); log.trace("" + me.hashCode()); log.trace("" + me.getDeclaringClass().getClassLoader().hashCode()); log.trace("equals " + me.equals(mi.getMethod()) + " " + mi.getMethod().equals(me)); } } } try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) getBeanMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // wire the transaction on the context, this is how the instance remember the tx // Unlike Entity beans we can't do that in the previous interceptors (ordering) EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); else if(ejbObjectRemove.equals(miMethod) || ejbLocalObjectRemove.equals(miMethod)) { throw new RemoveException("An attempt to remove a session " + "object while the object is in a transaction " + "(EJB2.1, 7.6.4 Restrictions for Transactions): ejb-name=" + metaData.getEjbName() + ", method=" + mi.getMethod() + ", tx=" + ctx.getTransaction()); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(StatefulSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { // Invoke and handle exceptions try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); // wire the transaction on the context, // this is how the instance remember the tx if (ctx.getTransaction() == null) { ctx.setTransaction(mi.getTransaction()); } // Get method and instance to invoke upon Method m = (Method) beanMapping.get(mi.getMethod()); if( m == null ) { // This is a configuration error that should have been caught earlier String msg = MessageDrivenContainer.this.getBeanMetaData().getEjbName() + " Invalid invocation, check your deployment packaging, interfaces, method=" + mi.getMethod(); throw new EJBException(msg); } // we have a method that needs to be done by a bean instance try { messageCount++; return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke and handle exceptions Method miMethod = mi.getMethod(); Method m = (Method) homeMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } if (m.getDeclaringClass().equals(EntityContainer.class)) { try { return mi.performCall(EntityContainer.this, m, new Object[] { mi }); } catch (Exception e) { rethrow(e); } } else // Home method { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); try { AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_EJB_HOME); return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } finally{ AllowedOperationsAssociation.popInMethodFlag(); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) beanMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(EntityContainer.class)) { // Invoke container try { return mi.performCall(EntityContainer.this, m, new Object[]{ mi }); } catch (Exception e) { rethrow(e); } } else { // Invoke bean instance try { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); Object instance = ctx.getInstance(); return mi.performCall(instance, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/proxy/compiler/Utility.java
public static Type getType(Class clazz) { if (clazz.isPrimitive()) { if (clazz.equals(Boolean.TYPE) ) { return Type.BOOLEAN; } else if (clazz.equals(Byte.TYPE) ) { return Type.BYTE; } else if (clazz.equals(Character.TYPE) ) { return Type.CHAR; } else if (clazz.equals(Double.TYPE) ) { return Type.DOUBLE; } else if (clazz.equals(Float.TYPE) ) { return Type.FLOAT; } else if (clazz.equals(Integer.TYPE) ) { return Type.INT; } else if (clazz.equals(Long.TYPE) ) { return Type.LONG; } else if (clazz.equals(Short.TYPE) ) { return Type.SHORT; } else if (clazz.equals(Void.TYPE) ) { return Type.VOID; } // should never get here throw new UnreachableStatementException(); } // if we get this far it is not a primitive String name = clazz.getName(); if (clazz.isArray()) { return Type.getType(name); } return new ObjectType(name); }
0 0
(Lib) IndexOutOfBoundsException 3
              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeSimple.java
public final Object getColumnValue(int index, Object value) { if(index != 0) { throw new IndexOutOfBoundsException("JDBCSimpleType does not support an index>0."); } return mapper == null ? value : mapper.toColumnValue(value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeSimple.java
public final Object setColumnValue(int index, Object value, Object columnValue) { if(index != 0) { throw new IndexOutOfBoundsException("JDBCSimpleType does not support an index>0."); } return mapper == null ? columnValue : mapper.toFieldValue(columnValue); }
// in src/main/java/org/jboss/verifier/Section.java
public String getSectionToken( int index ) { if( section.length >= index ) throw new IndexOutOfBoundsException(GET_SECTION_INDEX_ERROR); return section[index]; }
0 0
(Lib) NoSuchElementException 3
              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Object next() { if(!hasNext()) { throw new NoSuchElementException(); } hasNext = false; cursor = readNext(); results.add(cursor); return cursor; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public JDBCCMPFieldBridge next() { if(!hasNext()) throw new NoSuchElementException(); curIndex = nextIndex; return tableFields[nextIndex++]; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public JDBCCMPFieldBridge next() { throw new NoSuchElementException(); }
0 0
(Lib) NoSuchEntityException 3
              
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public Row loadRow(Object id) throws SQLException { View view = getView(); Row row = view.getRowByPk(id, false); if(row != null) { if(log.isTraceEnabled()) { log.trace("row is already loaded: pk=" + id); } return row; } JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + selectSql); } con = dataSource.getConnection(); ps = con.prepareStatement(selectSql); int paramInd = 1; for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object pkValue = pkField.getPrimaryKeyValue(id); paramInd = pkField.setArgumentParameters(ps, paramInd, pkValue); } rs = ps.executeQuery(); if(!rs.next()) { throw new NoSuchEntityException("Row not found: " + id); } return view.loadRow(rs, id, false); } catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private Object loadField(int i) { JDBCCMPFieldBridge2 field = (JDBCCMPFieldBridge2)entity.getFields().get(i); StringBuffer query = new StringBuffer(); query.append("select ") .append(field.getColumnName()) .append(" from ") .append(tableName) .append(" where "); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[])entity.getPrimaryKeyFields(); for(int pkI = 0; pkI < pkFields.length; ++pkI) { if(pkI > 0) { query.append(" and "); } query.append(pkFields[pkI].getColumnName()).append("=?"); } if(log.isDebugEnabled()) { log.debug("executing: " + query.toString()); } Object value = null; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = dataSource.getConnection(); ps = con.prepareStatement(query.toString()); for(int pkI = 0; pkI < pkFields.length; ++pkI) { JDBCCMPFieldBridge2 pkField = pkFields[pkI]; Object fieldValue = fields[pkField.getRowIndex()]; pkField.setArgumentParameters(ps, pkI + 1, fieldValue); } rs = ps.executeQuery(); if(!rs.next()) { throw new NoSuchEntityException("Row not found: " + pk); } value = field.loadArgumentResults(rs, 1); } catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } fields[field.getRowIndex()] = value; return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
private boolean execute(JDBCCMPFieldBridge requiredField, EntityEnterpriseContext ctx, boolean failIfNotFound) { // load the instance primary key fields into the context Object id = ctx.getId(); // TODO: when exactly do I need to do the following? entity.injectPrimaryKeyIntoInstance(ctx, id); // get the read ahead cache ReadAheadCache readAheadCache = manager.getReadAheadCache(); // load any preloaded fields into the context if(readAheadCache.load(ctx)) { if(requiredField == null || (requiredField != null && requiredField.isLoaded(ctx))) { return true; } } // get the finder results associated with this context, if it exists ReadAheadCache.EntityReadAheadInfo info = readAheadCache.getEntityReadAheadInfo(id); // determine the fields to load JDBCEntityBridge.FieldIterator loadIter = entity.getLoadIterator(requiredField, info.getReadAhead(), ctx); if(!loadIter.hasNext()) return true; // get the keys to load List loadKeys = info.getLoadKeys(); // generate the sql String sql = (rowLockingTemplate != null ? getRawLockingSQL(loadIter, loadKeys.size()) : getSQL(loadIter, loadKeys.size())); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { // create the statement if (log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql); // Set the fetch size of the statement if (entity.getFetchSize() > 0) { ps.setFetchSize(entity.getFetchSize()); } // set the parameters int paramIndex = 1; for (int i = 0; i < loadKeys.size(); i++) { paramIndex = entity.setPrimaryKeyParameters(ps, paramIndex, loadKeys.get(i)); } // execute statement rs = ps.executeQuery(); // load results boolean mainEntityLoaded = false; Object[] ref = new Object[1]; while (rs.next()) { // reset the column index for this row int index = 1; // ref must be reset to null before load ref[0] = null; // if we are loading more then one entity, load the pk from the row Object pk = null; if (loadKeys.size() > 1) { // load the pk index = entity.loadPrimaryKeyResults(rs, index, ref); pk = ref[0]; } // is this the main entity or a preload entity if (loadKeys.size() == 1 || pk.equals(id)) { // main entity; load the values into the context loadIter.reset(); while(loadIter.hasNext()) { JDBCCMPFieldBridge field = loadIter.next(); index = field.loadInstanceResults(rs, index, ctx); field.setClean(ctx); } mainEntityLoaded = true; } else { // preload entity; load the values into the read ahead cahce loadIter.reset(); while(loadIter.hasNext()) { JDBCCMPFieldBridge field = loadIter.next(); // ref must be reset to null before load ref[0] = null; // load the result of the field index = field.loadArgumentResults(rs, index, ref); // cache the field value readAheadCache.addPreloadData(pk, field, ref[0]); } } } // clear LOAD_REQUIRED flag loadIter.removeAll(); // did we load the main results if (!mainEntityLoaded) { if (failIfNotFound) throw new NoSuchEntityException("Entity not found: primaryKey=" + ctx.getId()); else return false; } else return true; } catch (EJBException e) { throw e; } catch (Exception e) { throw new EJBException("Load failed", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
0 0
(Lib) TransactionRequiredLocalException 3
              
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private Object runWithTransactions(Invocation invocation) throws Exception { // Old transaction is the transaction that comes with the MI Transaction oldTransaction = invocation.getTransaction(); // New transaction is the new transaction this might start Transaction newTransaction = null; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Current transaction in MI is " + oldTransaction); InvocationType type = invocation.getType(); byte transType = container.getBeanMetaData().getTransactionMethod(invocation.getMethod(), type); if ( trace ) printMethod(invocation.getMethod(), transType); // Thread arriving must be clean (jboss doesn't set the thread // previously). However optimized calls come with associated // thread for example. We suspend the thread association here, and // resume in the finally block of the following try. Transaction threadTx = tm.suspend(); if( trace ) log.trace("Thread came in with tx " + threadTx); try { switch (transType) { case MetaData.TX_NOT_SUPPORTED: { // Do not set a transaction on the thread even if in MI, just run try { invocation.setTransaction(null); return invokeNext(invocation, false); } finally { invocation.setTransaction(oldTransaction); } } case MetaData.TX_REQUIRED: { int oldTimeout = 0; Transaction theTransaction = oldTransaction; if (oldTransaction == null) { // No tx running // Create tx oldTimeout = startTransaction(invocation); // get the tx newTransaction = tm.getTransaction(); if( trace ) log.trace("Starting new tx " + newTransaction); // Let the method invocation know invocation.setTransaction(newTransaction); theTransaction = newTransaction; } else { // We have a tx propagated // Associate it with the thread tm.resume(oldTransaction); } // Continue invocation try { Object result = invokeNext(invocation, oldTransaction != null); checkTransactionStatus(theTransaction, type); return result; } finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); } } case MetaData.TX_SUPPORTS: { // Associate old transaction with the thread // Some TMs cannot resume a null transaction and will throw // an exception (e.g. Tyrex), so make sure it is not null if (oldTransaction != null) { tm.resume(oldTransaction); } try { Object result = invokeNext(invocation, oldTransaction != null); if (oldTransaction != null) checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } // Even on error we don't do anything with the tx, // we didn't start it } case MetaData.TX_REQUIRES_NEW: { // Always begin a transaction int oldTimeout = startTransaction(invocation); // get it newTransaction = tm.getTransaction(); // Set it on the method invocation invocation.setTransaction(newTransaction); // Continue invocation try { Object result = invokeNext(invocation, false); checkTransactionStatus(newTransaction, type); return result; } finally { // We started the transaction for sure so we commit or roll back endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); } } case MetaData.TX_MANDATORY: { if (oldTransaction == null) { if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new TransactionRequiredLocalException( "Transaction Required"); } else { throw new TransactionRequiredException( "Transaction Required"); } } // Associate it with the thread tm.resume(oldTransaction); try { Object result = invokeNext(invocation, true); checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } } case MetaData.TX_NEVER: { if (oldTransaction != null) { throw new EJBException("Transaction not allowed"); } return invokeNext(invocation, false); } default: log.error("Unknown TX attribute "+transType+" for method"+invocation.getMethod()); } } finally { // IN case we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } return null; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
2
              
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
0
(Lib) TransactionRolledbackLocalException 3
              
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
protected Object invokeNext(Invocation invocation, boolean inheritedTx) throws Exception { InvocationType type = invocation.getType(); try { if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || type == InvocationType.SERVICE_ENDPOINT) { // register the Timer with the transaction if (ejbTimeout.equals(invocation.getMethod())) registerTimer(invocation); return getNext().invoke(invocation); } else { return getNext().invokeHome(invocation); } } catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
3
              
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
0
(Lib) AccessLocalException 2
              
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
2
              
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
0
(Lib) InvocationTargetException 2
              
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
public static void configureSSLSocketFactory(HttpURLConnection conn) throws InvocationTargetException { Class connClass = conn.getClass(); if ( conn instanceof HttpsURLConnection && sslSocketFactoryBuilder != null) { try { SSLSocketFactory socketFactory = sslSocketFactoryBuilder.getSocketFactory(); Class[] sig = {SSLSocketFactory.class}; Method method = connClass.getMethod("setSSLSocketFactory", sig); Object[] args = {socketFactory}; method.invoke(conn, args); log.trace("Socket factory set on connection"); } catch(Exception e) { throw new InvocationTargetException(e); } } }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { // We are going to go through a Remote invocation, switch to a Marshalled Invocation MarshalledInvocation mi = new MarshalledInvocation(invocation); if( externalURL == null ) externalURL = Util.resolveURL(externalURLValue); try { Object value = Util.invoke(externalURL, mi); return value; } catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); } catch (IOException e) { throw new ServerException("IOE", e); } }
2
              
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { throw new InvocationTargetException(e); }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); }
3
              
// in src/main/java/org/jboss/invocation/Invocation.java
public Object performCall(Object instance, Method m, Object[] arguments) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Exception { return m.invoke(instance,arguments); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
public static void configureSSLSocketFactory(HttpURLConnection conn) throws InvocationTargetException { Class connClass = conn.getClass(); if ( conn instanceof HttpsURLConnection && sslSocketFactoryBuilder != null) { try { SSLSocketFactory socketFactory = sslSocketFactoryBuilder.getSocketFactory(); Class[] sig = {SSLSocketFactory.class}; Method method = connClass.getMethod("setSSLSocketFactory", sig); Object[] args = {socketFactory}; method.invoke(conn, args); log.trace("Socket factory set on connection"); } catch(Exception e) { throw new InvocationTargetException(e); } } }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
private Naming getNamingServer(URL providerURL) throws ClassNotFoundException, IOException, InvocationTargetException, IllegalAccessException { // Initialize the proxy Util class to integrate JAAS authentication Util.init(); if( log.isTraceEnabled() ) log.trace("Retrieving content from : "+providerURL); HttpURLConnection conn = (HttpURLConnection) providerURL.openConnection(); Util.configureHttpsHostVerifier(conn); Util.configureSSLSocketFactory(conn); int length = conn.getContentLength(); String type = conn.getContentType(); if( log.isTraceEnabled() ) log.trace("ContentLength: "+length+"\nContentType: "+type); InputStream is = conn.getInputStream(); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); ois.close(); Object obj = mv.get(); if( (obj instanceof Naming) == false ) { String msg = "Invalid reply content seen: "+obj.getClass(); Throwable t = null; if( obj instanceof Throwable ) { t = (Throwable) obj; if( t instanceof InvocationException ) t = ((InvocationException)t).getTargetException(); } if( t != null ) log.warn(msg, t); else log.warn(msg); IOException e = new IOException(msg); throw e; } Naming namingServer = (Naming) obj; return namingServer; }
(Lib) MissingResourceException 2
              
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
private Map loadErrorMessages() { try { InputStream in = getClass().getResourceAsStream( msgBundle ); Properties props = new Properties(); props.load(in); return props; } catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); } catch (NullPointerException e) { throw new MissingResourceException( "Resource not found.", msgBundle, "" ); } }
2
              
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); }
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (NullPointerException e) { throw new MissingResourceException( "Resource not found.", msgBundle, "" ); }
0
(Lib) NoSuchObjectException 2
              
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if (id == null) throw new IllegalArgumentException("Can't get an object with a null key"); EnterpriseContext ctx; synchronized (getCacheLock()) { CachePolicy cache = getCache(); ctx = (EnterpriseContext)cache.get(id); if (ctx == null) { try { ctx = acquireContext(); setKey(id, ctx); if (doActivate(ctx) == false) // This is a recursive activation return ctx; logActivation(id); // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here cache.insert(id, ctx); } catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if(id == null) throw new IllegalArgumentException("Can't get an object with a null key"); Map cache = getLocalCache(); EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id); if(instance == null) { try { // acquire instance = (EntityEnterpriseContext) container.getInstancePool().get(); // set key instance.setId(id); instance.setCacheKey(id); // activate container.getPersistenceManager().activateEntity(instance); // insert cache.put(id, instance); } catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); } } return instance; }
2
              
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); }
3
              
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { EnterpriseContext rtn = null; rtn = super.get(id); return rtn; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if (id == null) throw new IllegalArgumentException("Can't get an object with a null key"); EnterpriseContext ctx; synchronized (getCacheLock()) { CachePolicy cache = getCache(); ctx = (EnterpriseContext)cache.get(id); if (ctx == null) { try { ctx = acquireContext(); setKey(id, ctx); if (doActivate(ctx) == false) // This is a recursive activation return ctx; logActivation(id); // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here cache.insert(id, ctx); } catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if(id == null) throw new IllegalArgumentException("Can't get an object with a null key"); Map cache = getLocalCache(); EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id); if(instance == null) { try { // acquire instance = (EntityEnterpriseContext) container.getInstancePool().get(); // set key instance.setId(id); instance.setCacheKey(id); // activate container.getPersistenceManager().activateEntity(instance); // insert cache.put(id, instance); } catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); } } return instance; }
(Domain) ReentranceException 2
              
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
protected boolean acquireNonReentrant(long waitTime, Transaction miTx) throws ApplicationDeadlockException, InterruptedException, ReentranceException { synchronized(lock) { final Thread curThread = Thread.currentThread(); if(lockHolder != null) { if(lockHolder == curThread) { if(inNonReentrant) { throw new ReentranceException("The same thread reentered: thread-holder=" + lockHolder + ", holding tx=" + holdingTx + ", current tx=" + miTx); } } else if(miTx != null && miTx.equals(holdingTx)) { if(inNonReentrant) { throw new ReentranceException("The same tx reentered: tx=" + miTx + ", holding thread=" + lockHolder + ", current thread=" + curThread); } } else { // Always upgrade deadlock holder to Tx so that we can detect lock properly Object deadlocker = curThread; if(miTx != null) deadlocker = miTx; try { DeadlockDetector.singleton.deadlockDetection(deadlocker, this); while(lockHolder != null) { if(waitTime < 1) { lock.wait(); } else { lock.wait(waitTime); } // If we waited and never got lock, abort if(waitTime > 0 && lockHolder != null) return false; } } finally { DeadlockDetector.singleton.removeWaiting(deadlocker); } } } ++held; lockHolder = curThread; holdingTx = miTx; inNonReentrant = true; } return true; }
0 3
              
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
protected boolean acquireNonReentrant(long waitTime, Transaction miTx) throws ApplicationDeadlockException, InterruptedException, ReentranceException { synchronized(lock) { final Thread curThread = Thread.currentThread(); if(lockHolder != null) { if(lockHolder == curThread) { if(inNonReentrant) { throw new ReentranceException("The same thread reentered: thread-holder=" + lockHolder + ", holding tx=" + holdingTx + ", current tx=" + miTx); } } else if(miTx != null && miTx.equals(holdingTx)) { if(inNonReentrant) { throw new ReentranceException("The same tx reentered: tx=" + miTx + ", holding thread=" + lockHolder + ", current thread=" + curThread); } } else { // Always upgrade deadlock holder to Tx so that we can detect lock properly Object deadlocker = curThread; if(miTx != null) deadlocker = miTx; try { DeadlockDetector.singleton.deadlockDetection(deadlocker, this); while(lockHolder != null) { if(waitTime < 1) { lock.wait(); } else { lock.wait(waitTime); } // If we waited and never got lock, abort if(waitTime > 0 && lockHolder != null) return false; } } finally { DeadlockDetector.singleton.removeWaiting(deadlocker); } } } ++held; lockHolder = curThread; holdingTx = miTx; inNonReentrant = true; } return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
protected boolean acquireReentrant(long waitTime, Transaction miTx) throws ApplicationDeadlockException, InterruptedException, ReentranceException { synchronized(lock) { final Thread curThread = Thread.currentThread(); if(lockHolder != null) { if(lockHolder != curThread && (miTx == null || miTx.equals(holdingTx))) { // Always upgrade deadlock holder to Tx so that we can detect lock properly Object deadlocker = curThread; if(miTx != null) deadlocker = miTx; try { DeadlockDetector.singleton.deadlockDetection(deadlocker, this); while(lockHolder != null) { if(waitTime < 1) { lock.wait(); } else { lock.wait(waitTime); } // If we waited and never got lock, abort if(waitTime > 0 && lockHolder != null) return false; } } finally { DeadlockDetector.singleton.removeWaiting(deadlocker); } } } ++held; lockHolder = curThread; holdingTx = miTx; } return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
public boolean attempt(long waitTime, Transaction miTx, boolean nonReentrant) throws ApplicationDeadlockException, InterruptedException, ReentranceException { return nonReentrant ? acquireNonReentrant(waitTime, miTx) : acquireReentrant(waitTime, miTx); }
(Lib) ResourceException 2
              
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void before(Invocation mi) throws Throwable { // Called out of sequence if (getBeforeDeliveryInvoke()) throw new IllegalStateException("Missing afterDelivery from the previous beforeDelivery for message endpoint " + getProxyString(mi)); // Set the classloader MessageDrivenContainer container = getContainer(mi); synchronized (this) { oldClassLoader = GetTCLAction.getContextClassLoader(inUseThread); SetTCLAction.setContextClassLoader(inUseThread, container.getClassLoader()); } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " set context classloader to " + container.getClassLoader()); // start any transaction try { startTransaction("beforeDelivery", mi, container); setBeforeDeliveryInvoke(true); } catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void after(Invocation mi) throws Throwable { // Called out of sequence if(!getBeforeDeliveryInvoke()) { throw new IllegalStateException("afterDelivery without a previous beforeDelivery for message endpoint " + getProxyString(mi)); } // Finish this delivery committing if we can try { finish("afterDelivery", mi, true); } catch (Throwable t) { throw new ResourceException(t); } }
2
              
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { throw new ResourceException(t); }
0
(Lib) ClassNotFoundException 1
              
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { Class clazz = null; Class[] ifaceClasses = new Class[interfaces.length]; for(int i = 0; i < interfaces.length; i ++) ifaceClasses[i] = Class.forName(interfaces[i], false, appCl); try { clazz = Proxy.getProxyClass(appCl, ifaceClasses); } catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); } return clazz; }
1
              
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); }
45
              
// in src/main/java/org/jboss/invocation/ByValueInvokerInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { // We have no state }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { externalURLValue = (String) in.readObject(); externalURL = Util.resolveURL(externalURLValue); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
private MarshalledInvocation createInvocationCopy(Invocation invocation, IMarshalledValue value) throws IOException, ClassNotFoundException { MarshalledInvocation invocationCopy = new MarshalledInvocation(invocation); invocationCopy.setMethod(null); invocationCopy.setMethodHash(MarshalledInvocation.calculateHash(invocation.getMethod())); invocationCopy.setMarshalledArguments(value); invocationCopy.setArguments(null); InvocationContext copyContext = null; if (invocation.getInvocationContext()!=null) { copyContext = (InvocationContext)createMarshalledValueForCallByValue(invocation.getInvocationContext()).get(); } invocationCopy.setInvocationContext(copyContext); Map payLoad = invocation.getPayload(); Map payloadCopy = new HashMap(); if (payLoad!=null && payLoad.size()!=0) { Iterator keys = payLoad.keySet().iterator(); while (keys.hasNext()) { Object currentKey = keys.next(); Object valueSource = payLoad.get(currentKey); payloadCopy.put(currentKey,this.createMarshalledValueForCallByValue(valueSource)); } } invocationCopy.payload = payloadCopy; return invocationCopy; }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { invokerID = (GUID)in.readObject(); }
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { String className = v.getName(); Class resolvedClass = null; // Check the class cache first if it exists if( classCache != null ) { synchronized( classCache ) { resolvedClass = (Class) classCache.get(className); } } if( resolvedClass == null ) { ClassLoader loader = SecurityActions.getContextClassLoader(); try { resolvedClass = loader.loadClass(className); } catch(ClassNotFoundException e) { /* Use the super.resolveClass() call which will resolve array classes and primitives. We do not use this by default as this can result in caching of stale values across redeployments. */ resolvedClass = super.resolveClass(v); } if( classCache != null ) { synchronized( classCache ) { classCache.put(className, resolvedClass); } } } return resolvedClass; }
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("["); for(int i = 0; i < interfaces.length; i ++) { if( i > 0 ) tmp.append(','); tmp.append(interfaces[i]); } tmp.append(']'); log.trace("resolveProxyClass called, ifaces="+tmp.toString()); } // Load the interfaces from the cache or thread context class loader ClassLoader loader = null; Class[] ifaceClasses = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { Class iface = null; String className = interfaces[i]; // Check the proxy cache if it exists if( classCache != null ) { synchronized( classCache ) { iface = (Class) classCache.get(className); } } // Load the interface class using the thread context ClassLoader if( iface == null ) { if( loader == null ) loader = Thread.currentThread().getContextClassLoader(); iface = loader.loadClass(className); if( classCache != null ) { synchronized( classCache ) { classCache.put(className, iface); } } } ifaceClasses[i] = iface; } return Proxy.getProxyClass(loader, ifaceClasses); }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public Object get() throws IOException, ClassNotFoundException { if (serializedForm == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream(serializedForm); MarshalledValueInputStream mvis = new MarshalledValueInputStream(bais); Object retValue = mvis.readObject(); mvis.close(); return retValue; }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int length = in.readInt(); serializedForm = null; if( length > 0 ) { serializedForm = new byte[length]; in.readFully(serializedForm); } hashCode = in.readInt(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
public void readExternal(java.io.ObjectInput in) throws IOException, ClassNotFoundException { tpc = in.readObject(); this.methodHash = in.readLong(); this.objectName = in.readObject(); marshalledArgs = in.readObject(); int payloadSize = in.readInt(); if (payloadSize > 0) { payload = new HashMap(); for (int i = 0; i < payloadSize; i++) { Object key = in.readObject(); Object value = in.readObject(); payload.put(key, value); } } int as_is_payloadSize = in.readInt(); if (as_is_payloadSize > 0) { as_is_payload = new HashMap(); for (int i = 0; i < as_is_payloadSize; i++) { Object key = in.readObject(); Object value = in.readObject(); as_is_payload.put(key, value); } } // TODO invocationType should be removed from as is payload // for now, it is in there for binary compatibility invocationType = (InvocationType)getAsIsValue(InvocationKey.TYPE); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata); return removeDecoration(ret); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); return removeDecoration(ret); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); if(ret instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) ret; Object param = remoteInv.getParameter(); if(param instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) param; Object txCxt = mi.getTransactionPropagationContext(); if(txCxt != null) { TransactionPropagationContextImporter tpcImporter = TransactionPropagationContextUtil.getTPCImporter(); mi.setTransaction(tpcImporter.importTransactionPropagationContext(txCxt)); } } } return ret; }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { int version = in.readInt(); // Read in and map the version of the serialized data seen switch(version) { case VERSION_5_0: locator = new InvokerLocator(in.readUTF()); strictRMIException = in.readBoolean(); init(locator); break; default: throw new StreamCorruptedException("Unknown version seen: " + version); } }
// in src/main/java/org/jboss/metadata/EnvEntryBinder.java
public static void bindEnvEntry(Context ctx, EnvEntryMetaData entry) throws ClassNotFoundException, NamingException { ClassLoader loader = EnvEntryMetaData.class.getClassLoader(); Class type = loader.loadClass(entry.getType()); if (type == String.class) { Util.bind(ctx, entry.getName(), entry.getValue()); } else if (type == Integer.class) { Util.bind(ctx, entry.getName(), new Integer(entry.getValue())); } else if (type == Long.class) { Util.bind(ctx, entry.getName(), new Long(entry.getValue())); } else if (type == Double.class) { Util.bind(ctx, entry.getName(), new Double(entry.getValue())); } else if (type == Float.class) { Util.bind(ctx, entry.getName(), new Float(entry.getValue())); } else if (type == Byte.class) { Util.bind(ctx, entry.getName(), new Byte(entry.getValue())); } else if (type == Character.class) { Object value = null; String input = entry.getValue(); if (input == null || input.length() == 0) { value = new Character((char) 0); } else { value = new Character(input.charAt(0)); } Util.bind(ctx, entry.getName(), value); } else if (type == Short.class) { Util.bind(ctx, entry.getName(), new Short(entry.getValue())); } else if (type == Boolean.class) { Util.bind(ctx, entry.getName(), new Boolean(entry.getValue())); } else { // Default to a String type Util.bind(ctx, entry.getName(), entry.getValue()); } }
// in src/main/java/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
protected void processJBossClientMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder, String mainClassName) throws ClassNotFoundException { ApplicationClient5MetaDataCreator creator = new ApplicationClient5MetaDataCreator(finder, mainClassName); Collection<Class<?>> classes = new ArrayList<Class<?>>(1); Class<?> mainClass = unit.getClassLoader().loadClass(mainClassName); classes.add(mainClass); ApplicationClientMetaData annotationMetaData = creator.create(classes); if(annotationMetaData != null) unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
private void createPolicyConfiguration() throws PolicyContextException, ClassNotFoundException { if(parentPC == null) { PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory(); parentPC = pcf.getPolicyConfiguration(contextID, false); } }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void setInitialContext(String className) throws ClassNotFoundException { contextInfo.loadClass(className); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void loadClass(String className) throws ClassNotFoundException { ClassLoader loader = Thread.currentThread().getContextClassLoader(); contextClass = loader.loadClass(className); }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
private Naming getNamingServer(URL providerURL) throws ClassNotFoundException, IOException, InvocationTargetException, IllegalAccessException { // Initialize the proxy Util class to integrate JAAS authentication Util.init(); if( log.isTraceEnabled() ) log.trace("Retrieving content from : "+providerURL); HttpURLConnection conn = (HttpURLConnection) providerURL.openConnection(); Util.configureHttpsHostVerifier(conn); Util.configureSSLSocketFactory(conn); int length = conn.getContentLength(); String type = conn.getContentType(); if( log.isTraceEnabled() ) log.trace("ContentLength: "+length+"\nContentType: "+type); InputStream is = conn.getInputStream(); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); ois.close(); Object obj = mv.get(); if( (obj instanceof Naming) == false ) { String msg = "Invalid reply content seen: "+obj.getClass(); Throwable t = null; if( obj instanceof Throwable ) { t = (Throwable) obj; if( t instanceof InvocationException ) t = ((InvocationException)t).getTargetException(); } if( t != null ) log.warn(msg, t); else log.warn(msg); IOException e = new IOException(msg); throw e; } Naming namingServer = (Naming) obj; return namingServer; }
// in src/main/java/org/jboss/naming/NamingService.java
public void setClientSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setClientSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void setServerSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setServerSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void setJNPServerSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setJNPServerSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/ejb/EjbModule.java
void createMissingPermissions(Container con, BeanMetaData bean) throws ClassNotFoundException, PolicyContextException { String contextID = con.getJaccContextID(); PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, false); Class clazz = con.getHomeClass(); // If there is no security domain mark all methods as unchecked boolean hasSecurityDomain = con.getSecurityManager() != null; boolean exclude = hasSecurityDomain ? bean.isExcludeMissingMethods() : false; if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.HOME, pc); } clazz = con.getLocalHomeClass(); if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.LOCALHOME, pc); } clazz = con.getLocalClass(); if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.LOCAL, pc); } clazz = con.getRemoteClass(); if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.REMOTE, pc); } if (pc.inService() == false) pc.commit(); // Allow the policy to incorporate the policy configs Policy.getPolicy().refresh(); }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
private Collection<Class<?>> loadClasses(ClassLoader cl, Iterable<String> classNames) throws ClassNotFoundException { Collection<Class<?>> interceptorClasses = new HashSet<Class<?>>(); for (String interceptorClassName : classNames) { interceptorClasses.add(cl.loadClass(interceptorClassName)); } return interceptorClasses; }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException { // No state }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // No state }
// in src/main/java/org/jboss/ejb/CacheKey.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { id = in.readObject(); mo = (MarshalledObject) in.readObject(); hashCode = in.readInt(); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { try { // use the application classloader to resolve the class return appCl.loadClass(v.getName()); } catch (ClassNotFoundException e) { // we should probably never get here return super.resolveClass(v); } }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { Class clazz = null; Class[] ifaceClasses = new Class[interfaces.length]; for(int i = 0; i < interfaces.length; i ++) ifaceClasses[i] = Class.forName(interfaces[i], false, appCl); try { clazz = Proxy.getProxyClass(appCl, ifaceClasses); } catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); } return clazz; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); factory = (BaseLocalProxyFactory) BaseLocalProxyFactory.invokerMap.get(jndiName); }
// in src/main/java/org/jboss/ejb/ListCacheKey.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); listId = in.readLong(); index = in.readInt(); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void processEncReferences(WebApplication webApp, Context envCtx) throws ClassNotFoundException, NamingException { DeploymentUnit unit = webApp.getDeploymentUnit(); JBossWebMetaData metaData = webApp.getMetaData(); EnvironmentEntriesMetaData envEntries = metaData.getEnvironmentEntries(); log.debug("addEnvEntries"); addEnvEntries(envEntries, envCtx); ResourceEnvironmentReferencesMetaData resourceEnvRefs = metaData.getResourceEnvironmentReferences(); log.debug("linkResourceEnvRefs"); linkResourceEnvRefs(resourceEnvRefs, envCtx); ResourceReferencesMetaData resourceRefs = metaData.getResourceReferences(); log.debug("linkResourceRefs"); linkResourceRefs(resourceRefs, envCtx); log.debug("linkMessageDestinationRefs"); MessageDestinationReferencesMetaData msgRefs = metaData.getMessageDestinationReferences(); linkMessageDestinationRefs(unit, msgRefs, envCtx); EJBReferencesMetaData ejbRefs = metaData.getEjbReferences(); log.debug("linkEjbRefs"); linkEjbRefs(unit, ejbRefs, envCtx); EJBLocalReferencesMetaData ejbLocalRefs = metaData.getEjbLocalReferences(); log.debug("linkEjbLocalRefs"); linkEjbLocalRefs(unit, ejbLocalRefs, envCtx); log.debug("linkServiceRefs"); ServiceReferencesMetaData serviceRefs = metaData.getServiceReferences(); linkServiceRefs(unit, serviceRefs, envCtx); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx) throws ClassNotFoundException, NamingException { for (EnvironmentEntryMetaData entry : envEntries) { log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue()); bindEnvEntry(envCtx, entry); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry) throws ClassNotFoundException, NamingException { ClassLoader loader = EnvironmentEntryMetaData.class.getClassLoader(); Class type = loader.loadClass(entry.getType()); if (type == String.class) { Util.bind(ctx, entry.getName(), entry.getValue()); } else if (type == Integer.class) { Util.bind(ctx, entry.getName(), new Integer(entry.getValue())); } else if (type == Long.class) { Util.bind(ctx, entry.getName(), new Long(entry.getValue())); } else if (type == Double.class) { Util.bind(ctx, entry.getName(), new Double(entry.getValue())); } else if (type == Float.class) { Util.bind(ctx, entry.getName(), new Float(entry.getValue())); } else if (type == Byte.class) { Util.bind(ctx, entry.getName(), new Byte(entry.getValue())); } else if (type == Character.class) { Object value = null; String input = entry.getValue(); if (input == null || input.length() == 0) { value = new Character((char)0); } else { value = new Character(input.charAt(0)); } Util.bind(ctx, entry.getName(), value); } else if (type == Short.class) { Util.bind(ctx, entry.getName(), new Short(entry.getValue())); } else if (type == Boolean.class) { Util.bind(ctx, entry.getName(), new Boolean(entry.getValue())); } else { // Default to a String type Util.bind(ctx, entry.getName(), entry.getValue()); } }
// in src/main/java/org/jboss/proxy/Interceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { nextInterceptor = (Interceptor)in.readObject(); }
// in src/main/java/org/jboss/proxy/compiler/Runtime.java
public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { // isn't this redundant? if (name.endsWith("$Proxy") && name.equals(compiler.getProxyClassName())) { return compiler.proxyType; } // delegate to the original class loader ClassLoader cl = getTargetClassLoader(); if (cl == null) { return super.findSystemClass(name); } return cl.loadClass(name); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); id = getField.get("id", null); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public EJBObject readEJBObject(ObjectInputStream oistream) throws IOException, ClassNotFoundException { Object ejbObject = oistream.readObject(); reconnect(ejbObject); return (EJBObject) PortableRemoteObject.narrow(ejbObject, EJBObject.class); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public EJBHome readEJBHome(ObjectInputStream oistream) throws IOException, ClassNotFoundException { Object ejbHome = oistream.readObject(); reconnect(ejbHome); return (EJBHome) PortableRemoteObject.narrow(ejbHome, EJBHome.class); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); // Read the version identifier int version = in.readInt(); if( version == EXTERNAL_VERSION ) { // This version has no additional data } // Set the logging trace level trace = log.isTraceEnabled(); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); list = (List) in.readObject(); }
// in src/main/java/org/jboss/proxy/ejb/ReadAheadResult.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { mainResult = in.readObject(); aheadArray = (Object[]) in.readObject(); }
// in src/main/java/org/jboss/proxy/ClientContainer.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { next = (Interceptor) in.readObject(); context = (InvocationContext) in.readObject(); }
(Lib) InternalError 1
              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public Object getTransactionPropagationContext(Transaction tx) { // No need to implement in a stand-alone client. throw new InternalError("Should not have been used."); }
0 0
(Domain) InvocationException 1
              
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
public static Object invoke(URL externalURL, Invocation mi) throws Exception { if( log.isTraceEnabled() ) log.trace("invoke, externalURL="+externalURL); /* Post the MarshalledInvocation data. This is using the URL class for now but this should be improved to a cluster aware layer with full usage of HTTP 1.1 features, pooling, etc. */ HttpURLConnection conn = (HttpURLConnection) externalURL.openConnection(); configureHttpsHostVerifier(conn); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestProperty("ContentType", REQUEST_CONTENT_TYPE); conn.setRequestMethod("POST"); // @todo this should be configurable conn.setRequestProperty("Accept-Encoding", "x-gzip,x-deflate,gzip,deflate"); OutputStream os = conn.getOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(os); try { oos.writeObject(mi); oos.flush(); } catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); } // Get the response MarshalledValue object InputStream is = conn.getInputStream(); // Check the headers for gzip Content-Encoding String encoding = conn.getHeaderField("Content-Encoding"); if( encoding != null && encoding.indexOf("gzip") >= 0 ) is = new GZIPInputStream(is); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); // A hack for jsse connection pooling (see patch ). ois.read(); ois.close(); oos.close(); // If the encoded value is an exception throw it Object value = mv.get(); if( value instanceof Exception ) { throw (Exception) value; } return value; }
1
              
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); }
0
(Domain) InvokerAdaptorException 1
              
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public Object invoke(Invocation invocation) throws Exception { try { // Make sure we have the correct classloader before unmarshalling ClassLoader oldCL = SecurityActions.getContextClassLoader(); ClassLoader newCL = null; // Get the MBean this operation applies to ObjectName objectName = (ObjectName) invocation.getValue("JMX_OBJECT_NAME"); if (objectName != null) { newCL = server.getClassLoaderFor(objectName); } if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(newCL); //JBAS-6449: Cache the incoming security context to be retained on exit SecurityContext previousSecurityContext = SecurityActions.getSecurityContext(); try { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the MBeanServer method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Principal principal = invocation.getPrincipal(); Object credential = invocation.getCredential(); Object value = null; SecurityContext sc = SecurityActions.createSecurityContext(SecurityConstants.DEFAULT_APPLICATION_POLICY); SecurityActions.setSecurityContext(sc); // Associate the method SecurityActions.pushSubjectContext(principal, credential, null); try { if( addNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; NotificationFilter filter = (NotificationFilter) args[2]; Object handback = args[3]; addNotificationListener(name, listener, filter, handback); } else if( removeNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; removeNotificationListener(name, listener); } else { String name = method.getName(); Class[] paramTypes = method.getParameterTypes(); Method mbeanServerMethod = MBeanServer.class.getMethod(name, paramTypes); value = mbeanServerMethod.invoke(server, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; } finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); } } catch (Throwable t) { throw new InvokerAdaptorException(t); } }
1
              
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch (Throwable t) { throw new InvokerAdaptorException(t); }
0
(Domain) JBossTransactionRolledbackException 1
              
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
protected void throwJBossException(Exception e, InvocationType type) throws TransactionRolledbackException { // Unwrap a nested exception if possible. There is no // point in the extra wrapping, and the EJB spec should have // just used javax.transaction exceptions if (e instanceof NestedException) { NestedException rollback = (NestedException) e; if(rollback.getCause() instanceof Exception) { e = (Exception) rollback.getCause(); } } if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new JBossTransactionRolledbackLocalException(e); } else { throw new JBossTransactionRolledbackException(e); } }
0 0
(Domain) JBossTransactionRolledbackLocalException 1
              
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
protected void throwJBossException(Exception e, InvocationType type) throws TransactionRolledbackException { // Unwrap a nested exception if possible. There is no // point in the extra wrapping, and the EJB spec should have // just used javax.transaction exceptions if (e instanceof NestedException) { NestedException rollback = (NestedException) e; if(rollback.getCause() instanceof Exception) { e = (Exception) rollback.getCause(); } } if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new JBossTransactionRolledbackLocalException(e); } else { throw new JBossTransactionRolledbackException(e); } }
0 0
(Lib) ListenerNotFoundException 1
              
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void removeNotificationListener(ObjectName name, RMINotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("removeNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = (NotificationListenerDelegate) remoteListeners.remove(listener); if( delegate == null ) throw new ListenerNotFoundException("No listener matches: "+listener); getServer().removeNotificationListener(name, delegate); }
0 1
              
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void removeNotificationListener(ObjectName name, RMINotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("removeNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = (NotificationListenerDelegate) remoteListeners.remove(listener); if( delegate == null ) throw new ListenerNotFoundException("No listener matches: "+listener); getServer().removeNotificationListener(name, delegate); }
(Lib) MBeanException 1
              
// in src/main/java/org/jboss/ejb/Container.java
public Object invoke(Invocation mi) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); long start = System.currentTimeMillis(); Method m = null; Object type = null; String contextID = getJaccContextID(); try { pushENC(); // JBAS-3732 - Remove classloader.equals optimization SecurityActions.setContextClassLoader(this.classLoader); // Set the JACC context id mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID); contextID = SecurityActions.setContextID(contextID); // Set the standard JACC policy context handler data is not a SEI msg if (mi.getType() != InvocationType.SERVICE_ENDPOINT) { EJBArgsPolicyContextHandler.setArgs(mi.getArguments()); } else { SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE); SOAPMsgPolicyContextHandler.setMessage(msg); } // Set custom JACC policy handlers BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData()); // Check against home, remote, localHome, local, getHome, // getRemote, getLocalHome, getLocal type = mi.getType(); // stat gathering: concurrent calls this.invokeStats.callIn(); if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || // web service calls come in as "ordinary" application invocations type == InvocationType.SERVICE_ENDPOINT) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD REMOTE INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||"); } } m = mi.getMethod(); Object obj = internalInvoke(mi); return obj; } else if (type == InvocationType.HOME || type == InvocationType.LOCALHOME) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD HOME INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||" + mi.getArguments().toString()); } } m = mi.getMethod(); Object obj = internalInvokeHome(mi); return obj; } else { throw new MBeanException(new IllegalArgumentException("Unknown invocation type: " + type)); } } /** * Having to catch this exception here in case can not * unmarshall arguments, values, etc. Then, convert to * UnmarshalException as defined by spec (JBAS-2999) */ catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } } finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); } }
0 3
              
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public Object getAttribute (String attribute) throws javax.management.AttributeNotFoundException, javax.management.MBeanException, javax.management.ReflectionException { if (attribute == null || attribute.equals ("")) throw new IllegalArgumentException ("null or empty attribute name"); if (attribute.equals ("AsynchronousInvalidation")) return new Boolean(this.asynchronous); else throw new javax.management.AttributeNotFoundException(attribute + " is not a known attribute"); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public java.lang.Object invoke (java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature) throws javax.management.MBeanException, javax.management.ReflectionException { if ("invalidate".equals (actionName)) { if (params.length == 1) { if (params[0] instanceof Serializable[]) this.invalidate ((Serializable[])params[0]); else if (params[0] instanceof Serializable) this.invalidate ((Serializable)params[0]); else throw new IllegalArgumentException ("First argument must be Serializable (or array of)"); } else if (params.length == 2) { if (params[0] instanceof Serializable[]) this.invalidate ((Serializable[])params[0], ((Boolean)params[1]).booleanValue ()); else if (params[0] instanceof Serializable) this.invalidate ((Serializable)params[0], ((Boolean)params[1]).booleanValue ()); else throw new IllegalArgumentException ("First argument must be Serializable (or array of)"); } else { throw new IllegalArgumentException ("Unknown operation with these parameters: " + actionName); } } else if("invalidateAll".equals(actionName)) { if(params == null || params.length == 0) { this.invalidateAll(); } else if (params.length == 1) { this.invalidateAll (((Boolean)params[1]).booleanValue ()); } else { throw new IllegalArgumentException ("invalidateAll can take zero or one parameter but got " + params.length); } } else { throw new IllegalArgumentException ("Unknown operation: " + actionName); } return null; }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public void setAttribute (javax.management.Attribute attribute) throws javax.management.AttributeNotFoundException, javax.management.InvalidAttributeValueException, javax.management.MBeanException, javax.management.ReflectionException { String attrName = attribute.getName(); if (attrName == null || attrName.equals ("")) throw new IllegalArgumentException ("null or empty attribute name"); if (attrName.equals ("AsynchronousInvalidation")) { Object value = attribute.getValue (); if (value instanceof Boolean) this.asynchronous = ((Boolean)value).booleanValue (); else throw new javax.management.InvalidAttributeValueException("Attribute is of boolean type"); } else throw new javax.management.AttributeNotFoundException(attrName + " is not a known attribute"); }
(Lib) MarshalException 1
              
// in src/main/java/org/jboss/ejb/Container.java
public Object invoke(Invocation mi) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); long start = System.currentTimeMillis(); Method m = null; Object type = null; String contextID = getJaccContextID(); try { pushENC(); // JBAS-3732 - Remove classloader.equals optimization SecurityActions.setContextClassLoader(this.classLoader); // Set the JACC context id mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID); contextID = SecurityActions.setContextID(contextID); // Set the standard JACC policy context handler data is not a SEI msg if (mi.getType() != InvocationType.SERVICE_ENDPOINT) { EJBArgsPolicyContextHandler.setArgs(mi.getArguments()); } else { SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE); SOAPMsgPolicyContextHandler.setMessage(msg); } // Set custom JACC policy handlers BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData()); // Check against home, remote, localHome, local, getHome, // getRemote, getLocalHome, getLocal type = mi.getType(); // stat gathering: concurrent calls this.invokeStats.callIn(); if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || // web service calls come in as "ordinary" application invocations type == InvocationType.SERVICE_ENDPOINT) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD REMOTE INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||"); } } m = mi.getMethod(); Object obj = internalInvoke(mi); return obj; } else if (type == InvocationType.HOME || type == InvocationType.LOCALHOME) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD HOME INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||" + mi.getArguments().toString()); } } m = mi.getMethod(); Object obj = internalInvokeHome(mi); return obj; } else { throw new MBeanException(new IllegalArgumentException("Unknown invocation type: " + type)); } } /** * Having to catch this exception here in case can not * unmarshall arguments, values, etc. Then, convert to * UnmarshalException as defined by spec (JBAS-2999) */ catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } } finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); } }
1
              
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
0
(Lib) NestedError 2
              
// in src/main/java/org/jboss/ejb/Container.java
protected void rethrow(Exception e) throws Exception { if (e instanceof IllegalAccessException) { // Throw this as a bean exception...(?) throw new EJBException(e); } else if (e instanceof InvocationTargetException) { Throwable t = ((InvocationTargetException)e).getTargetException(); if (t instanceof EJBException) { throw (EJBException)t; } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new NestedError("Unexpected Throwable", t); } } throw e; }
1
              
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
0
(Lib) NotSupportedException 1
              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void begin() throws NotSupportedException, SystemException { if(getStatus() != Status.STATUS_NO_TRANSACTION) throw new NotSupportedException("Attempt to start a nested transaction (the transaction started previously hasn't been ended yet)."); ThreadInfo info = getThreadInfo(); trace = log.isTraceEnabled(); // Only check for trace enabled once per transaction if (trace) { log.trace("Calling UserTransaction.begin()"); } try { Object tpc = getSession().begin(info.getTimeout()); info.push(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
0 4
              
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void begin() throws NotSupportedException, SystemException { if(getStatus() != Status.STATUS_NO_TRANSACTION) throw new NotSupportedException("Attempt to start a nested transaction (the transaction started previously hasn't been ended yet)."); ThreadInfo info = getThreadInfo(); trace = log.isTraceEnabled(); // Only check for trace enabled once per transaction if (trace) { log.trace("Calling UserTransaction.begin()"); } try { Object tpc = getSession().begin(info.getTimeout()); info.push(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public Object begin(int timeout) throws RemoteException, NotSupportedException, SystemException { TransactionManager tm = getTransactionManager(); // Set timeout value tm.setTransactionTimeout(timeout); // Start tx, and get its TPC. tm.begin(); Object tpc = getTPCFactory().getTransactionPropagationContext(); // Suspend thread association. Transaction tx = tm.suspend(); // Remember that a new tx is now active. activeTx.put(tpc, tx); // return the TPC return tpc; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void begin() throws NotSupportedException, SystemException { TransactionManager tm = con.getTransactionManager(); int oldTimeout = -1; if (tm instanceof TransactionTimeoutConfiguration) oldTimeout = ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); // Set the timeout value tm.setTransactionTimeout(timeout); try { // Start the transaction tm.begin(); //notify checked out connections EJB2UserTransactionProvider.getSingleton().userTransactionStarted(); if (tsl != null) tsl.userTransactionStarted(); Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx begin: " + tx); // keep track of the transaction in enterprise context for BMT setTransaction(tx); } finally { // Reset the transaction timeout (if we know what it was) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); } }
(Lib) NullArgumentException 1
              
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void setInstancePool(final InstancePool instancePool) { if (instancePool == null) throw new NullArgumentException("instancePool"); this.instancePool = instancePool; }
0 0
(Lib) OperationNotSupportedException 1
              
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); if (methodName.equals("toString") == true) return "Client ENC(" + clientName + ")"; if (methodName.equals("lookup") == false) throw new OperationNotSupportedException("Only lookup is supported, op=" + method); NameParser parser = lookupCtx.getNameParser(""); Name name = null; if (args[0] instanceof String) name = parser.parse((String) args[0]); else name = (Name) args[0]; // Check for special objects not in the env if (name.size() < 2 || "java:comp".equals(name.get(0)) == false || "env".equals(name.get(1)) == false) return getSpecialObject(name); // Lookup the client application context from the server Context clientCtx = (Context) lookupCtx.lookup(clientName); // JBAS-3967: EJB3 Client container hack try { clientCtx = (Context) clientCtx.lookup("env"); } catch(NamingException e) { // ignore log.trace("No env sub context found", e); } // Strip the comp/env prefix Name bindingName = name.getSuffix(2); Object binding = clientCtx.lookup(bindingName); return binding; }
0 0
(Lib) RejectedExecutionException 1
              
// in src/main/java/org/jboss/executor/ControllerExecutorInstaller.java
public void execute(Runnable command) { Executor exec = mainExecutor; if (exec != null) { exec.execute(command); return; } exec = bootstrapExecutor; if (exec != null) { exec.execute(command); return; } throw new RejectedExecutionException("No executor available in " + this.getClass().getName()); }
0 0
(Lib) StreamCorruptedException 1
              
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { int version = in.readInt(); // Read in and map the version of the serialized data seen switch(version) { case VERSION_5_0: locator = new InvokerLocator(in.readUTF()); strictRMIException = in.readBoolean(); init(locator); break; default: throw new StreamCorruptedException("Unknown version seen: " + version); } }
0 0
(Lib) TransactionRequiredException 1
              
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private Object runWithTransactions(Invocation invocation) throws Exception { // Old transaction is the transaction that comes with the MI Transaction oldTransaction = invocation.getTransaction(); // New transaction is the new transaction this might start Transaction newTransaction = null; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Current transaction in MI is " + oldTransaction); InvocationType type = invocation.getType(); byte transType = container.getBeanMetaData().getTransactionMethod(invocation.getMethod(), type); if ( trace ) printMethod(invocation.getMethod(), transType); // Thread arriving must be clean (jboss doesn't set the thread // previously). However optimized calls come with associated // thread for example. We suspend the thread association here, and // resume in the finally block of the following try. Transaction threadTx = tm.suspend(); if( trace ) log.trace("Thread came in with tx " + threadTx); try { switch (transType) { case MetaData.TX_NOT_SUPPORTED: { // Do not set a transaction on the thread even if in MI, just run try { invocation.setTransaction(null); return invokeNext(invocation, false); } finally { invocation.setTransaction(oldTransaction); } } case MetaData.TX_REQUIRED: { int oldTimeout = 0; Transaction theTransaction = oldTransaction; if (oldTransaction == null) { // No tx running // Create tx oldTimeout = startTransaction(invocation); // get the tx newTransaction = tm.getTransaction(); if( trace ) log.trace("Starting new tx " + newTransaction); // Let the method invocation know invocation.setTransaction(newTransaction); theTransaction = newTransaction; } else { // We have a tx propagated // Associate it with the thread tm.resume(oldTransaction); } // Continue invocation try { Object result = invokeNext(invocation, oldTransaction != null); checkTransactionStatus(theTransaction, type); return result; } finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); } } case MetaData.TX_SUPPORTS: { // Associate old transaction with the thread // Some TMs cannot resume a null transaction and will throw // an exception (e.g. Tyrex), so make sure it is not null if (oldTransaction != null) { tm.resume(oldTransaction); } try { Object result = invokeNext(invocation, oldTransaction != null); if (oldTransaction != null) checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } // Even on error we don't do anything with the tx, // we didn't start it } case MetaData.TX_REQUIRES_NEW: { // Always begin a transaction int oldTimeout = startTransaction(invocation); // get it newTransaction = tm.getTransaction(); // Set it on the method invocation invocation.setTransaction(newTransaction); // Continue invocation try { Object result = invokeNext(invocation, false); checkTransactionStatus(newTransaction, type); return result; } finally { // We started the transaction for sure so we commit or roll back endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); } } case MetaData.TX_MANDATORY: { if (oldTransaction == null) { if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new TransactionRequiredLocalException( "Transaction Required"); } else { throw new TransactionRequiredException( "Transaction Required"); } } // Associate it with the thread tm.resume(oldTransaction); try { Object result = invokeNext(invocation, true); checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } } case MetaData.TX_NEVER: { if (oldTransaction != null) { throw new EJBException("Transaction not allowed"); } return invokeNext(invocation, false); } default: log.error("Unknown TX attribute "+transType+" for method"+invocation.getMethod()); } } finally { // IN case we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } return null; }
0 0
(Lib) UnavailableException 1
              
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException { trace = log.isTraceEnabled(); if (getState() != STARTED && getState() != STARTING) throw new UnavailableException("The container is not started"); HashMap context = new HashMap(); context.put(MessageEndpointInterceptor.MESSAGE_ENDPOINT_FACTORY, this); context.put(MessageEndpointInterceptor.MESSAGE_ENDPOINT_XARESOURCE, resource); String ejbName = container.getBeanMetaData().getContainerObjectNameJndiName(); if (trace) log.trace("createEndpoint " + this + " xaResource=" + resource); MessageEndpoint endpoint = (MessageEndpoint) proxyFactory.createProxy ( ejbName + "@" + nextProxyId.incrementAndGet(), container.getServiceName(), InvokerInterceptor.getLocal(), null, null, interceptors, container.getClassLoader(), interfaces, context ); if (trace) log.trace("Created endpoint " + endpoint + " from " + this); return endpoint; }
0 1
              
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException { trace = log.isTraceEnabled(); if (getState() != STARTED && getState() != STARTING) throw new UnavailableException("The container is not started"); HashMap context = new HashMap(); context.put(MessageEndpointInterceptor.MESSAGE_ENDPOINT_FACTORY, this); context.put(MessageEndpointInterceptor.MESSAGE_ENDPOINT_XARESOURCE, resource); String ejbName = container.getBeanMetaData().getContainerObjectNameJndiName(); if (trace) log.trace("createEndpoint " + this + " xaResource=" + resource); MessageEndpoint endpoint = (MessageEndpoint) proxyFactory.createProxy ( ejbName + "@" + nextProxyId.incrementAndGet(), container.getServiceName(), InvokerInterceptor.getLocal(), null, null, interceptors, container.getClassLoader(), interfaces, context ); if (trace) log.trace("Created endpoint " + endpoint + " from " + this); return endpoint; }
Explicit thrown (throw new...): 1242/1510
Explicit thrown ratio: 82.3%
Builder thrown ratio: 1.9%
Variable thrown ratio: 15.4%
Checked Runtime Total
Domain 4 11 15
Lib 20 503 523
Total 24 514

Caught Exceptions Summary

A (Domain) exception is defined in the application. A (Lib) exception is defined in the JDK or in a library. An exception can be caught, and it happens that the catch block contains a throw (e.g. for wrapping a low-level exception). Hovering over a number triggers showing code snippets from the application code.

Type Exception Caught
(directly)
Caught
with Thrown
(Lib) Exception 375
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { log.warn("Failed to install SecurityAssociationAuthenticator", e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { log.warn("Failed to read "+SSL_FACTORY_BUILDER, e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (Exception e) { log.warn("Could not instantiate SSLSocketFactoryFactory", e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { log.warn("Failed to install SecurityAssociationAuthenticator", e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { throw new InvocationTargetException(e); }
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { e.printStackTrace(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { e.printStackTrace(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { e.printStackTrace(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception ignored) { return null; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (Exception e) { log.error(e); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch (Exception e) { }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Exception e) { log.fatal("Could not initialize UnifiedInvokerProxy.", e); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { log.error("Error adding unified invoker as handler upon connector being set.", e); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { Throwable th = JMXExceptionDecoder.decode(e); if(log.isTraceEnabled()) { log.trace("Failed to invoke on mbean: " + mbean, th); } if(th instanceof Exception) { e = (Exception) th; } throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Exception e) { log.debug(iface+"No addNotificationListener(ObjectName, RMINotificationListener)"); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Exception e) { log.debug(iface+"No removeNotificationListener(ObjectName, RMINotificationListener)"); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Throwable t) { log.debug("Failed to notify client, unregistering listener", t); try { removeNotificationListener(targetName, client); } catch(Exception e) { log.debug("Failed to unregister listener", e); } }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Exception e) { log.debug("Failed to unregister listener", e); }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception inner) { throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(Exception e) { // Can't happen }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(Exception e) { String msg = "Failed to authorize principal=" + caller + ",MBean=" + objname + ", Operation=" + opname; SecurityException ex = new SecurityException(msg); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthenticationInterceptor.java
catch (Exception e) { }
// in src/main/java/org/jboss/jmx/connector/invoker/ExternalizableRolesAuthorization.java
catch (Exception e) { log.error("Error reading roles from jmxinvoker-roles.properties:",e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception e) { // ignore }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception e) { error = e; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception e) { close(); throw e; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception ignored) { log.trace("Ignored error during close", ignored); }
// in src/main/java/org/jboss/deployment/EARStructure.java
catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
catch (Exception ex) { DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex); }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(Exception ignored) { if(log.isTraceEnabled()) log.trace("Failed to load class: "+className, ignored); }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(Exception e) { }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(Exception e) { }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e); }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
catch (Exception e) { return false; }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { log.error("Cannot commit Parent Policy Configuration:",e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(Exception e) { NamingException ne = new NamingException("Failed to update jndiName"); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Exception e) { log.error("getDeployedApplications failed", e); appendErrorTag(buffer, "Failed to getDeployedApplications " + e.toString()); closeJndiTag(buffer); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Exception e) { // this is not expected - report it log.error("JNDIView.getHAJndiAttributes() failed", e); return null; }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception e) { handleOutputFileCreationException(file.toURI(), e); }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception ignored) { ; }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception ignored) {}
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception e) { log.warn("Failed to delete JNP URL file " + outputFile + " due to " + e); }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(Exception e) { NamingException ex = new NamingException("Failed to retrieve Naming interface for provider " + provider); ex.setRootCause(e); throw ex; }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch (Exception e) { if(e.getCause() instanceof IOException) { //no auth.conf or whatever so we make our own dummy conf = new DummyConfiguration(); } }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
catch(Exception e) { NamingException ne = new NamingException("Failed to obtain value from binding: "+name); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception ex) { throw new RuntimeException("UT factory lookup failed", ex); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception ex) { // ignore }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (Exception ex) { log.error("rollback failed", ex); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch (Exception e) { log.warn("Failed to unbind "+JNDI_NAME, e); }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (Exception e) { log.warn("Got Exception when looking for DeploymentUnit: " + e); return null; }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (Exception e) { log.warn("Got Exception when looking for DeploymentUnit: " + e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { throw new EJBException("Failed to create timer", e); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { log.error("Retry timeout failed for timer: " + txtimer, e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { log.error("Cannot create timer table", e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { log.error("Cannot deserialize", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { log.error("Cannot deserialize", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
catch (Exception e) { log.error("Cannot register txtimer with Tx: " + this); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
catch (Exception e) { log.error("Error invoking ejbTimeout", e); }
// in src/main/java/org/jboss/ejb/txtimer/FixedDelayRetryPolicy.java
catch (Exception ignore) { ignore.printStackTrace(); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (Exception e) { log.warn("Unable to restore timer record: " + handle); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.error("Cannot obtain the implementation of a RetryPolicy", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a PersistencePolicy, using NoopPersistencePolicy: " + e.toString()); persistencePolicy = new NoopPersistencePolicy(); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a TimerIdGenerator, using BigIntegerTimerIdGenerator: " + e.toString()); timerIdGenerator = new BigIntegerTimerIdGenerator(); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.error("Cannot create TimedObjectInvoker: " + timedObjectInvokerClassName, e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Unable to restore timer record: " + handle, e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception ignore) { }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new RuntimeException("Cannot start EJBTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new IllegalStateException("Cannot create EJBTimerService proxy: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot createTimerService", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot createTimerService", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot getTimerService", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot removeTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot removeTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot restoreTimer", e); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { destroyService(); throw e; }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.error("unexpected exception stopping Container: " + con.getJmxName(), e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.warn("Could not load the " + className + " interceptor for this container", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.warn("The Container Invoker " + invoker + " (in jboss.xml or standardjboss.xml) could not be created because of " + e + " We will ignore this error, but you may miss a transport for this bean."); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { log.warn("Failed to grant access to the Handle.getEJBObject method"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { throw new EJBException("Could not create timer service", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { log.error("Could not remove timer service", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { log.warn("Could not restore ejb timers", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { log.debug("failed to lookup DefaultDS; ignoring", e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { log.warn("Error undeploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception ignored) { // Ignore the lack of an EntityLockMonitor }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
catch (Exception x) { log.error("Failed to setSessionContext", x); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/CacheKey.java
catch (Exception e) { Logger log = Logger.getLogger(getClass()); log.error("failed to initialize, id="+id, e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (Exception e) { log.error("Error getting callerPrincipal for " + con.getBeanClass(),e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (Exception e) { log.error("isCallerInRole("+ roleName+") had exception:",e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { exception = e; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { exceptionThrown = e; throw e; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException (e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch (Exception e) { log.error("Failed to initialze DefaultSecurityProxy", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(Exception e) { log.error("Failed to initialze SecurityProxy", e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Could not load messaging-type class " + messagingType, e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Cannot locate resource adapter deployment " + resourceAdapterName, e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
catch (Exception ignore) { }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
catch (Exception ignored) { // backwards comaptibility }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactoryService.java
catch( Exception e ) { log.error( "Caught exception during startService()", e ); // Ingore }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactoryService.java
catch( Exception e ) { log.error( "Caught exception during startService()", e ); // Ingore }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactoryService.java
catch( Exception e ) { log.error( "Caught exception during stopService()", e ); // Ingore }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to begin a new transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { log.error("Failed to commit.", e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Exception ex) { log.warn("Unable to importXml for the TxInterceptorCMT", ex); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Exception ex) { checkRetryable(i, ex, oldTransaction); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Exception ex) { checkRetryable(i, ex, oldTransaction); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
catch (Exception ignored) { log.debug(ignored); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
catch (Exception ignored) { log.debug(ignored); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
catch (Exception e) { log.debug(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception ignored) { log.warn("failed to passivate, id="+id, ignored); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.warn(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { vcr = null; log.warn("problem scheduling valid contexts refresher", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.debug("Exception releasing context", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { // Exception - force reload on next call ctx.setValid(false); throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.debug("Exception releasing context", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.debug("Exception releasing context", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception ex) { log.warn("Unable to determine transaction context", ex); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (Exception e) { // catch JMSExceptions, tx.SystemExceptions, and NPE's // don't want to bother the container even if the metrics fail. return null; }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (Exception e) { }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { RemoveException re = new RemoveException(e.getMessage()); re.initCause(e); throw re; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ignore) { }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to register table cache for " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { log.error("Failed to stop entity bridge.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeRemoveRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeAddRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(Exception e) { throw new EJBException("Internal error extracting primary key from instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(Exception e) { throw new EJBException("Internal error", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCMappingMetaData.java
catch(Exception e) { log.warn("Unrecognized jdbc-type: " + name + ", using Types.OTHER", e); return Types.OTHER; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find getter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find setter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { throw new EJBException("Failed to obtain current transaction", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new IllegalStateException( "Failed to create an instance of " + valueType + " with the " + fieldValue + " as a ctor argument" ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.error("Could not suspend current transaction before drop table. " + "'" + qualifiedTableName + "' will not be dropped.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.debug("Could not drop table " + qualifiedTableName + ": " + e.getMessage()); success = false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.error("Could not reattach original transaction after drop table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("EXCEPTION ALTER :" + e.toString()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(Exception e) { throw new EJBException("Error getting application tx data map.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCPostCreateEntityCommand.java
catch(Exception e) { // no such object }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { throw new EJBException("Error getting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { throw new EJBException("Error creating primary key instance: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error extracting primary key from " + "instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP2xFieldBridge.java
catch(Exception e) { // no such object }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP2xFieldBridge.java
catch(Exception e) { // no such object }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception ignore) { // no such entity. it is ok to ignore }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception ignore) { // no such entity. it is ok to ignore valid = false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in getRelatedId", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in addRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in removeRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(Exception e) { throw new EJBException("Load relation failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { prepare = null; getGeneratedKeys = null; generateKeys = null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { throw processException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Exception ignored) { }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Exception ignored) { log.warn("failed to passivate, id=" + id, ignored); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (Exception e) { //ignore }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (Exception ex) { log.error("Failed to rollback", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (Exception ex) { log.error("Failed to rollback", ex); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to setup InstanceSynchronization", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to invoke afterBegin", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to invoke beforeCompletion", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to invoke afterCompletion", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
catch (Exception e) { if (log.isTraceEnabled()) { log.trace("Exception in creating TimedObject method:",e); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
catch (Exception ignored) { }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationsTxGrouper.java
catch(Exception ex) { InvalidationsTxGrouper.log.warn("Failed sending invalidations messages", ex); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn(ex.getMessage()); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn("Failed to stop JMS resources associated with the JMS bridge: ", ex); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn("failed to do cluster seppuku event: " , ex); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
catch (Exception e) { log.debug ("Problem while trying to register a new invalidation group in JMX", e); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
catch (Exception e) { log.debug ("Problem while trying to un-register a new invalidation group in JMX", e); }
// in src/main/java/org/jboss/monitor/EntityLockMonitor.java
catch (Exception ignored) {}
// in src/main/java/org/jboss/web/WebServer.java
catch (Exception ignore) {}
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (Exception e) { log.warn("Could not get global URL[] from default loader repository!", e); }
// in src/main/java/org/jboss/web/deployers/WebModule.java
catch (Exception e) { throw new DeploymentException("Error during stop", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { log.debug("Ignoring path element: " + vf, e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw new DeploymentException("Failed to create web module", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { log.debug("Failed to remove expanded war", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception ignore) { }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error scanning HandlesTypes", e); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (Exception e) { if (error) { DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jar, e); } else { log.info("Skipped SCI for JAR: " + jar, e); } }
// in src/main/java/org/jboss/web/WebService.java
catch (Exception e) { log.error("Failed to load org/jboss/web/mime.types; ignoring", e); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (Exception e) { return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (Exception e) { // e.printStackTrace(); return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (Exception e) { // e.printStackTrace(); return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (Exception ignored) { }
// in src/main/java/org/jboss/verifier/Main.java
catch (Exception e) { System.err.println("Problem starting the application:"); System.err.println("Exception: " + e); System.err.println("Message: " + e.getMessage()); e.printStackTrace(); System.exit(-1); }
// in src/main/java/org/jboss/proxy/compiler/Proxy.java
catch (Exception e) { throw new NestedRuntimeException("Failed to create new proxy target", e); }
// in src/main/java/org/jboss/proxy/compiler/ProxyCompiler.java
catch (Exception e) { log.error("Failed to dump class file", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { log.debug("Exception reported, try JNDI method to recover EJB object instead", e); return getEjbObjectViaJndi(); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new ServerException("Could not bind home", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { // ignore. }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
208
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { throw new InvocationTargetException(e); }
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { Throwable th = JMXExceptionDecoder.decode(e); if(log.isTraceEnabled()) { log.trace("Failed to invoke on mbean: " + mbean, th); } if(th instanceof Exception) { e = (Exception) th; } throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception inner) { throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(Exception e) { String msg = "Failed to authorize principal=" + caller + ",MBean=" + objname + ", Operation=" + opname; SecurityException ex = new SecurityException(msg); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception e) { close(); throw e; }
// in src/main/java/org/jboss/deployment/EARStructure.java
catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(Exception e) { NamingException ne = new NamingException("Failed to update jndiName"); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(Exception e) { NamingException ex = new NamingException("Failed to retrieve Naming interface for provider " + provider); ex.setRootCause(e); throw ex; }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
catch(Exception e) { NamingException ne = new NamingException("Failed to obtain value from binding: "+name); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception ex) { throw new RuntimeException("UT factory lookup failed", ex); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { throw new EJBException("Failed to create timer", e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new RuntimeException("Cannot start EJBTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new IllegalStateException("Cannot create EJBTimerService proxy: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { destroyService(); throw e; }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { throw new EJBException("Could not create timer service", e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { exceptionThrown = e; throw e; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException (e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to begin a new transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { // Exception - force reload on next call ctx.setValid(false); throw e; }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { RemoveException re = new RemoveException(e.getMessage()); re.initCause(e); throw re; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to register table cache for " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeRemoveRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeAddRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(Exception e) { throw new EJBException("Internal error extracting primary key from instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(Exception e) { throw new EJBException("Internal error", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find getter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find setter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { throw new EJBException("Failed to obtain current transaction", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new IllegalStateException( "Failed to create an instance of " + valueType + " with the " + fieldValue + " as a ctor argument" ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(Exception e) { throw new EJBException("Error getting application tx data map.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { throw new EJBException("Error getting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { throw new EJBException("Error creating primary key instance: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error extracting primary key from " + "instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in getRelatedId", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in addRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in removeRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(Exception e) { throw new EJBException("Load relation failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { throw processException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/web/deployers/WebModule.java
catch (Exception e) { throw new DeploymentException("Error during stop", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw new DeploymentException("Failed to create web module", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/proxy/compiler/Proxy.java
catch (Exception e) { throw new NestedRuntimeException("Failed to create new proxy target", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new ServerException("Could not bind home", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
(Lib) Throwable 79
            
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Throwable e) { log.error("Failed", e); return; }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch (Throwable ignored) { }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch (Throwable ignored) { }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); }
// in src/main/java/org/jboss/client/AppClientMain.java
catch(Throwable t) { log.warn("Failed to launch using: "+launcherName, t); }
// in src/main/java/org/jboss/jmx/adaptor/rmi/NotificationListenerDelegate.java
catch(Throwable t) { log.warn("Failed to notify client", t); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch (Throwable t) { throw new InvokerAdaptorException(t); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Throwable t) { log.debug("Failed to notify client, unregistering listener", t); try { removeNotificationListener(targetName, client); } catch(Exception e) { log.debug("Failed to unregister listener", e); } }
// in src/main/java/org/jboss/deployment/dependency/JndiDependencyItem.java
catch(Throwable ignored) { if (log.isTraceEnabled()) log.trace("Unexpected error", ignored); }
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.debug("Unable to list web applications ENC", e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getDeployedApplications failed", e); buffer.append("Failed to getDeployedApplications\n"); formatException(buffer, e); buffer.insert(0, "<pre>"); buffer.append("</pre>"); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getConainers failed", e); buffer.append("<pre>"); buffer.append("Failed to get ejbs in module\n"); formatException(buffer, e); buffer.append("</pre>"); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.debug("Unable to list web applications ENC", e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("getContainers failed", t); appendPreExceptionTag(buffer, "Failed to get ejbs in module", t); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed on list contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list contents of (java:)", t); appendErrorTag(buffer, "Failed to list contents of (java:), " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list global contents ", t); appendErrorTag(buffer, "Failed to list global contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list HA-JNDI contents ", t); appendErrorTag(buffer, "Failed to list HA-JNDI contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.debug("Invalid LinkRef for: " + name, t); buffer.append("invalid]"); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { buffer.append("Failed to lookup: " + name + ", errmsg=" + t.getMessage()); buffer.append('\n'); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Invalid LinkRef for: " + name, t); appendLinkRefErrorTag(buffer); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed to lookup: " + name + ", errmsg=" + t.getMessage()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed to list contents of: " + name + ", errmsg=" + t.getMessage()); }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(Throwable t) { ServiceUnavailableException sue = new ServiceUnavailableException("Unexpected failure"); sue.setRootCause(t); throw sue; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Throwable t) { // ignore }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (Throwable t) { log.debug("Failed to register pool as mbean", t); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (Throwable ignore) { }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Throwable e) { log.warn("Failed to unregister webClassLoader", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Throwable e) { log.error("unexpected exception destroying Container: " + jmxName, e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Throwable t) { log.debug("Failed to register cache as mbean", t); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Throwable ignore) { }
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch (Throwable t) { log.warn("Verify failed; continuing", t ); allOK = false; }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable t) { log.debug("Failed to register pool as mbean", t); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable t) { log.debug("Failed to register invoker binding as mbean", t); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable ignore) { }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable ignore) { }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { DeploymentException.rethrowAsDeploymentException("Error loading interceptor class " + className, t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Unable to create activation spec ra=" + resourceAdapterObjectName + " messaging-type=" + messagingTypeClass.getName() + " properties=" + metaData.getActivationConfigProperties(), t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); log.warn("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { log.warn("Error in release ", t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { log.warn("MessageEndpoint " + getProxyString(mi) + " failed to resume old transaction " + currentTx); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Throwable t) { log.debug("Ignored error trying to retrieve transaction status", t); }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (Throwable t) { log.debug("Ignored error while trying to passivate ctx", t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch (Throwable t) { log.debug("Ignored error while trying to flush() entity cache", t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/EJBQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JBossQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCJBossQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL " + "statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (Throwable t) { log.debug("Ignored error trying to remove passivated beans from cache", t); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable t) { log.debug("Failed to register cache as mbean", t); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable t) { log.debug("Failed to register cache as mbean", t); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable ignore) { }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable ignore) { }
// in src/main/java/org/jboss/ejb/ContainerRelection.java
catch(Throwable e) { if( e instanceof RuntimeOperationsException ) { RuntimeOperationsException roe = (RuntimeOperationsException) e; e = roe.getTargetException(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); buffer.append(sw.toString()); buffer.append("\n</pre>\n"); }
// in src/main/java/org/jboss/web/WebServer.java
catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); }
// in src/main/java/org/jboss/corba/ORBFactory.java
catch (Throwable t) { log.warn("Unable to activate POA", t); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(Throwable t) { retryCount++; if( trace ) log.trace("Retry attempt " + retryCount + ": Failed to lookup proxy", t); if (maxRetries > -1 && retryCount >= maxRetries) { if ( trace) log.trace("Maximum retry attempts made"); break; } }
41
            
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch (Throwable t) { throw new InvokerAdaptorException(t); }
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(Throwable t) { ServiceUnavailableException sue = new ServiceUnavailableException("Unexpected failure"); sue.setRootCause(t); throw sue; }
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/EJBQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JBossQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCJBossQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL " + "statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); }
(Lib) ClassNotFoundException 71
            
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
catch(ClassNotFoundException e) { /* Use the super.resolveClass() call which will resolve array classes and primitives. We do not use this by default as this can result in caching of stale values across redeployments. */ resolvedClass = super.resolveClass(v); }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (ClassNotFoundException e) { log.error(e); }
// in src/main/java/org/jboss/deployment/security/PolicyConfigurationFacade.java
catch (ClassNotFoundException e) { new RuntimeException(e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { // If this is a $Proxy* class its a proxy if (className.startsWith("$Proxy")) { isProxy = true; // We have to get the class from the binding try { Object p = ctx.lookup(name); c = p.getClass(); } catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } } } }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (ClassNotFoundException e) { log.warn("Could not load the " + className + " interceptor", e); }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch (ClassNotFoundException e) { // we should probably never get here return super.resolveClass(v); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCApplicationMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("Unable to load persistence manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("entity class not found for ejb-name: " + entityName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "could not load primary key class: " + entity.getPrimaryKeyClass() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("home class not found: " + home); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "remote class not found: " + entity.getRemote() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local home class not found: " + localHome ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local class not found: " + entity.getLocal() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("could not load the class for " + " unknown primary key: " + unknownPkClass); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValueClassMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("dependent-value-class not found: " + className); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { // Something is really broken }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException e) { if (cmp) fireSpecViolationEvent(entity, new Section("10.6.13.a")); else fireSpecViolationEvent(entity, new Section("12.2.12.a")); // Can't do any other checks if the class is null! return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { // javax.jms.Message is not available?! }
// in src/main/java/org/jboss/verifier/strategy/AbstractEJB2xVerifier.java
catch (ClassNotFoundException cnfe) { // FIXME: this should be handled differently, especially // there shouldn't be a DeploymentException being // thrown ... continue; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException e) { log.warn("Failed to find class: " + className, e); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException e) { log.warn("Failed to find class: " + assignableFromClassName, e); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException cnfe) { // Only check equality return m.getReturnType().getName().equals(entity.getPrimaryKeyClass()); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException cnfe) { // Ignored, if this happens we have more serious problems :) }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { // Something is really broken }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException e) { if (cmp) fireSpecViolationEvent(entity, new Section("10.6.13.a")); else fireSpecViolationEvent(entity, new Section("12.2.12.a")); // Can't do any other checks if the class is null! return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(mdBean, new Section("15.7.2.b", "Class not found on '" + messagingType + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("23.2", "Class not found on '" + seiName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The bean provider MUST specify the fully-qualified name of the * enterprise bean's home interface in the <home> element. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.c")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * enterprise bean's remote interface in the <remote> element. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.d")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * Java class that implements the enterprise bean's business * methods. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.b")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The bean provider MUST specify the fully-qualified name of the * enterprise bean's home interface in the <home> element. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.c")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * enterprise bean's remote interface in the <remote> element. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.d")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * Java class that implements the enterprise bean's business * methods. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.b")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { fireSpecViolationEvent(entity, new Section("16.2.e")); status = false; // Can't do any other checks if the class is null! }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { }
30
            
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCApplicationMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("Unable to load persistence manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("entity class not found for ejb-name: " + entityName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "could not load primary key class: " + entity.getPrimaryKeyClass() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("home class not found: " + home); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "remote class not found: " + entity.getRemote() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local home class not found: " + localHome ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local class not found: " + entity.getLocal() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("could not load the class for " + " unknown primary key: " + unknownPkClass); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValueClassMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("dependent-value-class not found: " + className); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
(Lib) NoSuchMethodException 63
            
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(NoSuchMethodException e) { ctx = newLdapContext(contextClass, contextProps); }
// in src/main/java/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java
catch (NoSuchMethodException ignore) { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.debug("Couldn't find getEJBObject method on container"); }
// in src/main/java/org/jboss/ejb/CacheKey.java
catch(NoSuchMethodException ex) { // Rely on the MarshalledObject for equals and hashCode mo = new MarshalledObject(id); // Precompute the hashCode (speed) hashCode = mo.hashCode(); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (NoSuchMethodException ignored) {}
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException ignored) {}
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class"); throw e; }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (NoSuchMethodException ignored) {}
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(NoSuchMethodException e) { // that's cool }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(NoSuchMethodException e) { throw new IllegalStateException( "Failed to find a ctor in " + valueType + " that takes an instance of " + argType + " as an argument." ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(NoSuchMethodException e) { // Should never happen log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
catch (NoSuchMethodException ignore) { }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (NoSuchMethodException ignore) {}
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { fireSpecViolationEvent(entity, new Section("10.6.2.g", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException e) { // The primary keyfield MUST be a CMP field within the // entity bean. // // Spec 10.8.1 // status = false; fireSpecViolationEvent(entity, new Section("10.8.1.b")); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasDefaultConstructor("); tmp.append(") failure, "); Classes.displayClassInfo(c, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingMethod("); tmp.append(method.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBPostCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { return null; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { return null; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBFind("); tmp.append(finder.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { return null; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBHome("); tmp.append(home.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { fireSpecViolationEvent(entity, new Section("10.6.2.g", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException e) { // The primary keyfield MUST be a CMP field within the // entity bean. // // Spec 10.8.1 // status = false; fireSpecViolationEvent(entity, new Section("10.8.1.b")); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchMethodException ee) { throw new IllegalArgumentException(ee+" in "+c); }
18
            
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class"); throw e; }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(NoSuchMethodException e) { throw new IllegalStateException( "Failed to find a ctor in " + valueType + " that takes an instance of " + argType + " as an argument." ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchMethodException ee) { throw new IllegalArgumentException(ee+" in "+c); }
(Lib) SQLException 45
            
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (SQLException e) { throw e; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { RuntimeException ex = new IllegalStateException("Unable to persist timer"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to delete timer", e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to get timer handles for containerId: " + containerId, e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to get timer handles", e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to clear timers", e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to update: table=" + tableName, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(SQLException e) { throw new EJBException("Failed to read ResultSet.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(SQLException e) { log.debug("Error getting database metadata for DROP TABLE command. " + " DROP TABLE will not be executed. ", e); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); }
44
            
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (SQLException e) { throw e; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { RuntimeException ex = new IllegalStateException("Unable to persist timer"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to update: table=" + tableName, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(SQLException e) { throw new EJBException("Failed to read ResultSet.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); }
(Lib) NamingException 35
            
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (NamingException ignore) { }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
catch(NamingException e) { // ignore log.trace("No env sub context found", e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(NamingException e) { // No binding exists, create a subcontext subctx = subctx.createSubcontext(atom); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(NamingException e) { log.error("unbind failed", e); }
// in src/main/java/org/jboss/naming/java/javaURLContextFactory.java
catch (NamingException e) { e.printStackTrace(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("lookup for java: failed", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { log.error("Failed to get InitialContext", ne); buffer.append("Failed to get InitialContext, " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext for (java:)", e); appendErrorTag(buffer, "Failed to get InitialContext for (java:), " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { // If this is a $Proxy* class its a proxy if (className.startsWith("$Proxy")) { isProxy = true; // We have to get the class from the binding try { Object p = ctx.lookup(name); c = p.getClass(); } catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } } } }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { appendErrorTag(buffer, "error while listing context " + ctx.toString() + ": " + ne.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { appendErrorTag(buffer, "Failed to getLinkName, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(NamingException e) { throw e; }
// in src/main/java/org/jboss/naming/JndiBinder.java
catch (NamingException e) { NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo); namingException.setRootCause(e); throw namingException; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (NamingException ex) { log.error("java:/TransactionManager lookup failed", ex); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (NamingException ignored) { }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (NamingException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (NamingException ignored) { }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (NamingException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(NamingException e) { throw new DeploymentException("Filed to lookup: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NamingException e) { throw new EJBException("Data source for relationship named " + relationName + " not found " + dataSourceName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException e) { throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch (NamingException e) { log.warn("Problem closing naming context used for reaquiring invoker: " + e.getClass() + " -- " + e.getLocalizedMessage()); }
13
            
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(NamingException e) { throw e; }
// in src/main/java/org/jboss/naming/JndiBinder.java
catch (NamingException e) { NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo); namingException.setRootCause(e); throw namingException; }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (NamingException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(NamingException e) { throw new DeploymentException("Filed to lookup: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NamingException e) { throw new EJBException("Data source for relationship named " + relationName + " not found " + dataSourceName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException e) { throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); }
(Lib) IOException 29
            
// in src/main/java/org/jboss/invocation/MarshalledValueOutputStream.java
catch(IOException ignore) { // Let the Serialization layer try with the orignal obj }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (IOException e) { throw new ServerException("IOE", e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); }
// in src/main/java/org/jboss/deployment/EARStructure.java
catch (IOException e) { // TODO - should we throw this fwd? log.warn("Exception while searching for lib dir: " + e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch (IOException e) { // Failed, try to locate a classpath resource below is = null; }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(IOException e) { CommunicationException ce = new CommunicationException("Operation failed"); ce.setRootCause(e); throw ce; }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (IOException e) { log.error("Cannot serialize: " + obj, e); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectOutputStream.java
catch(IOException ignore) { // Let the Serialization layer try with original object }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { throw e; }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { // If the server is not null meaning we were not stopped report the err if (server != null) log.error("Failed to accept connection", e); return; }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException ie) { return; }
// in src/main/java/org/jboss/web/WebServer.java
catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException ex) { // Ignore }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException ex) { log.error("error writting response", ex); }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (IOException e) { log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (IOException e) { ; }
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException cantHappen) { cantHappen.printStackTrace(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/etc/class.java
catch (IOException ioe) { }
15
            
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (IOException e) { throw new ServerException("IOE", e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(IOException e) { CommunicationException ce = new CommunicationException("Operation failed"); ce.setRootCause(e); throw ce; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { throw e; }
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
(Lib) SystemException 25
            
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (SystemException e) { return null; }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (SystemException e) { log.warn("failed to get tx manager status; ignoring", e); return true; }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (SystemException e) { log.warn("failed to set rollback only; ignoring", e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e) { throw new IllegalStateException("Failed to suspend current transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e1) { log.error("Failed to rollback.", e1); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (SystemException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
catch (SystemException e) { // SA FIXME: not sure what to do here return false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error getting transaction from the transaction manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error while creating RelationSet", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (SystemException ex) { log.error("Failed to get status", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (SystemException ex) { log.error("Failed to suspend transaction", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (SystemException ex) { log.error("Failed to get status", ex); }
15
            
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e) { throw new IllegalStateException("Failed to suspend current transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error getting transaction from the transaction manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error while creating RelationSet", e); }
(Lib) InvocationTargetException 24
            
// in src/main/java/org/jboss/client/ReflectionLauncher.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
catch (InvocationTargetException e) { Throwable ex = e.getTargetException(); if (ex instanceof EJBException) throw (Exception)ex; else if (ex instanceof RuntimeException) throw new EJBException((Exception)ex); // Transform runtime exception into what a bean *should* have thrown else if (ex instanceof Exception) throw (Exception)ex; else throw (Error)ex; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(InvocationTargetException e) { // Whatever, I guess non-binary will not work for this field. }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
71
            
// in src/main/java/org/jboss/client/ReflectionLauncher.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
catch (InvocationTargetException e) { Throwable ex = e.getTargetException(); if (ex instanceof EJBException) throw (Exception)ex; else if (ex instanceof RuntimeException) throw new EJBException((Exception)ex); // Transform runtime exception into what a bean *should* have thrown else if (ex instanceof Exception) throw (Exception)ex; else throw (Error)ex; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
(Lib) EJBException 23
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
23
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
(Lib) IllegalAccessException 23
            
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (IllegalAccessException e) { log.error(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IllegalAccessException e) { // Should never happen log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IllegalAccessException e) { // Whatever, I guess non-binary will not work for this field. }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (IllegalAccessException e) { // If CMP primary key class MUST have a public // constructor with no parameters. 10.8.2.a /// if (cmp) { fireSpecViolationEvent(entity, new Section("10.8.2.a")); status = false; } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (IllegalAccessException e) { // If CMP primary key class MUST have a public // constructor with no parameters. 10.8.2.a /// if (cmp) { fireSpecViolationEvent(entity, new Section("10.8.2.a")); status = false; } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (IllegalAccessException e) { // [FIXME] The two error messages below are incorrect. // The RMI-IDL language mapping does not require // the value types to have a no args constructor. // [JPL] // //fireSpecViolationEvent(entity, new Section("9.2.9.a")); //status = false; }
17
            
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
(Lib) RemoteException 23
            
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException ex) { // Ignore. }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (RemoteException e) { // DEBUG Logger.exception(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (RemoteException e) { if( log.isTraceEnabled() ) log.trace("Ctx.discard error", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); }
21
            
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); }
(Lib) NumberFormatException 14
            
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "alias-max-length " + aliasMaxLengthString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Failed to parse int value '" + str + "' for max-keys-in-delete", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCReadAheadMetaData.java
catch(NumberFormatException ex) { throw new DeploymentException("Invalid number format in read-ahead page-size '" + pageSizeStr + "': " + ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in read-" + "ahead list-cache-max '" + listCacheMaxStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "fetch-size '" + fetchSizeStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
catch(NumberFormatException e) { throw new IllegalArgumentException("The parameter must begin with a number"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
14
            
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "alias-max-length " + aliasMaxLengthString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Failed to parse int value '" + str + "' for max-keys-in-delete", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCReadAheadMetaData.java
catch(NumberFormatException ex) { throw new DeploymentException("Invalid number format in read-ahead page-size '" + pageSizeStr + "': " + ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in read-" + "ahead list-cache-max '" + listCacheMaxStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "fetch-size '" + fetchSizeStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
catch(NumberFormatException e) { throw new IllegalArgumentException("The parameter must begin with a number"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
(Lib) RuntimeException 13
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( RuntimeException e ) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
13
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( RuntimeException e ) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
(Lib) XAException 10
            
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
10
            
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
(Lib) DeploymentException 8
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (DeploymentException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(DeploymentException de) { throw de; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(DeploymentException e) { throw new FinderException(e.getMessage()); }
8
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (DeploymentException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(DeploymentException de) { throw de; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(DeploymentException e) { throw new FinderException(e.getMessage()); }
(Lib) Error 8
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Error e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
8
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Error e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
(Lib) MalformedObjectNameException 8
            
// in src/main/java/org/jboss/deployment/EarClassLoaderDeployer.java
catch (MalformedObjectNameException ignored) { // Not a JMX ObjectName??? }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (MalformedObjectNameException e) { log.trace("Ignored malformed invoker mbean '" + invokerName + "' " + e.toString()); }
// in src/main/java/org/jboss/ejb/Container.java
catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create EJB module " + unit.getName() + ": malformed EjbModule name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (MalformedObjectNameException ignored) { }
5
            
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create EJB module " + unit.getName() + ": malformed EjbModule name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); }
(Lib) NullPointerException 8
            
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (NullPointerException e) { throw new MissingResourceException( "Resource not found.", msgBundle, "" ); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NullPointerException e) { // That's OK - the implementor expected the fields to // have values }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NullPointerException e) { // That's OK - the implementor expected the fields to have values }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NullPointerException e) { // That's OK - the implementor expected the fields to // have values }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NullPointerException e) { // That's OK - the implementor expected the fields to have values }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NullPointerException e) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NullPointerException e) { }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
2
            
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (NullPointerException e) { throw new MissingResourceException( "Resource not found.", msgBundle, "" ); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
(Lib) PrivilegedActionException 8
            
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { throw e.getException(); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/Container.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
11
            
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { throw e.getException(); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/Container.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
(Lib) SecurityException 8
            
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(SecurityException e) { throw e; }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
catch (SecurityException e) { return null; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.SecurityException ex) { finished = false; throw ex; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/corba/ORBFactory.java
catch (SecurityException ignored) { log.trace("Unable to retrieve system properties", ignored); properties = null; }
6
            
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.SecurityException ex) { finished = false; throw ex; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; }
(Lib) IllegalStateException 7
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.IllegalStateException ex) { finished = false; throw ex; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (IllegalStateException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
catch (IllegalStateException e) { DeploymentException.rethrowAsDeploymentException("Invalid ordering", e); }
4
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.IllegalStateException ex) { finished = false; throw ex; }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
(Lib) InterruptedException 7
            
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (InterruptedException e) { Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/lock/BeanLockSupport.java
catch (InterruptedException ex) { intr = true; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (InterruptedException ignored) { intr = true; }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (InterruptedException e) { intr = true; }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (InterruptedException e) { // kill this thread intr = true; running = false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
catch(InterruptedException e) { intr = true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
catch(InterruptedException e) { intr = true; }
0
(Lib) NoSuchFieldException 7
            
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (NoSuchFieldException e) { // will be here with dependant value object's private attributes // should not be a problem }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (NoSuchFieldException e) { // will be here with dependant value object's private attributes // should not be a problem }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(NoSuchFieldException e) { // Non recoverable internal exception throw new DeploymentException("No field named '" + getFieldName() + "' found in entity class."); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NoSuchFieldException e) { fireSpecViolationEvent(entity, new Section("9.4.7.1.b")); status = false; }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchFieldException ee) { throw new IllegalArgumentException(ee+" in "+c); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
4
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(NoSuchFieldException e) { // Non recoverable internal exception throw new DeploymentException("No field named '" + getFieldName() + "' found in entity class."); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchFieldException ee) { throw new IllegalArgumentException(ee+" in "+c); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
(Lib) PolicyContextException 7
            
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException("Cannot create permissions:",e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/PolicyConfigurationFacade.java
catch (PolicyContextException e) { new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/PolicyConfigurationFacade.java
catch (PolicyContextException e) { new RuntimeException(e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (PolicyContextException pe) { if(log.isTraceEnabled()) log.trace("PolicyContextException in getting caller subject:",pe); }
4
            
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException("Cannot create permissions:",e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException(e); }
(Lib) ConcurrentModificationException 6
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); }
6
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); }
(Lib) MalformedURLException 6
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(MalformedURLException e) { // See if externalURL refers to a property String urlProperty = System.getProperty(urlValue); if( urlProperty == null ) throw e; externalURL = new URL(urlProperty); }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (MalformedURLException mue) { log.warn("Can't construct URL for: " + ourPath); return null; }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (MalformedURLException mue) { log.warn("Can't construct URL for: " + ourPath); return null; }
// in src/main/java/org/jboss/web/WebServer.java
catch (MalformedURLException e) { log.error("invalid url", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
3
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(MalformedURLException e) { // See if externalURL refers to a property String urlProperty = System.getProperty(urlValue); if( urlProperty == null ) throw e; externalURL = new URL(urlProperty); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
(Lib) RollbackException 6
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RollbackException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (RollbackException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RollbackException e) { throw new EJBException("Error while creating RelationSet", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RollbackException e) { }
4
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RollbackException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RollbackException e) { throw new EJBException("Error while creating RelationSet", e); }
(Lib) InstantiationException 5
            
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (InstantiationException e) { log.error(e); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (InstantiationException e) { //Not sure what condition this is at the moment - JMW //fireSpecViolationEvent(entity, new Section("9.2.9.a")); //status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (InstantiationException e) { //Not sure what condition this is at the moment - JMW //fireSpecViolationEvent(entity, new Section("9.2.9.a")); //status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (InstantiationException e) { //fireSpecViolationEvent(entity, new Section("9.2.9.a")); //status = false; }
1
            
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); }
(Lib) FinderException 4
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
catch(FinderException e) { throw new DeploymentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(FinderException e) { throw e; }
4
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
catch(FinderException e) { throw new DeploymentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(FinderException e) { throw e; }
(Lib) IllegalArgumentException 4
            
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch (IllegalArgumentException e) { log.debug("Could not create the finder " + name + ", because no matching CMP field was found."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/web/WebPermissionMapping.java
catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); }
3
            
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/web/WebPermissionMapping.java
catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); }
(Lib) NoSuchObjectException 4
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
6
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
(Lib) JMSException 3
            
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (JMSException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (JMSException e) { log.warn(e); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (JMSException ex) { log.debug("failed to publish seppuku event: ", ex); }
0
(Lib) NoSuchObjectLocalException 3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
(Domain) RemoveException 3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Cache.RemoveException e) { log.trace(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(Cache.RemoveException e) { if(log.isTraceEnabled()) { log.trace(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(Cache.RemoveException e) { if(trace) { log.trace(e.getMessage()); } }
0
(Lib) AccessException 2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
(Lib) CannotConnectException 2
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
2
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
(Lib) HeuristicMixedException 2
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicMixedException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (HeuristicMixedException e) { throwJBossException(e, invocation.getType()); }
1
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicMixedException e) { throw e; }
(Lib) HeuristicRollbackException 2
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicRollbackException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (HeuristicRollbackException e) { throwJBossException(e, invocation.getType()); }
1
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicRollbackException e) { throw e; }
(Lib) JBossXBException 2
            
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); }
2
            
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); }
(Lib) NameNotFoundException 2
            
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
catch (NameNotFoundException e) { ctx = ctx.createSubcontext(ctxName); }
// in src/main/java/org/jboss/deployment/dependency/JndiDependencyItem.java
catch(NameNotFoundException e) { // ignore }
0
(Lib) ParseException 2
            
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
catch (ParseException e) { throw new IllegalArgumentException("Cannot parse date/time in: " + externalForm); }
// in src/main/java/org/jboss/verifier/Section.java
catch ( ParseException e ) { throw new IllegalArgumentException( CONSTRUCTION_ERROR ); }
2
            
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
catch (ParseException e) { throw new IllegalArgumentException("Cannot parse date/time in: " + externalForm); }
// in src/main/java/org/jboss/verifier/Section.java
catch ( ParseException e ) { throw new IllegalArgumentException( CONSTRUCTION_ERROR ); }
(Lib) TransactionRequiredException 2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
(Lib) TransactionRolledbackException 2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
(Lib) UnknownHostException 2
            
// in src/main/java/org/jboss/config/ServerConfigUtil.java
catch (UnknownHostException ignored) { }
// in src/main/java/org/jboss/config/ServerConfigUtil.java
catch (UnknownHostException ignored) { }
0
(Lib) AccessControlException 1
            
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (AccessControlException ignored) { }
0
(Lib) BAD_OPERATION 1
            
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
1
            
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
(Lib) BindException 1
            
// in src/main/java/org/jboss/web/WebServer.java
catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); }
1
            
// in src/main/java/org/jboss/web/WebServer.java
catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); }
(Lib) ClassCastException 1
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); }
1
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); }
(Lib) InstanceNotFoundException 1
            
// in src/main/java/org/jboss/naming/JNDIView.java
catch (InstanceNotFoundException e1) { // this is expected if HA-JNDI service isn't deployed - do not report it return null; }
0
(Domain) InvocationException 1
            
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); }
3
            
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); }
(Domain) InvokerAdaptorException 1
            
// in src/main/java/org/jboss/jmx/connector/invoker/client/InvokerAdaptorClientInterceptor.java
catch (InvokerAdaptorException e) { throw e.getWrapped(); }
1
            
// in src/main/java/org/jboss/jmx/connector/invoker/client/InvokerAdaptorClientInterceptor.java
catch (InvokerAdaptorException e) { throw e.getWrapped(); }
(Domain) JBossLazyUnmarshallingException 1
            
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
2
            
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
(Lib) JMException 1
            
// in src/main/java/org/jboss/monitor/BeanCacheMonitor.java
catch (JMException e) { log.error("Problem getting bean cache snapshots", e); return null; }
0
(Lib) LoginException 1
            
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(LoginException e) { AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol); ex.setRootCause(e); throw ex; }
1
            
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(LoginException e) { AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol); ex.setRootCause(e); throw ex; }
(Lib) NoClassDefFoundError 1
            
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(NoClassDefFoundError ignored) { log.debug("Incomplete class: "+className+", NCDFE: "+ignored); }
0
(Lib) NoSuchFieldError 1
            
// in src/main/java/org/jboss/proxy/ejb/SecurityContextInterceptor.java
catch(NoSuchFieldError nsfe) { //Probably we are in 4.2.x return false; }
0
(Lib) NoSuchMethodError 1
            
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); }
0
(Lib) ObjectStreamException 1
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); }
1
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); }
(Domain) ReentranceException 1
            
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
2
            
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
(Lib) SAXException 1
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
1
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
(Lib) SAXParseException 1
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); }
1
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); }
(Domain) ServiceUnavailableException 1
            
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(ServiceUnavailableException e) { if( trace ) log.trace("Invocation failed", e); InvocationType type = invocation.getType(); if ((maxRetries > -1 && retryCount >= maxRetries) || reestablishInvokerProxy(ctx, type) == false) { throw e; } retryCount++; }
1
            
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(ServiceUnavailableException e) { if( trace ) log.trace("Invocation failed", e); InvocationType type = invocation.getType(); if ((maxRetries > -1 && retryCount >= maxRetries) || reestablishInvokerProxy(ctx, type) == false) { throw e; } retryCount++; }
(Lib) URISyntaxException 1
            
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (URISyntaxException e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jarURL, e); }
0
(Lib) UndeclaredThrowableException 1
            
// in src/main/java/org/jboss/Shutdown.java
catch(UndeclaredThrowableException e) { System.out.println("getUndeclaredThrowable: "+e.getUndeclaredThrowable()); throw e.getUndeclaredThrowable(); }
1
            
// in src/main/java/org/jboss/Shutdown.java
catch(UndeclaredThrowableException e) { System.out.println("getUndeclaredThrowable: "+e.getUndeclaredThrowable()); throw e.getUndeclaredThrowable(); }

Exception Recast Summary

There is a common practice of throwing exceptions from within a catch block (e.g. for wrapping a low-level exception). The following table summarizes the usage of this practice in the application. The last column gives the number of times it happens for a pair of exceptions. The graph below the table graphically renders the same information. For a given node, its color represents its origin (blue means library exception, orange means domain exception); the left-most number is the number of times it is thrown, the right-most is the number of times it is caught.

Catch Throw
(Domain) InvocationException
(Lib) InvocationTargetException
Unknown
1
                    
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); }
2
                    
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); }
(Lib) IOException
(Lib) ServerException
(Lib) DeploymentException
(Lib) SQLException
(Lib) MissingResourceException
(Lib) RuntimeException
Unknown
1
                    
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (IOException e) { throw new ServerException("IOE", e); }
2
                    
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); }
7
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
1
                    
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); }
2
                    
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
2
                    
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(IOException e) { CommunicationException ce = new CommunicationException("Operation failed"); ce.setRootCause(e); throw ce; }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { throw e; }
(Lib) IllegalArgumentException
(Lib) ClassNotFoundException
(Lib) FinderException
(Lib) IllegalArgumentException
1
                    
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); }
1
                    
// in src/main/java/org/jboss/web/WebPermissionMapping.java
catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); }
(Lib) Exception
(Lib) InvocationTargetException
(Lib) DeploymentException
(Lib) RuntimeException
(Lib) SystemException
(Lib) EJBException
(Lib) SQLException
(Lib) IllegalStateException
(Lib) ExceptionInInitializerError
(Lib) RemoteException
(Lib) NestedRuntimeException
(Lib) FinderException
(Domain) RemoveException
(Lib) ServerException
Unknown
1
                    
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { throw new InvocationTargetException(e); }
46
                    
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to register table cache for " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find getter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find setter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/web/deployers/WebModule.java
catch (Exception e) { throw new DeploymentException("Error during stop", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw new DeploymentException("Failed to create web module", e); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); }
9
                    
// in src/main/java/org/jboss/deployment/EARStructure.java
catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception ex) { throw new RuntimeException("UT factory lookup failed", ex); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new RuntimeException("Cannot start EJBTimerService", e); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); }
5
                    
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
62
                    
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { throw new EJBException("Failed to create timer", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { throw new EJBException("Could not create timer service", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException (e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeRemoveRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeAddRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(Exception e) { throw new EJBException("Internal error extracting primary key from instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(Exception e) { throw new EJBException("Internal error", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { throw new EJBException("Failed to obtain current transaction", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(Exception e) { throw new EJBException("Error getting application tx data map.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { throw new EJBException("Error getting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { throw new EJBException("Error creating primary key instance: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error extracting primary key from " + "instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in getRelatedId", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in addRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in removeRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(Exception e) { throw new EJBException("Load relation failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
1
                    
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); }
6
                    
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new IllegalStateException("Cannot create EJBTimerService proxy: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to begin a new transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new IllegalStateException( "Failed to create an instance of " + valueType + " with the " + fieldValue + " as a ctor argument" ); }
14
                    
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
4
                    
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
8
                    
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/compiler/Proxy.java
catch (Exception e) { throw new NestedRuntimeException("Failed to create new proxy target", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
2
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); }
2
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); }
3
                    
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new ServerException("Could not bind home", e); }
45
                    
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { Throwable th = JMXExceptionDecoder.decode(e); if(log.isTraceEnabled()) { log.trace("Failed to invoke on mbean: " + mbean, th); } if(th instanceof Exception) { e = (Exception) th; } throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception inner) { throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(Exception e) { String msg = "Failed to authorize principal=" + caller + ",MBean=" + objname + ", Operation=" + opname; SecurityException ex = new SecurityException(msg); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception e) { close(); throw e; }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(Exception e) { NamingException ne = new NamingException("Failed to update jndiName"); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(Exception e) { NamingException ex = new NamingException("Failed to retrieve Naming interface for provider " + provider); ex.setRootCause(e); throw ex; }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
catch(Exception e) { NamingException ne = new NamingException("Failed to obtain value from binding: "+name); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { destroyService(); throw e; }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { exceptionThrown = e; throw e; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { // Exception - force reload on next call ctx.setValid(false); throw e; }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { RemoveException re = new RemoveException(e.getMessage()); re.initCause(e); throw re; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { throw processException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); }
(Domain) InvokerAdaptorException
Unknown
1
                    
// in src/main/java/org/jboss/jmx/connector/invoker/client/InvokerAdaptorClientInterceptor.java
catch (InvokerAdaptorException e) { throw e.getWrapped(); }
(Domain) ReentranceException
(Lib) RemoteException
(Lib) EJBException
1
                    
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
1
                    
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
(Lib) ObjectStreamException
(Domain) InvocationException
1
                    
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); }
(Lib) InvocationTargetException
(Lib) UndeclaredThrowableException
(Lib) EJBException
(Lib) UnexpectedThrowable
(Lib) NestedError
(Lib) FinderException
Unknown
4
                    
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
13
                    
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
catch (InvocationTargetException e) { Throwable ex = e.getTargetException(); if (ex instanceof EJBException) throw (Exception)ex; else if (ex instanceof RuntimeException) throw new EJBException((Exception)ex); // Transform runtime exception into what a bean *should* have thrown else if (ex instanceof Exception) throw (Exception)ex; else throw (Error)ex; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
1
                    
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
1
                    
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
51
                    
// in src/main/java/org/jboss/client/ReflectionLauncher.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
catch (InvocationTargetException e) { Throwable ex = e.getTargetException(); if (ex instanceof EJBException) throw (Exception)ex; else if (ex instanceof RuntimeException) throw new EJBException((Exception)ex); // Transform runtime exception into what a bean *should* have thrown else if (ex instanceof Exception) throw (Exception)ex; else throw (Error)ex; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
(Lib) MalformedURLException
(Lib) NamingException
Unknown
2
                    
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
1
                    
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(MalformedURLException e) { // See if externalURL refers to a property String urlProperty = System.getProperty(urlValue); if( urlProperty == null ) throw e; externalURL = new URL(urlProperty); }
(Lib) NamingException
(Lib) DeploymentException
(Lib) RuntimeException
(Lib) Exception
(Lib) EJBException
(Lib) ServerException
(Lib) NestedRuntimeException
(Lib) IOException
Unknown
5
                    
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(NamingException e) { throw new DeploymentException("Filed to lookup: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); }
1
                    
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (NamingException e) { throw new RuntimeException(e); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NamingException e) { throw new EJBException("Data source for relationship named " + relationName + " not found " + dataSourceName); }
1
                    
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); }
1
                    
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException e) { throw new NestedRuntimeException(e); }
1
                    
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); }
2
                    
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(NamingException e) { throw e; }
// in src/main/java/org/jboss/naming/JndiBinder.java
catch (NamingException e) { NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo); namingException.setRootCause(e); throw namingException; }
(Lib) Throwable
(Lib) UndeclaredThrowableException
(Lib) Exception
(Domain) InvokerAdaptorException
(Lib) NestedRuntimeException
(Lib) ResourceException
(Lib) NoSuchObjectException
(Lib) EJBException
(Lib) TransactionRolledbackLocalException
(Lib) DeploymentException
(Lib) FinderException
(Lib) RemoteException
Unknown
2
                    
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
1
                    
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); }
1
                    
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch (Throwable t) { throw new InvokerAdaptorException(t); }
3
                    
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
2
                    
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { throw new ResourceException(t); }
2
                    
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); }
3
                    
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
4
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/EJBQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JBossQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCJBossQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL " + "statement '" + metadata.getJBossQL() + "'", t); }
3
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); }
1
                    
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); }
18
                    
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); }
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(Throwable t) { ServiceUnavailableException sue = new ServiceUnavailableException("Unexpected failure"); sue.setRootCause(t); throw sue; }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
(Lib) UndeclaredThrowableException
Unknown
1
                    
// in src/main/java/org/jboss/Shutdown.java
catch(UndeclaredThrowableException e) { System.out.println("getUndeclaredThrowable: "+e.getUndeclaredThrowable()); throw e.getUndeclaredThrowable(); }
(Lib) ClassNotFoundException
(Lib) DeploymentException
(Lib) IOException
(Lib) IllegalStateException
(Lib) SQLException
25
                    
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCApplicationMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("Unable to load persistence manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("entity class not found for ejb-name: " + entityName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "could not load primary key class: " + entity.getPrimaryKeyClass() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("home class not found: " + home); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "remote class not found: " + entity.getRemote() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local home class not found: " + localHome ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local class not found: " + entity.getLocal() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("could not load the class for " + " unknown primary key: " + unknownPkClass); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValueClassMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("dependent-value-class not found: " + className); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); }
3
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
(Lib) IllegalStateException
Unknown
4
                    
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.IllegalStateException ex) { finished = false; throw ex; }
(Lib) PrivilegedActionException
(Lib) UndeclaredThrowableException
Unknown
3
                    
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
8
                    
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { throw e.getException(); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/Container.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
(Domain) JBossLazyUnmarshallingException
(Lib) EJBException
(Lib) MarshalException
1
                    
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
1
                    
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
(Lib) SystemException
(Lib) IOException
(Lib) IllegalStateException
(Lib) EJBException
Unknown
2
                    
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
6
                    
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e) { throw new IllegalStateException("Failed to suspend current transaction."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
2
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error getting transaction from the transaction manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error while creating RelationSet", e); }
5
                    
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
(Lib) IllegalAccessException
(Lib) EJBException
(Lib) CreateException
(Lib) FinderException
Unknown
12
                    
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); }
2
                    
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); }
2
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
(Lib) InstantiationException
(Lib) EJBException
1
                    
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); }
(Lib) RemoteException
(Lib) ServerException
(Lib) SystemException
(Lib) SQLException
(Lib) EJBException
Unknown
1
                    
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } }
5
                    
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
4
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
1
                    
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); }
10
                    
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (RemoteException e) { throw e; }
(Domain) ServiceUnavailableException
Unknown
1
                    
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(ServiceUnavailableException e) { if( trace ) log.trace("Invocation failed", e); InvocationType type = invocation.getType(); if ((maxRetries > -1 && retryCount >= maxRetries) || reestablishInvokerProxy(ctx, type) == false) { throw e; } retryCount++; }
(Lib) RuntimeException
Unknown
13
                    
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( RuntimeException e ) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
(Lib) SecurityException
Unknown
6
                    
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.SecurityException ex) { finished = false; throw ex; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; }
(Lib) DeploymentException
(Lib) IllegalStateException
(Lib) FinderException
Unknown
5
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(DeploymentException e) { throw new FinderException(e.getMessage()); }
2
                    
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (DeploymentException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(DeploymentException de) { throw de; }
(Lib) SAXParseException
(Lib) DeploymentException
1
                    
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); }
(Lib) SAXException
(Lib) DeploymentException
1
                    
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
(Lib) XAException
Unknown
10
                    
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
(Lib) MalformedObjectNameException
(Lib) DeploymentException
(Lib) RuntimeException
4
                    
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create EJB module " + unit.getName() + ": malformed EjbModule name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); }
1
                    
// in src/main/java/org/jboss/ejb/Container.java
catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); }
(Lib) PolicyContextException
(Lib) DeploymentException
(Lib) RuntimeException
1
                    
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); }
3
                    
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException("Cannot create permissions:",e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException(e); }
(Lib) NoSuchMethodException
(Lib) NoSuchMethodException
(Lib) DeploymentException
(Lib) IllegalStateException
(Lib) IllegalArgumentException
Unknown
4
                    
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); }
9
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(NoSuchMethodException e) { throw new IllegalStateException( "Failed to find a ctor in " + valueType + " that takes an instance of " + argType + " as an argument." ); }
1
                    
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchMethodException ee) { throw new IllegalArgumentException(ee+" in "+c); }
3
                    
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class"); throw e; }
(Lib) LoginException
Unknown
1
                    
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(LoginException e) { AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol); ex.setRootCause(e); throw ex; }
(Lib) RollbackException
(Lib) EJBException
Unknown
3
                    
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RollbackException e) { throw new EJBException("Error while creating RelationSet", e); }
1
                    
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RollbackException e) { throw e; }
(Lib) HeuristicMixedException
Unknown
1
                    
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicMixedException e) { throw e; }
(Lib) HeuristicRollbackException
Unknown
1
                    
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicRollbackException e) { throw e; }
(Lib) CannotConnectException
(Lib) SystemException
2
                    
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
(Lib) EJBException
Unknown
23
                    
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
(Lib) SQLException
(Lib) IllegalStateException
(Lib) CreateException
(Lib) DuplicateKeyException
(Lib) EJBException
(Lib) DeploymentException
Unknown
1
                    
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
8
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); }
3
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
13
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(SQLException e) { throw new EJBException("Failed to read ResultSet.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); }
5
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); }
14
                    
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (SQLException e) { throw e; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { RuntimeException ex = new IllegalStateException("Unable to persist timer"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to update: table=" + tableName, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
(Lib) ParseException
(Lib) IllegalArgumentException
2
                    
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
catch (ParseException e) { throw new IllegalArgumentException("Cannot parse date/time in: " + externalForm); }
// in src/main/java/org/jboss/verifier/Section.java
catch ( ParseException e ) { throw new IllegalArgumentException( CONSTRUCTION_ERROR ); }
(Lib) NoSuchObjectLocalException
(Lib) IllegalArgumentException
3
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
(Lib) Error
Unknown
8
                    
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Error e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
(Lib) NoSuchObjectException
(Lib) NoSuchObjectLocalException
Unknown
4
                    
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
2
                    
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
(Lib) NoSuchFieldException
(Lib) DeploymentException
(Lib) IllegalArgumentException
(Lib) RuntimeException
2
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(NoSuchFieldException e) { // Non recoverable internal exception throw new DeploymentException("No field named '" + getFieldName() + "' found in entity class."); }
1
                    
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchFieldException ee) { throw new IllegalArgumentException(ee+" in "+c); }
1
                    
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
(Lib) TransactionRequiredException
(Lib) TransactionRequiredLocalException
2
                    
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
(Lib) NumberFormatException
(Lib) DeploymentException
(Lib) IllegalArgumentException
13
                    
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "alias-max-length " + aliasMaxLengthString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Failed to parse int value '" + str + "' for max-keys-in-delete", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCReadAheadMetaData.java
catch(NumberFormatException ex) { throw new DeploymentException("Invalid number format in read-ahead page-size '" + pageSizeStr + "': " + ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in read-" + "ahead list-cache-max '" + listCacheMaxStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "fetch-size '" + fetchSizeStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
catch(NumberFormatException e) { throw new IllegalArgumentException("The parameter must begin with a number"); }
(Lib) FinderException
(Lib) DeploymentException
Unknown
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
catch(FinderException e) { throw new DeploymentException(e.getMessage()); }
3
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(FinderException e) { throw e; }
(Lib) AccessException
(Lib) AccessLocalException
2
                    
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
(Lib) TransactionRolledbackException
(Lib) TransactionRolledbackLocalException
2
                    
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
(Lib) ClassCastException
(Lib) DeploymentException
1
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); }
(Lib) ConcurrentModificationException
(Lib) IllegalStateException
6
                    
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); }
(Lib) BindException
(Lib) Exception
1
                    
// in src/main/java/org/jboss/web/WebServer.java
catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); }
(Lib) JBossXBException
(Lib) DeploymentException
2
                    
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); }
(Lib) NullPointerException
(Lib) MissingResourceException
(Lib) RuntimeException
1
                    
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (NullPointerException e) { throw new MissingResourceException( "Resource not found.", msgBundle, "" ); }
1
                    
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
(Lib) BAD_OPERATION
(Lib) IOException
1
                    
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }

Caught / Thrown Exception

Not all exceptions are thrown AND caught in the same project. The following table gives the exceptions types with respect to this. The lower left hand side sell lists all exceptions thrown but not caught (prevalent for libraries), the upper right-hand side lists all exceptions caught but not thrown (usually coming from external dependencies).

Thrown Not Thrown
Caught
Type Name
(Domain) InvocationException
(Lib) IOException
(Lib) IllegalArgumentException
(Lib) Exception
(Domain) InvokerAdaptorException
(Domain) ReentranceException
(Lib) InvocationTargetException
(Lib) NamingException
(Lib) UndeclaredThrowableException
(Lib) ClassNotFoundException
(Lib) IllegalStateException
(Lib) SystemException
(Lib) RemoteException
(Lib) RuntimeException
(Domain) RemoveException
(Lib) SecurityException
(Lib) DeploymentException
(Lib) NoSuchMethodException
(Lib) EJBException
(Lib) SQLException
(Lib) NoSuchObjectLocalException
(Lib) Error
(Lib) NoSuchObjectException
(Lib) TransactionRequiredException
(Lib) FinderException
Type Name
(Lib) ObjectStreamException
(Lib) MalformedURLException
(Lib) Throwable
(Lib) PrivilegedActionException
(Domain) JBossLazyUnmarshallingException
(Lib) IllegalAccessException
(Lib) InstantiationException
(Lib) NoSuchMethodError
(Domain) ServiceUnavailableException
(Lib) SAXParseException
(Lib) SAXException
(Lib) NameNotFoundException
(Lib) XAException
(Lib) MalformedObjectNameException
(Lib) PolicyContextException
(Lib) NoClassDefFoundError
(Lib) InstanceNotFoundException
(Lib) LoginException
(Lib) RollbackException
(Lib) HeuristicMixedException
(Lib) HeuristicRollbackException
(Lib) CannotConnectException
(Lib) UnknownHostException
(Lib) ParseException
(Lib) NoSuchFieldException
(Lib) NumberFormatException
(Lib) InterruptedException
(Lib) JMSException
(Lib) AccessException
(Lib) TransactionRolledbackException
(Lib) ClassCastException
(Lib) ConcurrentModificationException
(Lib) JMException
(Lib) BindException
(Lib) JBossXBException
(Lib) URISyntaxException
(Lib) NullPointerException
(Lib) AccessControlException
(Lib) BAD_OPERATION
(Lib) NoSuchFieldError
Not caught
Type Name
(Lib) ServerException
(Lib) StreamCorruptedException
(Lib) ListenerNotFoundException
(Lib) OperationNotSupportedException
(Lib) MalformedLinkException
(Lib) NotSupportedException
(Lib) InternalError
(Lib) UnsupportedOperationException
(Lib) UnreachableStatementException
(Lib) UnexpectedThrowable
(Lib) NestedError
(Lib) NestedRuntimeException
(Lib) MBeanException
(Lib) MarshalException
(Lib) NullArgumentException
(Lib) ExceptionInInitializerError
(Lib) DuplicateKeyException
(Lib) CreateException
(Lib) UnavailableException
(Lib) ResourceException
(Lib) NotImplementedException
(Lib) TransactionRequiredLocalException
(Domain) JBossTransactionRolledbackLocalException
(Domain) JBossTransactionRolledbackException
(Lib) TransactionRolledbackLocalException
(Lib) AccessLocalException
(Lib) NoSuchEntityException
(Lib) ObjectNotFoundException
(Lib) NoSuchElementException
(Lib) IndexOutOfBoundsException
(Lib) AttributeNotFoundException
(Lib) InvalidAttributeValueException
(Lib) RejectedExecutionException
(Lib) MissingResourceException

Methods called in Catch and Finally Blocks

The following shows the methods that are called inside catch blocks (first column) and finally blocks (second column). For each method, we give the number of times it is called in a catch block (second sub-column), and the total number of calls (third sub-column). If the method name is red, it means that it is only called from catch/finally blocks. Hovering over a number triggers showing code snippets from the application code.

Catch Finally
Method Nbr Nbr total
error 128
                  
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Throwable e) { log.error("Failed", e); return; }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (Exception e) { log.error(e); }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (ClassNotFoundException e) { log.error(e); }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (IllegalAccessException e) { log.error(e); }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (InstantiationException e) { log.error(e); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { log.error("Error adding unified invoker as handler upon connector being set.", e); }
// in src/main/java/org/jboss/jmx/connector/invoker/ExternalizableRolesAuthorization.java
catch (Exception e) { log.error("Error reading roles from jmxinvoker-roles.properties:",e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { log.error("Cannot commit Parent Policy Configuration:",e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(NamingException e) { log.error("unbind failed", e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getDeployedApplications failed", e); buffer.append("Failed to getDeployedApplications\n"); formatException(buffer, e); buffer.insert(0, "<pre>"); buffer.append("</pre>"); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getConainers failed", e); buffer.append("<pre>"); buffer.append("Failed to get ejbs in module\n"); formatException(buffer, e); buffer.append("</pre>"); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("lookup for java: failed", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { log.error("Failed to get InitialContext", ne); buffer.append("Failed to get InitialContext, " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Exception e) { log.error("getDeployedApplications failed", e); appendErrorTag(buffer, "Failed to getDeployedApplications " + e.toString()); closeJndiTag(buffer); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("getContainers failed", t); appendPreExceptionTag(buffer, "Failed to get ejbs in module", t); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext for (java:)", e); appendErrorTag(buffer, "Failed to get InitialContext for (java:), " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list contents of (java:)", t); appendErrorTag(buffer, "Failed to list contents of (java:), " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list global contents ", t); appendErrorTag(buffer, "Failed to list global contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list HA-JNDI contents ", t); appendErrorTag(buffer, "Failed to list HA-JNDI contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Invalid LinkRef for: " + name, t); appendLinkRefErrorTag(buffer); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Exception e) { // this is not expected - report it log.error("JNDIView.getHAJndiAttributes() failed", e); return null; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (NamingException ex) { log.error("java:/TransactionManager lookup failed", ex); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (Exception ex) { log.error("rollback failed", ex); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { log.error("Retry timeout failed for timer: " + txtimer, e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { log.error("Cannot create timer table", e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (IOException e) { log.error("Cannot serialize: " + obj, e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { log.error("Cannot deserialize", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { log.error("Cannot deserialize", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
catch (Exception e) { log.error("Cannot register txtimer with Tx: " + this); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
catch (Exception e) { log.error("Error invoking ejbTimeout", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.error("Cannot obtain the implementation of a RetryPolicy", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.error("Cannot create TimedObjectInvoker: " + timedObjectInvokerClassName, e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot createTimerService", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot createTimerService", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot getTimerService", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot removeTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot removeTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot restoreTimer", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.error("unexpected exception stopping Container: " + con.getJmxName(), e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Throwable e) { log.error("unexpected exception destroying Container: " + jmxName, e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { log.error("Could not remove timer service", e); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
catch (Exception x) { log.error("Failed to setSessionContext", x); }
// in src/main/java/org/jboss/ejb/CacheKey.java
catch (Exception e) { Logger log = Logger.getLogger(getClass()); log.error("failed to initialize, id="+id, e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (Exception e) { log.error("Error getting callerPrincipal for " + con.getBeanClass(),e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (Exception e) { log.error("isCallerInRole("+ roleName+") had exception:",e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch (Exception e) { log.error("Failed to initialze DefaultSecurityProxy", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(Exception e) { log.error("Failed to initialze SecurityProxy", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactoryService.java
catch( Exception e ) { log.error( "Caught exception during startService()", e ); // Ingore }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactoryService.java
catch( Exception e ) { log.error( "Caught exception during startService()", e ); // Ingore }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactoryService.java
catch( Exception e ) { log.error( "Caught exception during stopService()", e ); // Ingore }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e1) { log.error("Failed to rollback.", e1); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { log.error("Failed to commit.", e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class"); throw e; }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to update: table=" + tableName, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { log.error("Failed to stop entity bridge.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.error("Could not suspend current transaction before drop table. " + "'" + qualifiedTableName + "' will not be dropped.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.error("Could not reattach original transaction after drop table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(NoSuchMethodException e) { // Should never happen log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IllegalAccessException e) { // Should never happen log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (SystemException ex) { log.error("Failed to get status", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (Exception ex) { log.error("Failed to rollback", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (SystemException ex) { log.error("Failed to suspend transaction", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (SystemException ex) { log.error("Failed to get status", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (Exception ex) { log.error("Failed to rollback", ex); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to setup InstanceSynchronization", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to invoke afterBegin", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to invoke beforeCompletion", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to invoke afterCompletion", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; }
// in src/main/java/org/jboss/monitor/BeanCacheMonitor.java
catch (JMException e) { log.error("Problem getting bean cache snapshots", e); return null; }
// in src/main/java/org/jboss/web/WebServer.java
catch (MalformedURLException e) { log.error("invalid url", e); }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { // If the server is not null meaning we were not stopped report the err if (server != null) log.error("Failed to accept connection", e); return; }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException ex) { log.error("error writting response", ex); }
// in src/main/java/org/jboss/web/WebService.java
catch (Exception e) { log.error("Failed to load org/jboss/web/mime.types; ignoring", e); }
// in src/main/java/org/jboss/proxy/compiler/ProxyCompiler.java
catch (Exception e) { log.error("Failed to dump class file", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
176
getMessage 107
                  
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
catch (Exception ex) { DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { // If this is a $Proxy* class its a proxy if (className.startsWith("$Proxy")) { isProxy = true; // We have to get the class from the binding try { Object p = ctx.lookup(name); c = p.getClass(); } catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } } } }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { buffer.append("Failed to lookup: " + name + ", errmsg=" + t.getMessage()); buffer.append('\n'); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed to lookup: " + name + ", errmsg=" + t.getMessage()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed to list contents of: " + name + ", errmsg=" + t.getMessage()); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new IllegalStateException("Cannot create EJBTimerService proxy: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/Container.java
catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.warn(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { RemoveException re = new RemoveException(e.getMessage()); re.initCause(e); throw re; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Cache.RemoveException e) { log.trace(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(Cache.RemoveException e) { if(log.isTraceEnabled()) { log.trace(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(Cache.RemoveException e) { if(trace) { log.trace(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
catch(FinderException e) { throw new DeploymentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.debug("Could not drop table " + qualifiedTableName + ": " + e.getMessage()); success = false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(DeploymentException e) { throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn(ex.getMessage()); }
// in src/main/java/org/jboss/web/WebServer.java
catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(mdBean, new Section("15.7.2.b", "Class not found on '" + messagingType + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("23.2", "Class not found on '" + seiName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/Main.java
catch (Exception e) { System.err.println("Problem starting the application:"); System.err.println("Exception: " + e); System.err.println("Message: " + e.getMessage()); e.printStackTrace(); System.exit(-1); }
123
warn 62
                  
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { log.warn("Failed to install SecurityAssociationAuthenticator", e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { log.warn("Failed to read "+SSL_FACTORY_BUILDER, e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (Exception e) { log.warn("Could not instantiate SSLSocketFactoryFactory", e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { log.warn("Failed to install SecurityAssociationAuthenticator", e); }
// in src/main/java/org/jboss/client/AppClientMain.java
catch(Throwable t) { log.warn("Failed to launch using: "+launcherName, t); }
// in src/main/java/org/jboss/jmx/adaptor/rmi/NotificationListenerDelegate.java
catch(Throwable t) { log.warn("Failed to notify client", t); }
// in src/main/java/org/jboss/deployment/EARStructure.java
catch (IOException e) { // TODO - should we throw this fwd? log.warn("Exception while searching for lib dir: " + e); }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception e) { log.warn("Failed to delete JNP URL file " + outputFile + " due to " + e); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch (Exception e) { log.warn("Failed to unbind "+JNDI_NAME, e); }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (MalformedURLException mue) { log.warn("Can't construct URL for: " + ourPath); return null; }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (Exception e) { log.warn("Got Exception when looking for DeploymentUnit: " + e); return null; }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (MalformedURLException mue) { log.warn("Can't construct URL for: " + ourPath); return null; }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (Exception e) { log.warn("Got Exception when looking for DeploymentUnit: " + e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); }
// in src/main/java/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to delete timer", e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to get timer handles for containerId: " + containerId, e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to get timer handles", e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (Exception e) { log.warn("Unable to restore timer record: " + handle); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to clear timers", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a PersistencePolicy, using NoopPersistencePolicy: " + e.toString()); persistencePolicy = new NoopPersistencePolicy(); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a TimerIdGenerator, using BigIntegerTimerIdGenerator: " + e.toString()); timerIdGenerator = new BigIntegerTimerIdGenerator(); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Unable to restore timer record: " + handle, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Throwable e) { log.warn("Failed to unregister webClassLoader", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (ClassNotFoundException e) { log.warn("Could not load the " + className + " interceptor", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.warn("Could not load the " + className + " interceptor for this container", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.warn("The Container Invoker " + invoker + " (in jboss.xml or standardjboss.xml) could not be created because of " + e + " We will ignore this error, but you may miss a transport for this bean."); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { log.warn("Failed to grant access to the Handle.getEJBObject method"); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { log.warn("Could not restore ejb timers", e); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch (Throwable t) { log.warn("Verify failed; continuing", t ); allOK = false; }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { log.warn("Error undeploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (SystemException e) { log.warn("failed to get tx manager status; ignoring", e); return true; }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (SystemException e) { log.warn("failed to set rollback only; ignoring", e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); log.warn("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { log.warn("Error in release ", t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { log.warn("MessageEndpoint " + getProxyString(mi) + " failed to resume old transaction " + currentTx); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Exception ex) { log.warn("Unable to importXml for the TxInterceptorCMT", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception ignored) { log.warn("failed to passivate, id="+id, ignored); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.warn(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { vcr = null; log.warn("problem scheduling valid contexts refresher", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception ex) { log.warn("Unable to determine transaction context", ex); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (NamingException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (JMSException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (JMSException e) { log.warn(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCMappingMetaData.java
catch(Exception e) { log.warn("Unrecognized jdbc-type: " + name + ", using Types.OTHER", e); return Types.OTHER; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("EXCEPTION ALTER :" + e.toString()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Exception ignored) { log.warn("failed to passivate, id=" + id, ignored); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationsTxGrouper.java
catch(Exception ex) { InvalidationsTxGrouper.log.warn("Failed sending invalidations messages", ex); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn(ex.getMessage()); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn("Failed to stop JMS resources associated with the JMS bridge: ", ex); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn("failed to do cluster seppuku event: " , ex); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (Exception e) { log.warn("Could not get global URL[] from default loader repository!", e); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (IOException e) { log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException e) { log.warn("Failed to find class: " + className, e); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException e) { log.warn("Failed to find class: " + assignableFromClassName, e); }
// in src/main/java/org/jboss/corba/ORBFactory.java
catch (Throwable t) { log.warn("Unable to activate POA", t); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch (NamingException e) { log.warn("Problem closing naming context used for reaquiring invoker: " + e.getClass() + " -- " + e.getLocalizedMessage()); }
137
toString 59
                  
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getDeployedApplications failed", e); buffer.append("Failed to getDeployedApplications\n"); formatException(buffer, e); buffer.insert(0, "<pre>"); buffer.append("</pre>"); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("lookup for java: failed", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { log.error("Failed to get InitialContext", ne); buffer.append("Failed to get InitialContext, " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Exception e) { log.error("getDeployedApplications failed", e); appendErrorTag(buffer, "Failed to getDeployedApplications " + e.toString()); closeJndiTag(buffer); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed on list contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext for (java:)", e); appendErrorTag(buffer, "Failed to get InitialContext for (java:), " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list contents of (java:)", t); appendErrorTag(buffer, "Failed to list contents of (java:), " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list global contents ", t); appendErrorTag(buffer, "Failed to list global contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list HA-JNDI contents ", t); appendErrorTag(buffer, "Failed to list HA-JNDI contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { appendErrorTag(buffer, "error while listing context " + ctx.toString() + ": " + ne.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { appendErrorTag(buffer, "Failed to getLinkName, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a PersistencePolicy, using NoopPersistencePolicy: " + e.toString()); persistencePolicy = new NoopPersistencePolicy(); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a TimerIdGenerator, using BigIntegerTimerIdGenerator: " + e.toString()); timerIdGenerator = new BigIntegerTimerIdGenerator(); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (MalformedObjectNameException e) { log.trace("Ignored malformed invoker mbean '" + invokerName + "' " + e.toString()); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("EXCEPTION ALTER :" + e.toString()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
// in src/main/java/org/jboss/ejb/ContainerRelection.java
catch(Throwable e) { if( e instanceof RuntimeOperationsException ) { RuntimeOperationsException roe = (RuntimeOperationsException) e; e = roe.getTargetException(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); buffer.append(sw.toString()); buffer.append("\n</pre>\n"); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasDefaultConstructor("); tmp.append(") failure, "); Classes.displayClassInfo(c, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingMethod("); tmp.append(method.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBPostCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBFind("); tmp.append(finder.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBHome("); tmp.append(home.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
295
debug 40
                  
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Exception e) { log.debug(iface+"No addNotificationListener(ObjectName, RMINotificationListener)"); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Exception e) { log.debug(iface+"No removeNotificationListener(ObjectName, RMINotificationListener)"); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Throwable t) { log.debug("Failed to notify client, unregistering listener", t); try { removeNotificationListener(targetName, client); } catch(Exception e) { log.debug("Failed to unregister listener", e); } }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Exception e) { log.debug("Failed to unregister listener", e); }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(NoClassDefFoundError ignored) { log.debug("Incomplete class: "+className+", NCDFE: "+ignored); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.debug("Unable to list web applications ENC", e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.debug("Unable to list web applications ENC", e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.debug("Invalid LinkRef for: " + name, t); buffer.append("invalid]"); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (Throwable t) { log.debug("Failed to register pool as mbean", t); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Throwable t) { log.debug("Failed to register cache as mbean", t); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.debug("Couldn't find getEJBObject method on container"); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { log.debug("failed to lookup DefaultDS; ignoring", e); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable t) { log.debug("Failed to register pool as mbean", t); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable t) { log.debug("Failed to register invoker binding as mbean", t); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Throwable t) { log.debug("Ignored error trying to retrieve transaction status", t); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
catch (Exception ignored) { log.debug(ignored); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
catch (Exception ignored) { log.debug(ignored); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
catch (Exception e) { log.debug(e); }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (Throwable t) { log.debug("Ignored error while trying to passivate ctx", t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.debug("Exception releasing context", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.debug("Exception releasing context", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.debug("Exception releasing context", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch (Throwable t) { log.debug("Ignored error while trying to flush() entity cache", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(SQLException e) { log.debug("Error getting database metadata for DROP TABLE command. " + " DROP TABLE will not be executed. ", e); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.debug("Could not drop table " + qualifiedTableName + ": " + e.getMessage()); success = false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch (IllegalArgumentException e) { log.debug("Could not create the finder " + name + ", because no matching CMP field was found."); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (Throwable t) { log.debug("Ignored error trying to remove passivated beans from cache", t); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable t) { log.debug("Failed to register cache as mbean", t); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable t) { log.debug("Failed to register cache as mbean", t); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (JMSException ex) { log.debug("failed to publish seppuku event: ", ex); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
catch (Exception e) { log.debug ("Problem while trying to register a new invalidation group in JMX", e); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
catch (Exception e) { log.debug ("Problem while trying to un-register a new invalidation group in JMX", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { log.debug("Ignoring path element: " + vf, e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { log.debug("Failed to remove expanded war", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { log.debug("Exception reported, try JNDI method to recover EJB object instead", e); return getEjbObjectViaJndi(); }
384
getName 37
                  
// in src/main/java/org/jboss/deployment/EARStructure.java
catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create EJB module " + unit.getName() + ": malformed EjbModule name", e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { log.warn("Error undeploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Unable to create activation spec ra=" + resourceAdapterObjectName + " messaging-type=" + messagingTypeClass.getName() + " properties=" + metaData.getActivationConfigProperties(), t); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (NamingException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (JMSException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find getter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find setter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException cnfe) { // Only check equality return m.getReturnType().getName().equals(entity.getPrimaryKeyClass()); }
639
Section 32
                  
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { fireSpecViolationEvent(entity, new Section("10.6.2.g", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException e) { if (cmp) fireSpecViolationEvent(entity, new Section("10.6.13.a")); else fireSpecViolationEvent(entity, new Section("12.2.12.a")); // Can't do any other checks if the class is null! return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (IllegalAccessException e) { // If CMP primary key class MUST have a public // constructor with no parameters. 10.8.2.a /// if (cmp) { fireSpecViolationEvent(entity, new Section("10.8.2.a")); status = false; } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException e) { // The primary keyfield MUST be a CMP field within the // entity bean. // // Spec 10.8.1 // status = false; fireSpecViolationEvent(entity, new Section("10.8.1.b")); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { fireSpecViolationEvent(entity, new Section("10.6.2.g", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException e) { if (cmp) fireSpecViolationEvent(entity, new Section("10.6.13.a")); else fireSpecViolationEvent(entity, new Section("12.2.12.a")); // Can't do any other checks if the class is null! return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (IllegalAccessException e) { // If CMP primary key class MUST have a public // constructor with no parameters. 10.8.2.a /// if (cmp) { fireSpecViolationEvent(entity, new Section("10.8.2.a")); status = false; } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException e) { // The primary keyfield MUST be a CMP field within the // entity bean. // // Spec 10.8.1 // status = false; fireSpecViolationEvent(entity, new Section("10.8.1.b")); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(mdBean, new Section("15.7.2.b", "Class not found on '" + messagingType + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("23.2", "Class not found on '" + seiName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The bean provider MUST specify the fully-qualified name of the * enterprise bean's home interface in the <home> element. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.c")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * enterprise bean's remote interface in the <remote> element. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.d")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * Java class that implements the enterprise bean's business * methods. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.b")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The bean provider MUST specify the fully-qualified name of the * enterprise bean's home interface in the <home> element. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.c")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * enterprise bean's remote interface in the <remote> element. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.d")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * Java class that implements the enterprise bean's business * methods. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.b")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { fireSpecViolationEvent(entity, new Section("16.2.e")); status = false; // Can't do any other checks if the class is null! }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NoSuchFieldException e) { fireSpecViolationEvent(entity, new Section("9.4.7.1.b")); status = false; }
460
fireSpecViolationEvent 32
                  
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { fireSpecViolationEvent(entity, new Section("10.6.2.g", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException e) { if (cmp) fireSpecViolationEvent(entity, new Section("10.6.13.a")); else fireSpecViolationEvent(entity, new Section("12.2.12.a")); // Can't do any other checks if the class is null! return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (IllegalAccessException e) { // If CMP primary key class MUST have a public // constructor with no parameters. 10.8.2.a /// if (cmp) { fireSpecViolationEvent(entity, new Section("10.8.2.a")); status = false; } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException e) { // The primary keyfield MUST be a CMP field within the // entity bean. // // Spec 10.8.1 // status = false; fireSpecViolationEvent(entity, new Section("10.8.1.b")); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { fireSpecViolationEvent(entity, new Section("10.6.2.g", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException e) { if (cmp) fireSpecViolationEvent(entity, new Section("10.6.13.a")); else fireSpecViolationEvent(entity, new Section("12.2.12.a")); // Can't do any other checks if the class is null! return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (IllegalAccessException e) { // If CMP primary key class MUST have a public // constructor with no parameters. 10.8.2.a /// if (cmp) { fireSpecViolationEvent(entity, new Section("10.8.2.a")); status = false; } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException e) { // The primary keyfield MUST be a CMP field within the // entity bean. // // Spec 10.8.1 // status = false; fireSpecViolationEvent(entity, new Section("10.8.1.b")); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(mdBean, new Section("15.7.2.b", "Class not found on '" + messagingType + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("23.2", "Class not found on '" + seiName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The bean provider MUST specify the fully-qualified name of the * enterprise bean's home interface in the <home> element. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.c")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * enterprise bean's remote interface in the <remote> element. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.d")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * Java class that implements the enterprise bean's business * methods. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.b")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The bean provider MUST specify the fully-qualified name of the * enterprise bean's home interface in the <home> element. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.c")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * enterprise bean's remote interface in the <remote> element. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.d")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * Java class that implements the enterprise bean's business * methods. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.b")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { fireSpecViolationEvent(entity, new Section("16.2.e")); status = false; // Can't do any other checks if the class is null! }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NoSuchFieldException e) { fireSpecViolationEvent(entity, new Section("9.4.7.1.b")); status = false; }
461
trace 28
                  
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { Throwable th = JMXExceptionDecoder.decode(e); if(log.isTraceEnabled()) { log.trace("Failed to invoke on mbean: " + mbean, th); } if(th instanceof Exception) { e = (Exception) th; } throw e; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception ignored) { log.trace("Ignored error during close", ignored); }
// in src/main/java/org/jboss/deployment/dependency/JndiDependencyItem.java
catch(Throwable ignored) { if (log.isTraceEnabled()) log.trace("Unexpected error", ignored); }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(Exception ignored) { if(log.isTraceEnabled()) log.trace("Failed to load class: "+className, ignored); }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
catch(NamingException e) { // ignore log.trace("No env sub context found", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (MalformedObjectNameException e) { log.trace("Ignored malformed invoker mbean '" + invokerName + "' " + e.toString()); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (PolicyContextException pe) { if(log.isTraceEnabled()) log.trace("PolicyContextException in getting caller subject:",pe); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Cache.RemoveException e) { log.trace(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(Cache.RemoveException e) { if(log.isTraceEnabled()) { log.trace(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(Cache.RemoveException e) { if(trace) { log.trace(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (RemoteException e) { if( log.isTraceEnabled() ) log.trace("Ctx.discard error", e); }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
catch (Exception e) { if (log.isTraceEnabled()) { log.trace("Exception in creating TimedObject method:",e); } }
// in src/main/java/org/jboss/web/WebServer.java
catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasDefaultConstructor("); tmp.append(") failure, "); Classes.displayClassInfo(c, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingMethod("); tmp.append(method.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBPostCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBFind("); tmp.append(finder.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBHome("); tmp.append(home.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/corba/ORBFactory.java
catch (SecurityException ignored) { log.trace("Unable to retrieve system properties", ignored); properties = null; }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(ServiceUnavailableException e) { if( trace ) log.trace("Invocation failed", e); InvocationType type = invocation.getType(); if ((maxRetries > -1 && retryCount >= maxRetries) || reestablishInvokerProxy(ctx, type) == false) { throw e; } retryCount++; }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(Throwable t) { retryCount++; if( trace ) log.trace("Retry attempt " + retryCount + ": Failed to lookup proxy", t); if (maxRetries > -1 && retryCount >= maxRetries) { if ( trace) log.trace("Maximum retry attempts made"); break; } }
386
append 27
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getDeployedApplications failed", e); buffer.append("Failed to getDeployedApplications\n"); formatException(buffer, e); buffer.insert(0, "<pre>"); buffer.append("</pre>"); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getConainers failed", e); buffer.append("<pre>"); buffer.append("Failed to get ejbs in module\n"); formatException(buffer, e); buffer.append("</pre>"); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("lookup for java: failed", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { log.error("Failed to get InitialContext", ne); buffer.append("Failed to get InitialContext, " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.debug("Invalid LinkRef for: " + name, t); buffer.append("invalid]"); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { buffer.append("Failed to lookup: " + name + ", errmsg=" + t.getMessage()); buffer.append('\n'); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/ejb/ContainerRelection.java
catch(Throwable e) { if( e instanceof RuntimeOperationsException ) { RuntimeOperationsException roe = (RuntimeOperationsException) e; e = roe.getTargetException(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); buffer.append(sw.toString()); buffer.append("\n</pre>\n"); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasDefaultConstructor("); tmp.append(") failure, "); Classes.displayClassInfo(c, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingMethod("); tmp.append(method.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBPostCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBFind("); tmp.append(finder.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBHome("); tmp.append(home.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
1308
getTargetException 26
                  
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); }
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; }
// in src/main/java/org/jboss/client/ReflectionLauncher.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
catch (InvocationTargetException e) { Throwable ex = e.getTargetException(); if (ex instanceof EJBException) throw (Exception)ex; else if (ex instanceof RuntimeException) throw new EJBException((Exception)ex); // Transform runtime exception into what a bean *should* have thrown else if (ex instanceof Exception) throw (Exception)ex; else throw (Error)ex; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
// in src/main/java/org/jboss/ejb/ContainerRelection.java
catch(Throwable e) { if( e instanceof RuntimeOperationsException ) { RuntimeOperationsException roe = (RuntimeOperationsException) e; e = roe.getTargetException(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); buffer.append(sw.toString()); buffer.append("\n</pre>\n"); }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
29
printStackTrace 24
                  
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { e.printStackTrace(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { e.printStackTrace(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { e.printStackTrace(); }
// in src/main/java/org/jboss/naming/java/javaURLContextFactory.java
catch (NamingException e) { e.printStackTrace(); }
// in src/main/java/org/jboss/ejb/txtimer/FixedDelayRetryPolicy.java
catch (Exception ignore) { ignore.printStackTrace(); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/EJBQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JBossQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCJBossQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL " + "statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/ContainerRelection.java
catch(Throwable e) { if( e instanceof RuntimeOperationsException ) { RuntimeOperationsException roe = (RuntimeOperationsException) e; e = roe.getTargetException(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); buffer.append(sw.toString()); buffer.append("\n</pre>\n"); }
// in src/main/java/org/jboss/verifier/Main.java
catch (Exception e) { System.err.println("Problem starting the application:"); System.err.println("Exception: " + e); System.err.println("Message: " + e.getMessage()); e.printStackTrace(); System.exit(-1); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException cantHappen) { cantHappen.printStackTrace(); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
33
rethrowAsDeploymentException
20
                  
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
catch (Exception ex) { DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex); }
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Could not load messaging-type class " + messagingType, e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Cannot locate resource adapter deployment " + resourceAdapterName, e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { DeploymentException.rethrowAsDeploymentException("Error loading interceptor class " + className, t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Unable to create activation spec ra=" + resourceAdapterObjectName + " messaging-type=" + messagingTypeClass.getName() + " properties=" + metaData.getActivationConfigProperties(), t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
catch (IllegalStateException e) { DeploymentException.rethrowAsDeploymentException("Invalid ordering", e); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (URISyntaxException e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jarURL, e); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error scanning HandlesTypes", e); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (Exception e) { if (error) { DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jar, e); } else { log.info("Skipped SCI for JAR: " + jar, e); } }
20
initCause 19
                  
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(Exception e) { String msg = "Failed to authorize principal=" + caller + ",MBean=" + objname + ", Operation=" + opname; SecurityException ex = new SecurityException(msg); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { RuntimeException ex = new IllegalStateException("Unable to persist timer"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { RemoveException re = new RemoveException(e.getMessage()); re.initCause(e); throw re; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
20
getFieldName 18
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(NoSuchFieldException e) { // Non recoverable internal exception throw new DeploymentException("No field named '" + getFieldName() + "' found in entity class."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); }
126
isTraceEnabled 15
                  
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { Throwable th = JMXExceptionDecoder.decode(e); if(log.isTraceEnabled()) { log.trace("Failed to invoke on mbean: " + mbean, th); } if(th instanceof Exception) { e = (Exception) th; } throw e; }
// in src/main/java/org/jboss/deployment/dependency/JndiDependencyItem.java
catch(Throwable ignored) { if (log.isTraceEnabled()) log.trace("Unexpected error", ignored); }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(Exception ignored) { if(log.isTraceEnabled()) log.trace("Failed to load class: "+className, ignored); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (PolicyContextException pe) { if(log.isTraceEnabled()) log.trace("PolicyContextException in getting caller subject:",pe); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(Cache.RemoveException e) { if(log.isTraceEnabled()) { log.trace(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (RemoteException e) { if( log.isTraceEnabled() ) log.trace("Ctx.discard error", e); }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
catch (Exception e) { if (log.isTraceEnabled()) { log.trace("Exception in creating TimedObject method:",e); } }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasDefaultConstructor("); tmp.append(") failure, "); Classes.displayClassInfo(c, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingMethod("); tmp.append(method.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBPostCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBFind("); tmp.append(finder.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBHome("); tmp.append(home.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
211
getId 13
                  
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
142
appendErrorTag 12
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Exception e) { log.error("getDeployedApplications failed", e); appendErrorTag(buffer, "Failed to getDeployedApplications " + e.toString()); closeJndiTag(buffer); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed on list contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext for (java:)", e); appendErrorTag(buffer, "Failed to get InitialContext for (java:), " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list contents of (java:)", t); appendErrorTag(buffer, "Failed to list contents of (java:), " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list global contents ", t); appendErrorTag(buffer, "Failed to list global contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list HA-JNDI contents ", t); appendErrorTag(buffer, "Failed to list HA-JNDI contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed to lookup: " + name + ", errmsg=" + t.getMessage()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed to list contents of: " + name + ", errmsg=" + t.getMessage()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { appendErrorTag(buffer, "error while listing context " + ctx.toString() + ": " + ne.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { appendErrorTag(buffer, "Failed to getLinkName, " + e.toString(true)); }
13
getType 12
                  
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (RollbackException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (HeuristicMixedException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (HeuristicRollbackException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (SystemException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (IllegalStateException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(ServiceUnavailableException e) { if( trace ) log.trace("Invocation failed", e); InvocationType type = invocation.getType(); if ((maxRetries > -1 && retryCount >= maxRetries) || reestablishInvokerProxy(ctx, type) == false) { throw e; } retryCount++; }
59
logCauseException
12
                  
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
12
formatException 11
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getDeployedApplications failed", e); buffer.append("Failed to getDeployedApplications\n"); formatException(buffer, e); buffer.insert(0, "<pre>"); buffer.append("</pre>"); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getConainers failed", e); buffer.append("<pre>"); buffer.append("Failed to get ejbs in module\n"); formatException(buffer, e); buffer.append("</pre>"); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("lookup for java: failed", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { log.error("Failed to get InitialContext", ne); buffer.append("Failed to get InitialContext, " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
16
rethrow
11
                  
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
11
check 10
                  
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
15
getSQLState 10
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
11
getException 8
                  
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { throw e.getException(); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/Container.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
9
reset 8
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
24
destroySession 7
                  
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
8
getEntityName 7
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
77
setRootCause
7
                  
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(Exception e) { NamingException ne = new NamingException("Failed to update jndiName"); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(Exception e) { NamingException ex = new NamingException("Failed to retrieve Naming interface for provider " + provider); ex.setRootCause(e); throw ex; }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(LoginException e) { AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol); ex.setRootCause(e); throw ex; }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
catch(Exception e) { NamingException ne = new NamingException("Failed to obtain value from binding: "+name); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(IOException e) { CommunicationException ce = new CommunicationException("Operation failed"); ce.setRootCause(e); throw ce; }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(Throwable t) { ServiceUnavailableException sue = new ServiceUnavailableException("Unexpected failure"); sue.setRootCause(t); throw sue; }
// in src/main/java/org/jboss/naming/JndiBinder.java
catch (NamingException e) { NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo); namingException.setRootCause(e); throw namingException; }
7
StringBuffer 6
                  
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasDefaultConstructor("); tmp.append(") failure, "); Classes.displayClassInfo(c, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingMethod("); tmp.append(method.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBPostCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBFind("); tmp.append(finder.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBHome("); tmp.append(home.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
149
displayClassInfo
6
                  
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasDefaultConstructor("); tmp.append(") failure, "); Classes.displayClassInfo(c, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingMethod("); tmp.append(method.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBPostCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBFind("); tmp.append(finder.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBHome("); tmp.append(home.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
6
getPrimaryKeyClass 6
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "could not load primary key class: " + entity.getPrimaryKeyClass() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException cnfe) { // Only check equality return m.getReturnType().getName().equals(entity.getPrimaryKeyClass()); }
41
safeClose 6
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; }
147
setEnterpriseContext 6
                  
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
17
decode 5
                  
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { Throwable th = JMXExceptionDecoder.decode(e); if(log.isTraceEnabled()) { log.trace("Failed to invoke on mbean: " + mbean, th); } if(th instanceof Exception) { e = (Exception) th; } throw e; }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Unable to create activation spec ra=" + resourceAdapterObjectName + " messaging-type=" + messagingTypeClass.getName() + " properties=" + metaData.getActivationConfigProperties(), t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); log.warn("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); }
9
getClass 5
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { // If this is a $Proxy* class its a proxy if (className.startsWith("$Proxy")) { isProxy = true; // We have to get the class from the binding try { Object p = ctx.lookup(name); c = p.getClass(); } catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } } } }
// in src/main/java/org/jboss/ejb/CacheKey.java
catch (Exception e) { Logger log = Logger.getLogger(getClass()); log.error("failed to initialize, id="+id, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch (NamingException e) { log.warn("Problem closing naming context used for reaquiring invoker: " + e.getClass() + " -- " + e.getLocalizedMessage()); }
136
remove 5
                  
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
127
throwJBossException 5
                  
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (RollbackException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (HeuristicMixedException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (HeuristicRollbackException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (SystemException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (IllegalStateException e) { throwJBossException(e, invocation.getType()); }
6
throwRemoteException
5
                  
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
5
clear 4
                  
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
70
currentThread 4
                  
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (InterruptedException e) { Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (NamingException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (JMSException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
115
equals 4
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException cnfe) { // Only check equality return m.getReturnType().getName().equals(entity.getPrimaryKeyClass()); }
452
getErrorCode
4
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
4
println 4
                  
// in src/main/java/org/jboss/Shutdown.java
catch(UndeclaredThrowableException e) { System.out.println("getUndeclaredThrowable: "+e.getUndeclaredThrowable()); throw e.getUndeclaredThrowable(); }
// in src/main/java/org/jboss/verifier/Main.java
catch (Exception e) { System.err.println("Problem starting the application:"); System.err.println("Exception: " + e); System.err.println("Message: " + e.getMessage()); e.printStackTrace(); System.exit(-1); }
37
discard 3
                  
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
11
getBeanClass 3
                  
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (Exception e) { log.error("Error getting callerPrincipal for " + con.getBeanClass(),e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; }
22
getBeanMetaData 3
                  
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
123
getEjbName 3
                  
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
101
getMapper 3
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); }
5
getTransaction 3
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
104
info 3
                  
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (Exception e) { if (error) { DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jar, e); } else { log.info("Skipped SCI for JAR: " + jar, e); } }
71
loadClass 3
                  
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
117
setRollbackOnly 3
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
12
checkRetryable
2
                  
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Exception ex) { checkRetryable(i, ex, oldTransaction); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Exception ex) { checkRetryable(i, ex, oldTransaction); }
2
createSubcontext 2
                  
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
catch (NameNotFoundException e) { ctx = ctx.createSubcontext(ctxName); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(NamingException e) { // No binding exists, create a subcontext subctx = subctx.createSubcontext(atom); }
4
get 2
                  
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
494
getCausedByException 2
                  
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
19
getContainer 2
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; }
84
getDataSourceName 2
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(NamingException e) { throw new DeploymentException("Filed to lookup: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); }
6
getEjbQl 2
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/EJBQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
8
getJBossQL 2
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JBossQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCJBossQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL " + "statement '" + metadata.getJBossQL() + "'", t); }
6
getMethod 2
                  
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
337
getPathName 2
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (IOException e) { log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e); }
16
getPrincipal 2
                  
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; }
35
getProxyString 2
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { log.warn("MessageEndpoint " + getProxyString(mi) + " failed to resume old transaction " + currentTx); }
20
getQualifiedTableName 2
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); }
83
getUndeclaredThrowable
2
                  
// in src/main/java/org/jboss/Shutdown.java
catch(UndeclaredThrowableException e) { System.out.println("getUndeclaredThrowable: "+e.getUndeclaredThrowable()); throw e.getUndeclaredThrowable(); }
2
handleException
2
                  
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
2
hasTxSynchronization 2
                  
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
11
isLocal 2
                  
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
10
lookup 2
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { // If this is a $Proxy* class its a proxy if (className.startsWith("$Proxy")) { isProxy = true; // We have to get the class from the binding try { Object p = ctx.lookup(name); c = p.getClass(); } catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } } } }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
71
resolveClass 2
                  
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
catch(ClassNotFoundException e) { /* Use the super.resolveClass() call which will resolve array classes and primitives. We do not use this by default as this can result in caching of stale values across redeployments. */ resolvedClass = super.resolveClass(v); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch (ClassNotFoundException e) { // we should probably never get here return super.resolveClass(v); }
3
setId 2
                  
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
27
setTxAssociation 2
                  
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
8
setValid 2
                  
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { // Exception - force reload on next call ctx.setValid(false); throw e; }
8
writeBytes 2
                  
// in src/main/java/org/jboss/web/WebServer.java
catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } }
6
AuthenticationException
1
                  
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(LoginException e) { AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol); ex.setRootCause(e); throw ex; }
1
BigIntegerTimerIdGenerator
1
                  
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a TimerIdGenerator, using BigIntegerTimerIdGenerator: " + e.toString()); timerIdGenerator = new BigIntegerTimerIdGenerator(); }
1
CommunicationException
1
                  
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(IOException e) { CommunicationException ce = new CommunicationException("Operation failed"); ce.setRootCause(e); throw ce; }
1
DummyConfiguration
1
                  
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch (Exception e) { if(e.getCause() instanceof IOException) { //no auth.conf or whatever so we make our own dummy conf = new DummyConfiguration(); } }
1
InitialContext 1
                  
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
86
MarshalledObject 1
                  
// in src/main/java/org/jboss/ejb/CacheKey.java
catch(NoSuchMethodException ex) { // Rely on the MarshalledObject for equals and hashCode mo = new MarshalledObject(id); // Precompute the hashCode (speed) hashCode = mo.hashCode(); }
2
MarshalledValue 1
                  
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
5
NoopPersistencePolicy
1
                  
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a PersistencePolicy, using NoopPersistencePolicy: " + e.toString()); persistencePolicy = new NoopPersistencePolicy(); }
1
PrintWriter 1
                  
// in src/main/java/org/jboss/ejb/ContainerRelection.java
catch(Throwable e) { if( e instanceof RuntimeOperationsException ) { RuntimeOperationsException roe = (RuntimeOperationsException) e; e = roe.getTargetException(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); buffer.append(sw.toString()); buffer.append("\n</pre>\n"); }
5
StringWriter 1
                  
// in src/main/java/org/jboss/ejb/ContainerRelection.java
catch(Throwable e) { if( e instanceof RuntimeOperationsException ) { RuntimeOperationsException roe = (RuntimeOperationsException) e; e = roe.getTargetException(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); buffer.append(sw.toString()); buffer.append("\n</pre>\n"); }
4
URL 1
                  
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(MalformedURLException e) { // See if externalURL refers to a property String urlProperty = System.getProperty(urlValue); if( urlProperty == null ) throw e; externalURL = new URL(urlProperty); }
14
UnexpectedThrowable
1
                  
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
1
appendLinkRefErrorTag
1
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Invalid LinkRef for: " + name, t); appendLinkRefErrorTag(buffer); }
1
appendPreExceptionTag
1
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("getContainers failed", t); appendPreExceptionTag(buffer, "Failed to get ejbs in module", t); }
1
close 1
                  
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception e) { close(); throw e; }
57
closeJndiTag 1
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Exception e) { log.error("getDeployedApplications failed", e); appendErrorTag(buffer, "Failed to getDeployedApplications " + e.toString()); closeJndiTag(buffer); return buffer.toString(); }
2
connect 1
                  
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
4
createdMarshalledValue 1
                  
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
3
currentTimeMillis 1
                  
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; }
32
destroyService 1
                  
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { destroyService(); throw e; }
4
exit 1
                  
// in src/main/java/org/jboss/verifier/Main.java
catch (Exception e) { System.err.println("Problem starting the application:"); System.err.println("Exception: " + e); System.err.println("Message: " + e.getMessage()); e.printStackTrace(); System.exit(-1); }
5
fatal
1
                  
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Exception e) { log.fatal("Could not initialize UnifiedInvokerProxy.", e); }
1
finishedContending 1
                  
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; }
2
flush 1
                  
// in src/main/java/org/jboss/web/WebServer.java
catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } }
23
getActivationConfigProperties 1
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Unable to create activation spec ra=" + resourceAdapterObjectName + " messaging-type=" + messagingTypeClass.getName() + " properties=" + metaData.getActivationConfigProperties(), t); }
2
getCause 1
                  
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch (Exception e) { if(e.getCause() instanceof IOException) { //no auth.conf or whatever so we make our own dummy conf = new DummyConfiguration(); } }
3
getColumnNumber
1
                  
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); }
1
getContextClassLoader 1
                  
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } }
141
getEjbObjectViaJndi 1
                  
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { log.debug("Exception reported, try JNDI method to recover EJB object instead", e); return getEjbObjectViaJndi(); }
2
getEntityClass 1
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); }
9
getInvocationContext 1
                  
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); }
23
getJmxName 1
                  
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.error("unexpected exception stopping Container: " + con.getJmxName(), e); }
32
getLineNumber 1
                  
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); }
4
getLocal 1
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local class not found: " + entity.getLocal() ); }
19
getLocalizedMessage
1
                  
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch (NamingException e) { log.warn("Problem closing naming context used for reaquiring invoker: " + e.getClass() + " -- " + e.getLocalizedMessage()); }
1
getLockManager 1
                  
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; }
26
getLogger 1
                  
// in src/main/java/org/jboss/ejb/CacheKey.java
catch (Exception e) { Logger log = Logger.getLogger(getClass()); log.error("failed to initialize, id="+id, e); }
132
getManagerInstance 1
                  
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
4
getMappedType 1
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); }
3
getNameInNamespace
1
                  
// in src/main/java/org/jboss/naming/JndiBinder.java
catch (NamingException e) { NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo); namingException.setRootCause(e); throw namingException; }
1
getProperty 1
                  
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(MalformedURLException e) { // See if externalURL refers to a property String urlProperty = System.getProperty(urlValue); if( urlProperty == null ) throw e; externalURL = new URL(urlProperty); }
24
getRemote 1
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "remote class not found: " + entity.getRemote() ); }
27
getReturnType 1
                  
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException cnfe) { // Only check equality return m.getReturnType().getName().equals(entity.getPrimaryKeyClass()); }
54
getRootCause
1
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { // If this is a $Proxy* class its a proxy if (className.startsWith("$Proxy")) { isProxy = true; // We have to get the class from the binding try { Object p = ctx.lookup(name); c = p.getClass(); } catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } } } }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } }
1
getSelectorName 1
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); }
2
getWrapped
1
                  
// in src/main/java/org/jboss/jmx/connector/invoker/client/InvokerAdaptorClientInterceptor.java
catch (InvokerAdaptorException e) { throw e.getWrapped(); }
1
handleOutputFileCreationException
1
                  
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception e) { handleOutputFileCreationException(file.toURI(), e); }
1
hashCode 1
                  
// in src/main/java/org/jboss/ejb/CacheKey.java
catch(NoSuchMethodException ex) { // Rely on the MarshalledObject for equals and hashCode mo = new MarshalledObject(id); // Precompute the hashCode (speed) hashCode = mo.hashCode(); }
72
increaseTimeouts
1
                  
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; }
1
insert 1
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getDeployedApplications failed", e); buffer.append("Failed to getDeployedApplications\n"); formatException(buffer, e); buffer.insert(0, "<pre>"); buffer.append("</pre>"); return buffer.toString(); }
15
interrupt 1
                  
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (InterruptedException e) { Thread.currentThread().interrupt(); }
8
isActive 1
                  
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
8
isDuplicateKey
1
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
1
isEmpty 1
                  
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
93
isTxExpired 1
                  
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; }
4
newInstance 1
                  
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } }
79
newLdapContext
1
                  
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(NoSuchMethodException e) { ctx = newLdapContext(contextClass, contextProps); }
1
processException
1
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { throw processException(e); }
1
reestablishInvokerProxy
1
                  
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(ServiceUnavailableException e) { if( trace ) log.trace("Invocation failed", e); InvocationType type = invocation.getType(); if ((maxRetries > -1 && retryCount >= maxRetries) || reestablishInvokerProxy(ctx, type) == false) { throw e; } retryCount++; }
1
release 1
                  
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); }
7
removeChild
1
                  
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); }
1
removeLockRef 1
                  
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; }
10
removeNotificationListener 1
                  
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Throwable t) { log.debug("Failed to notify client, unregistering listener", t); try { removeNotificationListener(targetName, client); } catch(Exception e) { log.debug("Failed to unregister listener", e); } }
3
resetContextClassLoader 1
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); }
2
rollback 1
                  
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
14
setBeforeDeliveryInvoke 1
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); }
3
setTransaction 1
                  
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
41
setValue 1
                  
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); }
43
startsWith 1
                  
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { // If this is a $Proxy* class its a proxy if (className.startsWith("$Proxy")) { isProxy = true; // We have to get the class from the binding try { Object p = ctx.lookup(name); c = p.getClass(); } catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } } } }
68
toURI 1
                  
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception e) { handleOutputFileCreationException(file.toURI(), e); }
8
undeploy 1
                  
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
4
Method Nbr Nbr total
safeClose 138
                  
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
finally { JDBCUtil.safeClose(insertSt); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(selectHiSt); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
finally { JDBCUtil.safeClose(updateHi); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { for(int i = 0; i < ps.length; ++i) { JDBCUtil.safeClose(ps[i]); } JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(duplicatePkPs); JDBCUtil.safeClose(insertPs); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
finally { JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
finally { safeClose(oos); safeClose(baos); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
finally { safeClose(bais); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
finally { // ois will close the input stream it wraps safeClose(ois); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
finally { safeClose(textData); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
finally { safeClose(baos); safeClose(input); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
finally { JDBCUtil.safeClose(reader); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
finally { JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
finally { JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
finally { JDBCUtil.safeClose(rs); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
finally { JDBCUtil.safeClose(rs); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); JDBCUtil.safeClose(con); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
finally { JDBCUtil.safeClose(rs); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
finally { JDBCUtil.safeClose( results ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); }
147
popInMethodFlag
41
                  
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
finally{ AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
finally{ AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
finally{ AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
finally{ AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
finally{ AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
finally{ AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
finally{ AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free((EnterpriseContext) mi.getEnterpriseContext()); } else { pool.discard(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { synchronized (ctx) { AllowedOperationsAssociation.popInMethodFlag(); // Release the lock ctx.unlock(); // Still free? Not free if create() was called successfully if (ctx.getId() == null) { pool.free(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally{ AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { container.popENC(); AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { container.popENC(); AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
finally{ AllowedOperationsAssociation.popInMethodFlag(); }
41
setContextClassLoader 31
                  
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
finally { Thread.currentThread().setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
finally { TCLAction.UTIL.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
finally { currentThread.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); }
// in src/main/java/org/jboss/deployment/dependency/JndiDependencyItem.java
finally { Thread.currentThread().setContextClassLoader(tcl); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
finally { // restore class loader Thread.currentThread().setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java
finally { container.popENC(); if(pushedRunAs) SecurityActions.popRunAsIdentity(); SecurityActions.setContextClassLoader(callerClassLoader); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/EjbModule.java
finally { con.popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
finally { SecurityActions.setContextClassLoader(ccl); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); container.popENC(); if(setCl) { SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
finally { container.popENC(); SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
finally { SecurityActions.setContextClassLoader(oldCl); synchronizing = false; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationsTxGrouper.java
finally { Thread.currentThread().setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
finally { thread.setContextClassLoader(appClassLoader); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
finally { currentThread.setContextClassLoader(currentLoader); }
// in src/main/java/org/jboss/web/deployers/WarSecurityDeployer.java
finally { SecurityActions.setContextClassLoader(oldCL); }
125
close 24
                  
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
finally { ctx.close(); }
// in src/main/java/org/jboss/client/AppClientMain.java
finally { is.close(); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
finally { // close the InputStream to get around "too many open files" errors // with large heaps try { if( is != null ) is.close(); } catch (Exception e) { // ignore } }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
finally { context.close(); }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
finally { context.close(); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
finally { ctx.close(); }
// in src/main/java/org/jboss/deployment/EARStructure.java
finally { in.close(); }
// in src/main/java/org/jboss/deployment/EARStructure.java
finally { in.close(); }
// in src/main/java/org/jboss/naming/LinkRefPairService.java
finally { ctx.close(); }
// in src/main/java/org/jboss/naming/LinkRefPairService.java
finally { ctx.close(); }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
finally { if (writer != null) { writer.close(); } }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
finally { if (fr != null) { try { fr.close(); } catch (Exception ignored) {} } }
// in src/main/java/org/jboss/naming/NamingService.java
finally { is.close(); }
// in src/main/java/org/jboss/ejb/Container.java
finally { dsCtx.close(); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
finally { out.close(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
finally { in.close(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
finally { out.close(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
finally { in.close(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
finally { out.close(); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { // thread cleanup synchronized (msgQueue) { msgQueue.clear(); } try { if (connection != null) connection.close(); } catch (JMSException e) { log.warn(e); } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/web/WebServer.java
finally { // Close the client request socket try { socket.close(); } catch (IOException e) { } }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
finally { if (inputStream != null) { inputStream.close(); } }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
finally { try { if (is != null) is.close(); } catch (IOException e) { ; } }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
finally { // JBAS-5906 -- clean up after ourselves if (namingCtx != null) { try { namingCtx.close(); } catch (NamingException e) { log.warn("Problem closing naming context used for reaquiring invoker: " + e.getClass() + " -- " + e.getLocalizedMessage()); } } }
57
popENC
24
                  
// in src/main/java/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java
finally { container.popENC(); if(pushedRunAs) SecurityActions.popRunAsIdentity(); SecurityActions.setContextClassLoader(callerClassLoader); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/EjbModule.java
finally { con.popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/Container.java
finally { popENC(); }
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); container.popENC(); if(setCl) { SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { container.popENC(); AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { container.popENC(); AllowedOperationsAssociation.popInMethodFlag(); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
finally { container.popENC(); SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
finally { container.popENC(); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
finally { container.popENC(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); }
24
trace 13
                  
// in src/main/java/org/jboss/ejb/BeanLockManager.java
finally { // schrouf: ALLWAYS ensure proper map lock removal even in case // of exception within lock.removeRef ! There seems to be a bug // in the ref counting of QueuedPessimisticEJBLock under certain // conditions ( lock.ref < 0 should never happen !!! ) if (lock.getRefs() <= 0) { Object mapLock = mapInUse.remove(lock.getId()); if( trace ) log.trace("Lock no longer referenced, lock: "+lock); } }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
finally { // We are done with the lock in general container.getLockManager().removeLockRef(key); if( trace ) log.trace("End invoke, key="+key); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { synchronized (this) { suspended = null; } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " transaction=" + suspended + " already active, IGNORED=" + resource); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { if(trace) log.trace("afterCompletion, clear tx for ctx=" + ctx + ", tx=" + tx); lock.endTransaction(tx); if(trace) log.trace("afterCompletion, sent notify on TxLock for ctx=" + ctx); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
finally { if (trace) { log.trace("End method=" + methodName); } }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
finally { if (trace) { log.trace("End method=" + methodName); } }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
finally { SecurityActions.popCallerRunAsIdentity(); if(mi.isLocal() && si != null) SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si); if(mi.isLocal() && incomingDomain != null) SecurityActions.setSecurityDomain(SecurityActions.getSecurityContext(), incomingDomain); if (log.isTraceEnabled()) { log.trace("Exit process():isInvoke="+isInvoke); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
finally { if (trace) log.trace("afterCompletion, clear tx for ctx=" + ctx + ", tx=" + tx); }
386
unlock 13
                  
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
finally { ctx.unlock(); methodLock.release(nonReentrant); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
finally { partition.unlock(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { cache.unlock(pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { cache.unlock(row.pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { cache.unlock(id); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
finally { cache.unlock(cursor.pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
finally { cache.unlock(key); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
finally { cache.unlock(keys[i]); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
finally { cache.unlock(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
finally { unlock(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
finally { unlock(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { synchronized (ctx) { AllowedOperationsAssociation.popInMethodFlag(); // Release the lock ctx.unlock(); // Still free? Not free if create() was called successfully if (ctx.getId() == null) { pool.free(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } }
16
currentThread 12
                  
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
finally { Thread.currentThread().setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/deployment/dependency/JndiDependencyItem.java
finally { Thread.currentThread().setContextClassLoader(tcl); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
finally { // restore class loader Thread.currentThread().setContextClassLoader(oldCl); }
// in src/main/java/org/jboss/ejb/plugins/lock/BeanLockSupport.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { // thread cleanup synchronized (msgQueue) { msgQueue.clear(); } try { if (connection != null) connection.close(); } catch (JMSException e) { log.warn(e); } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationsTxGrouper.java
finally { Thread.currentThread().setContextClassLoader(oldCl); }
115
getId 12
                  
// in src/main/java/org/jboss/ejb/BeanLockManager.java
finally { // schrouf: ALLWAYS ensure proper map lock removal even in case // of exception within lock.removeRef ! There seems to be a bug // in the ref counting of QueuedPessimisticEJBLock under certain // conditions ( lock.ref < 0 should never happen !!! ) if (lock.getRefs() <= 0) { Object mapLock = mapInUse.remove(lock.getId()); if( trace ) log.trace("Lock no longer referenced, lock: "+lock); } }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { container.getLockManager().removeLockRef(lock.getId()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { // We were read-only and the context wasn't already synchronized, tidyup the cache if(isReadOnly && ctx.hasTxSynchronization() == false) { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // FIXME: We cannot passivate here, because previous // interceptors work with the context, in particular // the re-entrance interceptor is doing lock counting // Just remove it from the cache if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // Do not call release if getId() is null. This means that // the entity has been removed from cache. // release will schedule a passivation and this removed ctx // could be put back into the cache! // This is necessary because we have no lock, we // don't want to return an instance to the pool that is // being used if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); container.popENC(); if(setCl) { SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { synchronized (ctx) { AllowedOperationsAssociation.popInMethodFlag(); // Release the lock ctx.unlock(); // Still free? Not free if create() was called successfully if (ctx.getId() == null) { pool.free(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); }
142
releaseSync 12
                  
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
finally { lock.releaseSync(); getLockManager().removeLockRef(id); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(ctx.getCacheKey()); }
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
finally { // we are done with the method, decrease the count, if it reaches 0 it will wake up // the next thread lock.sync(); lock.endInvocation(mi); lock.releaseSync(); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
finally { releaseSync(); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
finally { lock.releaseSync(); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
finally { if (miTx == null // non-transactional && wasThreadScheduled) { // if this non-transctional thread was // scheduled in txWaitQueue, we need to call nextTransaction // Otherwise, threads in txWaitQueue will never wake up. nextTransaction(); } this.releaseSync(); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
finally { if( lockedBean ) lock.releaseSync(); getContainer().getLockManager().removeLockRef(id); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); container.popENC(); if(setCl) { SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(id); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { lock.releaseSync(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { lock.releaseSync(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); }
14
resume 10
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { synchronized (this) { transaction = null; } // Resume any suspended transaction if (currentTx != null) { try { tm.resume(currentTx); } catch (Throwable t) { log.warn("MessageEndpoint " + getProxyString(mi) + " failed to resume old transaction " + currentTx); } } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
finally { if(curTx != null) { try { tm.resume(curTx); } catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); } } }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { // IN case we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { log.error("Could not reattach original transaction after drop table"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { // Reset threadlocal to its old value userTransaction.set(oldUserTx); // Restore old MI transaction // OSH: Why ??? mi.setTransaction(oldTransaction); // If we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); }
19
getLockManager 9
                  
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
finally { lock.releaseSync(); getLockManager().removeLockRef(id); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(ctx.getCacheKey()); }
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
finally { // We are done with the lock in general container.getLockManager().removeLockRef(key); if( trace ) log.trace("End invoke, key="+key); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
finally { if( lockedBean ) lock.releaseSync(); getContainer().getLockManager().removeLockRef(id); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { container.getLockManager().removeLockRef(lock.getId()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); container.popENC(); if(setCl) { SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(id); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); }
26
removeLockRef 9
                  
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
finally { lock.releaseSync(); getLockManager().removeLockRef(id); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(ctx.getCacheKey()); }
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
finally { // We are done with the lock in general container.getLockManager().removeLockRef(key); if( trace ) log.trace("End invoke, key="+key); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
finally { if( lockedBean ) lock.releaseSync(); getContainer().getLockManager().removeLockRef(id); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { container.getLockManager().removeLockRef(lock.getId()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); container.popENC(); if(setCl) { SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(id); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(lock.getId()); }
10
remove 8
                  
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
finally { activeTx.remove(tpc); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
finally { // schrouf: ALLWAYS ensure proper map lock removal even in case // of exception within lock.removeRef ! There seems to be a bug // in the ref counting of QueuedPessimisticEJBLock under certain // conditions ( lock.ref < 0 should never happen !!! ) if (lock.getRefs() <= 0) { Object mapLock = mapInUse.remove(lock.getId()); if( trace ) log.trace("Lock no longer referenced, lock: "+lock); } }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { // We were read-only and the context wasn't already synchronized, tidyup the cache if(isReadOnly && ctx.hasTxSynchronization() == false) { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // FIXME: We cannot passivate here, because previous // interceptors work with the context, in particular // the re-entrance interceptor is doing lock counting // Just remove it from the cache if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // Do not call release if getId() is null. This means that // the entity has been removed from cache. // release will schedule a passivation and this removed ctx // could be put back into the cache! // This is necessary because we have no lock, we // don't want to return an instance to the pool that is // being used if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
finally { synchronized (activating) { activating.remove(id); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } }
127
interrupt 6
                  
// in src/main/java/org/jboss/ejb/plugins/lock/BeanLockSupport.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { // thread cleanup synchronized (msgQueue) { msgQueue.clear(); } try { if (connection != null) connection.close(); } catch (JMSException e) { log.warn(e); } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
finally { if (intr) Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
finally { if (intr) Thread.currentThread().interrupt(); }
8
setTransaction 6
                  
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { invocation.setTransaction(oldTransaction); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { // reassociate the oldTransaction with the Invocation (even null) invocation.setTransaction(oldTx); // Always drop thread association even if committing or // rolling back the newTransaction because not all TMs // will drop thread associations when commit() or rollback() // are called through tx itself (see JTA spec that seems to // indicate that thread assoc is required to be dropped only // when commit() and rollback() are called through TransactionManager // interface) //tx has committed, so we can't throw txRolledbackException. tm.suspend(); // Reset the transaction timeout (unless we didn't set it) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { // Reset threadlocal to its old value userTransaction.set(oldUserTx); // Restore old MI transaction // OSH: Why ??? mi.setTransaction(oldTransaction); // If we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); }
41
suspend 6
                  
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { tm.suspend(); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { tm.suspend(); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { // reassociate the oldTransaction with the Invocation (even null) invocation.setTransaction(oldTx); // Always drop thread association even if committing or // rolling back the newTransaction because not all TMs // will drop thread associations when commit() or rollback() // are called through tx itself (see JTA spec that seems to // indicate that thread assoc is required to be dropped only // when commit() and rollback() are called through TransactionManager // interface) //tx has committed, so we can't throw txRolledbackException. tm.suspend(); // Reset the transaction timeout (unless we didn't set it) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { try { if (stateless) checkStatelessDone(); else checkBadStateful(); } finally { tm.suspend(); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { tm.suspend(); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { Transaction tx = null; try { tx = tm.suspend(); } catch (SystemException ex) { log.error("Failed to suspend transaction", ex); } if (tx != null) { String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ; log.error(msg); throw new RemoteException(msg); } }
18
DeploymentException 5
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } }
298
free 5
                  
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free((EnterpriseContext) mi.getEnterpriseContext()); } else { pool.discard(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
finally { mi.setEnterpriseContext(null); // If an instance was created, return it to the pool if( ctx != null ) pool.free(ctx); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { synchronized (ctx) { AllowedOperationsAssociation.popInMethodFlag(); // Release the lock ctx.unlock(); // Still free? Not free if create() was called successfully if (ctx.getId() == null) { pool.free(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } }
14
setEnterpriseBean 5
                  
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free((EnterpriseContext) mi.getEnterpriseContext()); } else { pool.discard(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); }
10
endTransaction 4
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { // No before/after delivery, end any transaction and release the lock if (getOldClassLoader() == null) { try { // Finish any transaction we started endTransaction(mi, commit); } finally { releaseThreadLock(mi); } } }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { // We started the transaction for sure so we commit or roll back endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { if(trace) log.trace("afterCompletion, clear tx for ctx=" + ctx + ", tx=" + tx); lock.endTransaction(tx); if(trace) log.trace("afterCompletion, sent notify on TxLock for ctx=" + ctx); }
6
getEnterpriseContext 4
                  
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free((EnterpriseContext) mi.getEnterpriseContext()); } else { pool.discard(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } }
34
getInstanceCache 4
                  
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { // We were read-only and the context wasn't already synchronized, tidyup the cache if(isReadOnly && ctx.hasTxSynchronization() == false) { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // FIXME: We cannot passivate here, because previous // interceptors work with the context, in particular // the re-entrance interceptor is doing lock counting // Just remove it from the cache if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // Do not call release if getId() is null. This means that // the entity has been removed from cache. // release will schedule a passivation and this removed ctx // could be put back into the cache! // This is necessary because we have no lock, we // don't want to return an instance to the pool that is // being used if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } }
31
setSecurityContext 4
                  
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthenticationInterceptor.java
finally { // restore previous security context if (subject != null) SecurityActions.setSecurityContext(previousSC); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
finally { SecurityActions.setSecurityContext(cachedContext); }
// in src/main/java/org/jboss/proxy/ejb/SecurityContextInterceptor.java
finally { if(compatib && sc != null) SecurityActions.setSecurityContext(sc); }
23
currentTimeMillis 3
                  
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } }
32
debug 3
                  
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
finally { if (timerState == IN_TIMEOUT) { log.debug("Timer was not registered with Tx, resetting state: " + timer); if (periode == 0) { setTimerState(EXPIRED); killTimer(); } else { setTimerState(ACTIVE); } } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { // We were read-only and the context wasn't already synchronized, tidyup the cache if(isReadOnly && ctx.hasTxSynchronization() == false) { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // FIXME: We cannot passivate here, because previous // interceptors work with the context, in particular // the re-entrance interceptor is doing lock counting // Just remove it from the cache if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // Do not call release if getId() is null. This means that // the entity has been removed from cache. // release will schedule a passivation and this removed ctx // could be put back into the cache! // This is necessary because we have no lock, we // don't want to return an instance to the pool that is // being used if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } }
384
error 3
                  
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { log.error("Could not reattach original transaction after drop table"); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { Transaction tx = null; try { tx = tm.suspend(); } catch (SystemException ex) { log.error("Failed to suspend transaction", ex); } if (tx != null) { String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ; log.error(msg); throw new RemoteException(msg); } }
176
hasTxSynchronization 3
                  
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { // We were read-only and the context wasn't already synchronized, tidyup the cache if(isReadOnly && ctx.hasTxSynchronization() == false) { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // FIXME: We cannot passivate here, because previous // interceptors work with the context, in particular // the re-entrance interceptor is doing lock counting // Just remove it from the cache if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } }
11
popRunAsIdentity
3
                  
// in src/main/java/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java
finally { container.popENC(); if(pushedRunAs) SecurityActions.popRunAsIdentity(); SecurityActions.setContextClassLoader(callerClassLoader); }
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
finally { SecurityActions.popRunAsIdentity(); SecurityActions.popCallerRunAsIdentity(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
finally { SecurityActions.popRunAsIdentity(); SecurityActions.popSubjectContext(); }
3
sync 3
                  
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
finally { // we are done with the method, decrease the count, if it reaches 0 it will wake up // the next thread lock.sync(); lock.endInvocation(mi); lock.releaseSync(); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
finally { sync(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } }
19
warn 3
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { synchronized (this) { transaction = null; } // Resume any suspended transaction if (currentTx != null) { try { tm.resume(currentTx); } catch (Throwable t) { log.warn("MessageEndpoint " + getProxyString(mi) + " failed to resume old transaction " + currentTx); } } }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { // thread cleanup synchronized (msgQueue) { msgQueue.clear(); } try { if (connection != null) connection.close(); } catch (JMSException e) { log.warn(e); } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
finally { // JBAS-5906 -- clean up after ourselves if (namingCtx != null) { try { namingCtx.close(); } catch (NamingException e) { log.warn("Problem closing naming context used for reaquiring invoker: " + e.getClass() + " -- " + e.getLocalizedMessage()); } } }
137
addEntry
2
                  
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } }
2
clearSecurityContext 2
                  
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); }
3
discard 2
                  
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free((EnterpriseContext) mi.getEnterpriseContext()); } else { pool.discard(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } }
11
getMethod 2
                  
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } }
337
getProxyString 2
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { synchronized (this) { suspended = null; } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " transaction=" + suspended + " already active, IGNORED=" + resource); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { synchronized (this) { transaction = null; } // Resume any suspended transaction if (currentTx != null) { try { tm.resume(currentTx); } catch (Throwable t) { log.warn("MessageEndpoint " + getProxyString(mi) + " failed to resume old transaction " + currentTx); } } }
20
getSecurityContext 2
                  
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
finally { SecurityActions.popCallerRunAsIdentity(); if(mi.isLocal() && si != null) SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si); if(mi.isLocal() && incomingDomain != null) SecurityActions.setSecurityDomain(SecurityActions.getSecurityContext(), incomingDomain); if (log.isTraceEnabled()) { log.trace("Exit process():isInvoke="+isInvoke); } }
81
isAlive
2
                  
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } }
2
isLocal 2
                  
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
finally { SecurityActions.popCallerRunAsIdentity(); if(mi.isLocal() && si != null) SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si); if(mi.isLocal() && incomingDomain != null) SecurityActions.setSecurityDomain(SecurityActions.getSecurityContext(), incomingDomain); if (log.isTraceEnabled()) { log.trace("Exit process():isInvoke="+isInvoke); } }
10
pop 2
                  
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
finally { info.pop(); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
finally { info.pop(); }
15
popCallerRunAsIdentity
2
                  
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
finally { SecurityActions.popRunAsIdentity(); SecurityActions.popCallerRunAsIdentity(); }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
finally { SecurityActions.popCallerRunAsIdentity(); if(mi.isLocal() && si != null) SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si); if(mi.isLocal() && incomingDomain != null) SecurityActions.setSecurityDomain(SecurityActions.getSecurityContext(), incomingDomain); if (log.isTraceEnabled()) { log.trace("Exit process():isInvoke="+isInvoke); } }
2
popSubjectContext
2
                  
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
finally { SecurityActions.popRunAsIdentity(); SecurityActions.popSubjectContext(); }
2
releaseThreadLock
2
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { // No before/after delivery, end any transaction and release the lock if (getOldClassLoader() == null) { try { // Finish any transaction we started endTransaction(mi, commit); } finally { releaseThreadLock(mi); } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { releaseThreadLock(mi); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { setBeforeDeliveryInvoke(false); // Reset delivered flag delivered.set(false); // Change back to the original context classloader resetContextClassLoader(mi); // We no longer hold the lock releaseThreadLock(mi); }
2
removeWaiting 2
                  
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
finally { DeadlockDetector.singleton.removeWaiting(deadlocker); }
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
finally { DeadlockDetector.singleton.removeWaiting(deadlocker); }
4
reset 2
                  
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
finally { // Restores the TCCL if (clSwitchContext != null) clSwitchContext.reset(); }
// in src/main/java/org/jboss/web/WebServer.java
finally { if (tclSwitchContext != null) { tclSwitchContext.reset(); } }
24
set 2
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { setBeforeDeliveryInvoke(false); // Reset delivered flag delivered.set(false); // Change back to the original context classloader resetContextClassLoader(mi); // We no longer hold the lock releaseThreadLock(mi); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { // Reset threadlocal to its old value userTransaction.set(oldUserTx); // Restore old MI transaction // OSH: Why ??? mi.setTransaction(oldTransaction); // If we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); }
34
setKey 2
                  
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
finally { ENCThreadLocalKey.setKey(oldInvokerBinding); // JBAS-4192 clear the container's thread local container.setProxyFactory(null); }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
finally { ENCThreadLocalKey.setKey(oldInvokerBinding); // JBAS-4192 clear the container's thread local container.setProxyFactory(null); }
5
setProxyFactory 2
                  
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
finally { ENCThreadLocalKey.setKey(oldInvokerBinding); // JBAS-4192 clear the container's thread local container.setProxyFactory(null); }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
finally { ENCThreadLocalKey.setKey(oldInvokerBinding); // JBAS-4192 clear the container's thread local container.setProxyFactory(null); }
5
setTimerState 2
                  
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
finally { if (timerState == IN_TIMEOUT) { log.debug("Timer was not registered with Tx, resetting state: " + timer); if (periode == 0) { setTimerState(EXPIRED); killTimer(); } else { setTimerState(ACTIVE); } } }
17
setTransactionTimeout 2
                  
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
finally { // Reset the transaction timeout (if we know what it was) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
finally { // reassociate the oldTransaction with the Invocation (even null) invocation.setTransaction(oldTx); // Always drop thread association even if committing or // rolling back the newTransaction because not all TMs // will drop thread associations when commit() or rollback() // are called through tx itself (see JTA spec that seems to // indicate that thread assoc is required to be dropped only // when commit() and rollback() are called through TransactionManager // interface) //tx has committed, so we can't throw txRolledbackException. tm.suspend(); // Reset the transaction timeout (unless we didn't set it) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); }
7
setValid 2
                  
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { // We were read-only and the context wasn't already synchronized, tidyup the cache if(isReadOnly && ctx.hasTxSynchronization() == false) { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // FIXME: We cannot passivate here, because previous // interceptors work with the context, in particular // the re-entrance interceptor is doing lock counting // Just remove it from the cache if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // Do not call release if getId() is null. This means that // the entity has been removed from cache. // release will schedule a passivation and this removed ctx // could be put back into the cache! // This is necessary because we have no lock, we // don't want to return an instance to the pool that is // being used if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } }
8
IllegalStateException 1
                  
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
finally { if(curTx != null) { try { tm.resume(curTx); } catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); } } }
233
RemoteException 1
                  
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { Transaction tx = null; try { tx = tm.suspend(); } catch (SystemException ex) { log.error("Failed to suspend transaction", ex); } if (tx != null) { String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ; log.error(msg); throw new RemoteException(msg); } }
16
callOut
1
                  
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
1
checkBadStateful
1
                  
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { try { if (stateless) checkStatelessDone(); else checkBadStateful(); } finally { tm.suspend(); } }
1
checkStatelessDone
1
                  
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { try { if (stateless) checkStatelessDone(); else checkBadStateful(); } finally { tm.suspend(); } }
1
clear 1
                  
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
finally { // thread cleanup synchronized (msgQueue) { msgQueue.clear(); } try { if (connection != null) connection.close(); } catch (JMSException e) { log.warn(e); } finally { if (intr) Thread.currentThread().interrupt(); } }
70
closeWebModuleTag
1
                  
// in src/main/java/org/jboss/naming/JNDIView.java
finally { closeWebModuleTag(buffer); }
1
endInvocation 1
                  
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
finally { // we are done with the method, decrease the count, if it reaches 0 it will wake up // the next thread lock.sync(); lock.endInvocation(mi); lock.releaseSync(); }
2
equals 1
                  
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
452
getBeanMetaData 1
                  
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { Transaction tx = null; try { tx = tm.suspend(); } catch (SystemException ex) { log.error("Failed to suspend transaction", ex); } if (tx != null) { String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ; log.error(msg); throw new RemoteException(msg); } }
123
getCacheKey 1
                  
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { lock.releaseSync(); container.getLockManager().removeLockRef(ctx.getCacheKey()); }
12
getClass 1
                  
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
finally { // JBAS-5906 -- clean up after ourselves if (namingCtx != null) { try { namingCtx.close(); } catch (NamingException e) { log.warn("Problem closing naming context used for reaquiring invoker: " + e.getClass() + " -- " + e.getLocalizedMessage()); } } }
136
getContainer 1
                  
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
finally { if( lockedBean ) lock.releaseSync(); getContainer().getLockManager().removeLockRef(id); }
84
getEjbName 1
                  
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
finally { Transaction tx = null; try { tx = tm.suspend(); } catch (SystemException ex) { log.error("Failed to suspend transaction", ex); } if (tx != null) { String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ; log.error(msg); throw new RemoteException(msg); } }
101
getLocalizedMessage
1
                  
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
finally { // JBAS-5906 -- clean up after ourselves if (namingCtx != null) { try { namingCtx.close(); } catch (NamingException e) { log.warn("Problem closing naming context used for reaquiring invoker: " + e.getClass() + " -- " + e.getLocalizedMessage()); } } }
1
getMessage 1
                  
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
finally { if(curTx != null) { try { tm.resume(curTx); } catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); } } }
123
getOldClassLoader 1
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { // No before/after delivery, end any transaction and release the lock if (getOldClassLoader() == null) { try { // Finish any transaction we started endTransaction(mi, commit); } finally { releaseThreadLock(mi); } } }
4
getRefs 1
                  
// in src/main/java/org/jboss/ejb/BeanLockManager.java
finally { // schrouf: ALLWAYS ensure proper map lock removal even in case // of exception within lock.removeRef ! There seems to be a bug // in the ref counting of QueuedPessimisticEJBLock under certain // conditions ( lock.ref < 0 should never happen !!! ) if (lock.getRefs() <= 0) { Object mapLock = mapInUse.remove(lock.getId()); if( trace ) log.trace("Lock no longer referenced, lock: "+lock); } }
2
getTransaction 1
                  
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }
104
getType 1
                  
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
59
isTraceEnabled 1
                  
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
finally { SecurityActions.popCallerRunAsIdentity(); if(mi.isLocal() && si != null) SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si); if(mi.isLocal() && incomingDomain != null) SecurityActions.setSecurityDomain(SecurityActions.getSecurityContext(), incomingDomain); if (log.isTraceEnabled()) { log.trace("Exit process():isInvoke="+isInvoke); } }
211
killTimer 1
                  
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
finally { if (timerState == IN_TIMEOUT) { log.debug("Timer was not registered with Tx, resetting state: " + timer); if (periode == 0) { setTimerState(EXPIRED); killTimer(); } else { setTimerState(ACTIVE); } } }
2
nextTransaction 1
                  
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
finally { if (miTx == null // non-transactional && wasThreadScheduled) { // if this non-transctional thread was // scheduled in txWaitQueue, we need to call nextTransaction // Otherwise, threads in txWaitQueue will never wake up. nextTransaction(); } this.releaseSync(); }
4
release 1
                  
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
finally { ctx.unlock(); methodLock.release(nonReentrant); }
7
resetContextClassLoader 1
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { setBeforeDeliveryInvoke(false); // Reset delivered flag delivered.set(false); // Change back to the original context classloader resetContextClassLoader(mi); // We no longer hold the lock releaseThreadLock(mi); }
2
setArgs 1
                  
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
2
setBeforeDeliveryInvoke 1
                  
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
finally { setBeforeDeliveryInvoke(false); // Reset delivered flag delivered.set(false); // Change back to the original context classloader resetContextClassLoader(mi); // We no longer hold the lock releaseThreadLock(mi); }
3
setContextID 1
                  
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
3
setEnterpriseContext 1
                  
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
finally { mi.setEnterpriseContext(null); // If an instance was created, return it to the pool if( ctx != null ) pool.free(ctx); }
17
setMessage 1
                  
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
6
setMetaData 1
                  
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
2
setReadOnly 1
                  
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
finally { // if we marked the context as read only we need to reset it if(didSetReadOnly) { ctx.setReadOnly(false); } }
2
setSecurityDomain 1
                  
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
finally { SecurityActions.popCallerRunAsIdentity(); if(mi.isLocal() && si != null) SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si); if(mi.isLocal() && incomingDomain != null) SecurityActions.setSecurityDomain(SecurityActions.getSecurityContext(), incomingDomain); if (log.isTraceEnabled()) { log.trace("Exit process():isInvoke="+isInvoke); } }
6
setSecurityIdentity 1
                  
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
finally { SecurityActions.popCallerRunAsIdentity(); if(mi.isLocal() && si != null) SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si); if(mi.isLocal() && incomingDomain != null) SecurityActions.setSecurityDomain(SecurityActions.getSecurityContext(), incomingDomain); if (log.isTraceEnabled()) { log.trace("Exit process():isInvoke="+isInvoke); } }
3
updateStats
1
                  
// in src/main/java/org/jboss/ejb/Container.java
finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); }
1

Reference Table

This table concatenates the results of the previous tables.

Checked/Runtime Type Exception Thrown Thrown from Catch Declared Caught directly Caught
with Thrown
Caught
with Thrown Runtime
unknown (Lib) . 0 0 0 0 0 0
unknown (Lib) AccessControlException 0 0 0 1
            
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (AccessControlException ignored) { }
0 0
unknown (Lib) AccessException 0 0 0 2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
0
unknown (Lib) AccessLocalException 2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); }
0 0 0 0
unknown (Lib) BAD_OPERATION 0 0 0 1
            
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
1
            
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
0
unknown (Lib) BindException 0 0 0 1
            
// in src/main/java/org/jboss/web/WebServer.java
catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); }
1
            
// in src/main/java/org/jboss/web/WebServer.java
catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); }
0
unknown (Lib) CannotConnectException 0 0 0 2
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
2
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
0
unknown (Lib) ClassCastException 0 0 0 1
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); }
1
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); }
0
unknown (Lib) ClassNotFoundException 1
            
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { Class clazz = null; Class[] ifaceClasses = new Class[interfaces.length]; for(int i = 0; i < interfaces.length; i ++) ifaceClasses[i] = Class.forName(interfaces[i], false, appCl); try { clazz = Proxy.getProxyClass(appCl, ifaceClasses); } catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); } return clazz; }
1
            
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); }
45
            
// in src/main/java/org/jboss/invocation/ByValueInvokerInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { // We have no state }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { externalURLValue = (String) in.readObject(); externalURL = Util.resolveURL(externalURLValue); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
private MarshalledInvocation createInvocationCopy(Invocation invocation, IMarshalledValue value) throws IOException, ClassNotFoundException { MarshalledInvocation invocationCopy = new MarshalledInvocation(invocation); invocationCopy.setMethod(null); invocationCopy.setMethodHash(MarshalledInvocation.calculateHash(invocation.getMethod())); invocationCopy.setMarshalledArguments(value); invocationCopy.setArguments(null); InvocationContext copyContext = null; if (invocation.getInvocationContext()!=null) { copyContext = (InvocationContext)createMarshalledValueForCallByValue(invocation.getInvocationContext()).get(); } invocationCopy.setInvocationContext(copyContext); Map payLoad = invocation.getPayload(); Map payloadCopy = new HashMap(); if (payLoad!=null && payLoad.size()!=0) { Iterator keys = payLoad.keySet().iterator(); while (keys.hasNext()) { Object currentKey = keys.next(); Object valueSource = payLoad.get(currentKey); payloadCopy.put(currentKey,this.createMarshalledValueForCallByValue(valueSource)); } } invocationCopy.payload = payloadCopy; return invocationCopy; }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { invokerID = (GUID)in.readObject(); }
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { String className = v.getName(); Class resolvedClass = null; // Check the class cache first if it exists if( classCache != null ) { synchronized( classCache ) { resolvedClass = (Class) classCache.get(className); } } if( resolvedClass == null ) { ClassLoader loader = SecurityActions.getContextClassLoader(); try { resolvedClass = loader.loadClass(className); } catch(ClassNotFoundException e) { /* Use the super.resolveClass() call which will resolve array classes and primitives. We do not use this by default as this can result in caching of stale values across redeployments. */ resolvedClass = super.resolveClass(v); } if( classCache != null ) { synchronized( classCache ) { classCache.put(className, resolvedClass); } } } return resolvedClass; }
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("["); for(int i = 0; i < interfaces.length; i ++) { if( i > 0 ) tmp.append(','); tmp.append(interfaces[i]); } tmp.append(']'); log.trace("resolveProxyClass called, ifaces="+tmp.toString()); } // Load the interfaces from the cache or thread context class loader ClassLoader loader = null; Class[] ifaceClasses = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { Class iface = null; String className = interfaces[i]; // Check the proxy cache if it exists if( classCache != null ) { synchronized( classCache ) { iface = (Class) classCache.get(className); } } // Load the interface class using the thread context ClassLoader if( iface == null ) { if( loader == null ) loader = Thread.currentThread().getContextClassLoader(); iface = loader.loadClass(className); if( classCache != null ) { synchronized( classCache ) { classCache.put(className, iface); } } } ifaceClasses[i] = iface; } return Proxy.getProxyClass(loader, ifaceClasses); }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public Object get() throws IOException, ClassNotFoundException { if (serializedForm == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream(serializedForm); MarshalledValueInputStream mvis = new MarshalledValueInputStream(bais); Object retValue = mvis.readObject(); mvis.close(); return retValue; }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int length = in.readInt(); serializedForm = null; if( length > 0 ) { serializedForm = new byte[length]; in.readFully(serializedForm); } hashCode = in.readInt(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
public void readExternal(java.io.ObjectInput in) throws IOException, ClassNotFoundException { tpc = in.readObject(); this.methodHash = in.readLong(); this.objectName = in.readObject(); marshalledArgs = in.readObject(); int payloadSize = in.readInt(); if (payloadSize > 0) { payload = new HashMap(); for (int i = 0; i < payloadSize; i++) { Object key = in.readObject(); Object value = in.readObject(); payload.put(key, value); } } int as_is_payloadSize = in.readInt(); if (as_is_payloadSize > 0) { as_is_payload = new HashMap(); for (int i = 0; i < as_is_payloadSize; i++) { Object key = in.readObject(); Object value = in.readObject(); as_is_payload.put(key, value); } } // TODO invocationType should be removed from as is payload // for now, it is in there for binary compatibility invocationType = (InvocationType)getAsIsValue(InvocationKey.TYPE); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata); return removeDecoration(ret); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); return removeDecoration(ret); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); if(ret instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) ret; Object param = remoteInv.getParameter(); if(param instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) param; Object txCxt = mi.getTransactionPropagationContext(); if(txCxt != null) { TransactionPropagationContextImporter tpcImporter = TransactionPropagationContextUtil.getTPCImporter(); mi.setTransaction(tpcImporter.importTransactionPropagationContext(txCxt)); } } } return ret; }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { int version = in.readInt(); // Read in and map the version of the serialized data seen switch(version) { case VERSION_5_0: locator = new InvokerLocator(in.readUTF()); strictRMIException = in.readBoolean(); init(locator); break; default: throw new StreamCorruptedException("Unknown version seen: " + version); } }
// in src/main/java/org/jboss/metadata/EnvEntryBinder.java
public static void bindEnvEntry(Context ctx, EnvEntryMetaData entry) throws ClassNotFoundException, NamingException { ClassLoader loader = EnvEntryMetaData.class.getClassLoader(); Class type = loader.loadClass(entry.getType()); if (type == String.class) { Util.bind(ctx, entry.getName(), entry.getValue()); } else if (type == Integer.class) { Util.bind(ctx, entry.getName(), new Integer(entry.getValue())); } else if (type == Long.class) { Util.bind(ctx, entry.getName(), new Long(entry.getValue())); } else if (type == Double.class) { Util.bind(ctx, entry.getName(), new Double(entry.getValue())); } else if (type == Float.class) { Util.bind(ctx, entry.getName(), new Float(entry.getValue())); } else if (type == Byte.class) { Util.bind(ctx, entry.getName(), new Byte(entry.getValue())); } else if (type == Character.class) { Object value = null; String input = entry.getValue(); if (input == null || input.length() == 0) { value = new Character((char) 0); } else { value = new Character(input.charAt(0)); } Util.bind(ctx, entry.getName(), value); } else if (type == Short.class) { Util.bind(ctx, entry.getName(), new Short(entry.getValue())); } else if (type == Boolean.class) { Util.bind(ctx, entry.getName(), new Boolean(entry.getValue())); } else { // Default to a String type Util.bind(ctx, entry.getName(), entry.getValue()); } }
// in src/main/java/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
protected void processJBossClientMetaData(VFSDeploymentUnit unit, AnnotationFinder<AnnotatedElement> finder, String mainClassName) throws ClassNotFoundException { ApplicationClient5MetaDataCreator creator = new ApplicationClient5MetaDataCreator(finder, mainClassName); Collection<Class<?>> classes = new ArrayList<Class<?>>(1); Class<?> mainClass = unit.getClassLoader().loadClass(mainClassName); classes.add(mainClass); ApplicationClientMetaData annotationMetaData = creator.create(classes); if(annotationMetaData != null) unit.addAttachment(CLIENT_ANNOTATED_ATTACHMENT_NAME, annotationMetaData, ApplicationClientMetaData.class); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
private void createPolicyConfiguration() throws PolicyContextException, ClassNotFoundException { if(parentPC == null) { PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory(); parentPC = pcf.getPolicyConfiguration(contextID, false); } }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void setInitialContext(String className) throws ClassNotFoundException { contextInfo.loadClass(className); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void loadClass(String className) throws ClassNotFoundException { ClassLoader loader = Thread.currentThread().getContextClassLoader(); contextClass = loader.loadClass(className); }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
private Naming getNamingServer(URL providerURL) throws ClassNotFoundException, IOException, InvocationTargetException, IllegalAccessException { // Initialize the proxy Util class to integrate JAAS authentication Util.init(); if( log.isTraceEnabled() ) log.trace("Retrieving content from : "+providerURL); HttpURLConnection conn = (HttpURLConnection) providerURL.openConnection(); Util.configureHttpsHostVerifier(conn); Util.configureSSLSocketFactory(conn); int length = conn.getContentLength(); String type = conn.getContentType(); if( log.isTraceEnabled() ) log.trace("ContentLength: "+length+"\nContentType: "+type); InputStream is = conn.getInputStream(); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); ois.close(); Object obj = mv.get(); if( (obj instanceof Naming) == false ) { String msg = "Invalid reply content seen: "+obj.getClass(); Throwable t = null; if( obj instanceof Throwable ) { t = (Throwable) obj; if( t instanceof InvocationException ) t = ((InvocationException)t).getTargetException(); } if( t != null ) log.warn(msg, t); else log.warn(msg); IOException e = new IOException(msg); throw e; } Naming namingServer = (Naming) obj; return namingServer; }
// in src/main/java/org/jboss/naming/NamingService.java
public void setClientSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setClientSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void setServerSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setServerSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void setJNPServerSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setJNPServerSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/ejb/EjbModule.java
void createMissingPermissions(Container con, BeanMetaData bean) throws ClassNotFoundException, PolicyContextException { String contextID = con.getJaccContextID(); PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, false); Class clazz = con.getHomeClass(); // If there is no security domain mark all methods as unchecked boolean hasSecurityDomain = con.getSecurityManager() != null; boolean exclude = hasSecurityDomain ? bean.isExcludeMissingMethods() : false; if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.HOME, pc); } clazz = con.getLocalHomeClass(); if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.LOCALHOME, pc); } clazz = con.getLocalClass(); if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.LOCAL, pc); } clazz = con.getRemoteClass(); if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.REMOTE, pc); } if (pc.inService() == false) pc.commit(); // Allow the policy to incorporate the policy configs Policy.getPolicy().refresh(); }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
private Collection<Class<?>> loadClasses(ClassLoader cl, Iterable<String> classNames) throws ClassNotFoundException { Collection<Class<?>> interceptorClasses = new HashSet<Class<?>>(); for (String interceptorClassName : classNames) { interceptorClasses.add(cl.loadClass(interceptorClassName)); } return interceptorClasses; }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException { // No state }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // No state }
// in src/main/java/org/jboss/ejb/CacheKey.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { id = in.readObject(); mo = (MarshalledObject) in.readObject(); hashCode = in.readInt(); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { try { // use the application classloader to resolve the class return appCl.loadClass(v.getName()); } catch (ClassNotFoundException e) { // we should probably never get here return super.resolveClass(v); } }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { Class clazz = null; Class[] ifaceClasses = new Class[interfaces.length]; for(int i = 0; i < interfaces.length; i ++) ifaceClasses[i] = Class.forName(interfaces[i], false, appCl); try { clazz = Proxy.getProxyClass(appCl, ifaceClasses); } catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); } return clazz; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); factory = (BaseLocalProxyFactory) BaseLocalProxyFactory.invokerMap.get(jndiName); }
// in src/main/java/org/jboss/ejb/ListCacheKey.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); listId = in.readLong(); index = in.readInt(); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void processEncReferences(WebApplication webApp, Context envCtx) throws ClassNotFoundException, NamingException { DeploymentUnit unit = webApp.getDeploymentUnit(); JBossWebMetaData metaData = webApp.getMetaData(); EnvironmentEntriesMetaData envEntries = metaData.getEnvironmentEntries(); log.debug("addEnvEntries"); addEnvEntries(envEntries, envCtx); ResourceEnvironmentReferencesMetaData resourceEnvRefs = metaData.getResourceEnvironmentReferences(); log.debug("linkResourceEnvRefs"); linkResourceEnvRefs(resourceEnvRefs, envCtx); ResourceReferencesMetaData resourceRefs = metaData.getResourceReferences(); log.debug("linkResourceRefs"); linkResourceRefs(resourceRefs, envCtx); log.debug("linkMessageDestinationRefs"); MessageDestinationReferencesMetaData msgRefs = metaData.getMessageDestinationReferences(); linkMessageDestinationRefs(unit, msgRefs, envCtx); EJBReferencesMetaData ejbRefs = metaData.getEjbReferences(); log.debug("linkEjbRefs"); linkEjbRefs(unit, ejbRefs, envCtx); EJBLocalReferencesMetaData ejbLocalRefs = metaData.getEjbLocalReferences(); log.debug("linkEjbLocalRefs"); linkEjbLocalRefs(unit, ejbLocalRefs, envCtx); log.debug("linkServiceRefs"); ServiceReferencesMetaData serviceRefs = metaData.getServiceReferences(); linkServiceRefs(unit, serviceRefs, envCtx); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx) throws ClassNotFoundException, NamingException { for (EnvironmentEntryMetaData entry : envEntries) { log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue()); bindEnvEntry(envCtx, entry); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry) throws ClassNotFoundException, NamingException { ClassLoader loader = EnvironmentEntryMetaData.class.getClassLoader(); Class type = loader.loadClass(entry.getType()); if (type == String.class) { Util.bind(ctx, entry.getName(), entry.getValue()); } else if (type == Integer.class) { Util.bind(ctx, entry.getName(), new Integer(entry.getValue())); } else if (type == Long.class) { Util.bind(ctx, entry.getName(), new Long(entry.getValue())); } else if (type == Double.class) { Util.bind(ctx, entry.getName(), new Double(entry.getValue())); } else if (type == Float.class) { Util.bind(ctx, entry.getName(), new Float(entry.getValue())); } else if (type == Byte.class) { Util.bind(ctx, entry.getName(), new Byte(entry.getValue())); } else if (type == Character.class) { Object value = null; String input = entry.getValue(); if (input == null || input.length() == 0) { value = new Character((char)0); } else { value = new Character(input.charAt(0)); } Util.bind(ctx, entry.getName(), value); } else if (type == Short.class) { Util.bind(ctx, entry.getName(), new Short(entry.getValue())); } else if (type == Boolean.class) { Util.bind(ctx, entry.getName(), new Boolean(entry.getValue())); } else { // Default to a String type Util.bind(ctx, entry.getName(), entry.getValue()); } }
// in src/main/java/org/jboss/proxy/Interceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { nextInterceptor = (Interceptor)in.readObject(); }
// in src/main/java/org/jboss/proxy/compiler/Runtime.java
public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { // isn't this redundant? if (name.endsWith("$Proxy") && name.equals(compiler.getProxyClassName())) { return compiler.proxyType; } // delegate to the original class loader ClassLoader cl = getTargetClassLoader(); if (cl == null) { return super.findSystemClass(name); } return cl.loadClass(name); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); id = getField.get("id", null); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public EJBObject readEJBObject(ObjectInputStream oistream) throws IOException, ClassNotFoundException { Object ejbObject = oistream.readObject(); reconnect(ejbObject); return (EJBObject) PortableRemoteObject.narrow(ejbObject, EJBObject.class); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public EJBHome readEJBHome(ObjectInputStream oistream) throws IOException, ClassNotFoundException { Object ejbHome = oistream.readObject(); reconnect(ejbHome); return (EJBHome) PortableRemoteObject.narrow(ejbHome, EJBHome.class); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); // Read the version identifier int version = in.readInt(); if( version == EXTERNAL_VERSION ) { // This version has no additional data } // Set the logging trace level trace = log.isTraceEnabled(); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); list = (List) in.readObject(); }
// in src/main/java/org/jboss/proxy/ejb/ReadAheadResult.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { mainResult = in.readObject(); aheadArray = (Object[]) in.readObject(); }
// in src/main/java/org/jboss/proxy/ClientContainer.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { next = (Interceptor) in.readObject(); context = (InvocationContext) in.readObject(); }
71
            
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
catch(ClassNotFoundException e) { /* Use the super.resolveClass() call which will resolve array classes and primitives. We do not use this by default as this can result in caching of stale values across redeployments. */ resolvedClass = super.resolveClass(v); }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (ClassNotFoundException e) { log.error(e); }
// in src/main/java/org/jboss/deployment/security/PolicyConfigurationFacade.java
catch (ClassNotFoundException e) { new RuntimeException(e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { // If this is a $Proxy* class its a proxy if (className.startsWith("$Proxy")) { isProxy = true; // We have to get the class from the binding try { Object p = ctx.lookup(name); c = p.getClass(); } catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } } } }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (ClassNotFoundException e) { log.warn("Could not load the " + className + " interceptor", e); }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch (ClassNotFoundException e) { // we should probably never get here return super.resolveClass(v); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCApplicationMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("Unable to load persistence manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("entity class not found for ejb-name: " + entityName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "could not load primary key class: " + entity.getPrimaryKeyClass() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("home class not found: " + home); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "remote class not found: " + entity.getRemote() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local home class not found: " + localHome ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local class not found: " + entity.getLocal() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("could not load the class for " + " unknown primary key: " + unknownPkClass); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValueClassMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("dependent-value-class not found: " + className); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { // Something is really broken }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException e) { if (cmp) fireSpecViolationEvent(entity, new Section("10.6.13.a")); else fireSpecViolationEvent(entity, new Section("12.2.12.a")); // Can't do any other checks if the class is null! return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (ClassNotFoundException cnfe) { // javax.jms.Message is not available?! }
// in src/main/java/org/jboss/verifier/strategy/AbstractEJB2xVerifier.java
catch (ClassNotFoundException cnfe) { // FIXME: this should be handled differently, especially // there shouldn't be a DeploymentException being // thrown ... continue; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException e) { log.warn("Failed to find class: " + className, e); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException e) { log.warn("Failed to find class: " + assignableFromClassName, e); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException cnfe) { // Only check equality return m.getReturnType().getName().equals(entity.getPrimaryKeyClass()); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (ClassNotFoundException cnfe) { // Ignored, if this happens we have more serious problems :) }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(theBean, new Section("22.2.b", "Class not found on '" + beanName + "': " + cnfe.getMessage())); return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.c", "Class not found on '" + homeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.d", "Class not found on '" + remoteName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.e", "Class not found on '" + localHomeName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("22.2.f", "Class not found on '" + localName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { // Something is really broken }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException e) { if (cmp) fireSpecViolationEvent(entity, new Section("10.6.13.a")); else fireSpecViolationEvent(entity, new Section("12.2.12.a")); // Can't do any other checks if the class is null! return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(mdBean, new Section("15.7.2.b", "Class not found on '" + messagingType + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (ClassNotFoundException cnfe) { fireSpecViolationEvent(bean, new Section("23.2", "Class not found on '" + seiName + "': " + cnfe.getMessage())); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The bean provider MUST specify the fully-qualified name of the * enterprise bean's home interface in the <home> element. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.c")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * enterprise bean's remote interface in the <remote> element. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.d")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * Java class that implements the enterprise bean's business * methods. * * Spec 16.2 */ fireSpecViolationEvent(session, new Section("16.2.b")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The bean provider MUST specify the fully-qualified name of the * enterprise bean's home interface in the <home> element. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.c")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * enterprise bean's remote interface in the <remote> element. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.d")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { /* * The Bean Provider MUST specify the fully-qualified name of the * Java class that implements the enterprise bean's business * methods. * * Spec 16.2 */ fireSpecViolationEvent(entity, new Section("16.2.b")); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { fireSpecViolationEvent(entity, new Section("16.2.e")); status = false; // Can't do any other checks if the class is null! }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (ClassNotFoundException e) { }
30
            
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCApplicationMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("Unable to load persistence manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("entity class not found for ejb-name: " + entityName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "could not load primary key class: " + entity.getPrimaryKeyClass() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("home class not found: " + home); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "remote class not found: " + entity.getRemote() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local home class not found: " + localHome ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local class not found: " + entity.getLocal() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("could not load the class for " + " unknown primary key: " + unknownPkClass); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValueClassMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("dependent-value-class not found: " + className); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
1
unknown (Lib) ConcurrentModificationException 0 0 0 6
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); }
6
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); }
6
unknown (Lib) CreateException 20
            
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object createEntity (Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get (ctx.getInstance ()); // Check exist if (this.beans.containsKey (id)) throw new javax.ejb.DuplicateKeyException ("Already exists: "+id); // Store to file storeEntity (id, ctx.getInstance ()); return id; } catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object createEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get(ctx.getInstance()); // Check exist if (getFile(id).exists()) throw new DuplicateKeyException("Already exists: "+id); // Store to file storeEntity(id, ctx.getInstance()); return id; } catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { pk = entityBridge.extractPrimaryKeyFromInstance(ctx); if(pk == null) { throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void checkCreateAllowed() throws CreateException { if(!createAllowed) { throw new CreateException("Creation is not allowed because a primary key field is read only."); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void performInsert(EntityEnterpriseContext ctx) throws CreateException { Connection c = null; PreparedStatement ps = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { c = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; } } try { if(debug) log.debug("Executing SQL: " + insertSQL); // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { c = entity.getDataSource().getConnection(); } ps = prepareStatement(c, insertSQL, ctx); // set the parameters int index = 1; for(int fieldInd = 0; fieldInd < insertFields.length; ++fieldInd) { index = insertFields[fieldInd].setInstanceParameters(ps, index, ctx); } // execute statement int rowsAffected = executeInsert(index, ps, ctx); if(rowsAffected != 1) { throw new CreateException("Expected one affected row but update returned" + rowsAffected + " for id=" + ctx.getId()); } } catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } // Mark the inserted fields as clean. for(int fieldInd = 0; fieldInd < insertFields.length; ++fieldInd) { insertFields[fieldInd].setClean(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
protected void beforeInsert(EntityEnterpriseContext ctx) throws CreateException { // are we checking existance by query? if(existsSQL != null) { Connection c = null; PreparedStatement ps = null; ResultSet rs = null; try { if(debug) log.debug("Executing SQL: " + existsSQL); c = entity.getDataSource().getConnection(); ps = c.prepareStatement(existsSQL); // bind PK // @todo add a method to EntityBridge that binds pk fields directly Object pk = entity.extractPrimaryKeyFromInstance(ctx); entity.setPrimaryKeyParameters(ps, 1, pk); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("Error checking if entity with primary pk " + pk + "exists: SQL returned no rows"); } if(rs.getInt(1) > 0) { throw new DuplicateKeyException("Entity with primary key " + pk + " already exists"); } } catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object createEntity(Method createMethod, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk = createEntityCommand.execute(createMethod, args, ctx); if(pk == null) throw new CreateException("Primary key for created instance is null."); return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
protected void generateFields(EntityEnterpriseContext ctx) throws CreateException { super.generateFields(ctx); Connection con = null; Statement s = null; ResultSet rs = null; try { if(debug) { log.debug("Executing SQL: " + pkSQL); } DataSource dataSource = entity.getDataSource(); con = dataSource.getConnection(); s = con.createStatement(); rs = s.executeQuery(pkSQL); if(!rs.next()) { throw new CreateException("Error fetching next primary key value: result set contains no rows"); } pkField.loadInstanceResults(rs, 1, ctx); } catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); JDBCUtil.safeClose(con); } }
10
            
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); }
18
            
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBLocalObject createLocalHome() throws CreateException { if (localProxyFactory == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; return localProxyFactory.getStatelessSessionEJBLocalObject(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBObject createHome() throws RemoteException, CreateException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; Object obj = ci.getStatelessSessionEJBObject(); return (EJBObject) obj; }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBObject createHome() throws java.rmi.RemoteException, CreateException { throw new Error("createHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Object createEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { /* Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { pk = entityBridge.extractPrimaryKeyFromInstance(ctx); if(pk == null) { throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; */ return createCmd.execute(m, args, ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Object postCreateEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { pk = entityBridge.extractPrimaryKeyFromInstance(ctx); if(pk == null) { throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { // TODO: implement this logic nicer if(insertAfterEjbPostCreate) { if(!JDBCEntityBridge.isEjbCreateDone(ctx)) { checkCreateAllowed(); generateFields(ctx); JDBCEntityBridge.setEjbCreateDone(ctx); } else { beforeInsert(ctx); performInsert(ctx); afterInsert(ctx); JDBCEntityBridge.setCreated(ctx); } } else { checkCreateAllowed(); generateFields(ctx); beforeInsert(ctx); performInsert(ctx); afterInsert(ctx); JDBCEntityBridge.setCreated(ctx); } return getPrimaryKey(ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void checkCreateAllowed() throws CreateException { if(!createAllowed) { throw new CreateException("Creation is not allowed because a primary key field is read only."); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void generateFields(EntityEnterpriseContext ctx) throws CreateException { // Audit principal fields if(securityManager != null) { String principalName = ctx.getEJBContext().getCallerPrincipal().getName(); if(createdPrincipal != null && createdPrincipal.getInstanceValue(ctx) == null) { createdPrincipal.setInstanceValue(ctx, principalName); } /* if(updatedPrincipal != null && updatedPrincipal.getInstanceValue(ctx) == null) { updatedPrincipal.setInstanceValue(ctx, principalName); } */ } // Audit time fields Date date = null; if(createdTime != null && createdTime.getInstanceValue(ctx) == null) { date = new Date(); createdTime.setInstanceValue(ctx, date); } /* if(updatedTime != null && updatedTime.getInstanceValue(ctx) == null) { if(date == null) date = new Date(); updatedTime.setInstanceValue(ctx, date); } */ }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void beforeInsert(EntityEnterpriseContext ctx) throws CreateException { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void performInsert(EntityEnterpriseContext ctx) throws CreateException { Connection c = null; PreparedStatement ps = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { c = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; } } try { if(debug) log.debug("Executing SQL: " + insertSQL); // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { c = entity.getDataSource().getConnection(); } ps = prepareStatement(c, insertSQL, ctx); // set the parameters int index = 1; for(int fieldInd = 0; fieldInd < insertFields.length; ++fieldInd) { index = insertFields[fieldInd].setInstanceParameters(ps, index, ctx); } // execute statement int rowsAffected = executeInsert(index, ps, ctx); if(rowsAffected != 1) { throw new CreateException("Expected one affected row but update returned" + rowsAffected + " for id=" + ctx.getId()); } } catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } // Mark the inserted fields as clean. for(int fieldInd = 0; fieldInd < insertFields.length; ++fieldInd) { insertFields[fieldInd].setClean(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void afterInsert(EntityEnterpriseContext ctx) throws CreateException { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
protected void beforeInsert(EntityEnterpriseContext ctx) throws CreateException { // are we checking existance by query? if(existsSQL != null) { Connection c = null; PreparedStatement ps = null; ResultSet rs = null; try { if(debug) log.debug("Executing SQL: " + existsSQL); c = entity.getDataSource().getConnection(); ps = c.prepareStatement(existsSQL); // bind PK // @todo add a method to EntityBridge that binds pk fields directly Object pk = entity.extractPrimaryKeyFromInstance(ctx); entity.setPrimaryKeyParameters(ps, 1, pk); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("Error checking if entity with primary pk " + pk + "exists: SQL returned no rows"); } if(rs.getInt(1) > 0) { throw new DuplicateKeyException("Entity with primary key " + pk + " already exists"); } } catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object createEntity(Method createMethod, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk = createEntityCommand.execute(createMethod, args, ctx); if(pk == null) throw new CreateException("Primary key for created instance is null."); return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
protected void generateFields(EntityEnterpriseContext ctx) throws CreateException { super.generateFields(ctx); Object pk = keyGenerator.generateKey(); log.debug("Generated new pk: " + pk); pkField.setInstanceValue(ctx, pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
protected void generateFields(EntityEnterpriseContext ctx) throws CreateException { super.generateFields(ctx); Connection con = null; Statement s = null; ResultSet rs = null; try { if(debug) { log.debug("Executing SQL: " + pkSQL); } DataSource dataSource = entity.getDataSource(); con = dataSource.getConnection(); s = con.createStatement(); rs = s.executeQuery(pkSQL); if(!rs.next()) { throw new CreateException("Error fetching next primary key value: result set contains no rows"); } pkField.loadInstanceResults(rs, 1, ctx); } catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); JDBCUtil.safeClose(con); } }
0 0 0
unknown (Lib) DeploymentException 278
            
// in src/main/java/org/jboss/jmx/connector/invoker/MBeanProxyRemote.java
protected void startService() throws Exception { if (MBeanProxyExt.remote != null) throw new IllegalStateException("Remote MBeanServerConnection is already set " + MBeanProxyExt.remote); Object o = server.getAttribute(mbeanServerConnection, "Proxy"); if (o instanceof MBeanServerConnection == false) throw new DeploymentException(mbeanServerConnection + " does not define an MBeanServerConnection"); MBeanProxyExt.remote = (MBeanServerConnection) o; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public ApplicationMetaData load(URL alternativeDD) throws Exception { URL ejbjarUrl = null; if (alternativeDD != null) { log.debug("Using alternativeDD: " + alternativeDD); ejbjarUrl = alternativeDD; } else { ejbjarUrl = getClassLoader().getResource("META-INF/ejb-jar.xml"); } if (ejbjarUrl == null) { throw new DeploymentException("no ejb-jar.xml found"); } // create the metadata JBossMetaData realMetaData = new JBossMetaData(); metaData = new ApplicationMetaData(realMetaData); Document ejbjarDocument = getDocumentFromURL(ejbjarUrl); // the url may be used to report errors metaData.setUrl(ejbjarUrl); metaData.importEjbJarXml(ejbjarDocument.getDocumentElement()); // Load jbossdefault.xml from the default classLoader // we always load defaults first // we use the context classloader, because this guy has to know where // this file is URL defaultJbossUrl = Thread.currentThread().getContextClassLoader().getResource("standardjboss.xml"); if (defaultJbossUrl == null) { throw new DeploymentException("no standardjboss.xml found"); } Document defaultJbossDocument = null; try { defaultJbossDocument = getDocumentFromURL(defaultJbossUrl); metaData.setUrl(defaultJbossUrl); metaData.importJbossXml(defaultJbossDocument.getDocumentElement()); } catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; } // Load jboss.xml // if this file is provided, then we override the defaults try { URL jbossUrl = getClassLoader().getResource("META-INF/jboss.xml"); if (jbossUrl != null) { Document jbossDocument = getDocumentFromURL(jbossUrl); metaData.setUrl(jbossUrl); metaData.importJbossXml(jbossDocument.getDocumentElement()); } } catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; } return metaData; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocumentFromURL(URL url) throws DeploymentException { InputStream is = null; try { is = url.openStream(); return getDocument(is, url.toExternalForm()); } catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); } }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocument(InputSource is, String inPath) throws DeploymentException { try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); // Enable DTD validation based on our validateDTDs flag docBuilderFactory.setValidating(validateDTDs); // make the parser namespace-aware in case we deal // with ejb2.1 descriptors, will not break dtd parsing in any way // in which case there would be just a default namespace docBuilderFactory.setNamespaceAware(true); // this will (along JAXP in conjunction with // validation+namespace-awareness) enable xml schema checking. // Will currently fail because some J2EE1.4/W3C schemas // are still lacking. //docBuilderFactory.setAttribute // ("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema"); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); JBossEntityResolver lr = new JBossEntityResolver(); LocalErrorHandler eh = new LocalErrorHandler( inPath, lr ); docBuilder.setEntityResolver(lr); docBuilder.setErrorHandler(eh ); Document doc = docBuilder.parse(is); if(validateDTDs && eh.hadError()) { throw new DeploymentException("Invalid XML: file=" + inPath, eh.getException()); } return doc; } catch (DeploymentException e) { throw e; } catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); } catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); } catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); } }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
protected void startService() throws Exception { // validate the configuration if (queueFactoryRef == null) throw new DeploymentException("missing required attribute: QueueFactoryRef"); if (topicFactoryRef == null) throw new DeploymentException("missing required attribute: TopicFactoryRef"); Class cls = Thread.currentThread().getContextClassLoader().loadClass(providerAdapterClass); providerAdapter = (JMSProviderAdapter) cls.newInstance(); providerAdapter.setName(providerName); providerAdapter.setProperties(properties); providerAdapter.setFactoryRef(factoryRef); providerAdapter.setQueueFactoryRef(queueFactoryRef); providerAdapter.setTopicFactoryRef(topicFactoryRef); InitialContext context = new InitialContext(); try { // Bind in JNDI if (jndiName == null) { String name = providerAdapter.getName(); jndiName = "java:/" + name; } bind(context, jndiName, providerAdapter); log.debug("Bound adapter to " + jndiName); } finally { context.close(); } }
// in src/main/java/org/jboss/deployment/J2eeModuleMetaData.java
public void importXml(Element rootElement) throws DeploymentException { String rootTag = rootElement.getOwnerDocument().getDocumentElement().getTagName(); if (rootTag.equals("application")) importXml(rootElement, false); else if (rootTag.equals("jboss-app")) importXml(rootElement, true); else throw new DeploymentException("Unrecognized root tag: " + rootTag); }
// in src/main/java/org/jboss/deployment/J2eeModuleMetaData.java
protected void importXml(Element element, boolean jbossSpecific) throws DeploymentException { String name = element.getTagName(); if (name.equals("module")) { boolean done = false; // only one of the tags can hit! for (int i = 0; done == false && i < tags.length; ++i) { Element child = getOptionalChild(element, tags[i]); if (child == null) { continue; } type = i; switch (type) { case SERVICE: if (jbossSpecific == false) { throw new DeploymentException("Service archives must be in jboss-app.xml"); } // end of if () //fall through. case HAR: if (jbossSpecific == false) { throw new DeploymentException("Hibernate archives must be in jboss-app.xml"); } case EJB: case CLIENT: case CONNECTOR: fileName = getElementContent(child); alternativeDD = getElementContent(getOptionalChild(element, "alt-dd")); break; case WEB: fileName = getElementContent(getUniqueChild(child, "web-uri")); webContext = getElementContent(getOptionalChild(child, "context-root")); alternativeDD = getElementContent(getOptionalChild(element, "alt-dd")); break; } done = true; } // If the module content is not recognized throw an exception if (done == false) { StringBuffer msg = new StringBuffer("Invalid module content, must be one of: "); for (int i = 0; i < tags.length; i ++) { msg.append(tags[i]); msg.append(", "); } throw new DeploymentException(msg.toString()); } } else { throw new DeploymentException("non-module tag in application dd: " + name); } }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (deploymentName == null) throw new IllegalArgumentException("Null deployment name"); if (loaderMetaData == null) throw new IllegalArgumentException("Null loader repository metadata"); LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig(); repositoryConfig.repositoryClassName = loaderMetaData.getLoaderRepositoryClass(); if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0) repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS; // Get the object name of the repository String name = loaderMetaData.getName(); if (name != null) { try { repositoryConfig.repositoryName = new ObjectName(name.trim()); } catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); } } StringBuilder configData = new StringBuilder(); Set<LoaderRepositoryConfigMetaData> children = loaderMetaData.getLoaderRepositoryConfig(); if (children != null) { for (LoaderRepositoryConfigMetaData child : children) { // This looks stupid? Why inside a loop? String parserClassName = child.getConfigParserClass(); if (parserClassName == null || parserClassName.length() == 0) repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS; else repositoryConfig.configParserClassName = parserClassName; // Append all config String childConfig = child.getConfig(); if (childConfig != null) configData.append(childConfig); } } repositoryConfig.repositoryConfig = configData.toString().trim(); return LoaderRepositoryConfigHelper.create(name, repositoryConfig, parentDelegation); }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
private JBossMetaData getStandardMetaData() throws DeploymentException { if (standardMetaData == null) { try { if(standardJBossXmlPath == null) { // Use default server conf/standardjboss.xml location final String configPropName = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_CONF_URL; String configPath = System.getProperty(configPropName); if(configPath == null ) { if(ignoreMissingStandardJBossXml == false) throw new DeploymentException("standardjboss.xml not specified and "+configPropName+" does not exist"); return null; } URL configUrl = new URL(configPath); standardJBossXmlPath = new URL(configUrl, "standardjboss.xml"); } VirtualFile stdJBoss = VFS.getChild(standardJBossXmlPath); if (stdJBoss == null && ignoreMissingStandardJBossXml == false) { throw new DeploymentException("standardjboss.xml not found in config dir: " + standardJBossXmlPath); } standardMetaData = super.parse(stdJBoss); } catch (Exception ex) { DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex); } } return standardMetaData; }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
Override public void deploy(DeploymentUnit unit, JBossAppMetaData deployment) throws DeploymentException { //Perform JACC Policy Configuration String contextID = shortNameFromDeploymentName(unit.getSimpleName()); PolicyConfigurationFactory pcFactory = null; try { pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true); unit.addAttachment(PolicyConfiguration.class, pc); } catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); } catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
public void internalDeploy(DeploymentUnit unit) throws DeploymentException { JBossMetaData ejbMetaData = unit.getAttachment(JBossMetaData.class); JBossWebMetaData webMetaData = unit.getAttachment(JBossWebMetaData.class); JBossClientMetaData clientMetaData = unit.getAttachment(JBossClientMetaData.class); if(ejbMetaData == null && webMetaData == null && clientMetaData == null) return; // Create a map of the reference endpoints if it does not exist in the top unit DeploymentUnit top = unit.getTopLevel(); Map<String, ContainerDependencyMetaData> endpointMap = top.getAttachment(ENDPOINT_MAP_KEY, Map.class); Map<String, String> endpointAlternateMap = top.getAttachment(ALTERNATE_MAP_KEY, Map.class); if(endpointMap == null) { endpointMap = new ConcurrentHashMap<String, ContainerDependencyMetaData>(); endpointAlternateMap = new ConcurrentHashMap<String, String>(); mapEndpoints(top, endpointMap, endpointAlternateMap); top.addAttachment(ENDPOINT_MAP_KEY, endpointMap, Map.class); top.addAttachment(ALTERNATE_MAP_KEY, endpointAlternateMap); DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver(endpointMap, endpointAlternateMap, unit.getRelativePath()); top.addAttachment(DeploymentEndpointResolver.class, resolver); } DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver( endpointMap, endpointAlternateMap, unit.getRelativePath()); List<String> unresolvedPaths = new ArrayList<String>(); if(ejbMetaData != null) { JBossEnterpriseBeansMetaData beans = ejbMetaData.getEnterpriseBeans(); // Process ejb references try { resolve(unit, endpointMap, beans, resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossMetaData:"+unresolvedPaths); } if(webMetaData != null) { // Process web app references ContainerDependencyMetaData webAppCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "web-app", unit.getRelativePath()); try { resolve(webAppCDMD, unit, endpointMap, webMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossWebMetaData:"+unresolvedPaths); } if(clientMetaData != null) { // Process client app references ContainerDependencyMetaData clientCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "client", unit.getRelativePath()); try { resolve(clientCDMD, unit, endpointMap, clientMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossClientMetaData: "+unresolvedPaths); } // Add the unique set of ContainerDependencyMetaData Set<ContainerDependencyMetaData> depends = new HashSet<ContainerDependencyMetaData>(); for(ContainerDependencyMetaData cdmd : endpointMap.values()) { depends.add(cdmd); } top.addAttachment(DEPENDS_SET_KEY, depends, Set.class); unit.addAttachment(DeploymentEndpointResolver.class, resolver); dump(unit); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
public void deploy(VFSDeploymentUnit unit) throws DeploymentException { VirtualFile root = unit.getRoot(); String relativePath = unit.getRelativePath(); VirtualFile ear = unit.getFile(relativePath); if (ear == null) throw new DeploymentException("No such ear file, relative path: '" + relativePath + "', root: " + root); deploy(unit, root, ear); }
// in src/main/java/org/jboss/deployment/ModuleNameDeployer.java
private String establishUniqueModuleName(DeploymentUnit unit, String configuredName, JBossAppMetaData appMetaData) throws DeploymentException { String name = configuredName == null ? trimExtension(unit.getRelativePath()): configuredName; String modulePath = unit.getRelativePath(); ModulesMetaData modules = appMetaData.getModules(); if (modules == null) { throw new DeploymentException(unit + " has attached " + JBossAppMetaData.class.getSimpleName() + " but it has no associated " + ModulesMetaData.class.getSimpleName()); } ModuleMetaData ourModule = null; String uniqueName = null; // Synchronize on the modules to ensure concurrent deployments of the // modules pass serially through this logic synchronized(modules) { ourModule = modules.get(modulePath); if (ourModule == null) { String parentUnitName = unit.getParent().getName(); throw new DeploymentException("No module with relative path " + modulePath + " found in set of modules for " + parentUnitName + " " + modules.keySet()); } uniqueName = name; if (!isNameUnique(uniqueName, ourModule, modules)) { // Try the relative path w/ extension removed uniqueName = trimExtension(unit.getRelativePath()); if (uniqueName.equals(name) || !isNameUnique(uniqueName, ourModule, modules)) { // Try leaving the extension uniqueName = unit.getRelativePath(); if (!isNameUnique(uniqueName, ourModule, modules)) { // To get here, people would have to configure in xml a // module name that conflicts with the relative path of // another module. Not likely, but... // Append a digit until the name is unique int i = 0; do { i++; uniqueName = name + "-" + i; } while (!isNameUnique(uniqueName, ourModule, modules)); } } } ourModule.setUniqueName(uniqueName); } // Log a WARN if we had to change the module name if (configuredName != null && !configuredName.equals(uniqueName)) { log.warn("Module name " + configuredName + " specified in deployment descriptor for " + unit + " was not unique within the application; using module name " + uniqueName + " instead"); } else if (!name.equals(uniqueName)) { log.warn("Module name " + name + " derived from the modules relative path in " + unit + " was not unique within the application; using module name " + uniqueName + " instead"); } return uniqueName; }
// in src/main/java/org/jboss/naming/LinkRefPairService.java
protected void startService() throws Exception { if (jndiName == null) throw new DeploymentException("The jndiName is null for LinkRefPair " + getServiceName()); if (remoteJndiName == null) throw new DeploymentException("The remoteJndiName is null for LinkRefPair " + getServiceName()); if (localJndiName == null) throw new DeploymentException("The localJndiName is null for LinkRefPair " + getServiceName()); LinkRefPair pair = new LinkRefPair(remoteJndiName, localJndiName); InitialContext ctx = new InitialContext(); try { Util.bind(ctx, jndiName, pair); } finally { ctx.close(); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void addContainer(Container con) throws DeploymentException { String ejbName = con.getBeanMetaData().getEjbName(); if (containers.containsKey(ejbName)) throw new DeploymentException("Duplicate ejb-name. Container for " + ejbName + " already exists."); containers.put(ejbName, con); containerOrdering.add(con); con.setEjbModule(this); }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void initializeContainer(Container container, ConfigurationMetaData conf, BeanMetaData bean, int transType, DeploymentUnit unit) throws NamingException, DeploymentException { // Create local classloader for this container // For loading resources that must come from the local jar. Not for loading classes! // The VFS should be used for this // container.setLocalClassLoader(new URLClassLoader(new URL[0], localCl)); // Set metadata (do it *before* creating the container's WebClassLoader) container.setEjbModule(this); container.setBeanMetaData(bean); ClassLoader unitCl = unit.getClassLoader(); // Create the container's WebClassLoader // and register it with the web service. String webClassLoaderName = getWebClassLoader(conf, bean); log.debug("Creating WebClassLoader of class " + webClassLoaderName); WebClassLoader wcl = null; try { Class clazz = unitCl.loadClass(webClassLoaderName); wcl = WebClassLoaderFactory.createWebClassLoader(clazz, container.getJmxName(), (RealClassLoader) unitCl); } catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); } if (webServiceName != null) { WebServiceMBean webServer = (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName); URL[] codebase = {webServer.addClassLoader(wcl)}; wcl.setWebURLs(codebase); } // end of if () container.setWebClassLoader(wcl); // Create classloader for this container // Only used to unique the bean ENC and does not augment class loading container.setClassLoader(new DelegatingClassLoader(wcl)); // Set transaction manager InitialContext iniCtx = new InitialContext(); container.setTransactionManager(tmFactory.getTransactionManager()); // Set container.setTimerService(timerService); // Set security domain manager String securityDomain = bean.getApplicationMetaData().getSecurityDomain(); // JBAS-5960: Set default security domain if there is security metadata boolean hasSecurityMetaData = hasSecurityMetaData(bean); if (securityDomain == null && hasSecurityMetaData) { securityDomain = SecurityConstants.DEFAULT_EJB_APPLICATION_POLICY; } String confSecurityDomain = conf.getSecurityDomain(); // Default the config security to the application security manager if (confSecurityDomain == null) confSecurityDomain = securityDomain; // Check for an empty confSecurityDomain which signifies to disable security if (confSecurityDomain != null && confSecurityDomain.length() == 0) confSecurityDomain = null; if (confSecurityDomain != null) { // Either the application has a security domain or the container has security setup try { String unprefixed = SecurityUtil.unprefixSecurityDomain(confSecurityDomain); log.debug("Setting security domain from: " + confSecurityDomain); String domainCtx = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + unprefixed + "/domainContext"; SecurityDomainContext sdc = (SecurityDomainContext) iniCtx.lookup(domainCtx); Object securityMgr = sdc.getSecurityManager(); // Object securityMgr = iniCtx.lookup(confSecurityDomain); AuthenticationManager ejbS = (AuthenticationManager) securityMgr; RealmMapping rM = (RealmMapping) securityMgr; container.setSecurityManager(ejbS); container.setRealmMapping(rM); container.setSecurityManagement(securityManagement); container.setPolicyRegistration(policyRegistration); container.setDefaultSecurityDomain((String) unit.getAttachment("EJB.defaultSecurityDomain")); container.setSecurityContextClassName((String) unit.getAttachment("EJB.securityContextClassName")); } catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); } catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); } } else { if ("".equals(securityDomain) && hasSecurityMetaData) log.warn("EJB configured to bypass security. Please verify if this is intended. Bean=" + bean.getEjbName() + " Deployment=" + unit.getName()); } // Load the security proxy instance if one was configured String securityProxyClassName = bean.getSecurityProxy(); if (securityProxyClassName != null) { try { Class proxyClass = unitCl.loadClass(securityProxyClassName); Object proxy = proxyClass.newInstance(); container.setSecurityProxy(proxy); log.debug("setSecurityProxy, " + proxy); } catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); } } // Install the container interceptors based on the configuration addInterceptors(container, transType, conf.getContainerInterceptorsConf()); }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static String getWebClassLoader(ConfigurationMetaData conf, BeanMetaData bmd) throws DeploymentException { String webClassLoader = null; Iterator it = bmd.getInvokerBindings(); int count = 0; while (it.hasNext()) { String invoker = (String) it.next(); ApplicationMetaData amd = bmd.getApplicationMetaData(); InvokerProxyBindingMetaData imd = amd.getInvokerProxyBindingMetaDataByName(invoker); if (imd == null) { String msg = "Failed to find InvokerProxyBindingMetaData for: '" + invoker + "'. Check the invoker-proxy-binding-name to " + "invoker-proxy-binding/name mappings in jboss.xml"; throw new DeploymentException(msg); } Element proxyFactoryConfig = imd.getProxyFactoryConfig(); String webCL = MetaData.getOptionalChildContent(proxyFactoryConfig, "web-class-loader"); if (webCL != null) { log.debug("Invoker " + invoker + " specified WebClassLoader class" + webCL); webClassLoader = webCL; count++; } } if (count > 1) { log.warn(count + " invokers have WebClassLoader specifications."); log.warn("Using the last specification seen (" + webClassLoader + ")."); } else if (count == 0) { webClassLoader = conf.getWebClassLoader(); if (webClassLoader == null) webClassLoader = "org.jboss.web.WebClassLoader"; } return webClassLoader; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static void createProxyFactories(BeanMetaData conf, Container container) throws Exception { ClassLoader cl = container.getClassLoader(); Iterator it = conf.getInvokerBindings(); boolean foundOne = false; while (it.hasNext()) { String invoker = (String) it.next(); String jndiBinding = conf.getInvokerBinding(invoker); log.debug("creating binding for " + jndiBinding + ":" + invoker); InvokerProxyBindingMetaData imd = conf.getApplicationMetaData().getInvokerProxyBindingMetaDataByName(invoker); EJBProxyFactory ci = null; // create a ProxyFactory instance try { ci = (EJBProxyFactory) cl.loadClass(imd.getProxyFactory()).newInstance(); ci.setContainer(container); ci.setInvokerMetaData(imd); ci.setInvokerBinding(jndiBinding); if (ci instanceof XmlLoadable) { // the container invoker can load its configuration from the jboss.xml element ((XmlLoadable) ci).importXml(imd.getProxyFactoryConfig()); } container.addProxyFactory(invoker, ci); foundOne = true; } catch (Exception e) { log.warn("The Container Invoker " + invoker + " (in jboss.xml or standardjboss.xml) could not be created because of " + e + " We will ignore this error, but you may miss a transport for this bean."); } } if (!foundOne) { throw new DeploymentException("Missing or invalid Container Invokers (in jboss.xml or standardjboss.xml)."); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static BeanLockManager createBeanLockManager(Container container, boolean reentrant, String beanLock, ClassLoader cl) throws Exception { // The bean lock manager BeanLockManager lockManager = new BeanLockManager(container); Class lockClass = null; try { if (beanLock == null) beanLock = "org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock"; lockClass = cl.loadClass(beanLock); } catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); } lockManager.setLockCLass(lockClass); lockManager.setReentrant(reentrant); return lockManager; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static InstancePool createInstancePool(ConfigurationMetaData conf, ClassLoader cl) throws Exception { // Set instance pool InstancePool ip = null; try { ip = (InstancePool) cl.loadClass(conf.getInstancePool()).newInstance(); } catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); } if (ip instanceof XmlLoadable) ((XmlLoadable) ip).importXml(conf.getContainerPoolConf()); return ip; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static InstanceCache createInstanceCache(ConfigurationMetaData conf, ClassLoader cl) throws Exception { // Set instance cache InstanceCache ic = null; try { ic = (InstanceCache) cl.loadClass(conf.getInstanceCache()).newInstance(); } catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); } if (ic instanceof XmlLoadable) ((XmlLoadable) ic).importXml(conf.getContainerCacheConf()); return ic; }
// in src/main/java/org/jboss/ejb/Container.java
private void setupEnvironment() throws Exception { BeanMetaData beanMetaData = getBeanMetaData(); // debug log.debug("Begin java:comp/env for EJB: " + beanMetaData.getEjbName()); ClassLoader tcl = SecurityActions.getContextClassLoader(); log.debug("TCL: " + tcl); ORB orb = null; HandleDelegate hd = null; try { orb = (ORB)server.getAttribute(ORB_NAME, "ORB"); hd = (HandleDelegate)server.getAttribute(ORB_NAME, "HandleDelegate"); } catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); } // Since the BCL is already associated with this thread we can start // using the java: namespace directly Context ctx = (Context)new InitialContext().lookup("java:comp"); Object id = ENCFactory.getCurrentId(); log.debug("Using java:comp using id=" + id); // Bind the orb if (orb != null) { NonSerializableFactory.rebind(ctx, "ORB", orb); log.debug("Bound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName()); NonSerializableFactory.rebind(ctx, "HandleDelegate", hd); log.debug("Bound java:comp/HandleDelegate for EJB: " + getBeanMetaData().getEjbName()); } // JTA links ctx.bind("TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry")); log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry"); Context envCtx = ctx.createSubcontext("env"); // Bind environment properties { Iterator i = beanMetaData.getEnvironmentEntries(); while (i.hasNext()) { EnvEntryMetaData entry = (EnvEntryMetaData)i.next(); log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue()); EnvEntryBinder.bindEnvEntry(envCtx, entry); } } // Bind EJB references { Iterator i = beanMetaData.getEjbReferences(); while (i.hasNext()) { EjbRefMetaData ref = (EjbRefMetaData)i.next(); log.debug("Binding an EJBReference " + ref.getName()); if (ref.getLink() != null) { // Internal link String linkName = ref.getLink(); String jndiName = ref.getJndiName(); log.debug("Binding " + ref.getName() + " to ejb-link: " + linkName + " -> " + jndiName); if (jndiName == null) { String msg = "Failed to resolve ejb-link: " + linkName + " from ejb-ref: " + ref.getName() + " in ejb: " + beanMetaData.getEjbName(); throw new DeploymentException(msg); } Util.bind(envCtx, ref.getName(), new LinkRef(jndiName)); } else { // Get the invoker specific ejb-ref mappings Iterator it = beanMetaData.getInvokerBindings(); Reference reference = null; while (it.hasNext()) { String invokerBinding = (String)it.next(); // Check for an invoker level jndi-name String name = ref.getInvokerBinding(invokerBinding); // Check for an global jndi-name if (name == null) name = ref.getJndiName(); if (name == null) { throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml or " + "jndi-name in jboss.xml"); } StringRefAddr addr = new StringRefAddr(invokerBinding, name); log.debug("adding " + invokerBinding + ":" + name + " to Reference"); if (reference == null) { reference = new Reference("javax.naming.LinkRef", ENCThreadLocalKey.class.getName(), null); } reference.add(addr); } // If there were invoker bindings create bind the reference if (reference != null) { if (ref.getJndiName() != null) { // Add default for the bean level ejb-ref/jndi-name StringRefAddr addr = new StringRefAddr("default", ref.getJndiName()); reference.add(addr); } if (reference.size() == 1 && reference.get("default") == null) { /* There is only one invoker binding and its not default so create a default binding to allow the link to have a value when accessed without an invoker active. */ StringRefAddr addr = (StringRefAddr)reference.get(0); String target = (String)addr.getContent(); StringRefAddr addr1 = new StringRefAddr("default", target); reference.add(addr1); } Util.bind(envCtx, ref.getName(), reference); } else { // Bind the bean level ejb-ref/jndi-name if (ref.getJndiName() == null) { throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or jndi-name in jboss.xml"); } Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } } // Bind Local EJB references { Iterator i = beanMetaData.getEjbLocalReferences(); while (i.hasNext()) { EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next(); String refName = ref.getName(); log.debug("Binding an EJBLocalReference " + ref.getName()); if (ref.getLink() != null) { // Internal link log.debug("Binding " + refName + " to bean source: " + ref.getLink()); String jndiName = ref.getJndiName(); Util.bind(envCtx, ref.getName(), new LinkRef(jndiName)); } else { // Bind the bean level ejb-local-ref/local-jndi-name if (ref.getJndiName() == null) { throw new DeploymentException("ejb-local-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or local-jndi-name in jboss.xml"); } Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } // Bind service references { ClassLoader loader = unit.getClassLoader(); UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot()); Iterator<ServiceReferenceMetaData> serviceReferences = beanMetaData.getServiceReferences(); if (serviceReferences != null) { while (serviceReferences.hasNext()) { ServiceReferenceMetaData sref = serviceReferences.next(); String refName = sref.getServiceRefName(); new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref); } } } // Bind resource references { Iterator i = beanMetaData.getResourceReferences(); // let's play guess the cast game ;) New metadata should fix this. ApplicationMetaData application = beanMetaData.getApplicationMetaData(); while (i.hasNext()) { ResourceRefMetaData ref = (ResourceRefMetaData)i.next(); String resourceName = ref.getResourceName(); String finalName = application.getResourceByName(resourceName); String resType = ref.getType(); // If there was no resource-manager specified then an immeadiate // jndi-name or res-url name should have been given if (finalName == null) finalName = ref.getJndiName(); if (finalName == null && resType.equals("java.net.URL") == false) { // the application assembler did not provide a resource manager // if the type is javax.sql.Datasoure use the default one if (ref.getType().equals("javax.sql.DataSource")) { // Go through JNDI and look for DataSource - use the first one Context dsCtx = new InitialContext(); try { // Check if it is available in JNDI dsCtx.lookup("java:/DefaultDS"); finalName = "java:/DefaultDS"; } catch (Exception e) { log.debug("failed to lookup DefaultDS; ignoring", e); } finally { dsCtx.close(); } } // Default failed? Warn user and move on // POTENTIALLY DANGEROUS: should this be a critical error? if (finalName == null) { log.warn("No resource manager found for " + ref.getResourceName()); continue; } } if (resType.equals("java.net.URL")) { // URL bindings if (ref.getResURL() != null) { // The URL string was given by the res-url log.debug("Binding URL: " + ref.getRefName() + " to JDNI ENC as: " + ref.getResURL()); URL resURL = new URL(ref.getResURL()); Util.bind(envCtx, ref.getRefName(), resURL); } else { log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName); Object bind = null; if (ref.getJndiName() != null) { // Was the url given as a jndi-name reference to link to it bind = new LinkRef(finalName); } else { // The url string was given via a resource-name mapping bind = new URL(finalName); } Util.bind(envCtx, ref.getRefName(), bind); } } else { // Resource Manager bindings, should validate the type... log.debug("Binding resource manager: " + ref.getRefName() + " to JDNI ENC as: " + finalName); Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName)); } } } // Bind resource env references { Iterator i = beanMetaData.getResourceEnvReferences(); while (i.hasNext()) { ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData)i.next(); String encName = resRef.getRefName(); String jndiName = resRef.getJndiName(); // Should validate the type... log.debug("Binding env resource: " + encName + " to JDNI ENC as: " + jndiName); Util.bind(envCtx, encName, new LinkRef(jndiName)); } } // Bind message destination references { Iterator i = beanMetaData.getMessageDestinationReferences(); while (i.hasNext()) { MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next(); String refName = ref.getRefName(); String jndiName = ref.getJNDIName(); String link = ref.getLink(); if (link != null) { if (jndiName == null) { MessageDestinationMetaData messageDestination = getMessageDestination(link); if (messageDestination == null) throw new DeploymentException("message-destination-ref '" + refName + "' message-destination-link '" + link + "' not found and no jndi-name in jboss.xml"); else { String linkJNDIName = messageDestination.getJndiName(); if (linkJNDIName == null) log.warn("message-destination '" + link + "' has no jndi-name in jboss.xml"); else jndiName = linkJNDIName; } } else log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss.xml"); } else if (jndiName == null) throw new DeploymentException("message-destination-ref '" + refName + "' has no message-destination-link in ejb-jar.xml and no jndi-name in jboss.xml"); Util.bind(envCtx, refName, new LinkRef(jndiName)); } } // Create a java:comp/env/security/security-domain link to the container // or application security-domain if one exists so that access to the // security manager can be made without knowing the global jndi name. String securityDomain = metaData.getContainerConfiguration().getSecurityDomain(); if (securityDomain == null) securityDomain = metaData.getApplicationMetaData().getSecurityDomain(); if (securityDomain != null) { //JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix if(securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false) securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain; log.debug("Binding securityDomain: " + securityDomain + " to JDNI ENC as: security/security-domain"); Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain)); Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject")); Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain + "/realmMapping")); Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain + "/authorizationMgr")); } log.debug("End java:comp/env for EJB: " + beanMetaData.getEjbName()); }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); JBossMetaData metaData = unit.getAttachment(JBossMetaData.class); // Check for an annotated view String key = AnnotationMetaDataDeployer.EJB_ANNOTATED_ATTACHMENT_NAME; JBossMetaData annotatedMetaData = unit.getAttachment(key, JBossMetaData.class); if(ejbJarMetaData == null && metaData == null && annotatedMetaData == null) return; JBossMetaData specMetaData = new JBoss50MetaData(); if(ejbJarMetaData != null) { specMetaData.merge(null, ejbJarMetaData); if(annotatedMetaData != null) { JBossMetaData specMerged = new JBoss50MetaData(); specMerged.merge(specMetaData, annotatedMetaData); specMetaData = specMerged; } } else specMetaData = annotatedMetaData; // Create a merged view JBossMetaData mergedMetaData = new JBossMetaData(); mergedMetaData.merge(metaData, specMetaData); // Incorporate any ear level overrides DeploymentUnit topUnit = unit.getTopLevel(); if(topUnit != null && topUnit.getAttachment(JBossAppMetaData.class) != null) { JBossAppMetaData earMetaData = topUnit.getAttachment(JBossAppMetaData.class); // Security domain String securityDomain = earMetaData.getSecurityDomain(); if(securityDomain != null && mergedMetaData.getSecurityDomain() == null) mergedMetaData.setSecurityDomain(securityDomain); //Security Roles SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles(); if(earSecurityRolesMetaData != null) { JBossAssemblyDescriptorMetaData jadmd = mergedMetaData.getAssemblyDescriptor(); if( jadmd == null) { jadmd = new JBossAssemblyDescriptorMetaData(); mergedMetaData.setAssemblyDescriptor(jadmd); } SecurityRolesMetaData mergedSecurityRolesMetaData = jadmd.getSecurityRoles(); if(mergedSecurityRolesMetaData == null) jadmd.setSecurityRoles(earSecurityRolesMetaData); //perform a merge to rebuild the principalVersusRolesMap if(mergedSecurityRolesMetaData != null ) { mergedSecurityRolesMetaData.merge(mergedSecurityRolesMetaData, earSecurityRolesMetaData); } } } // Create interceptors metadata by processing interceptor classes (from the merged // jboss metadata) Collection<String> interceptorClassNames = JBossMetaData.getAllInterceptorClasses(mergedMetaData); Collection<Class<?>> interceptorClasses = null; try { interceptorClasses = this.loadClasses(unit.getClassLoader(), interceptorClassNames); } catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); } // Process the interceptor classes AnnotationFinder<AnnotatedElement> annotationFinder = new DefaultAnnotationFinder<AnnotatedElement>(); InterceptorMetaDataCreator interceptorMetaDataCreator = new InterceptorMetaDataCreator(annotationFinder); // create interceptors metadata from the interceptor classes InterceptorsMetaData annotatedInterceptorsMetaData = interceptorMetaDataCreator.create(interceptorClasses); InterceptorsMetaData mergedInterceptorsMetaData = new InterceptorsMetaData(); // merge the interceptors metadata mergedInterceptorsMetaData.merge(mergedMetaData.getInterceptors(), annotatedInterceptorsMetaData); // now set the merged interceptors metadata into the merged jboss metadata mergedMetaData.setInterceptors(mergedInterceptorsMetaData); // Output the merged JBossMetaData unit.getTransientManagedObjects().addAttachment(JBossMetaData.class, mergedMetaData); unit.addAttachment(EJB_MERGED_ATTACHMENT_NAME, mergedMetaData, JBossMetaData.class); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
Override public void deploy(VFSDeploymentUnit unit, JBossMetaData deployment) throws DeploymentException { // If it is a deployment with ejbVersion unknown or 3 if (!deployment.isEJB2x() && !deployment.isEJB1x()) return; // let EJB3 deployer handle this ApplicationMetaData legacyMD = new ApplicationMetaData(deployment); if( verifyDeployments ) { // we have a positive attitude boolean allOK = true; // wrapping this into a try - catch block to prevent errors in // verifier from stopping the deployment try { BeanVerifier verifier = new BeanVerifier(); // add a listener so we can log the results verifier.addVerificationListener(new VerificationListener() { Logger verifierLog = Logger.getLogger(EjbDeployer.class, "verifier"); public void beanChecked(VerificationEvent event) { verifierLog.debug( "Bean checked: " + event.getMessage() ); } public void specViolation(VerificationEvent event) { verifierLog.warn( "EJB spec violation: " + (verifierVerbose ? event.getVerbose() : event.getMessage())); } }); log.debug("Verifying " + unit.getRoot().toURL()); verifier.verify(unit.getRoot().toURL(), legacyMD, unit.getClassLoader()); allOK = verifier.getSuccess(); } catch (Throwable t) { log.warn("Verify failed; continuing", t ); allOK = false; } // If the verifier is in strict mode and an error/warning // was found in the Verification process, throw a Deployment // Exception if( strictVerifier && !allOK ) { throw new DeploymentException("Verification of Enterprise Beans failed, see above for error messages."); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void resolveResourceAdapter() throws DeploymentException { resourceAdapterName = resolveResourceAdapterName(); try { resourceAdapterObjectName = new ObjectName("jboss.jca:service=RARDeployment,name='" + resourceAdapterName + "'"); int state = ((Integer) server.getAttribute(resourceAdapterObjectName, "State")).intValue(); if (state != STARTED) throw new DeploymentException("The resource adapter is not started " + resourceAdapterName); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Cannot locate resource adapter deployment " + resourceAdapterName, e); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void setupProxyParameters() throws DeploymentException { // Set the interfaces interfaces = new Class[] { MessageEndpoint.class, messagingTypeClass }; // Set the interceptors interceptors = new ArrayList<Class<?>>(); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element endpointInterceptors = MetaData.getOptionalChild(proxyConfig, "endpoint-interceptors", null); if (endpointInterceptors == null) throw new DeploymentException("No endpoint interceptors found"); else { NodeList children = endpointInterceptors.getElementsByTagName("interceptor"); for (int i = 0; i < children.getLength(); ++i) { Node currentChild = children.item(i); if (currentChild.getNodeType() == Node.ELEMENT_NODE) { Element interceptor = (Element) children.item(i); String className = MetaData.getElementContent(interceptor); try { Class<?> clazz = container.getClassLoader().loadClass(className); interceptors.add(clazz); } catch (Throwable t) { DeploymentException.rethrowAsDeploymentException("Error loading interceptor class " + className, t); } } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void augmentActivationConfigProperties() throws DeploymentException { // Allow activation config properties from invoker proxy binding Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element activationConfig = MetaData.getOptionalChild(proxyConfig, "activation-config"); if (activationConfig != null) { Iterator<Element> iterator = MetaData.getChildrenByTagName(activationConfig, "activation-config-property"); while (iterator.hasNext()) { Element xml = iterator.next(); org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData md = new org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData(); ActivationConfigPropertyMetaData metaData = new ActivationConfigPropertyMetaData(md); String name = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-name")); String value = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-value")); if (name == null || name.trim().length() == 0) throw new DeploymentException("activation-config-property doesn't have a name"); if (Strings.isValidJavaIdentifier(name) == false) throw new DeploymentException("activation-config-property '" + name + "' is not a valid java identifier"); md.setName(name); md.setValue(value); if (properties.containsKey(metaData.getName()) == false) properties.put(metaData.getName(), metaData); } } // Message Destination Link String link = metaData.getDestinationLink(); if (link != null) { link = link.trim(); if (link.length() > 0) { if (properties.containsKey("destination")) log.warn("Ignoring message-destination-link '" + link + "' when the destination " + "is already in the activation-config."); else { MessageDestinationMetaData destinationMetaData = container.getMessageDestination(link); if (destinationMetaData == null) throw new DeploymentException("Unresolved message-destination-link '" + link + "' no message-destination in ejb-jar.xml"); String jndiName = destinationMetaData.getJndiName(); if (jndiName == null) throw new DeploymentException("The message-destination '" + link + "' has no jndi-name in jboss.xml"); org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData acpmd = new org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData(); acpmd.setActivationConfigPropertyName("destination"); acpmd.setValue(jndiName); ActivationConfigPropertyMetaData wrapper = new ActivationConfigPropertyMetaData(acpmd); properties.put("destination", wrapper); } } } }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
public void importXml(Element element) throws DeploymentException { String min = MetaData.getElementContent(MetaData.getOptionalChild(element, "min-capacity")); String max = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-capacity")); String op = MetaData.getElementContent(MetaData.getOptionalChild(element, "overager-period")); String rp = MetaData.getElementContent(MetaData.getOptionalChild(element, "resizer-period")); String ma = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-bean-age")); String map = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-cache-miss-period")); String mip = MetaData.getElementContent(MetaData.getOptionalChild(element, "min-cache-miss-period")); String fa = MetaData.getElementContent(MetaData.getOptionalChild(element, "cache-load-factor")); try { if (min != null) { int s = Integer.parseInt(min); if (s <= 0) { throw new DeploymentException("Min cache capacity can't be <= 0"); } m_minCapacity = s; } if (max != null) { int s = Integer.parseInt(max); if (s <= 0) { throw new DeploymentException("Max cache capacity can't be <= 0"); } m_maxCapacity = s; } if (op != null) { int p = Integer.parseInt(op); if (p <= 0) {throw new DeploymentException("Overager period can't be <= 0");} m_overagerPeriod = p * 1000; } if (rp != null) { int p = Integer.parseInt(rp); if (p <= 0) {throw new DeploymentException("Resizer period can't be <= 0");} m_resizerPeriod = p * 1000; } if (ma != null) { int a = Integer.parseInt(ma); if (a <= 0) {throw new DeploymentException("Max bean age can't be <= 0");} m_maxBeanAge = a * 1000; } if (map != null) { int p = Integer.parseInt(map); if (p <= 0) {throw new DeploymentException("Max cache miss period can't be <= 0");} m_maxPeriod = p * 1000; } if (mip != null) { int p = Integer.parseInt(mip); if (p <= 0) {throw new DeploymentException("Min cache miss period can't be <= 0");} m_minPeriod = p * 1000; } if (fa != null) { double f = Double.parseDouble(fa); if (f <= 0.0) {throw new DeploymentException("Cache load factor can't be <= 0");} m_factor = f; } } catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void importXml(Element element) throws DeploymentException { // This one is mandatory String p = MetaData.getElementContent(MetaData.getUniqueChild(element, "cache-policy")); try { Class cls = SecurityActions.getContextClassLoader().loadClass(p); Constructor ctor = cls.getConstructor(new Class[] {AbstractInstanceCache.class}); m_cache = (CachePolicy)ctor.newInstance(new Object[] {this}); } catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); } Element policyConf = MetaData.getOptionalChild(element, "cache-policy-conf"); if (policyConf != null) { if (m_cache instanceof XmlLoadable) { try { ((XmlLoadable)m_cache).importXml(policyConf); } catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2) manager.getEntityBridge(); log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName()); final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields(); if(pkFields.length > 1) { throw new DeploymentException("This entity-command cannot be used with composite primary keys!"); } this.pkField = (JDBCCMPFieldBridge2) pkFields[0]; JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand(); pkSql = metadata.getAttribute("pk-sql"); if(pkSql == null) { throw new DeploymentException("pk-sql attribute must be set for entity " + entityBridge.getEntityName()); } if(log.isDebugEnabled()) { log.debug("entity-command generate pk sql: " + pkSql); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
public void init() throws DeploymentException { Method findByPkMethod; Class home = entity.getHomeClass(); if(home != null) { try { findByPkMethod = home.getMethod("findByPrimaryKey", new Class[]{entity.getPrimaryKeyClass()}); } catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } FindByPrimaryKeyCommand findByPk = new FindByPrimaryKeyCommand(entity); queriesByMethod.put(findByPkMethod, findByPk); } Class local = entity.getLocalHomeClass(); if(local != null) { try { findByPkMethod = local.getMethod("findByPrimaryKey", new Class[]{entity.getPrimaryKeyClass()}); } catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } FindByPrimaryKeyCommand findByPk = new FindByPrimaryKeyCommand(entity); queriesByMethod.put(findByPkMethod, findByPk); } // // Defined finders - Overrides automatic finders. // Iterator definedFinders = entity.getMetaData().getQueries().iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData q = (JDBCQueryMetaData) definedFinders.next(); if(!queriesByMethod.containsKey(q.getMethod())) { if(q instanceof JDBCJBossQLQueryMetaData) { QueryCommand queryCommand = new JBossQLQueryCommand(entity, (JDBCJBossQLQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCQlQueryMetaData) { QueryCommand queryCommand = new EJBQLQueryCommand(entity, (JDBCQlQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCDeclaredQueryMetaData) { QueryCommand queryCommand = new DeclaredSQLQueryCommand(entity, (JDBCDeclaredQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCDynamicQLQueryMetaData) { QueryCommand queryCommand = new DynamicQueryCommand(entity, (JDBCDynamicQLQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else { throw new DeploymentException("Unsupported query metadata: method=" + q.getMethod().getName() + ", metadata=" + q); } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void start() throws DeploymentException { final JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); relationsTotal = (cmrFields != null ? cmrFields.length : 0); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); // DELETE SQL deleteSql = "delete from " + tableName + " where "; deleteSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { deleteSql += " and " + pkFields[i].getColumnName() + "=?"; } log.debug("delete sql: " + deleteSql); // INSERT SQL insertSql = "insert into " + tableName + "("; insertSql += tableFields[0].getColumnName(); for(int i = 1; i < tableFields.length; ++i) { insertSql += ", " + tableFields[i].getColumnName(); } insertSql += ") values (?"; for(int i = 1; i < tableFields.length; ++i) { insertSql += ", ?"; } insertSql += ")"; log.debug("insert sql: " + insertSql); // UPDATE SQL updateSql = "update " + tableName + " set "; int setFields = 0; for(int i = 0; i < tableFields.length; ++i) { JDBCCMPFieldBridge2 field = tableFields[i]; if(!field.isPrimaryKeyMember()) { if(setFields++ > 0) { updateSql += ", "; } updateSql += field.getColumnName() + "=?"; } } updateSql += " where "; updateSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { updateSql += " and " + pkFields[i].getColumnName() + "=?"; } if(entity.getVersionField() != null) { updateSql += " and " + entity.getVersionField().getColumnName() + "=?"; } log.debug("update sql: " + updateSql); // SELECT SQL String selectColumns = tableFields[0].getColumnName(); for(int i = 1; i < tableFields.length; ++i) { JDBCCMPFieldBridge2 field = tableFields[i]; selectColumns += ", " + field.getColumnName(); } String whereColumns = pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { whereColumns += " and " + pkFields[i].getColumnName() + "=?"; } if(entity.getMetaData().hasRowLocking()) { JDBCEntityPersistenceStore manager = entity.getManager(); JDBCTypeFactory typeFactory = manager.getJDBCTypeFactory(); JDBCTypeMappingMetaData typeMapping = typeFactory.getTypeMapping(); JDBCFunctionMappingMetaData rowLockingTemplate = typeMapping.getRowLockingTemplate(); if(rowLockingTemplate == null) { throw new DeploymentException("Row locking template is not defined for mapping: " + typeMapping.getName()); } selectSql = rowLockingTemplate.getFunctionSql(new Object[]{selectColumns, tableName, whereColumns, null}, new StringBuffer()).toString(); } else { selectSql = "select "; selectSql += selectColumns; selectSql += " from " + tableName + " where "; selectSql += whereColumns; } log.debug("select sql: " + selectSql); // DUPLICATE KEY if(dontFlushCreated) { duplicatePkSql = "select "; duplicatePkSql += pkFields[0].getColumnName(); for(int i = 1; i < pkFields.length; ++i) { duplicatePkSql += ", " + pkFields[i].getColumnName(); } duplicatePkSql += " from " + tableName + " where "; duplicatePkSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { duplicatePkSql += " and " + pkFields[i].getColumnName() + "=?"; } log.debug("duplicate pk sql: " + duplicatePkSql); } if(cacheName != null) { try { serviceController.start(cacheName); } catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DeclaredSQLQueryCommand.java
private void initResultReader(JDBCEntityBridge2 entity, JDBCDeclaredQueryMetaData metadata) throws DeploymentException { String entityName = metadata.getEJBName(); if(entityName != null) { Catalog catalog = entity.getManager().getCatalog(); JDBCEntityBridge2 otherEntity = (JDBCEntityBridge2) catalog.getEntityByEJBName(entityName); if(otherEntity == null) { throw new DeploymentException("Unknown entity: " + entityName); } this.entity = otherEntity; } else { this.entity = entity; } String fieldName = metadata.getFieldName(); if(fieldName == null) { setEntityReader(this.entity, metadata.isSelectDistinct()); } else { selectedField = (JDBCCMPFieldBridge2) entity.getFieldByName(fieldName); if(selectedField == null) { throw new DeploymentException("Unknown cmp field: " + fieldName); } setFieldReader(selectedField); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DeclaredSQLQueryCommand.java
protected String parseParameters(String sql, JDBCDeclaredQueryMetaData metadata) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); ArrayList params = new ArrayList(); // Replace placeholders {0} with ? if(sql != null) { sql = sql.trim(); StringTokenizer tokens = new StringTokenizer(sql, "{}", true); while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); if(token.equals("{")) { token = tokens.nextToken(); if(Character.isDigit(token.charAt(0))) { QueryParameter parameter = new QueryParameter(entity.getManager(), metadata.getMethod(), token); // of if we are here we can assume that we have // a parameter and not a function sqlBuf.append("?"); params.add(parameter); if(!tokens.nextToken().equals("}")) { throw new DeploymentException("Invalid parameter - missing closing '}' : " + sql); } } else { // ok we don't have a parameter, we have a function // push the tokens on the buffer and continue sqlBuf.append("{").append(token); } } else { // not parameter... just append it sqlBuf.append(token); } } } setParameters(params); return sqlBuf.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
protected void startStoreManager() throws Exception { queryFactory = new QueryFactory(entityBridge); queryFactory.init(); instanceFactory = new InstanceFactory(this, entityBridge); startCmd = new JDBCStartCommand(this); startCmd.execute(); final JDBCEntityCommandMetaData entityCommand = getMetaData().getEntityCommand(); if(entityCommand == null || "default".equals(entityCommand.getCommandName())) { createCmd = new ApplicationPkCreateCommand(); } else { final Class cmdClass = entityCommand.getCommandClass(); if(cmdClass == null) { throw new DeploymentException( "entity-command class name is not specified for entity " + entityBridge.getEntityName() ); } try { createCmd = (CreateCommand)cmdClass.newInstance(); } catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); } } createCmd.init(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
private JDBCEntityMetaData loadJDBCEntityMetaData() throws DeploymentException { ApplicationMetaData amd = container.getBeanMetaData().getApplicationMetaData(); // Get JDBC MetaData JDBCApplicationMetaData jamd = (JDBCApplicationMetaData)amd.getPluginData(CMP_JDBC); if(jamd == null) { // we are the first cmp entity to need jbosscmp-jdbc. // Load jbosscmp-jdbc.xml for the whole application JDBCXmlFileLoader jfl = new JDBCXmlFileLoader(container, log); jamd = jfl.load(); amd.addPluginData(CMP_JDBC, jamd); } // Get JDBC Bean MetaData String ejbName = container.getBeanMetaData().getEjbName(); JDBCEntityMetaData metadata = jamd.getBeanByEjbName(ejbName); if(metadata == null) { throw new DeploymentException("No metadata found for bean " + ejbName); } return metadata; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
private static Map createFieldMap(JDBCEntityBridge2 entityBridge) throws DeploymentException { Map abstractAccessors = getAbstractAccessors(entityBridge.getMetaData().getEntityClass()); List fields = entityBridge.getFields(); Map map = new HashMap(fields.size() * 2); for(int i = 0; i < fields.size(); i++) { FieldBridge field = (FieldBridge) fields.get(i); // get the names String fieldName = field.getFieldName(); String fieldBaseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getterName = "get" + fieldBaseName; String setterName = "set" + fieldBaseName; // get the accessor methods Method getterMethod = (Method) abstractAccessors.get(getterName); Method setterMethod = (Method) abstractAccessors.get(setterName); // getters and setters must come in pairs if(getterMethod != null && setterMethod == null) { throw new DeploymentException("Getter was found but, no setter was found for field: " + fieldName); } else if(getterMethod == null && setterMethod != null) { throw new DeploymentException("Setter was found but, no getter was found for field: " + fieldName); } else if(getterMethod != null && setterMethod != null) { // add methods map.put(getterMethod.getName(), new EntityBridgeInvocationHandler.FieldGetInvoker(field)); map.put(setterMethod.getName(), new EntityBridgeInvocationHandler.FieldSetInvoker(field)); // remove the accessors (they have been used) abstractAccessors.remove(getterName); abstractAccessors.remove(setterName); } } return Collections.unmodifiableMap(map); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
private static Map createSelectorMap(JDBCEntityBridge2 entityBridge, QueryFactory queryFactory) throws DeploymentException { Collection queries = entityBridge.getMetaData().getQueries(); Map selectorsByMethod = new HashMap(queries.size()); Iterator definedFinders = queries.iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData metadata = (JDBCQueryMetaData)definedFinders.next(); if(metadata.getMethod().getName().startsWith("ejbSelect")) { try { QueryCommand queryCommand = queryFactory.getQueryCommand(metadata.getMethod()); Schema schema = ((JDBCStoreManager2)entityBridge.getManager()).getSchema(); EJBSelectBridge ejbSelectBridge = new EJBSelectBridge(entityBridge.getContainer(), schema, metadata, queryCommand); selectorsByMethod.put(metadata.getMethod(), ejbSelectBridge); } catch(FinderException e) { throw new DeploymentException(e.getMessage()); } } } return selectorsByMethod; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void resolveRelationship() throws DeploymentException { // // Set handles to the related entity's container, cache, manager, and invoker // // Related Entity Name String relatedEntityName = metadata.getRelatedRole().getEntity().getName(); // Related Entity Catalog catalog = (Catalog)manager.getApplicationData("CATALOG"); relatedEntity = (JDBCEntityBridge2)catalog.getEntityByEJBName(relatedEntityName); if(relatedEntity == null) { throw new DeploymentException("Related entity not found: " + "entity=" + entity.getEntityName() + ", " + "cmrField=" + getFieldName() + ", " + "relatedEntity=" + relatedEntityName ); } // Related CMR Field JDBCCMRFieldBridge2[] cmrFields = (JDBCCMRFieldBridge2[])relatedEntity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge2 cmrField = cmrFields[i]; if(metadata.getRelatedRole() == cmrField.getMetaData()) { relatedCMRField = cmrField; break; } } // if we didn't find the related CMR field throw an exception with a detailed message if(relatedCMRField == null) { String message = "Related CMR field not found in " + relatedEntity.getEntityName() + " for relationship from "; message += entity.getEntityName() + "."; if(getFieldName() != null) { message += getFieldName(); } else { message += "<no-field>"; } message += " to "; message += relatedEntityName + "."; if(metadata.getRelatedRole().getCMRFieldName() != null) { message += metadata.getRelatedRole().getCMRFieldName(); } else { message += "<no-field>"; } throw new DeploymentException(message); } // Related Container relatedContainer = relatedEntity.getContainer(); // // Initialize the key fields // if(metadata.getRelationMetaData().isTableMappingStyle()) { // initialize relation table key fields Collection tableKeys = metadata.getKeyFields(); List keyFieldsList = new ArrayList(tableKeys.size()); // first phase is to create fk fields Map pkFieldsToFKFields = new HashMap(tableKeys.size()); for(Iterator i = tableKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData)i.next(); FieldBridge pkField = entity.getFieldByName(cmpFieldMetaData.getFieldName()); if(pkField == null) { throw new DeploymentException("Primary key not found for key-field " + cmpFieldMetaData.getFieldName()); } pkFieldsToFKFields.put(pkField, new JDBCCMPFieldBridge2(manager, entity, cmpFieldMetaData, -1)); } // second step is to order fk fields to match the order of pk fields JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { Object fkField = pkFieldsToFKFields.get(pkFields[i]); if(fkField == null) { throw new DeploymentException("Primary key " + pkFields[i].getFieldName() + " is not mapped."); } keyFieldsList.add(fkField); } tableKeyFields = (JDBCCMPFieldBridge2[])keyFieldsList.toArray(new JDBCCMPFieldBridge2[keyFieldsList.size()]); } else { initializeForeignKeyFields(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void init() throws DeploymentException { loadCMPFields(metadata); loadCMRFields(metadata); JDBCOptimisticLockingMetaData olMD = metadata.getOptimisticLocking(); if(olMD != null) { if(olMD.getLockingStrategy() != JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY) { throw new DeploymentException( "Only version-column optimistic locking strategy is supported at the moment."); } JDBCCMPFieldMetaData versionMD = olMD.getLockingField(); versionField = (JDBCCMPFieldBridge2) getFieldByName(versionMD.getFieldName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2)manager.getEntityBridge(); this.log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName()); final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields(); if(pkFields.length > 1) { throw new DeploymentException("This entity-command cannot be used with composite primary keys!"); } this.pkField = (JDBCCMPFieldBridge2) pkFields[0]; this.pkSql = ""; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { log = Logger.getLogger(getClass().getName() + '.' + manager.getMetaData().getName()); debug = log.isDebugEnabled(); trace = log.isTraceEnabled(); entity = (JDBCEntityBridge) manager.getEntityBridge(); securityManager = manager.getContainer().getSecurityManager(); insertAfterEjbPostCreate = manager.getContainer() .getBeanMetaData().getContainerConfiguration().isInsertAfterEjbPostCreate(); // set create allowed createAllowed = true; JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; i++) { if(pkFields[i].isReadOnly()) { createAllowed = false; log.debug("Create will not be allowed because pk field " + pkFields[i].getFieldName() + "is read only."); break; } } initGeneratedFields(); JDBCEntityCommandMetaData entityCommand = manager.getMetaData().getEntityCommand(); if(entityCommand == null) { throw new DeploymentException("entity-command is null"); } initEntityCommand(entityCommand); initInsertFields(); initInsertSQL(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { String objectName = entityCommand.getAttribute("SQLExceptionProcessor"); if(objectName != null) { try { exceptionProcessor = (SQLExceptionProcessorMBean) MBeanProxyExt.create(SQLExceptionProcessorMBean.class, objectName); } catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected JDBCCMPFieldBridge getGeneratedPKField() throws DeploymentException { // extract the pk field to be generated JDBCCMPFieldBridge pkField = null; JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { if(pkField != null) throw new DeploymentException("Generation only supported with single PK field"); pkField = (JDBCCMPFieldBridge)pkFields[i]; } return pkField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void initGeneratedFields() throws DeploymentException { createdPrincipal = entity.getCreatedPrincipalField(); if(securityManager == null && createdPrincipal != null) { throw new DeploymentException("No security-domain configured but created-by specified"); } updatedPrincipal = entity.getUpdatedPrincipalField(); if(securityManager == null && updatedPrincipal != null) { throw new DeploymentException("No security-domain configured but updated-by specified"); } createdTime = entity.getCreatedTimeField(); updatedTime = entity.getUpdatedTimeField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/MetaDataLibrary.java
public void startService() throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL stdJDBCUrl = classLoader.getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if(debug) { log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); } Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); Element typeMaps = MetaData.getOptionalChild(stdJDBCElement, "type-mappings"); if(typeMaps != null) { for(Iterator i = MetaData.getChildrenByTagName(typeMaps, "type-mapping"); i.hasNext();) { Element typeMappingElement = (Element)i.next(); JDBCTypeMappingMetaData typeMapping = new JDBCTypeMappingMetaData(typeMappingElement); typeMappings.put(typeMapping.getName(), typeMapping); log.debug("added type-mapping: " + typeMapping.getName()); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationshipRoleMetaData.java
private Map loadKeyFields(Element element) throws DeploymentException { Element keysElement = MetaData.getOptionalChild(element, "key-fields"); // no field overrides, we're done if(keysElement == null) { return loadKeyFields(); } // load overrides Iterator iter = MetaData.getChildrenByTagName(keysElement, "key-field"); // if key-fields element empty, no key should be used if(!iter.hasNext()) { return Collections.EMPTY_MAP; } else if(relationMetaData.isForeignKeyMappingStyle() && isMultiplicityMany()) { throw new DeploymentException("Role: " + relationshipRoleName + " with multiplicity many using " + "foreign-key mapping is not allowed to have key-fields"); } // load the default field values Map defaultFields = getPrimaryKeyFields(); // load overrides Map fields = new HashMap(defaultFields.size()); while(iter.hasNext()) { Element keyElement = (Element) iter.next(); String fieldName = MetaData.getUniqueChildContent(keyElement, "field-name"); JDBCCMPFieldMetaData cmpField = (JDBCCMPFieldMetaData) defaultFields.remove(fieldName); if(cmpField == null) { throw new DeploymentException( "Role '" + relationshipRoleName + "' on Entity Bean '" + entity.getName() + "' : CMP field for key not found: field " + "name='" + fieldName + "'"); } String isIndexedtmp = MetaData.getOptionalChildContent(keyElement, "dbindex"); boolean isIndexed; if(isIndexedtmp != null) isIndexed = true; else isIndexed = false; genIndex = isIndexed; cmpField = new JDBCCMPFieldMetaData( entity, keyElement, cmpField, false, relationMetaData.isTableMappingStyle(), relationMetaData.isReadOnly(), relationMetaData.getReadTimeOut(), relationMetaData.isTableMappingStyle()); fields.put(cmpField.getFieldName(), cmpField); } // all fields must be overriden if(!defaultFields.isEmpty()) { throw new DeploymentException("Mappings were not provided for all " + "fields: unmaped fields=" + defaultFields.keySet() + " in role=" + relationshipRoleName); } return Collections.unmodifiableMap(fields); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private int loadMappingStyle(Element element, JDBCRelationMetaData defaultValues) throws DeploymentException { // if defaults check for preferred-relation-mapping if ("defaults".equals(element.getTagName())) { // set mapping style based on preferred-relation-mapping (if possible) String perferredRelationMapping = MetaData.getOptionalChildContent(element, "preferred-relation-mapping"); if ("relation-table".equals(perferredRelationMapping) || defaultValues.isManyToMany()) { return TABLE; } else { return FOREIGN_KEY; } } // check for table mapping style if (MetaData.getOptionalChild(element, "relation-table-mapping") != null) { return TABLE; } // check for foreign-key mapping style if (MetaData.getOptionalChild(element, "foreign-key-mapping") != null) { if (defaultValues.isManyToMany()) { throw new DeploymentException("Foreign key mapping-style " + "is not allowed for many-to-many relationsips."); } return FOREIGN_KEY; } // no mapping style element, will use defaultValues return defaultValues.mappingStyle; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private static Element getEJBRelationshipRoleElement(Element element, JDBCRelationshipRoleMetaData defaultRole) throws DeploymentException { String roleName = defaultRole.getRelationshipRoleName(); if (roleName == null) throw new DeploymentException("No ejb-relationship-role-name element found"); Iterator iter = MetaData.getChildrenByTagName(element, "ejb-relationship-role"); if (!iter.hasNext()) { throw new DeploymentException("No ejb-relationship-role " + "elements found"); } Element roleElement = null; for (int i = 0; iter.hasNext(); i++) { // only 2 roles are allowed if (i > 1) { throw new DeploymentException("Expected only 2 " + "ejb-relationship-role but found more then 2"); } Element tempElement = (Element) iter.next(); if (roleName.equals(MetaData.getUniqueChildContent(tempElement, "ejb-relationship-role-name"))) { roleElement = tempElement; } } if (roleElement == null) { throw new DeploymentException("An ejb-relationship-role element was " + "not found for role '" + roleName + "'"); } return roleElement; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
private void loadLoadGroupsXml(Element element) throws DeploymentException { Element loadGroupsElement = MetaData.getOptionalChild(element, "load-groups"); if(loadGroupsElement == null) { // no info, default work already done in constructor return; } // only allowed for cmp 2.x if(isCMP1x) { throw new DeploymentException( "load-groups are only allowed " + "for CMP 2.x" ); } // load each group Iterator groups = MetaData.getChildrenByTagName(loadGroupsElement, "load-group"); while(groups.hasNext()) { Element groupElement = (Element) groups.next(); // get the load-group-name String loadGroupName = MetaData.getUniqueChildContent(groupElement, "load-group-name"); if(loadGroups.containsKey(loadGroupName)) { throw new DeploymentException( "Load group already defined: " + " load-group-name=" + loadGroupName ); } if(loadGroupName.equals("*")) { throw new DeploymentException( "The * load group is automatically " + "defined and can't be overriden" ); } ArrayList group = new ArrayList(); // add each field Iterator fields = MetaData.getChildrenByTagName(groupElement, "field-name"); while(fields.hasNext()) { String fieldName = MetaData.getElementContent((Element) fields.next()); // check if the field is a cmp field that it is not a pk memeber JDBCCMPFieldMetaData field = getCMPFieldByName(fieldName); if(field != null && field.isPrimaryKeyMember()) { throw new DeploymentException( "Primary key fields can not be" + " a member of a load group: " + " load-group-name=" + loadGroupName + " field-name=" + fieldName ); } group.add(fieldName); } loadGroups.put(loadGroupName, Collections.unmodifiableList(group)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
private void loadLazyLoadGroupsXml(Element element) throws DeploymentException { Element lazyLoadGroupsElement = MetaData.getOptionalChild(element, "lazy-load-groups"); // If no info, we're done. Default work was already done in constructor. if(lazyLoadGroupsElement == null) { return; } // only allowed for cmp 2.x if(isCMP1x) { throw new DeploymentException("lazy-load-groups is only allowed for CMP 2.x"); } // get the fields Iterator loadGroupNames = MetaData.getChildrenByTagName(lazyLoadGroupsElement, "load-group-name"); while(loadGroupNames.hasNext()) { String loadGroupName = MetaData.getElementContent((Element) loadGroupNames.next()); if(!loadGroupName.equals("*") && !loadGroups.containsKey(loadGroupName)) { throw new DeploymentException( "Lazy load group not found: " + "load-group-name=" + loadGroupName ); } lazyLoadGroups.add(loadGroupName); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public List getLoadGroup(String name) throws DeploymentException { List group = (List) loadGroups.get(name); if(group == null) { throw new DeploymentException("Unknown load group: name=" + name); } return group; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public static JDBCTypeMappingMetaData obtainTypeMappingFromLibrary(String dataSourceName) throws DeploymentException { JDBCTypeMappingMetaData typeMapping = null; String datasource; if(dataSourceName.startsWith("java:")) { datasource = dataSourceName.substring("java:".length()); if(datasource.startsWith("/")) { datasource = datasource.substring(1); } } else { datasource = dataSourceName; } final ObjectName metadataService; final String str = "jboss.jdbc:service=metadata,datasource=" + datasource; try { metadataService = new ObjectName(str); } catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); } try { final MBeanServer server = MBeanServerLocator.locateJBoss(); if(server.isRegistered(metadataService)) { typeMapping = (JDBCTypeMappingMetaData)server.getAttribute(metadataService, "TypeMappingMetaData"); } } catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); } /* if(typeMapping == null) { throw new DeploymentException( "type-mapping for datasource " + datasource + " not found in the library. " + "Check the value of metadata/type-mapping in the -ds.xml file." ); } */ return typeMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
private Class loadFieldType(JDBCEntityMetaData entity, String fieldName) throws DeploymentException { if(entity.isCMP1x()) { // CMP 1.x field Style try { return entity.getEntityClass().getField(fieldName).getType(); } catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); } } else { // CMP 2.x abstract accessor style String baseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getName = "get" + baseName; String setName = "set" + baseName; Method[] methods = entity.getEntityClass().getMethods(); for(int i = 0; i < methods.length; i++) { // is this a public abstract method? if(Modifier.isPublic(methods[i].getModifiers()) && Modifier.isAbstract(methods[i].getModifiers())) { // get accessor if(getName.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 0 && !methods[i].getReturnType().equals(Void.TYPE)) { return methods[i].getReturnType(); } // set accessor if(setName.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 1 && methods[i].getReturnType().equals(Void.TYPE)) { return methods[i].getParameterTypes()[0]; } } } throw new DeploymentException("No abstract accessors for field " + "named '" + fieldName + "' found in entity class " + entity.getEntityClass().getName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
public JDBCApplicationMetaData load() throws DeploymentException { JDBCApplicationMetaData jamd = new JDBCApplicationMetaData( container.getBeanMetaData().getApplicationMetaData(), container.getClassLoader() ); // Load standardjbosscmp-jdbc.xml from the default classLoader // we always load defaults first URL stdJDBCUrl = container.getClassLoader().getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if (debug) log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); // first create the metadata jamd = new JDBCApplicationMetaData(stdJDBCElement, jamd); // Load jbosscmp-jdbc.xml if provided URL jdbcUrl = null; VirtualFile dd = container.getDeploymentUnit().getMetaDataFile("jbosscmp-jdbc.xml"); if(dd != null) { try { jdbcUrl = dd.toURL(); } catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); } } if(jdbcUrl != null) { if (debug) log.debug(jdbcUrl.toString() + " found. Overriding defaults"); Element jdbcElement = XmlFileLoader.getDocument(jdbcUrl, true).getDocumentElement(); jamd = new JDBCApplicationMetaData(jdbcElement, jamd); } return jamd; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
private JDBCCMPFieldMetaData constructLockingField( JDBCEntityMetaData entity, Element element) throws DeploymentException { // field name String fieldName = MetaData.getOptionalChildContent(element, "field-name"); if(fieldName == null || fieldName.trim().length() < 1) fieldName = (lockingStrategy == VERSION_COLUMN_STRATEGY ? "version_lock" : (lockingStrategy == TIMESTAMP_COLUMN_STRATEGY ? "timestamp_lock" : "generated_lock")); // column name String columnName = MetaData.getOptionalChildContent(element, "column-name"); if(columnName == null || columnName.trim().length() < 1) columnName = (lockingStrategy == VERSION_COLUMN_STRATEGY ? "version_lock" : (lockingStrategy == TIMESTAMP_COLUMN_STRATEGY ? "timestamp_lock" : "generated_lock")); // field type Class fieldType = null; if(lockingStrategy == VERSION_COLUMN_STRATEGY) fieldType = java.lang.Long.class; else if(lockingStrategy == TIMESTAMP_COLUMN_STRATEGY) fieldType = java.util.Date.class; String fieldTypeStr = MetaData.getOptionalChildContent(element, "field-type"); if(fieldTypeStr != null) { try { fieldType = GetTCLAction. getContextClassLoader().loadClass(fieldTypeStr); } catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); } } // JDBC/SQL Type int jdbcType; String sqlType; String jdbcTypeName = MetaData.getOptionalChildContent(element, "jdbc-type"); if(jdbcTypeName != null) { jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcTypeName); sqlType = MetaData.getUniqueChildContent(element, "sql-type"); } else { jdbcType = Integer.MIN_VALUE; sqlType = null; } return new JDBCCMPFieldMetaData( entity, fieldName, fieldType, columnName, jdbcType, sqlType ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCMappingMetaData.java
public static int getJdbcTypeFromName(String name) throws DeploymentException { if(name == null) { throw new DeploymentException("jdbc-type cannot be null"); } try { Integer constant = (Integer)Types.class.getField(name).get(null); return constant.intValue(); } catch(Exception e) { log.warn("Unrecognized jdbc-type: " + name + ", using Types.OTHER", e); return Types.OTHER; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
private static JDBCCMPFieldMetaData constructAuditField( JDBCEntityMetaData entity, Element element, String defaultName) throws DeploymentException { // field name String fieldName = MetaData.getOptionalChildContent(element, "field-name"); if (fieldName == null || fieldName.trim().length() < 1) fieldName = defaultName; // column name String columnName = MetaData.getOptionalChildContent(element, "column-name"); if (columnName == null || columnName.trim().length() < 1) columnName = defaultName; // field type Class fieldType; String fieldTypeStr = MetaData.getOptionalChildContent(element, "field-type"); if (fieldTypeStr != null) { try { fieldType = GetTCLAction.getContextClassLoader().loadClass(fieldTypeStr); } catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); } } else { if (defaultName.endsWith("by")) fieldType = String.class; else fieldType = java.util.Date.class; } // JDBC/SQL Type int jdbcType; String sqlType; String jdbcTypeName = MetaData.getOptionalChildContent(element, "jdbc-type"); if (jdbcTypeName != null) { jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcTypeName); sqlType = MetaData.getUniqueChildContent(element, "sql-type"); } else { jdbcType = Integer.MIN_VALUE; sqlType = null; } // Is the field exposed? JDBCCMPFieldMetaData result = entity.getCMPFieldByName(fieldName); if (result == null) result = new JDBCCMPFieldMetaData(entity, fieldName, fieldType, columnName, jdbcType, sqlType); return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
private void initFromString(String sql) throws DeploymentException { ArrayList chunkList = new ArrayList(); ArrayList parameterList = new ArrayList(); // add a dummy chunk so we can be assured that the sql started with chunk before a number if(sql.charAt(0) == '?') { chunkList.add(""); } // break the sql into chunks and parameters StringBuffer chunk = new StringBuffer(); StringReader reader = new StringReader(sql); try { for(int c = reader.read(); c >= 0; c = reader.read()) { if(c != '?') { chunk.append((char)c); } else { chunkList.add(chunk.toString()); chunk = new StringBuffer(); // read the number StringBuffer number = new StringBuffer(); for(int digit = reader.read(); digit >= 0; digit = reader.read()) { if(Character.isDigit((char)digit)) { number.append((char)digit); } else { if(digit >= 0) { chunk.append((char)digit); } break; } } if(number.length() == 0) { throw new DeploymentException("Invalid parameter in function-sql: " + sql); } Integer parameter; try { parameter = new Integer(number.toString()); } catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); } parameterList.add(parameter); } } } catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); } chunkList.add(chunk.toString()); // save out the chunks sqlChunks = new String[chunkList.size()]; chunkList.toArray(sqlChunks); // save out the parameter order parameters = new int[parameterList.size()]; for(int i = 0; i < parameters.length; i++) { parameters[i] = ((Integer)parameterList.get(i)).intValue() - 1; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
public static JDBCQueryMetaData createJDBCQueryMetaData(JDBCQueryMetaData jdbcQueryMetaData, JDBCReadAheadMetaData readAhead, Class qlCompiler) throws DeploymentException { // RAW-SQL if(jdbcQueryMetaData instanceof JDBCRawSqlQueryMetaData) { return new JDBCRawSqlQueryMetaData(jdbcQueryMetaData.getMethod(), qlCompiler, false); } // JBOSS-QL if(jdbcQueryMetaData instanceof JDBCJBossQLQueryMetaData) { return new JDBCJBossQLQueryMetaData( (JDBCJBossQLQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // DYNAMIC-SQL if(jdbcQueryMetaData instanceof JDBCDynamicQLQueryMetaData) { return new JDBCDynamicQLQueryMetaData( (JDBCDynamicQLQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // DECLARED-SQL if(jdbcQueryMetaData instanceof JDBCDeclaredQueryMetaData) { return new JDBCDeclaredQueryMetaData( (JDBCDeclaredQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // EJB-QL: default if(jdbcQueryMetaData instanceof JDBCQlQueryMetaData) { return new JDBCQlQueryMetaData( (JDBCQlQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } throw new DeploymentException( "Error in query specification for method " + jdbcQueryMetaData.getMethod().getName() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private JDBCQueryMetaData createJDBCQueryMetaData(JDBCQueryMetaData jdbcQueryMetaData, Element queryElement, Method method, JDBCReadAheadMetaData readAhead) throws DeploymentException { final Class qlCompiler = JDBCQueryManager.getQLCompiler(queryElement, entity); final boolean isResultTypeMappingLocal = (jdbcQueryMetaData == null ? false : jdbcQueryMetaData.isResultTypeMappingLocal()); final boolean lazyResultSetLoading = Collection.class.isAssignableFrom(method.getReturnType()) && MetaData.getOptionalChildBooleanContent(queryElement, "lazy-resultset-loading"); // RAW-SQL Element rawSql = MetaData.getOptionalChild(queryElement, "raw-sql"); if(rawSql != null) { return new JDBCRawSqlQueryMetaData(method, qlCompiler, lazyResultSetLoading); } // JBOSS-QL Element jbossQL = MetaData.getOptionalChild(queryElement, "jboss-ql"); if(jbossQL != null) { return new JDBCJBossQLQueryMetaData( isResultTypeMappingLocal, jbossQL, method, readAhead, qlCompiler, lazyResultSetLoading ); } // DYNAMIC-SQL Element dynamicQL = MetaData.getOptionalChild(queryElement, "dynamic-ql"); if(dynamicQL != null) { return new JDBCDynamicQLQueryMetaData(isResultTypeMappingLocal, method, readAhead, qlCompiler, lazyResultSetLoading); } // DECLARED-SQL Element delcaredSql = MetaData.getOptionalChild(queryElement, "declared-sql"); if(delcaredSql != null) { return new JDBCDeclaredQueryMetaData( isResultTypeMappingLocal, delcaredSql, method, readAhead, qlCompiler, lazyResultSetLoading ); } // EJB-QL: default if(jdbcQueryMetaData instanceof JDBCQlQueryMetaData) { return new JDBCQlQueryMetaData( (JDBCQlQueryMetaData) jdbcQueryMetaData, method, readAhead ); } throw new DeploymentException("Error in query specification for method " + method.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(Element queryElement) throws DeploymentException { // query-method sub-element Element queryMethod = MetaData.getUniqueChild(queryElement, "query-method"); // method name String methodName = MetaData.getUniqueChildContent(queryMethod, "method-name"); // method params ArrayList methodParams = new ArrayList(); Element methodParamsElement = MetaData.getUniqueChild(queryMethod, "method-params"); Iterator iterator = MetaData.getChildrenByTagName(methodParamsElement, "method-param"); while(iterator.hasNext()) { methodParams.add(MetaData.getElementContent((Element) iterator.next())); } try { Class[] parameters = Classes.convertToJavaClasses(methodParams.iterator(), entity.getClassLoader()); return getQueryMethods(methodName, parameters); } catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(QueryMetaData queryData) throws DeploymentException { String methodName = queryData.getMethodName(); try { Class[] parameters = Classes.convertToJavaClasses(queryData.getMethodParams(), entity.getClassLoader()); return getQueryMethods(methodName, parameters); } catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(String methodName, Class parameters[]) throws DeploymentException { // find the query and load the xml ArrayList methods = new ArrayList(2); if(methodName.startsWith("ejbSelect")) { // bean method Method method = getQueryMethod(methodName, parameters, entity.getEntityClass()); if(method != null) { methods.add(method); } } else { // remote home Class homeClass = entity.getHomeClass(); if(homeClass != null) { Method method = getQueryMethod(methodName, parameters, homeClass); if(method != null) { methods.add(method); } } // local home Class localHomeClass = entity.getLocalHomeClass(); if(localHomeClass != null) { Method method = getQueryMethod(methodName, parameters, localHomeClass); if(method != null) { methods.add(method); } } } if(methods.size() == 0) { StringBuffer sb = new StringBuffer(300); sb.append("Query method not found: ") .append(methodName).append('('); for(int i = 0; i < parameters.length; i++) { if(i > 0) { sb.append(','); } sb.append(parameters[i].getName()); } sb.append(')'); throw new DeploymentException(sb.toString()); } return (Method[]) methods.toArray(new Method[methods.size()]); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected void setSelectEntity(JDBCEntityBridge selectEntity) throws DeploymentException { if(queryMetaData.getMethod().getName().startsWith("find") && this.selectEntity != null && this.selectEntity != selectEntity) { throw new DeploymentException("Finder " + queryMetaData.getMethod().getName() + " defined on " + this.selectEntity.getEntityName() + " should return only instances of " + this.selectEntity.getEntityName() + " but the query results in instances of " + selectEntity.getEntityName()); } this.selectField = null; this.selectFunction = null; this.selectEntity = selectEntity; this.selectManager = (JDBCStoreManager) selectEntity.getManager(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected String parseParameters(String sql) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); ArrayList params = new ArrayList(); // Replace placeholders {0} with ? if(sql != null) { sql = sql.trim(); StringTokenizer tokens = new StringTokenizer(sql, "{}", true); while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); if(token.equals("{")) { token = tokens.nextToken(); if(Character.isDigit(token.charAt(0))) { QueryParameter parameter = new QueryParameter(selectManager, queryMetaData.getMethod(), token); // of if we are here we can assume that we have // a parameter and not a function sqlBuf.append("?"); params.add(parameter); if(!tokens.nextToken().equals("}")) { throw new DeploymentException("Invalid parameter - missing closing '}' : " + sql); } } else { // ok we don't have a parameter, we have a function // push the tokens on the buffer and continue sqlBuf.append("{").append(token); } } else { // not parameter... just append it sqlBuf.append(token); } } } parameters = params; return sqlBuf.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public static List getLeftJoinCMRNodes(JDBCEntityBridge entity, String path, Iterator leftJoinIter, Set declaredPaths) throws DeploymentException { List leftJoinCMRNodes; if(leftJoinIter.hasNext()) { leftJoinCMRNodes = new ArrayList(); while(leftJoinIter.hasNext()) { JDBCLeftJoinMetaData leftJoin = (JDBCLeftJoinMetaData) leftJoinIter.next(); JDBCCMRFieldBridge cmrField = entity.getCMRFieldByName(leftJoin.getCmrField()); if(cmrField == null) { throw new DeploymentException("cmr-field in left-join was not found: cmr-field=" + leftJoin.getCmrField() + ", entity=" + entity.getEntityName()); } List subNodes; JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity(); String childPath = path + '.' + cmrField.getFieldName(); if(declaredPaths != null) { declaredPaths.add(childPath); } subNodes = getLeftJoinCMRNodes(relatedEntity, childPath, leftJoin.getLeftJoins(), declaredPaths); boolean[] mask = relatedEntity.getLoadGroupMask(leftJoin.getEagerLoadGroup()); LeftJoinCMRNode node = new LeftJoinCMRNode(childPath, cmrField, mask, subNodes); leftJoinCMRNodes.add(node); } } else { leftJoinCMRNodes = Collections.EMPTY_LIST; } return leftJoinCMRNodes; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public static final CMPFieldStateFactory getCMPFieldStateFactory(JDBCTypeFactory factory, String implClassName, Class clazz) throws DeploymentException { CMPFieldStateFactory stateFactory; // if the state factory is not provided on the field level use the one from the user type mapping if any if(implClassName == null) { JDBCUserTypeMappingMetaData userMapping = (JDBCUserTypeMappingMetaData)factory.userTypeMappings.get(clazz.getName()); if(userMapping != null) { implClassName = userMapping.getStateFactory(); } } if(implClassName != null) { try { Class implClass = TCLAction.UTIL.getContextClassLoader().loadClass(implClassName); stateFactory = (CMPFieldStateFactory)implClass.newInstance(); } catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); } catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); } } else if(Map.class.isAssignableFrom(clazz)) { stateFactory = MAP; } else if(List.class.isAssignableFrom(clazz)) { stateFactory = LIST; } else if(Set.class.isAssignableFrom(clazz)) { stateFactory = SET; } else if(clazz.isArray()) { stateFactory = ARRAY; } else if(usedWithEqualsStateFactory(clazz)) { stateFactory = EQUALS; } else { stateFactory = INVALID_UNLESS_NULL; } return stateFactory; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private JDBCTypeSimple createTypeSimple(JDBCCMPFieldMetaData cmpField) throws DeploymentException { String columnName = cmpField.getColumnName(); Class javaType = cmpField.getFieldType(); JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType); String paramSetter = typeMappingMD.getParamSetter(); String resultReader = typeMappingMD.getResultReader(); int jdbcType; String sqlType = cmpField.getSQLType(); if(sqlType != null) { jdbcType = cmpField.getJDBCType(); } else { // get jdbcType and sqlType from typeMapping sqlType = typeMappingMD.getSqlType(); jdbcType = typeMappingMD.getJdbcType(); } boolean notNull = cmpField.isNotNull(); boolean autoIncrement = cmpField.isAutoIncrement(); Mapper mapper = null; JDBCUserTypeMappingMetaData userTypeMapping = (JDBCUserTypeMappingMetaData)userTypeMappings.get(javaType.getName()); if(userTypeMapping != null) { String mappedTypeStr = userTypeMapping.getMappedType(); try { final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader(); Class mapperClass = contextClassLoader.loadClass(userTypeMapping.getMapper()); mapper = (Mapper)mapperClass.newInstance(); javaType = contextClassLoader.loadClass(mappedTypeStr); if(cmpField.getSQLType() == null) { JDBCMappingMetaData mappingMD = typeMapping.getTypeMappingMetaData(javaType); sqlType = mappingMD.getSqlType(); jdbcType = mappingMD.getJdbcType(); paramSetter = mappingMD.getParamSetter(); resultReader = mappingMD.getResultReader(); } } catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); } catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); } } JDBCParameterSetter paramSetterImpl; if(paramSetter == null) { paramSetterImpl = JDBCUtil.getParameterSetter(jdbcType, javaType); } else { paramSetterImpl = (JDBCParameterSetter)newInstance(paramSetter); } JDBCResultSetReader resultReaderImpl; if(resultReader == null) { resultReaderImpl = JDBCUtil.getResultSetReader(jdbcType, javaType); } else { resultReaderImpl = (JDBCResultSetReader)newInstance(resultReader); } return new JDBCTypeSimple( columnName, javaType, jdbcType, sqlType, notNull, autoIncrement, mapper, paramSetterImpl, resultReaderImpl ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private Object newInstance(String className) throws DeploymentException { Class clazz = loadClass(className); try { return clazz.newInstance(); } catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private Class loadClass(String className) throws DeploymentException { try { final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader(); return contextClassLoader.loadClass(className); } catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCreateBeanClassInstanceCommand.java
private Map createFieldMap() throws DeploymentException { Map abstractAccessors = getAbstractAccessors(); List fields = entityBridge.getFields(); Map map = new HashMap(fields.size() * 2); for(int i = 0; i < fields.size(); i++) { FieldBridge field = (FieldBridge) fields.get(i); // get the names String fieldName = field.getFieldName(); String fieldBaseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getterName = "get" + fieldBaseName; String setterName = "set" + fieldBaseName; // get the accessor methods Method getterMethod = (Method) abstractAccessors.get(getterName); Method setterMethod = (Method) abstractAccessors.get(setterName); // getters and setters must come in pairs if(getterMethod != null && setterMethod == null) { throw new DeploymentException("Getter was found but no setter was found for field " + fieldName + " in entity " + entityBridge.getEntityName()); } else if(getterMethod == null && setterMethod != null) { throw new DeploymentException("Setter was found but no getter was found for field " + fieldName + " in entity " + entityBridge.getEntityName()); } else if(getterMethod != null && setterMethod != null) { // add methods map.put(getterMethod.getName(), new EntityBridgeInvocationHandler.FieldGetInvoker(field)); map.put(setterMethod.getName(), new EntityBridgeInvocationHandler.FieldSetInvoker(field)); // remove the accessors (they have been used) abstractAccessors.remove(getterName); abstractAccessors.remove(setterName); } } return Collections.unmodifiableMap(map); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void alterTable(DataSource dataSource, JDBCFunctionMappingMetaData mapping, String tableName, String fieldName, String fieldStructure) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); mapping.getFunctionSql( new String[]{tableName, fieldName, fieldStructure}, sqlBuf ); String sql = sqlBuf.toString(); if(log.isDebugEnabled()) log.debug("Executing: " + sql); // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); } try { Connection con = null; Statement statement = null; try { con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); } } // success if ( log.isDebugEnabled() ) log.debug("Table altered successfully."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createTable(DataSource dataSource, String tableName, String sql) throws DeploymentException { // does this table already exist if(SQLUtil.tableExists(tableName, dataSource)) { log.debug("Table '" + tableName + "' already exists"); return; } // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); } try { Connection con = null; Statement statement = null; try { // execute sql if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } // success Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); createdTables.add(tableName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createIndex(DataSource dataSource, String tableName, String indexName, String sql) throws DeploymentException { // we are only called directly after creating a table // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); } try { Connection con = null; Statement statement = null; try { // execute sql if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void issuePostCreateSQL(DataSource dataSource, List sql, String table) throws DeploymentException { if(sql == null) { // no work to do. log.trace("issuePostCreateSQL: sql is null"); return; } log.debug("issuePostCreateSQL::sql: " + sql.toString() + " on table " + table); TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); } String currentCmd = ""; try { Connection con = null; Statement statement = null; try { con = dataSource.getConnection(); statement = con.createStatement(); // execute sql for(int i = 0; i < sql.size(); i++) { currentCmd = (String) sql.get(i); /* * Replace %%t in the sql command with the current table name */ currentCmd = replaceTable(currentCmd, table); currentCmd = replaceIndexCounter(currentCmd); log.debug("Executing SQL: " + currentCmd); statement.executeUpdate(currentCmd); } } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } } // success log.debug("Issued SQL " + sql + " successfully."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addForeignKeyConstraint(DataSource dataSource, String tableName, String cmrFieldName, JDBCFieldBridge[] fields, String referencesTableName, JDBCFieldBridge[] referencesFields) throws DeploymentException { // can only alter tables we created Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); if(!createdTables.contains(tableName)) { return; } JDBCFunctionMappingMetaData fkConstraint = manager.getMetaData().getTypeMapping().getFkConstraintTemplate(); if(fkConstraint == null) { throw new IllegalStateException("Foreign key constraint is not allowed for this type of datastore"); } String a = SQLUtil.getColumnNamesClause(fields, new StringBuffer(50)).toString(); String b = SQLUtil.getColumnNamesClause(referencesFields, new StringBuffer(50)).toString(); String[] args = new String[]{ tableName, SQLUtil.fixConstraintName("fk_" + tableName + "_" + cmrFieldName, dataSource), a, referencesTableName, b}; String sql = fkConstraint.getFunctionSql(args, new StringBuffer(100)).toString(); // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); } try { Connection con = null; Statement statement = null; try { if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private JDBCEntityMetaData loadJDBCEntityMetaData() throws DeploymentException { ApplicationMetaData amd = container.getBeanMetaData().getApplicationMetaData(); // Get JDBC MetaData JDBCApplicationMetaData jamd = (JDBCApplicationMetaData)amd.getPluginData(CMP_JDBC); if(jamd == null) { // we are the first cmp entity to need jbosscmp-jdbc. // Load jbosscmp-jdbc.xml for the whole application JDBCXmlFileLoader jfl = new JDBCXmlFileLoader(container, log); jamd = jfl.load(); amd.addPluginData(CMP_JDBC, jamd); } // Get JDBC Bean MetaData String ejbName = container.getBeanMetaData().getEjbName(); JDBCEntityMetaData metadata = jamd.getBeanByEjbName(ejbName); if(metadata == null) { throw new DeploymentException("No metadata found for bean " + ejbName); } return metadata; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeclaredSQLQuery.java
private void initSelectObject(JDBCStoreManager manager) throws DeploymentException { String entityName = metadata.getEJBName(); // if no name is specified we are done if(entityName == null) { return; } Catalog catalog = manager.getCatalog(); JDBCEntityBridge entity = (JDBCEntityBridge)catalog.getEntityByEJBName(entityName); if(entity == null) { throw new DeploymentException("Unknown entity: " + entityName); } String fieldName = metadata.getFieldName(); if(fieldName == null) { setSelectEntity(entity); } else { JDBCCMPFieldBridge field = entity.getCMPFieldByName(fieldName); if(field == null) { throw new DeploymentException("Unknown cmp field: " + fieldName); } setSelectField(field); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCCreateCommand createCreateEntityCommand() throws DeploymentException { JDBCCreateCommand cec; try { cec = (JDBCCreateCommand)manager.getMetaData(). getEntityCommand().getCommandClass().newInstance(); cec.init(manager); } catch(DeploymentException de) { throw de; } catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); } if(log.isDebugEnabled()) log.debug("entity-command: " + manager.getMetaData().getEntityCommand()); return cec; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public static final Class getQLCompiler(Element query, JDBCEntityMetaData entity) throws DeploymentException { String compiler = MetaData.getOptionalChildContent(query, "ql-compiler"); Class impl; if(compiler == null || compiler.trim().length() == 0) { impl = entity.getQLCompiler(); } else { try { impl = TCLAction.UTIL.getContextClassLoader().loadClass(compiler); } catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); } } return impl; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public static final QLCompiler getInstance(Class impl, Catalog catalog) throws DeploymentException { if(impl == null) { throw new DeploymentException("ql-compiler is not specified."); } final Constructor constructor; try { constructor = impl.getConstructor(new Class[]{Catalog.class}); } catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); } try { return (QLCompiler)constructor.newInstance(new Object[]{catalog}); } catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public void start() throws DeploymentException { Logger log = Logger.getLogger( this.getClass().getName() + "." + manager.getMetaData().getName()); JDBCCommandFactory factory = manager.getCommandFactory(); Class homeClass = manager.getContainer().getHomeClass(); Class localHomeClass = manager.getContainer().getLocalHomeClass(); // // findByPrimaryKey // JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge(); if(homeClass != null) { try { // try to get the finder method on the home interface Method method = homeClass.getMethod(FIND_BY_PK, new Class[]{entity.getPrimaryKeyClass()}); JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method); JDBCReadAheadMetaData readAhead = (findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead()); // got it add it to known finders JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData( method, readAhead, entity.getMetaData().getQLCompiler(), false ); knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q)); if(log.isDebugEnabled()) log.debug("Added findByPrimaryKey query command for home interface"); } catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); } } if(localHomeClass != null) { Method method; try { // try to get the finder method on the local home interface method = localHomeClass.getMethod(FIND_BY_PK, new Class[] { entity.getPrimaryKeyClass() }); } catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } // got it add it to known finders JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method); JDBCReadAheadMetaData readAhead = (findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead()); JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false); knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q)); if(log.isDebugEnabled()) log.debug("Added findByPrimaryKey query command for local home interface"); } // // Custom finders - Overrides defined and automatic finders. // Class ejbClass = manager.getMetaData().getEntityClass(); Method[] customMethods = ejbClass.getMethods(); for (int i = 0; i < customMethods.length; i++) { Method m = customMethods[i]; String methodName = m.getName(); if(methodName.startsWith(EJB_FIND)) { String interfaceName = 'f' + methodName.substring(4); if(homeClass != null) { try { // try to get the finder method on the home interface Method interfaceMethod = homeClass.getMethod( interfaceName, m.getParameterTypes()); // got it add it to known finders knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m)); if(log.isDebugEnabled()) log.debug("Added custom finder " + methodName + " on home interface"); } catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface } } if(localHomeClass != null) { try { // try to get the finder method on the local home interface Method interfaceMethod = localHomeClass.getMethod( interfaceName, m.getParameterTypes()); // got it add it to known finders knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m)); if(log.isDebugEnabled()) log.debug("Added custom finder " + methodName + " on local home interface"); } catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface } } } } // // Defined finders - Overrides automatic finders. // Iterator definedFinders = manager.getMetaData().getQueries().iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData q = (JDBCQueryMetaData)definedFinders.next(); if(!knownQueries.containsKey(q.getMethod()) ) { if(q instanceof JDBCJBossQLQueryMetaData) { knownQueries.put(q.getMethod(), factory.createJBossQLQuery(q)); } else if(q instanceof JDBCDynamicQLQueryMetaData) { knownQueries.put(q.getMethod(), factory.createDynamicQLQuery(q)); } else if(q instanceof JDBCDeclaredQueryMetaData) { knownQueries.put(q.getMethod(), factory.createDeclaredSQLQuery(q)); } else if(q instanceof JDBCQlQueryMetaData) { knownQueries.put(q.getMethod(), factory.createEJBQLQuery(q)); } } } // // Automatic finders - The last resort // if(homeClass != null) { addAutomaticFinders(manager, homeClass.getMethods(), log); } if(localHomeClass != null) { addAutomaticFinders(manager, localHomeClass.getMethods(), log); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String fixTableName(String tableName, DataSource dataSource) throws DeploymentException { // don't fix the quited table name char firstChar = tableName.charAt(0); if(firstChar == '"' || firstChar == '\'') { return tableName; } // Separate schema name and table name String strSchema = ""; int iIndex; if((iIndex = tableName.indexOf('.')) != -1) { strSchema = tableName.substring(0, iIndex); tableName = tableName.substring(iIndex + 1); } // check for SQL reserved word and escape it with prepending a "X" // IMHO one should reject reserved words and throw a // DeploymentException - pilhuhn if(rwords != null) { for(int i = 0; i < rwords.size(); i++) { if(((String)rwords.elementAt(i)).equalsIgnoreCase(tableName)) { tableName = "X" + tableName; break; } } } Connection con = null; try { con = dataSource.getConnection(); DatabaseMetaData dmd = con.getMetaData(); // fix length int maxLength = dmd.getMaxTableNameLength(); if(maxLength > 0 && tableName.length() > maxLength) { CRC32 crc = new CRC32(); crc.update(tableName.getBytes()); String nameCRC = Long.toString(crc.getValue(), 36); tableName = tableName.substring( 0, maxLength - nameCRC.length() - 2); tableName += "_" + nameCRC; } // fix case if(dmd.storesLowerCaseIdentifiers()) { tableName = tableName.toLowerCase(); } else if(dmd.storesUpperCaseIdentifiers()) { tableName = tableName.toUpperCase(); } // now put the schema name back on the table name if(strSchema.length() > 0) { tableName = strSchema + "." + tableName; } return tableName; } catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); } finally { JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static boolean tableExists(String tableName, DataSource dataSource) throws DeploymentException { Connection con = null; ResultSet rs = null; try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; String quote = dmd.getIdentifierQuoteString(); if(tableName.startsWith(quote)) { if(tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); if(dmd.storesLowerCaseQuotedIdentifiers()) tableName = tableName.toLowerCase(); else if(dmd.storesUpperCaseQuotedIdentifiers()) tableName = tableName.toUpperCase(); } else { if(dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if(dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); } // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getTables(catalog, schema, tableName, null); return rs.next(); } catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static OldColumns getOldColumns(String tableName, DataSource dataSource) throws DeploymentException { Connection con = null; ResultSet rs = null; ArrayList columnNames = new ArrayList(); ArrayList typeNames = new ArrayList(); ArrayList columnSizes = new ArrayList(); try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; String quote = dmd.getIdentifierQuoteString(); if (tableName.startsWith(quote)) { if (tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); if (dmd.storesLowerCaseQuotedIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseQuotedIdentifiers()) tableName = tableName.toUpperCase(); } else { if (dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); } // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getColumns(catalog, schema, tableName, null); while (rs.next()) { String columnName = rs.getString("COLUMN_NAME"); columnNames.add(columnName == null ? null : columnName.toUpperCase()); typeNames.add(rs.getString("TYPE_NAME")); columnSizes.add(new Integer(rs.getInt("COLUMN_SIZE"))); } return new OldColumns(columnNames, typeNames, columnSizes); } catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static OldIndexes getOldIndexes(String tableName, DataSource dataSource) throws DeploymentException { tableName = unquote(tableName, dataSource); Connection con = null; ResultSet rs = null; ArrayList indexNames = new ArrayList(); ArrayList columnNames = new ArrayList(); ArrayList ascDesc = new ArrayList(); try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; if (dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getIndexInfo(catalog, schema, tableName, false, false); while (rs.next()) { indexNames.add(rs.getString("INDEX_NAME")); columnNames.add(rs.getString("COLUMN_NAME")); ascDesc.add(rs.getString("ASC_OR_DESC")); } return new OldIndexes(indexNames, columnNames, ascDesc); } catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String unquote(String tableName, DataSource ds) throws DeploymentException { Connection con = null; try { con = ds.getConnection(); String quote = con.getMetaData().getIdentifierQuoteString(); if (tableName.startsWith(quote)) { if (tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); } } catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); } finally { JDBCUtil.safeClose(con); } return tableName; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static void dropTable(DataSource dataSource, String tableName) throws DeploymentException { Logger log = Logger.getLogger("CLEANER"); String sql = "DROP TABLE " + tableName; try { Connection con = null; Statement statement = null; try { // execute sql con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); } log.info("Dropped table "+tableName+" succesfuly"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void init() throws DeploymentException { try { InitialContext ic = new InitialContext(); dataSource = (DataSource)ic.lookup(metadata.getDataSourceName()); } catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); } qualifiedTableName = SQLUtil.fixTableName(metadata.getDefaultTableName(), dataSource); int dotIndex = qualifiedTableName.indexOf('.'); tableName = dotIndex == -1 ? qualifiedTableName : qualifiedTableName.substring(dotIndex + 1); // CMP fields loadCMPFields(metadata); // CMR fields loadCMRFields(metadata); // create locking field JDBCOptimisticLockingMetaData lockMetaData = metadata.getOptimisticLocking(); if(lockMetaData != null && lockMetaData.getLockingField() != null) { Integer strategy = lockMetaData.getLockingStrategy(); JDBCCMPFieldMetaData versionMD = lockMetaData.getLockingField(); versionField = getCMPFieldByName(versionMD.getFieldName()); boolean hidden = versionField == null; if(strategy == JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCLongVersionFieldBridge(manager, versionMD); else versionField = new JDBCLongVersionFieldBridge((JDBCCMP2xFieldBridge)versionField); } else if(strategy == JDBCOptimisticLockingMetaData.TIMESTAMP_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCTimestampVersionFieldBridge(manager, versionMD); else versionField = new JDBCTimestampVersionFieldBridge((JDBCCMP2xFieldBridge)versionField); } else if(strategy == JDBCOptimisticLockingMetaData.KEYGENERATOR_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCKeyGenVersionFieldBridge( manager, versionMD, lockMetaData.getKeyGeneratorFactory()); else versionField = new JDBCKeyGenVersionFieldBridge( (JDBCCMP2xFieldBridge)versionField, lockMetaData.getKeyGeneratorFactory()); } if(hidden) addCMPField(versionField); else tableFields[versionField.getTableIndex()] = versionField; } // audit fields JDBCAuditMetaData auditMetaData = metadata.getAudit(); if(auditMetaData != null) { JDBCCMPFieldMetaData auditField = auditMetaData.getCreatedPrincipalField(); if(auditField != null) { createdPrincipalField = getCMPFieldByName(auditField.getFieldName()); if(createdPrincipalField == null) { createdPrincipalField = new JDBCCMP2xFieldBridge(manager, auditField); addCMPField(createdPrincipalField); } } else { createdPrincipalField = null; } auditField = auditMetaData.getCreatedTimeField(); if(auditField != null) { createdTimeField = getCMPFieldByName(auditField.getFieldName()); if(createdTimeField == null) { createdTimeField = new JDBCCMP2xFieldBridge(manager, auditField, JDBCTypeFactory.EQUALS, false); addCMPField(createdTimeField); } else { // just to override state factory and check-dirty-after-get createdTimeField = new JDBCCMP2xFieldBridge( (JDBCCMP2xFieldBridge)createdTimeField, JDBCTypeFactory.EQUALS, false); tableFields[createdTimeField.getTableIndex()] = createdTimeField; } } else { createdTimeField = null; } auditField = auditMetaData.getUpdatedPrincipalField(); if(auditField != null) { updatedPrincipalField = getCMPFieldByName(auditField.getFieldName()); if(updatedPrincipalField == null) { updatedPrincipalField = new JDBCCMP2xUpdatedPrincipalFieldBridge(manager, auditField); addCMPField(updatedPrincipalField); } else { updatedPrincipalField = new JDBCCMP2xUpdatedPrincipalFieldBridge( (JDBCCMP2xFieldBridge)updatedPrincipalField); tableFields[updatedPrincipalField.getTableIndex()] = updatedPrincipalField; } } else { updatedPrincipalField = null; } auditField = auditMetaData.getUpdatedTimeField(); if(auditField != null) { updatedTimeField = getCMPFieldByName(auditField.getFieldName()); if(updatedTimeField == null) { updatedTimeField = new JDBCCMP2xUpdatedTimeFieldBridge(manager, auditField); addCMPField(updatedTimeField); } else { updatedTimeField = new JDBCCMP2xUpdatedTimeFieldBridge((JDBCCMP2xFieldBridge)updatedTimeField); tableFields[updatedTimeField.getTableIndex()] = updatedTimeField; } } else { updatedTimeField = null; } } // ejbSelect methods loadSelectors(metadata); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private boolean[] loadGroupMask(String groupName, boolean[] defaultGroup) throws DeploymentException { List fieldNames = metadata.getLoadGroup(groupName); boolean[] group = new boolean[tableFields.length]; if(defaultGroup != null) System.arraycopy(defaultGroup, 0, group, 0, group.length); for(Iterator iter = fieldNames.iterator(); iter.hasNext();) { String fieldName = (String)iter.next(); JDBCFieldBridge field = (JDBCFieldBridge)getFieldByName(fieldName); if(field == null) throw new DeploymentException( "Field " + fieldName + " not found for entity " + getEntityName()); if(field instanceof JDBCCMRFieldBridge) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)field; if(cmrField.hasForeignKey()) { JDBCCMPFieldBridge[] fkFields = (JDBCCMPFieldBridge[]) cmrField.getForeignKeyFields(); for(int i = 0; i < fkFields.length; ++i) { group[fkFields[i].getTableIndex()] = true; } } else { throw new DeploymentException("Only CMR fields that have " + "a foreign-key may be a member of a load group: " + "fieldName=" + fieldName); } } else { group[((JDBCCMPFieldBridge)field).getTableIndex()] = true; } } return group; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void resolveRelationship() throws DeploymentException { // // Set handles to the related entity's container, cache, // manager, and invoker // // Related Entity Name String relatedEntityName = metadata.getRelatedRole().getEntity().getName(); // Related Entity Catalog catalog = (Catalog) manager.getApplicationData("CATALOG"); relatedEntity = (JDBCEntityBridge) catalog.getEntityByEJBName(relatedEntityName); if(relatedEntity == null) { throw new DeploymentException("Related entity not found: " + "entity=" + entity.getEntityName() + ", " + "cmrField=" + getFieldName() + ", " + "relatedEntity=" + relatedEntityName); } // Related CMR Field JDBCCMRFieldBridge[] cmrFields = (JDBCCMRFieldBridge[]) relatedEntity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge cmrField = cmrFields[i]; if(metadata.getRelatedRole() == cmrField.getMetaData()) { relatedCMRField = cmrField; break; } } // if we didn't find the related CMR field throw an exception // with a detailed message if(relatedCMRField == null) { String message = "Related CMR field not found in " + relatedEntity.getEntityName() + " for relationship from"; message += entity.getEntityName() + "."; if(getFieldName() != null) { message += getFieldName(); } else { message += "<no-field>"; } message += " to "; message += relatedEntityName + "."; if(metadata.getRelatedRole().getCMRFieldName() != null) { message += metadata.getRelatedRole().getCMRFieldName(); } else { message += "<no-field>"; } throw new DeploymentException(message); } // Related Manager relatedManager = (JDBCStoreManager) relatedEntity.getManager(); // Related Container EntityContainer relatedContainer = relatedManager.getContainer(); this.relatedContainerRef = new WeakReference(relatedContainer); // related findByPrimaryKey Class homeClass = (relatedContainer.getLocalHomeClass() != null ? relatedContainer.getLocalHomeClass() : relatedContainer.getHomeClass()); try { relatedFindByPrimaryKey = homeClass.getMethod("findByPrimaryKey", new Class[]{relatedEntity.getPrimaryKeyClass()}); } catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); } // // Initialize the key fields // if(metadata.getRelationMetaData().isTableMappingStyle()) { // initialize relation table key fields Collection tableKeys = metadata.getKeyFields(); List keyFieldsList = new ArrayList(tableKeys.size()); // first phase is to create fk fields Map pkFieldsToFKFields = new HashMap(tableKeys.size()); for(Iterator i = tableKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData) i.next(); FieldBridge pkField = entity.getFieldByName(cmpFieldMetaData.getFieldName()); if(pkField == null) { throw new DeploymentException("Primary key not found for key-field " + cmpFieldMetaData.getFieldName()); } pkFieldsToFKFields.put(pkField, new JDBCCMP2xFieldBridge(manager, cmpFieldMetaData)); } // second step is to order fk fields to match the order of pk fields JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { Object fkField = pkFieldsToFKFields.get(pkFields[i]); if(fkField == null) { throw new DeploymentException("Primary key " + pkFields[i].getFieldName() + " is not mapped."); } keyFieldsList.add(fkField); } tableKeyFields = (JDBCCMP2xFieldBridge[]) keyFieldsList.toArray( new JDBCCMP2xFieldBridge[keyFieldsList.size()]); dataSource = metadata.getRelationMetaData().getDataSource(); } else { initializeForeignKeyFields(); dataSource = hasForeignKey() ? entity.getDataSource() : relatedEntity.getDataSource(); } // Fix table name // // This code doesn't work here... The problem each side will generate // the table name and this will only work for simple generation. qualifiedTableName = SQLUtil.fixTableName(metadata.getRelationMetaData().getDefaultTableName(), dataSource); tableName = SQLUtil.getTableNameWithoutSchema(qualifiedTableName); relationManager = relatedCMRField.initRelationManager(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
private KeyGenerator initKeyGenerator(String keygenFactoryName) throws DeploymentException { try { InitialContext ctx = new InitialContext(); KeyGeneratorFactory keygenFactory = (KeyGeneratorFactory)ctx.lookup(keygenFactoryName); return keygenFactory.getKeyGenerator(); } catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); } catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); ClassLoader loader = GetTCLAction.getContextClassLoader(); try { Class psClass = loader.loadClass(className); method = psClass.getMethod(methodName, null); } catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); } catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); } try { Class wrapperClass = loader.loadClass("org.jboss.resource.adapter.jdbc.StatementAccess"); getUnderlyingStatement = wrapperClass.getMethod("getUnderlyingStatement", null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); } catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { if (CONNECTION_PREPARE == null) { throw new DeploymentException("Create command requires JDBC 3.0 (JDK1.4+)"); } super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); String factoryName = entityCommand.getAttribute("key-generator-factory"); if(factoryName == null) { throw new DeploymentException("key-generator-factory attribute must be set for entity " + entity.getEntityName()); } try { KeyGeneratorFactory keyGeneratorFactory = (KeyGeneratorFactory) new InitialContext().lookup(factoryName); keyGenerator = keyGeneratorFactory.getKeyGenerator(); } catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); } catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { throw new DeploymentException("pk-sql attribute must be set for entity " + entity.getEntityName()); } if(debug) { log.debug("Generate PK sql is: " + pkSQL); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); ClassLoader loader = GetTCLAction.getContextClassLoader(); try { Class psClass = loader.loadClass(className); method = psClass.getMethod(methodName, null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); } catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); } try { Class wrapperClass = loader.loadClass("org.jboss.resource.adapter.jdbc.StatementAccess"); getUnderlyingStatement = wrapperClass.getMethod("getUnderlyingStatement", null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); } catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence = entityCommand.getAttribute("sequence"); if (sequence == null) { throw new DeploymentException("Sequence must be specified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence_name = entityCommand.getAttribute("sequence_name"); if (sequence_name == null) { throw new DeploymentException("sequence_name attribute must be specified inside <entity-command>"); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
public void importXml(Element element) throws DeploymentException { String maximumSize = MetaData.getElementContent(MetaData.getUniqueChild(element, "MaximumSize")); try { this.maxSize = Integer.parseInt(maximumSize); } catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); } // Get whether the pool will block when MaximumSize instances are active String strictValue = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictMaximumSize")); this.isStrict = Boolean.valueOf(strictValue); String delay = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictTimeout")); try { if( delay != null ) this.strictTimeout = Long.parseLong(delay); } catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); } }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
public void importXml(Element element) throws DeploymentException { super.importXml(element); String rp = MetaData.getElementContent(MetaData.getOptionalChild(element, "remover-period")); String ml = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-bean-life")); try { if (rp != null) { int p = Integer.parseInt(rp); if (p <= 0) { throw new DeploymentException("Remover period can't be <= 0"); } m_removerPeriod = p * 1000; } if (ml != null) { int a = Integer.parseInt(ml); if (a <= 0) { throw new DeploymentException("Max bean life can't be <= 0"); } m_maxBeanLife = a * 1000; } } catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); } }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { synchronized (this) { if ((sharedWebMetaData == null && webXml != null) || (sharedJBossWebMetaData == null && jbossWebXml != null)) { UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); SchemaBindingResolver resolver = SingletonSchemaResolverFactory .getInstance().getSchemaBindingResolver(); if (webXml != null) { try { sharedWebMetaData = (WebMetaData) unmarshaller.unmarshal(webXml, resolver); } catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); } } if (jbossWebXml != null) { try { sharedJBossWebMetaData = (JBossWebMetaData) unmarshaller.unmarshal(jbossWebXml, resolver); } catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); } } } } if (sharedWebMetaData != null || sharedJBossWebMetaData != null) { JBossWebMetaData clone = new JBoss60WebMetaData(); clone.merge(sharedJBossWebMetaData, sharedWebMetaData); unit.addAttachment(SHARED_JBOSSWEB_ATTACHMENT_NAME, clone); } }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public synchronized void stopModule() throws DeploymentException { String warURL = unit.getName(); try { WebApplication webApp = container.removeDeployedApp(warURL); if (deployment != null && webApp != null) { deployment.stop(unit, webApp); } else { log.debug("Failed to find deployer/deployment for war: " + warURL); } } catch (Exception e) { throw new DeploymentException("Error during stop", e); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
Override public void deploy(DeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException { log.debug("Begin deploy, " + metaData); // Merge any settings from the ear level JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class); if (earMetaData != null) { String path = unit.getRelativePath(); ModuleMetaData webModule = earMetaData.getModule(path); if (webModule != null) { // Check for a context-root setting String contextRoot = metaData.getContextRoot(); if (contextRoot == null) { WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue(); contextRoot = wmodule.getContextRoot(); metaData.setContextRoot(contextRoot); } // Add any alt-dd setting metaData.setAlternativeDD(webModule.getAlternativeDD()); } // Merge security domain/roles if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null) metaData.setSecurityDomain(earMetaData.getSecurityDomain()); // TODO metaData.mergeSecurityRoles(earMetaData.getSecurityRoles()); } try { /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since * the vfs deals with the distinction between a true directory, the only way we can tell from * this level of the api is to look for a url that ends in '/'. Here we assume that the name is * the root url. */ String warName = unit.getName(); /** * Ignore the jacc policy service bean */ if (warName.startsWith("jboss:") && warName.contains("id=")) return; if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit; VirtualFile root = vfsUnit.getRoot(); final URL expandedWarURL = root.getPhysicalFile().toURI().toURL(); // Map String warPathName = root.getPathName(); if (warPathName.endsWith("/") == false) warPathName += "/"; List<VirtualFile> classpathVFs = vfsUnit.getClassPath(); if (classpathVFs != null) { List<URL> classpath = new ArrayList<URL>(); for (VirtualFile vf : classpathVFs) { try { String path = vf.getPathName(); if (path.startsWith(warPathName)) { path = path.substring(warPathName.length()); URL pathURL = new URL(expandedWarURL, path); classpath.add(pathURL); } else { log.debug("Ignoring path element: " + vf); } } catch (Exception e) { log.debug("Ignoring path element: " + vf, e); } } unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath); } // Indicate that an expanded URL exists unit.addAttachment("org.jboss.web.expandedWarURL", expandedWarURL, URL.class); // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file String altDDPath = metaData.getAlternativeDD(); if (altDDPath != null) { // First see if this is already a war local dd VirtualFile altDD = vfsUnit.getMetaDataFile(altDDPath); if (altDD == null) { // Pass absolute paths through File file = new File(altDDPath); if (!file.exists() || !file.isAbsolute()) { // Should be an relative to the top deployment VFSDeploymentUnit topUnit = vfsUnit.getTopLevel(); if (topUnit == unit) throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path"); altDD = topUnit.getFile(altDDPath); if (altDD == null) throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path"); VirtualFile altDDFile = root.getChild("WEB-INF/" + altDD.getName()); log.debug("Copying the altDD to: " + altDDFile); VFSUtils.writeFile(altDDFile, altDD.openStream()); metaData.setAlternativeDD(altDDFile.getPathName()); } } } } ClassLoadingMetaData classLoading = metaData.getClassLoading(); if (classLoading == null) classLoading = new ClassLoadingMetaData(); // pass in the java2ClassLoadingCompliance if it was not set at the war level if (classLoading.wasJava2ClassLoadingComplianceSet() == false) classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance); metaData.setClassLoading(classLoading); // Build the context root if its not been set or is specified at the ear String webContext = metaData.getContextRoot(); webContext = buildWebContext(webContext, warName, metaData, unit); metaData.setContextRoot(webContext); AbstractWarDeployment deployment = getDeployment(unit, metaData); deployment.setMainDeployer(mainDeployer); // TODO: until deployment is a MC bean deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver); deployWebModule(unit, metaData, deployment); } catch (Exception e) { throw new DeploymentException("Failed to create web module", e); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
public void build(DeploymentUnit unit, Set<String> outputs, Map<String, ManagedObject> managedObjects) throws DeploymentException { JBossWebMetaData meta = unit.getAttachment(JBossWebMetaData.class); if (meta == null) return; ManagedObject mo = ManagedObjectFactory.getInstance().createManagedObject(ContextMO.class); if (mo == null) throw new DeploymentException("could not create managed object"); mo.getProperty("contextRoot").setValue(SimpleValueSupport.wrap(meta.getContextRoot())); managedObjects.put("ContextMO", mo); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
public void deploy(final DeploymentUnit unit) throws DeploymentException { // we require a VFSDeploymentUnit, to be able to pick up context relative // config files if (unit instanceof VFSDeploymentUnit == false) { return; } final VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; // get hold of the parsed web.xml metadata WebMetaData webMetaData = unit.getAttachment(WebMetaData.class); // shouldn't really happen, because we have set WebMetaData as a required input. if (webMetaData == null) { return; } List<ParamValueMetaData> contextParams = webMetaData.getContextParams(); if (contextParams == null || contextParams.isEmpty()) { return; } JSFDeployment jsfDeployment = vfsDeploymentUnit.getAttachment(JSFDeployment.class); if (jsfDeployment == null) { // create and attach jsfDeployment = new JSFDeployment(); vfsDeploymentUnit.addAttachment(JSFDeployment.class, jsfDeployment); } for (ParamValueMetaData contextParam : contextParams) { if (contextParam == null) { continue; } if (JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME.equals(contextParam.getParamName())) { try { logger.debug("Found " + JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME + " param with values: " + contextParam.getParamValue() + " in unit " + vfsDeploymentUnit); // process each of the paths specified in the context param value this.processConfigFilesContextParamValue(vfsDeploymentUnit, jsfDeployment, contextParam.getParamValue()); } catch (Exception e) { throw new DeploymentException(e); } } } }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (!unit.getSimpleName().endsWith(".war")) { return; } synchronized (this) { if (sharedTldMetaData == null && tldJars != null) { UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); SchemaBindingResolver resolver = SingletonSchemaResolverFactory .getInstance().getSchemaBindingResolver(); // Parse shared JARs for TLDs sharedTldMetaData = new ArrayList<TldMetaData>(); if (tldJars != null) { VirtualFileFilter tldFilter = new SuffixMatchFilter(".tld", VisitorAttributes.DEFAULT); for (URL tldJar : tldJars) { try { VirtualFile virtualFile = VFS.getChild(tldJar); VirtualFile metaInf = virtualFile.getChild("META-INF"); if (metaInf != null) { List<VirtualFile> tlds = metaInf.getChildren(tldFilter); for (VirtualFile tld : tlds) { TldMetaData tldMetaData = (TldMetaData) unmarshaller.unmarshal(tld.toURL().toString(), resolver); sharedTldMetaData.add(tldMetaData); } } } catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); } } } } } if (sharedTldMetaData != null) { List<TldMetaData> clone = new ArrayList<TldMetaData>(); clone.addAll(sharedTldMetaData); unit.addAttachment(SHARED_TLDS_ATTACHMENT_NAME, clone); } }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { WebMetaData specMetaData = unit.getAttachment(WebMetaData.class); JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); if(specMetaData == null && metaData == null) return; // Check metadata-complete (see AnnotationMetaDataDeployer) boolean isComplete = this.isMetaDataCompleteIsDefault(); if(specMetaData != null) { if (specMetaData instanceof Web25MetaData) { isComplete |= ((Web25MetaData)specMetaData).isMetadataComplete(); } else if (specMetaData instanceof Web30MetaData) { isComplete |= ((Web30MetaData)specMetaData).isMetadataComplete(); } else { // Any web.xml 2.4 or earlier deployment is metadata complete isComplete = true; } } // Find all fragments that have been processed by deployers, and place them in a map keyed by location LinkedList<String> order = new LinkedList<String>(); List<WebOrdering> orderings = new ArrayList<WebOrdering>(); HashSet<String> jarsSet = new HashSet<String>(); Set<VirtualFile> overlays = new HashSet<VirtualFile>(); Map<String, VirtualFile> scis = new HashMap<String, VirtualFile>(); VirtualFile webInfLib = null; boolean fragmentFound = false; HashMap<String, WebFragmentMetaData> webFragments = new HashMap<String, WebFragmentMetaData>(); if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit; webInfLib = vfsUnit.getFile("WEB-INF/lib"); if (webInfLib != null) { List<VirtualFile> jars = webInfLib.getChildren(); for (VirtualFile jar : jars) { jarsSet.add(jar.getName()); // Find overlays VirtualFile overlay = jar.getChild("META-INF/resources"); if (overlay.exists()) { overlays.add(overlay); } // Find ServletContainerInitializer services VirtualFile sci = jar.getChild("META-INF/services/javax.servlet.ServletContainerInitializer"); if (sci.exists()) { scis.put(jar.getName(), sci); } } } if (!isComplete) { String base = unit.getName(); int pos = base.indexOf(':'); if (pos > 0) { base = base.substring(pos); } Iterator<String> attachementNames = unit.getAttachments().keySet().iterator(); HashSet<String> jarsWithoutFragmentsSet = new HashSet<String>(); jarsWithoutFragmentsSet.addAll(jarsSet); while (attachementNames.hasNext()) { String location = attachementNames.next(); Object attachement = unit.getAttachment(location); if (attachement != null && attachement instanceof WebFragmentMetaData) { if (!location.startsWith(WebFragmentMetaData.class.getName() + ":")) { // If there is only one fragment, it will also get mapped as this attachement continue; } String relativeLocation = "/" + location.substring(WebFragmentMetaData.class.getName().length() + 1); String jarName = null; if (relativeLocation.startsWith("/WEB-INF/lib/")) { jarName = relativeLocation.substring("/WEB-INF/lib/".length()); pos = jarName.indexOf('/'); if (pos > 0) jarName = jarName.substring(0, pos); } if (jarName == null) { continue; } fragmentFound = true; WebFragmentMetaData fragmentMetaData = (WebFragmentMetaData) attachement; webFragments.put(jarName, fragmentMetaData); WebOrdering webOrdering = new WebOrdering(); webOrdering.setName(fragmentMetaData.getName()); webOrdering.setJar(jarName); jarsWithoutFragmentsSet.remove(jarName); if (fragmentMetaData.getOrdering() != null) { if (fragmentMetaData.getOrdering().getAfter() != null) { for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getAfter().getOrdering()) { if (orderingElementMetaData.isOthers()) { webOrdering.setAfterOthers(true); } else { webOrdering.addAfter(orderingElementMetaData.getName()); } } } if (fragmentMetaData.getOrdering().getBefore() != null) { for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getBefore().getOrdering()) { if (orderingElementMetaData.isOthers()) { webOrdering.setBeforeOthers(true); } else { webOrdering.addBefore(orderingElementMetaData.getName()); } } } } orderings.add(webOrdering); } } // If there is no fragment, still consider it for ordering as a // fragment specifying no name and no order for (String jarName : jarsWithoutFragmentsSet) { WebOrdering ordering = new WebOrdering(); ordering.setJar(jarName); orderings.add(ordering); } } } if (!fragmentFound) { // Drop the order as there is no fragment in the webapp orderings.clear(); } // Generate web fragments parsing order AbsoluteOrderingMetaData absoluteOrderingMetaData = null; if (!isComplete && specMetaData instanceof Web30MetaData) { absoluteOrderingMetaData = ((Web30MetaData) specMetaData).getAbsoluteOrdering(); } if (absoluteOrderingMetaData != null) { // Absolute ordering from web.xml, any relative fragment ordering is ignored int otherPos = -1; int i = 0; for (OrderingElementMetaData orderingElementMetaData : absoluteOrderingMetaData.getOrdering()) { if (orderingElementMetaData.isOthers()) { if (otherPos >= 0) { throw new DeploymentException("Duplicate others in absolute ordering"); } otherPos = i; } else { for (WebOrdering ordering : orderings) { if (orderingElementMetaData.getName().equals(ordering.getName())) { order.add(ordering.getJar()); jarsSet.remove(ordering.getJar()); break; } } } i++; } if (otherPos >= 0) { order.addAll(otherPos, jarsSet); jarsSet.clear(); } } else if (orderings.size() > 0) { // Resolve relative ordering try { resolveOrder(orderings, order); } catch (IllegalStateException e) { DeploymentException.rethrowAsDeploymentException("Invalid ordering", e); } jarsSet.clear(); } else { // No order specified order.addAll(jarsSet); jarsSet.clear(); unit.addAttachment(WEB_NOORDER_ATTACHMENT_NAME, Boolean.TRUE); } if (log.isDebugEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("Resolved order: [ "); for (String jar : order) { builder.append(jar).append(' '); } builder.append(']'); log.debug(builder.toString()); } unit.addAttachment(WEB_ORDER_ATTACHMENT_NAME, order); unit.addAttachment(WEB_OVERLAYS_ATTACHMENT_NAME, overlays); unit.addAttachment(WEB_SCIS_ATTACHMENT_NAME, scis); // The fragments and corresponding annotations will need to be merged in order // For each JAR in the order: // - Merge the annotation metadata into the fragment meta data // (unless the fragment exists and is meta data complete) // - Merge the fragment metadata into merged fragment meta data WebCommonMetaData mergedFragmentMetaData = new WebCommonMetaData(); if (specMetaData == null) { // If there is no web.xml, it has to be considered to be the latest version specMetaData = new Web30MetaData(); specMetaData.setVersion("3.0"); } String key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":classes"; // Augment with meta data from annotations in /WEB-INF/classes WebMetaData classesAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if (classesAnnotatedMetaData != null) { if (isComplete) { // Discard @WebFilter, @WebListener and @WebServlet classesAnnotatedMetaData.setFilters(null); classesAnnotatedMetaData.setFilterMappings(null); classesAnnotatedMetaData.setListeners(null); classesAnnotatedMetaData.setServlets(null); classesAnnotatedMetaData.setServletMappings(null); } specMetaData.augment(classesAnnotatedMetaData, null, true); } // Augment with meta data from fragments and annotations from the corresponding JAR for (String jar : order) { WebFragmentMetaData webFragmentMetaData = webFragments.get(jar); if (webFragmentMetaData == null) { webFragmentMetaData = new WebFragmentMetaData(); // Add non overriding default distributable flag webFragmentMetaData.setDistributable(new EmptyMetaData()); } key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":" + jar; WebMetaData jarAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if ((isComplete || webFragmentMetaData.isMetadataComplete()) && jarAnnotatedMetaData != null) { // Discard @WebFilter, @WebListener and @WebServlet jarAnnotatedMetaData.setFilters(null); jarAnnotatedMetaData.setFilterMappings(null); jarAnnotatedMetaData.setListeners(null); jarAnnotatedMetaData.setServlets(null); jarAnnotatedMetaData.setServletMappings(null); } if (jarAnnotatedMetaData != null) { // Merge annotations corresponding to the JAR webFragmentMetaData.augment(jarAnnotatedMetaData, null, true); } // Merge fragment meta data according to the conflict rules try { mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); } } // Augment with meta data from annotations from JARs excluded from the order for (String jar : jarsSet) { WebFragmentMetaData webFragmentMetaData = new WebFragmentMetaData(); // Add non overriding default distributable flag webFragmentMetaData.setDistributable(new EmptyMetaData()); key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":" + jar; WebMetaData jarAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if (jarAnnotatedMetaData != null) { // Discard @WebFilter, @WebListener and @WebServlet jarAnnotatedMetaData.setFilters(null); jarAnnotatedMetaData.setFilterMappings(null); jarAnnotatedMetaData.setListeners(null); jarAnnotatedMetaData.setServlets(null); jarAnnotatedMetaData.setServletMappings(null); } if (jarAnnotatedMetaData != null) { // Merge annotations corresponding to the JAR webFragmentMetaData.augment(jarAnnotatedMetaData, null, true); } // Merge fragment meta data according to the conflict rules try { mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); } } specMetaData.augment(mergedFragmentMetaData, null, true); // Override with meta data (JBossWebMetaData) // Create a merged view JBossWebMetaData mergedMetaData = new JBossWebMetaData(); mergedMetaData.merge(metaData, specMetaData); // Incorporate any ear level overrides DeploymentUnit topUnit = unit.getTopLevel(); if(topUnit != null && topUnit.getAttachment(JBossAppMetaData.class) != null) { JBossAppMetaData earMetaData = topUnit.getAttachment(JBossAppMetaData.class); // Security domain String securityDomain = earMetaData.getSecurityDomain(); if(securityDomain != null && mergedMetaData.getSecurityDomain() == null) mergedMetaData.setSecurityDomain(securityDomain); //Security Roles SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles(); if(earSecurityRolesMetaData != null) { SecurityRolesMetaData mergedSecurityRolesMetaData = mergedMetaData.getSecurityRoles(); if(mergedSecurityRolesMetaData == null) mergedMetaData.setSecurityRoles(earSecurityRolesMetaData); //perform a merge to rebuild the principalVersusRolesMap if(mergedSecurityRolesMetaData != null ) { mergedSecurityRolesMetaData.merge(mergedSecurityRolesMetaData, earSecurityRolesMetaData); } } } // Output the merged JBossWebMetaData unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, mergedMetaData); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void initInterceptorClasses() throws Exception { HashMap interceptors = new HashMap(); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element clientInterceptors = MetaData.getOptionalChild( proxyConfig, "client-interceptors", null ); if(clientInterceptors != null) { String value = MetaData.getElementAttribute(clientInterceptors, "exposeContainer"); this.includeIClientIface = Boolean.valueOf(value).booleanValue(); NodeList children = clientInterceptors.getChildNodes(); for(int i = 0; i < children.getLength(); i++) { Node currentChild = children.item(i); if(currentChild.getNodeType() == Node.ELEMENT_NODE) { Element interceptor = (Element) children.item(i); interceptors.put(interceptor.getTagName(), interceptor); } } } else { log.debug("client interceptors element is null"); } Element homeInterceptorConf = (Element) interceptors.get(HOME_INTERCEPTOR); loadInterceptorClasses(homeInterceptorClasses, homeInterceptorConf); if(homeInterceptorClasses.size() == 0) { throw new DeploymentException("There are no home interface interceptors configured"); } Element beanInterceptorConf = (Element) interceptors.get(BEAN_INTERCEPTOR); loadInterceptorClasses(beanInterceptorClasses, beanInterceptorConf); if(beanInterceptorClasses.size() == 0) { throw new DeploymentException("There are no bean interface interceptors configured"); } Element listEntityInterceptorConf = (Element) interceptors.get(LIST_ENTITY_INTERCEPTOR); loadInterceptorClasses(listEntityInterceptorClasses, listEntityInterceptorConf); }
122
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create EJB module " + unit.getName() + ": malformed EjbModule name", e); }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(NamingException e) { throw new DeploymentException("Filed to lookup: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to register table cache for " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/EJBQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
catch(FinderException e) { throw new DeploymentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JBossQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "alias-max-length " + aliasMaxLengthString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Failed to parse int value '" + str + "' for max-keys-in-delete", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCApplicationMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("Unable to load persistence manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCReadAheadMetaData.java
catch(NumberFormatException ex) { throw new DeploymentException("Invalid number format in read-ahead page-size '" + pageSizeStr + "': " + ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("entity class not found for ejb-name: " + entityName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "could not load primary key class: " + entity.getPrimaryKeyClass() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("home class not found: " + home); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "remote class not found: " + entity.getRemote() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local home class not found: " + localHome ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "local class not found: " + entity.getLocal() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in read-" + "ahead list-cache-max '" + listCacheMaxStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "fetch-size '" + fetchSizeStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException("could not load the class for " + " unknown primary key: " + unknownPkClass); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find getter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find setter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValueClassMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException("dependent-value-class not found: " + className); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityCommandMetaData.java
catch (ClassNotFoundException e) { throw new DeploymentException( "Could not load class: " + commandClassStr); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCJBossQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL " + "statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(NoSuchFieldException e) { // Non recoverable internal exception throw new DeploymentException("No field named '" + getFieldName() + "' found in entity class."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); }
// in src/main/java/org/jboss/web/deployers/WebModule.java
catch (Exception e) { throw new DeploymentException("Error during stop", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw new DeploymentException("Failed to create web module", e); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); }
307
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public static Document getDocument(URL url) throws DeploymentException { return getDocument(url, defaultValidateDTDs); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public static Document getDocument(URL url, boolean validateDTDs) throws DeploymentException { XmlFileLoader loader = new XmlFileLoader(validateDTDs); return loader.getDocumentFromURL(url); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocumentFromURL(URL url) throws DeploymentException { InputStream is = null; try { is = url.openStream(); return getDocument(is, url.toExternalForm()); } catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); } }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocument(InputStream is, String inPath) throws DeploymentException { InputSource is2 = new InputSource(is); is2.setSystemId(inPath); Document doc = null; try { doc = getDocument(is2, inPath); } finally { // close the InputStream to get around "too many open files" errors // with large heaps try { if( is != null ) is.close(); } catch (Exception e) { // ignore } } return doc; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public Document getDocument(InputSource is, String inPath) throws DeploymentException { try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); // Enable DTD validation based on our validateDTDs flag docBuilderFactory.setValidating(validateDTDs); // make the parser namespace-aware in case we deal // with ejb2.1 descriptors, will not break dtd parsing in any way // in which case there would be just a default namespace docBuilderFactory.setNamespaceAware(true); // this will (along JAXP in conjunction with // validation+namespace-awareness) enable xml schema checking. // Will currently fail because some J2EE1.4/W3C schemas // are still lacking. //docBuilderFactory.setAttribute // ("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema"); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); JBossEntityResolver lr = new JBossEntityResolver(); LocalErrorHandler eh = new LocalErrorHandler( inPath, lr ); docBuilder.setEntityResolver(lr); docBuilder.setErrorHandler(eh ); Document doc = docBuilder.parse(is); if(validateDTDs && eh.hadError()) { throw new DeploymentException("Invalid XML: file=" + inPath, eh.getException()); } return doc; } catch (DeploymentException e) { throw e; } catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); } catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); } catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); } }
// in src/main/java/org/jboss/deployment/J2eeModuleMetaData.java
public void importXml(Element rootElement) throws DeploymentException { String rootTag = rootElement.getOwnerDocument().getDocumentElement().getTagName(); if (rootTag.equals("application")) importXml(rootElement, false); else if (rootTag.equals("jboss-app")) importXml(rootElement, true); else throw new DeploymentException("Unrecognized root tag: " + rootTag); }
// in src/main/java/org/jboss/deployment/J2eeModuleMetaData.java
protected void importXml(Element element, boolean jbossSpecific) throws DeploymentException { String name = element.getTagName(); if (name.equals("module")) { boolean done = false; // only one of the tags can hit! for (int i = 0; done == false && i < tags.length; ++i) { Element child = getOptionalChild(element, tags[i]); if (child == null) { continue; } type = i; switch (type) { case SERVICE: if (jbossSpecific == false) { throw new DeploymentException("Service archives must be in jboss-app.xml"); } // end of if () //fall through. case HAR: if (jbossSpecific == false) { throw new DeploymentException("Hibernate archives must be in jboss-app.xml"); } case EJB: case CLIENT: case CONNECTOR: fileName = getElementContent(child); alternativeDD = getElementContent(getOptionalChild(element, "alt-dd")); break; case WEB: fileName = getElementContent(getUniqueChild(child, "web-uri")); webContext = getElementContent(getOptionalChild(child, "context-root")); alternativeDD = getElementContent(getOptionalChild(element, "alt-dd")); break; } done = true; } // If the module content is not recognized throw an exception if (done == false) { StringBuffer msg = new StringBuffer("Invalid module content, must be one of: "); for (int i = 0; i < tags.length; i ++) { msg.append(tags[i]); msg.append(", "); } throw new DeploymentException(msg.toString()); } } else { throw new DeploymentException("non-module tag in application dd: " + name); } }
// in src/main/java/org/jboss/deployment/EarClassLoaderDeployer.java
Override public void deploy(DeploymentUnit unit, JBossAppMetaData metaData) throws DeploymentException { ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class); if (classLoadingMetaData != null) return; LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository(); if (lrmd != null && LoaderRepositoryMetaDataHelper.create(unit, lrmd) != null) return; // For isolated automatically create the classloader in a new domain if (isolated) { String domain = null; // let's first try CLDomainMD ClassLoadingDomainMetaData cldmd = unit.getAttachment(ClassLoadingDomainMetaData.class); if (cldmd != null) { String name = cldmd.getName(); if (name == null || "<unknown>".equals(name)) domain = unit.getName(); else domain = name; } if (domain == null) { domain = EARDeployment.getJMXName(metaData, unit) + ",extension=LoaderRepository"; try { ObjectName canonical = ObjectName.getInstance(domain); domain = canonical.getCanonicalName(); } catch (MalformedObjectNameException ignored) { // Not a JMX ObjectName??? } } classLoadingMetaData = new ClassLoadingMetaData(); classLoadingMetaData.setName(unit.getName()); classLoadingMetaData.setDomain(domain); classLoadingMetaData.setExportAll(ExportAll.NON_EMPTY); classLoadingMetaData.setImportAll(true); classLoadingMetaData.setVersion(Version.DEFAULT_VERSION); classLoadingMetaData.setJ2seClassLoadingCompliance(false); unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData); } }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException { return create(unit, loaderMetaData, false); }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (unit == null) throw new IllegalArgumentException("Null unit"); ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class); if (clmd != null) return clmd; clmd = create(unit.getName(), loaderMetaData, parentDelegation); if (clmd != null) unit.addAttachment(ClassLoadingMetaData.class, clmd); return clmd; }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData) throws DeploymentException { return create(deploymentName, loaderMetaData, false); }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (deploymentName == null) throw new IllegalArgumentException("Null deployment name"); if (loaderMetaData == null) throw new IllegalArgumentException("Null loader repository metadata"); LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig(); repositoryConfig.repositoryClassName = loaderMetaData.getLoaderRepositoryClass(); if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0) repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS; // Get the object name of the repository String name = loaderMetaData.getName(); if (name != null) { try { repositoryConfig.repositoryName = new ObjectName(name.trim()); } catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); } } StringBuilder configData = new StringBuilder(); Set<LoaderRepositoryConfigMetaData> children = loaderMetaData.getLoaderRepositoryConfig(); if (children != null) { for (LoaderRepositoryConfigMetaData child : children) { // This looks stupid? Why inside a loop? String parserClassName = child.getConfigParserClass(); if (parserClassName == null || parserClassName.length() == 0) repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS; else repositoryConfig.configParserClassName = parserClassName; // Append all config String childConfig = child.getConfig(); if (childConfig != null) configData.append(childConfig); } } repositoryConfig.repositoryConfig = configData.toString().trim(); return LoaderRepositoryConfigHelper.create(name, repositoryConfig, parentDelegation); }
// in src/main/java/org/jboss/deployment/EARStructure.java
public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException { ContextInfo context; boolean valid; boolean trace = log.isTraceEnabled(); VirtualFile file = structureContext.getFile(); try { if (hasValidName(file) == false) return false; context = createContext(structureContext, "META-INF"); context.setComparatorClassName(comparatorClassName); VirtualFile applicationXml = getMetaDataFile(file, "META-INF/application.xml"); VirtualFile jbossAppXml = getMetaDataFile(file, "META-INF/jboss-app.xml"); VirtualFile lib; boolean scan = true; Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setValidation(useValidation); EarMetaData specMetaData = null; JBossAppMetaData appMetaData = null; if (applicationXml != null) { InputStream in = applicationXml.openStream(); try { specMetaData = (EarMetaData) unmarshaller.unmarshal(in, resolver); } finally { in.close(); } scan = false; } if (jbossAppXml != null) { InputStream in = jbossAppXml.openStream(); try { appMetaData = (JBossAppMetaData) unmarshaller.unmarshal(in, resolver); } finally { in.close(); } } // Need a metadata instance and there will not be one if there are no descriptors if (appMetaData == null) { appMetaData = new JBossAppMetaData(); } // Create the merged view appMetaData.merge(appMetaData, specMetaData); String libDir = appMetaData.getLibraryDirectory(); if (libDir == null || libDir.length() > 0) { if (libDir == null) libDir = "lib"; // Add the ear lib contents to the classpath if(trace) log.trace("Checking for ear lib directory: "+libDir); try { lib = file.getChild(libDir); if (lib.exists()) { if(trace) log.trace("Found ear lib directory: "+lib); List<VirtualFile> archives = lib.getChildren(earLibFilter); for (VirtualFile archive : archives) { Automounter.mount(file, archive); addClassPath(structureContext, archive, true, true, context); // add any jars with persistence.xml as a deployment VirtualFile child = archive.getChild("META-INF/persistence.xml"); if (child.exists()) { log.trace(archive.getName() + " in ear lib directory has persistence units"); addMetaDataPath(structureContext, context, child.getParent().getPathNameRelativeTo(file), MetaDataType.ALTERNATIVE); } else if (trace) log.trace(archive.getPathName() + " does not contain META-INF/persistence.xml"); } } else if (trace) log.trace("No lib directory in ear archive."); } catch (IOException e) { // TODO - should we throw this fwd? log.warn("Exception while searching for lib dir: " + e); } } else if (trace) { log.trace("Ignoring library directory, got empty library-directory element."); } // Add the ear manifest locations? addClassPath(structureContext, file, includeEarRootInClasspath, true, context); // TODO: need to scan for annotationss if( scan ) { scanEar(file, appMetaData); } // Create subdeployments for the ear modules ModulesMetaData modules = appMetaData.getModules(); if(modules != null) { for (ModuleMetaData mod : modules) { String fileName = mod.getFileName(); if (fileName != null && (fileName = fileName.trim()).length() > 0) { if (log.isTraceEnabled()) log.trace("Checking application.xml module: " + fileName); VirtualFile module = file.getChild(fileName); if (module.exists() == false) { throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + file.toURI()); } // Ask the deployers to analyze this if(structureContext.determineChildStructure(module) == false) { throw new RuntimeException(fileName + " module listed in application.xml is not a recognized deployment, .ear: " + file.getName()); } } } if (appMetaData.getModuleOrderEnum() == ModuleOrder.STRICT || (specMetaData instanceof Ear6xMetaData && ((Ear6xMetaData)specMetaData).getInitializeInOrder())) { context.setComparatorClassName(RelativeDeploymentContextComparator.class.getName()); int i = 0; for (ContextInfo ctx : structureContext.getMetaData().getContexts()) { ctx.setRelativeOrder(i++); } } } valid = true; } catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); } return valid; }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
protected void createMetaData(DeploymentUnit unit, Set<String> names, String suffix, String key) throws DeploymentException { // First see whether it already exists WebFragmentMetaData result = getMetaData(unit, key); if (result != null && allowsReparse() == false) return; // Create it try { result = parse(unit, getName(), suffix, result); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e); } // Doesn't exist if (result == null) return; // Register it unit.getTransientManagedObjects().addAttachment(key, result, getOutput()); }
// in src/main/java/org/jboss/deployment/ResourcesIndexDeployer.java
public void deploy(DeploymentUnit unit, JBossWebMetaData deployment) throws DeploymentException { AnnotationIndex ai = unit.getAttachment(AnnotationIndex.class); if (ai == null) return; HierarchyIndex hi = unit.getAttachment(HierarchyIndex.class); if (hi == null) return; ResourcesIndex ri = new DefaultResourcesIndex(ai, hi); unit.addAttachment(ResourcesIndex.class, ri); }
// in src/main/java/org/jboss/deployment/ResourceUtilSetupDeployer.java
Override public void deploy(DeploymentUnit unit, Module deployment) throws DeploymentException { unit.addAttachment(ReflectProvider.class, new CachingReflectProvider(provider)); // wrap with cache if (handler != null) unit.addAttachment(ErrorHandler.class, handler); if (finder != null) unit.addAttachment(ResourceOwnerFinder.class, finder); }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
Override protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException { super.createMetaData(unit, name, suffix); JBossMetaData jbossMetaData = unit.getAttachment(getOutput()); EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); if (ejbJarMetaData != null || jbossMetaData != null) { // Save this as a transient(non-managed) attachment // only for EJB2.x and earlier beans (since standardjboss.xml does not apply for EJB3.x and // later) if (this.isPreEJB3x(ejbJarMetaData, jbossMetaData)) { JBossMetaData stdMetaData = getStandardMetaData(); if(stdMetaData != null) unit.addAttachment("standardjboss.xml", stdMetaData); } if (jbossMetaData != null) { // For legacy - but its totally redundant???? ApplicationMetaData amd = new ApplicationMetaData(jbossMetaData); unit.addAttachment(ApplicationMetaData.class, amd); } } }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
private JBossMetaData getStandardMetaData() throws DeploymentException { if (standardMetaData == null) { try { if(standardJBossXmlPath == null) { // Use default server conf/standardjboss.xml location final String configPropName = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_CONF_URL; String configPath = System.getProperty(configPropName); if(configPath == null ) { if(ignoreMissingStandardJBossXml == false) throw new DeploymentException("standardjboss.xml not specified and "+configPropName+" does not exist"); return null; } URL configUrl = new URL(configPath); standardJBossXmlPath = new URL(configUrl, "standardjboss.xml"); } VirtualFile stdJBoss = VFS.getChild(standardJBossXmlPath); if (stdJBoss == null && ignoreMissingStandardJBossXml == false) { throw new DeploymentException("standardjboss.xml not found in config dir: " + standardJBossXmlPath); } standardMetaData = super.parse(stdJBoss); } catch (Exception ex) { DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex); } } return standardMetaData; }
// in src/main/java/org/jboss/deployment/ResourceUtilCleanupDeployer.java
public void deploy(DeploymentUnit unit, Module deployment) throws DeploymentException { ReflectProvider provider = unit.removeAttachment(ReflectProvider.class); if (provider != null && provider instanceof CachingReflectProvider) { CachingReflectProvider crp = (CachingReflectProvider)provider; crp.reset(); } }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
Override public void deploy(DeploymentUnit unit, JBossAppMetaData deployment) throws DeploymentException { //Perform JACC Policy Configuration String contextID = shortNameFromDeploymentName(unit.getSimpleName()); PolicyConfigurationFactory pcFactory = null; try { pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, true); unit.addAttachment(PolicyConfiguration.class, pc); } catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); } catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); } }
// in src/main/java/org/jboss/deployment/ReferenceMetaDataResolverDeployer.java
public void internalDeploy(DeploymentUnit unit) throws DeploymentException { JBossMetaData ejbMetaData = unit.getAttachment(JBossMetaData.class); JBossWebMetaData webMetaData = unit.getAttachment(JBossWebMetaData.class); JBossClientMetaData clientMetaData = unit.getAttachment(JBossClientMetaData.class); if(ejbMetaData == null && webMetaData == null && clientMetaData == null) return; // Create a map of the ejbs dump(unit); if(ejbMetaData != null) { JBossEnterpriseBeansMetaData beans = ejbMetaData.getEnterpriseBeans(); // Map the ejbs this.mapEjbs(unit.getRelativePath(), beans); // Process ejb references List<String> unresolvedPaths = resolve(unit, beans); if(unresolvedPaths != null && unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossMetaData: "+unresolvedPaths); } if(webMetaData != null) { // Process web app references List<String> unresolvedPaths = new ArrayList<String>(); resolve(unit, webMetaData.getJndiEnvironmentRefsGroup(), unresolvedPaths); if(unresolvedPaths != null && unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossWebMetaData: "+unresolvedPaths); } if(clientMetaData != null) { // Process client app references List<String> unresolvedPaths = new ArrayList<String>(); resolve(unit, clientMetaData.getJndiEnvironmentRefsGroup(), unresolvedPaths); if(unresolvedPaths != null && unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossClientMetaData: "+unresolvedPaths); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
public void internalDeploy(DeploymentUnit unit) throws DeploymentException { JBossMetaData ejbMetaData = unit.getAttachment(JBossMetaData.class); JBossWebMetaData webMetaData = unit.getAttachment(JBossWebMetaData.class); JBossClientMetaData clientMetaData = unit.getAttachment(JBossClientMetaData.class); if(ejbMetaData == null && webMetaData == null && clientMetaData == null) return; // Create a map of the reference endpoints if it does not exist in the top unit DeploymentUnit top = unit.getTopLevel(); Map<String, ContainerDependencyMetaData> endpointMap = top.getAttachment(ENDPOINT_MAP_KEY, Map.class); Map<String, String> endpointAlternateMap = top.getAttachment(ALTERNATE_MAP_KEY, Map.class); if(endpointMap == null) { endpointMap = new ConcurrentHashMap<String, ContainerDependencyMetaData>(); endpointAlternateMap = new ConcurrentHashMap<String, String>(); mapEndpoints(top, endpointMap, endpointAlternateMap); top.addAttachment(ENDPOINT_MAP_KEY, endpointMap, Map.class); top.addAttachment(ALTERNATE_MAP_KEY, endpointAlternateMap); DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver(endpointMap, endpointAlternateMap, unit.getRelativePath()); top.addAttachment(DeploymentEndpointResolver.class, resolver); } DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver( endpointMap, endpointAlternateMap, unit.getRelativePath()); List<String> unresolvedPaths = new ArrayList<String>(); if(ejbMetaData != null) { JBossEnterpriseBeansMetaData beans = ejbMetaData.getEnterpriseBeans(); // Process ejb references try { resolve(unit, endpointMap, beans, resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossMetaData:"+unresolvedPaths); } if(webMetaData != null) { // Process web app references ContainerDependencyMetaData webAppCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "web-app", unit.getRelativePath()); try { resolve(webAppCDMD, unit, endpointMap, webMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossWebMetaData:"+unresolvedPaths); } if(clientMetaData != null) { // Process client app references ContainerDependencyMetaData clientCDMD = new ContainerDependencyMetaData(unit.getSimpleName(), "client", unit.getRelativePath()); try { resolve(clientCDMD, unit, endpointMap, clientMetaData.getJndiEnvironmentRefsGroup(), resolver, unresolvedPaths); } catch (Exception e) { throw new DeploymentException(e); } if(unresolvedPaths.size() > 0) log.warn("Unresolved references exist in JBossClientMetaData: "+unresolvedPaths); } // Add the unique set of ContainerDependencyMetaData Set<ContainerDependencyMetaData> depends = new HashSet<ContainerDependencyMetaData>(); for(ContainerDependencyMetaData cdmd : endpointMap.values()) { depends.add(cdmd); } top.addAttachment(DEPENDS_SET_KEY, depends, Set.class); unit.addAttachment(DeploymentEndpointResolver.class, resolver); dump(unit); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { /* If there is a META-INF/application.xml we don't process this. */ if (unit.isAttachmentPresent(EarMetaData.class)) { log.tracef("Ignoring ear with META-INF/application.xml: %1s", unit.getSimpleName()); return; } // Ignore non-vfs deployments if (unit instanceof VFSDeploymentUnit == false) { log.tracef("Not a vfs deployment: %1s", unit.getName()); return; } // See if the suffix matches the .ear requirement if (requiresEarSuffix && unit.getSimpleName().endsWith(".ear") == false) { log.tracef("Unit name does not end in .ear: %1s", unit.getSimpleName()); return; } VFSDeploymentUnit vfsunit = VFSDeploymentUnit.class.cast(unit); deploy(vfsunit); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
public void deploy(VFSDeploymentUnit unit) throws DeploymentException { VirtualFile root = unit.getRoot(); String relativePath = unit.getRelativePath(); VirtualFile ear = unit.getFile(relativePath); if (ear == null) throw new DeploymentException("No such ear file, relative path: '" + relativePath + "', root: " + root); deploy(unit, root, ear); }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { PolicyConfiguration pc = unit.getAttachment(PolicyConfiguration.class); if (pc == null) return; DeploymentUnit parent = unit.getParent(); if (parent == null) throw new IllegalStateException("Unit has not parent: " + unit); PolicyConfiguration parentPc = parent.getAttachment(PolicyConfiguration.class); try { if (parentPc != null && pc != parentPc) { parentPc.linkConfiguration(pc); } pc.commit(); } catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); } }
// in src/main/java/org/jboss/deployment/PUHackDeployer.java
Override public void deploy(DeploymentUnit unit, PersistenceUnitMetaData deployment) throws DeploymentException { DeploymentUnit wrapper = wrap(unit); delegate.deploy(wrapper, deployment); }
// in src/main/java/org/jboss/deployment/PUHackDeployer.java
public boolean createClassLoader(ClassLoaderFactory factory) throws DeploymentException { return delegate.createClassLoader(factory); }
// in src/main/java/org/jboss/deployment/PUHackDeployer.java
public void visit(DeploymentUnitVisitor visitor) throws DeploymentException { delegate.visit(visitor); }
// in src/main/java/org/jboss/deployment/JBossAppParsingDeployer.java
Override protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException { EarMetaData specMetaData = unit.getAttachment(EarMetaData.class); JBossAppMetaData metaData = unit.getAttachment(JBossAppMetaData.class); // from ear contents deployer // do parse super.createMetaData(unit, name, suffix); // new parsed metadata JBossAppMetaData parsed = unit.getAttachment(JBossAppMetaData.class); if (metaData != null && parsed != null) { ModulesMetaData mmd = metaData.getModules(); if (mmd != null && mmd.isEmpty() == false) { ModulesMetaData parsedMMD = parsed.getModules(); if (parsedMMD == null) { parsedMMD = new ModulesMetaData(); parsed.setModules(parsedMMD); } parsedMMD.merge(parsedMMD, mmd); } } // parsed is the one we use after merged modules metaData = parsed; if(specMetaData == null && metaData == null) return; // If there no JBossMetaData was created from a jboss-app.xml, create one if (metaData == null) metaData = new JBossAppMetaData(); // Create a merged view JBossAppMetaData mergedMetaData = new JBossAppMetaData(); mergedMetaData.merge(metaData, specMetaData); // Set the merged as the output unit.getTransientManagedObjects().addAttachment(JBossAppMetaData.class, mergedMetaData); // Keep the raw parsed metadata as well unit.addAttachment("Raw"+JBossAppMetaData.class.getName(), metaData, JBossAppMetaData.class); // Pass the ear callByValue setting if (isCallByValue()) unit.addAttachment("EAR.callByValue", Boolean.TRUE, Boolean.class); //Pass the unauthenticated identity if (this.unauthenticatedIdentity != null) unit.addAttachment("EAR.unauthenticatedIdentity", this.unauthenticatedIdentity, String.class); }
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
Override protected <U> void deploy(DeploymentUnit unit, DeploymentVisitor<U> visitor) throws DeploymentException { U deployment = unit.getAttachment(attachmentName, visitor.getVisitorType()); try { visitor.deploy(unit, deployment); } catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); } }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (unit instanceof VFSDeploymentUnit == false) return; VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; deploy(vfsDeploymentUnit); }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
protected void deploy(VFSDeploymentUnit unit) throws DeploymentException { /* Ignore any spec metadata complete deployments. This expects that a deployment unit only represents one of the client, ejb or web deployments and its metadata completeness applies to the unit in terms of whether annotations should be scanned for. */ boolean isComplete = this.isMetaDataCompleteIsDefault(); EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); if(ejbJarMetaData != null && ejbJarMetaData instanceof EjbJar3xMetaData) { isComplete |= ((EjbJar3xMetaData) ejbJarMetaData).isMetadataComplete(); } else if(ejbJarMetaData != null) { // Any ejb-jar.xml 2.1 or earlier deployment is metadata complete isComplete = true; } WebMetaData webMetaData = unit.getAttachment(WebMetaData.class); if(webMetaData != null) { if (webMetaData instanceof Web25MetaData) { isComplete |= ((Web25MetaData)webMetaData).isMetadataComplete(); } else if (webMetaData instanceof Web30MetaData) { isComplete |= ((Web30MetaData)webMetaData).isMetadataComplete(); } else { // Any web.xml 2.4 or earlier deployment is metadata complete isComplete = true; } } ApplicationClientMetaData clientMetaData = unit.getAttachment(ApplicationClientMetaData.class); if(clientMetaData != null) isComplete |= clientMetaData.isMetadataComplete(); // OSGi bundle deployments are metadata-complete // [TODO] Replace with a check for OSGiMetaData once this becomes generally available in AS String symbolicName = (String) unit.getAttachment("org.jboss.osgi.bundle.symbolic.name"); isComplete |= (symbolicName != null); if(isComplete) { log.debug("Deployment is metadata-complete, skipping annotation processing" + ", ejbJarMetaData="+ejbJarMetaData + ", jbossWebMetaData="+webMetaData + ", jbossClientMetaData="+clientMetaData + ", bundleSymbolicName="+symbolicName + ", metaDataCompleteIsDefault="+metaDataCompleteIsDefault ); return; } VirtualFile root = unit.getRoot(); if(root.isLeaf()) return; List<VirtualFile> classpath = unit.getClassPath(); if(classpath == null || classpath.isEmpty()) return; if (log.isTraceEnabled()) log.trace("Deploying annotations for unit: " + unit + ", classpath: " + classpath); try { processMetaData(unit, webMetaData, clientMetaData, classpath); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); } }
// in src/main/java/org/jboss/deployment/LegacyWebXmlLessDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (unit.getSimpleName().endsWith(".war")) { if (unit.isAttachmentPresent(JBossWebMetaData.class)) return; // only care about true deployments if (unit instanceof VFSDeploymentUnit == false) return; // Detect and ignore OSGi WAR deployments // FIXME Use typed OSGiMetaData when we have it available at runtime String bundleSymbolicName = unit.getAttachment("org.jboss.osgi.bundle.symbolic.name", String.class); if (bundleSymbolicName != null) { log.debug("Ignore OSGi webapp: " + bundleSymbolicName); return; } log.debug("Web archive doesn't contain web.xml: " + unit.getName()); unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, new JBossWebMetaData()); } }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { boolean accepted = false; for (String accept : acceptedAttachments) { if (unit.isAttachmentPresent(accept)) { accepted = true; break; } } if (accepted == false) return; String contextID = unit.getName(); PolicyConfiguration pc = null; try { PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); pc = pcFactory.getPolicyConfiguration(contextID, true); } catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); } unit.addAttachment(PolicyConfiguration.class, pc); }
// in src/main/java/org/jboss/deployment/ModuleNameDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { // Find all the metadata types assoc w/ unit that specify a moduleName List<NamedModule> metadatas = null; for (Class<? extends NamedModule> type : inputTypes) { NamedModule nm = unit.getAttachment(type); if (nm != null) { if (metadatas == null) { metadatas = new ArrayList<NamedModule>(); } metadatas.add(nm); } } if (metadatas == null) { return; } String moduleName = null; // See if any of the existing metadata specifies a module name for (NamedModule nm : metadatas) { moduleName = nm.getModuleName(); if (moduleName != null) { break; } } // Enforce EAR rules from EE 6 EE.8.1.1 JBossAppMetaData appMetaData = null; DeploymentUnit parent = unit.getParent(); if (parent != null) { appMetaData = parent.getAttachment(JBossAppMetaData.class); } if (appMetaData != null) { moduleName = establishUniqueModuleName(unit, moduleName, appMetaData); } else if (moduleName == null) { // Not in an EAR and no name was configured. // Create a default module name as per EE 6 EE.8.1.2: // "when a stand-alone module is deployed.... [t]he module name can be // explicitly set in the module deployment descriptor. If not set, the // name of the module is the base name of the module file with any // extension (.war, .jar, .rar) removed and with any directory names removed." moduleName = trimExtension(unit.getSimpleName()); } // Apply the name to all metadata for (NamedModule nm : metadatas) { nm.setModuleName(moduleName); } // Let other deployers get the module name w/o having to search // for all the possible metadata types unit.addAttachment(NamedModule.class, metadatas.get(0)); }
// in src/main/java/org/jboss/deployment/ModuleNameDeployer.java
private String establishUniqueModuleName(DeploymentUnit unit, String configuredName, JBossAppMetaData appMetaData) throws DeploymentException { String name = configuredName == null ? trimExtension(unit.getRelativePath()): configuredName; String modulePath = unit.getRelativePath(); ModulesMetaData modules = appMetaData.getModules(); if (modules == null) { throw new DeploymentException(unit + " has attached " + JBossAppMetaData.class.getSimpleName() + " but it has no associated " + ModulesMetaData.class.getSimpleName()); } ModuleMetaData ourModule = null; String uniqueName = null; // Synchronize on the modules to ensure concurrent deployments of the // modules pass serially through this logic synchronized(modules) { ourModule = modules.get(modulePath); if (ourModule == null) { String parentUnitName = unit.getParent().getName(); throw new DeploymentException("No module with relative path " + modulePath + " found in set of modules for " + parentUnitName + " " + modules.keySet()); } uniqueName = name; if (!isNameUnique(uniqueName, ourModule, modules)) { // Try the relative path w/ extension removed uniqueName = trimExtension(unit.getRelativePath()); if (uniqueName.equals(name) || !isNameUnique(uniqueName, ourModule, modules)) { // Try leaving the extension uniqueName = unit.getRelativePath(); if (!isNameUnique(uniqueName, ourModule, modules)) { // To get here, people would have to configure in xml a // module name that conflicts with the relative path of // another module. Not likely, but... // Append a digit until the name is unique int i = 0; do { i++; uniqueName = name + "-" + i; } while (!isNameUnique(uniqueName, ourModule, modules)); } } } ourModule.setUniqueName(uniqueName); } // Log a WARN if we had to change the module name if (configuredName != null && !configuredName.equals(uniqueName)) { log.warn("Module name " + configuredName + " specified in deployment descriptor for " + unit + " was not unique within the application; using module name " + uniqueName + " instead"); } else if (!name.equals(uniqueName)) { log.warn("Module name " + name + " derived from the modules relative path in " + unit + " was not unique within the application; using module name " + uniqueName + " instead"); } return uniqueName; }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
public void deploy(VFSDeploymentUnit unit, JBossAppMetaData jBossAppMetaData) throws DeploymentException { try { VirtualFile root = unit.getRoot(); String libDir = jBossAppMetaData.getLibraryDirectory(); if (libDir == null || libDir.length() == 0) // take 'lib' even on empty libDir = "lib"; VirtualFile lib = root.getChild(libDir); if (lib != null) { ResourceFilter recurseFilter = new UrlExcludeResourceFilter(lib.toURL()); unit.addAttachment(ResourceFilter.class.getName() + ".recurse", recurseFilter, ResourceFilter.class); log.debug("Excluding ear's lib directory: " + lib); } } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e); } }
// in src/main/java/org/jboss/deployment/EjbClassLoaderDeployer.java
Override public void deploy(DeploymentUnit unit, JBossMetaData metaData) throws DeploymentException { ClassLoadingMetaData classLoadingMetaData = unit.getAttachment(ClassLoadingMetaData.class); if (classLoadingMetaData != null) return; LoaderRepositoryMetaData lrmd = metaData.getLoaderRepository(); if (lrmd != null) LoaderRepositoryMetaDataHelper.create(unit, lrmd); }
// in src/main/java/org/jboss/deployment/JBossWebAppParsingDeployer.java
Override protected boolean accepts(final DeploymentUnit unit) throws DeploymentException { return unit.getSimpleName().endsWith(".war"); }
// in src/main/java/org/jboss/deployment/JBossWebAppParsingDeployer.java
Override protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException { super.createMetaData(unit, name, suffix); JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); // If there no JBossWebMetaData was created from a jboss-web.xml, create one if (metaData == null) { metaData = new JBossWebMetaData(); } unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, metaData); unit.addAttachment("Raw"+JBossWebMetaData.class.getName(), metaData, JBossWebMetaData.class); }
// in src/main/java/org/jboss/deployment/JBossWebAppParsingDeployer.java
Override protected void createMetaData(DeploymentUnit unit, String name, String suffix, String key) throws DeploymentException { super.createMetaData(unit, name, suffix, key); JBossWebMetaData result = unit.getTransientManagedObjects().getAttachment(getOutput()); if (result == null) { result = new JBossWebMetaData(); unit.getTransientManagedObjects().addAttachment(key, result, getOutput()); } }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { T metaData = unit.getAttachment(getMetaDataClassType()); if (metaData == null) return; String contextId = unit.getSimpleName(); // Is the war the top level deployment? // DeploymentUnit topUnit = unit.getTopLevel(); if (unit.getParent() == null || getParentJaccPolicyBean(unit) == null) { createTopLevelServiceBeanWithMetaData(contextId, unit, metaData); } else { ServiceMetaData subjaccPolicy = getServiceMetaData(); String deploymentName = unit.getSimpleName(); try { subjaccPolicy.setObjectName(new ObjectName(getObjectName(unit))); } catch (Exception e) { throw new RuntimeException(e); } // Provide a constructor for the service bean ServiceConstructorMetaData serviceConstructor = new ServiceConstructorMetaData(); serviceConstructor.setSignature(new String[]{String.class.getName(), getMetaDataClassType().getName()}); serviceConstructor.setParameters(new Object[]{deploymentName, metaData}); subjaccPolicy.setConstructor(serviceConstructor); ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>(); services.add(subjaccPolicy); unit.addAttachment(JACC_ATTACHMENT_NAME, subjaccPolicy, ServiceMetaData.class); // Add a dependence into the parent JaccPolicy ServiceMetaData parentServiceMetaData = this.getParentJaccPolicyBean(unit); if (parentServiceMetaData != null) { ServiceDependencyMetaData serviceDependencyMetaData = new ServiceDependencyMetaData(); serviceDependencyMetaData.setIDependOnObjectName(subjaccPolicy.getObjectName()); parentServiceMetaData.addDependency(serviceDependencyMetaData); // Add an attribute in the parent service ServiceAttributeMetaData serviceAttributeMetaData = new ServiceAttributeMetaData(); serviceAttributeMetaData.setName("PolicyConfigurationFacadeMBean"); ServiceDependencyValueMetaData dependencyValue = new ServiceDependencyValueMetaData(); dependencyValue.setDependency(subjaccPolicy.getObjectName().toString()); dependencyValue.setProxyType("attribute"); serviceAttributeMetaData.setValue(dependencyValue); parentServiceMetaData.addAttribute(serviceAttributeMetaData); } } /** Register XACML/ACL policies if present in the deployment */ if(this.policyRegistration != null) { String xacmlType = PolicyRegistration.XACML; JAXBElement<?> policyConfig = (JAXBElement<?>) unit.getAttachment(XACML_ATTACHMENT_NAME); if(policyConfig != null) this.policyRegistration.registerPolicyConfig(contextId, xacmlType, policyConfig); String aclType = PolicyRegistration.ACL; ACLConfiguration aclConfig = (ACLConfiguration) unit.getAttachment(ACLConfiguration.class.getName()); if(aclConfig != null) this.policyRegistration.registerPolicyConfig(contextId, aclType, aclConfig); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void addContainer(Container con) throws DeploymentException { String ejbName = con.getBeanMetaData().getEjbName(); if (containers.containsKey(ejbName)) throw new DeploymentException("Duplicate ejb-name. Container for " + ejbName + " already exists."); containers.put(ejbName, con); containerOrdering.add(con); con.setEjbModule(this); }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void initializeContainer(Container container, ConfigurationMetaData conf, BeanMetaData bean, int transType, DeploymentUnit unit) throws NamingException, DeploymentException { // Create local classloader for this container // For loading resources that must come from the local jar. Not for loading classes! // The VFS should be used for this // container.setLocalClassLoader(new URLClassLoader(new URL[0], localCl)); // Set metadata (do it *before* creating the container's WebClassLoader) container.setEjbModule(this); container.setBeanMetaData(bean); ClassLoader unitCl = unit.getClassLoader(); // Create the container's WebClassLoader // and register it with the web service. String webClassLoaderName = getWebClassLoader(conf, bean); log.debug("Creating WebClassLoader of class " + webClassLoaderName); WebClassLoader wcl = null; try { Class clazz = unitCl.loadClass(webClassLoaderName); wcl = WebClassLoaderFactory.createWebClassLoader(clazz, container.getJmxName(), (RealClassLoader) unitCl); } catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); } if (webServiceName != null) { WebServiceMBean webServer = (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName); URL[] codebase = {webServer.addClassLoader(wcl)}; wcl.setWebURLs(codebase); } // end of if () container.setWebClassLoader(wcl); // Create classloader for this container // Only used to unique the bean ENC and does not augment class loading container.setClassLoader(new DelegatingClassLoader(wcl)); // Set transaction manager InitialContext iniCtx = new InitialContext(); container.setTransactionManager(tmFactory.getTransactionManager()); // Set container.setTimerService(timerService); // Set security domain manager String securityDomain = bean.getApplicationMetaData().getSecurityDomain(); // JBAS-5960: Set default security domain if there is security metadata boolean hasSecurityMetaData = hasSecurityMetaData(bean); if (securityDomain == null && hasSecurityMetaData) { securityDomain = SecurityConstants.DEFAULT_EJB_APPLICATION_POLICY; } String confSecurityDomain = conf.getSecurityDomain(); // Default the config security to the application security manager if (confSecurityDomain == null) confSecurityDomain = securityDomain; // Check for an empty confSecurityDomain which signifies to disable security if (confSecurityDomain != null && confSecurityDomain.length() == 0) confSecurityDomain = null; if (confSecurityDomain != null) { // Either the application has a security domain or the container has security setup try { String unprefixed = SecurityUtil.unprefixSecurityDomain(confSecurityDomain); log.debug("Setting security domain from: " + confSecurityDomain); String domainCtx = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + unprefixed + "/domainContext"; SecurityDomainContext sdc = (SecurityDomainContext) iniCtx.lookup(domainCtx); Object securityMgr = sdc.getSecurityManager(); // Object securityMgr = iniCtx.lookup(confSecurityDomain); AuthenticationManager ejbS = (AuthenticationManager) securityMgr; RealmMapping rM = (RealmMapping) securityMgr; container.setSecurityManager(ejbS); container.setRealmMapping(rM); container.setSecurityManagement(securityManagement); container.setPolicyRegistration(policyRegistration); container.setDefaultSecurityDomain((String) unit.getAttachment("EJB.defaultSecurityDomain")); container.setSecurityContextClassName((String) unit.getAttachment("EJB.securityContextClassName")); } catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); } catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); } } else { if ("".equals(securityDomain) && hasSecurityMetaData) log.warn("EJB configured to bypass security. Please verify if this is intended. Bean=" + bean.getEjbName() + " Deployment=" + unit.getName()); } // Load the security proxy instance if one was configured String securityProxyClassName = bean.getSecurityProxy(); if (securityProxyClassName != null) { try { Class proxyClass = unitCl.loadClass(securityProxyClassName); Object proxy = proxyClass.newInstance(); container.setSecurityProxy(proxy); log.debug("setSecurityProxy, " + proxy); } catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); } } // Install the container interceptors based on the configuration addInterceptors(container, transType, conf.getContainerInterceptorsConf()); }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static String getWebClassLoader(ConfigurationMetaData conf, BeanMetaData bmd) throws DeploymentException { String webClassLoader = null; Iterator it = bmd.getInvokerBindings(); int count = 0; while (it.hasNext()) { String invoker = (String) it.next(); ApplicationMetaData amd = bmd.getApplicationMetaData(); InvokerProxyBindingMetaData imd = amd.getInvokerProxyBindingMetaDataByName(invoker); if (imd == null) { String msg = "Failed to find InvokerProxyBindingMetaData for: '" + invoker + "'. Check the invoker-proxy-binding-name to " + "invoker-proxy-binding/name mappings in jboss.xml"; throw new DeploymentException(msg); } Element proxyFactoryConfig = imd.getProxyFactoryConfig(); String webCL = MetaData.getOptionalChildContent(proxyFactoryConfig, "web-class-loader"); if (webCL != null) { log.debug("Invoker " + invoker + " specified WebClassLoader class" + webCL); webClassLoader = webCL; count++; } } if (count > 1) { log.warn(count + " invokers have WebClassLoader specifications."); log.warn("Using the last specification seen (" + webClassLoader + ")."); } else if (count == 0) { webClassLoader = conf.getWebClassLoader(); if (webClassLoader == null) webClassLoader = "org.jboss.web.WebClassLoader"; } return webClassLoader; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void addInterceptors(Container container, int transType, Element element) throws DeploymentException { // Get the interceptor stack(either jboss.xml or standardjboss.xml) Iterator interceptorElements = MetaData.getChildrenByTagName(element, "interceptor"); String transTypeString = stringTransactionValue(transType); ClassLoader loader = container.getClassLoader(); /* * First build the container interceptor stack from interceptorElements match transType values */ ArrayList istack = new ArrayList(); while (interceptorElements != null && interceptorElements.hasNext()) { Element ielement = (Element) interceptorElements.next(); /* * Check that the interceptor is configured for the transaction mode of the bean by comparing its 'transaction' * attribute to the string representation of transType */ String transAttr = ielement.getAttribute("transaction"); if (transAttr == null || transAttr.length() == 0) transAttr = ANY_VALUE; if (transAttr.equalsIgnoreCase(ANY_VALUE) || transAttr.equalsIgnoreCase(transTypeString)) { // The transaction type matches the container bean trans type String className = null; try { className = MetaData.getFirstElementContent(ielement, null); Class clazz = loader.loadClass(className); Interceptor interceptor = (Interceptor) clazz.newInstance(); if (interceptor instanceof XmlLoadable) { ((XmlLoadable) interceptor).importXml(ielement); } istack.add(interceptor); } catch (ClassNotFoundException e) { log.warn("Could not load the " + className + " interceptor", e); } catch (Exception e) { log.warn("Could not load the " + className + " interceptor for this container", e); } } } if (istack.size() == 0) log.warn("There are no interceptors configured. Check the standardjboss.xml file"); // Now add the interceptors to the container for (int i = 0; i < istack.size(); i++) { Interceptor interceptor = (Interceptor) istack.get(i); container.addInterceptor(interceptor); } /* * If there is a security proxy associated with the container add its interceptor just before the container * interceptor */ if (container.getSecurityProxy() != null) container.addInterceptor(new SecurityProxyInterceptor()); // Finally we add the last interceptor from the container container.addInterceptor(container.createContainerInterceptor()); }
// in src/main/java/org/jboss/ejb/deployers/SimpleCreateDestinationMatcher.java
public boolean isMatch(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException { if (noMatch(messageListener, mdb.getMessagingType(), isDefault())) return false; if (noMatch(rarName, mdb.getResourceAdapterName(), isDefault())) return false; return true; }
// in src/main/java/org/jboss/ejb/deployers/MergedJBossMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { EjbJarMetaData ejbJarMetaData = unit.getAttachment(EjbJarMetaData.class); JBossMetaData metaData = unit.getAttachment(JBossMetaData.class); // Check for an annotated view String key = AnnotationMetaDataDeployer.EJB_ANNOTATED_ATTACHMENT_NAME; JBossMetaData annotatedMetaData = unit.getAttachment(key, JBossMetaData.class); if(ejbJarMetaData == null && metaData == null && annotatedMetaData == null) return; JBossMetaData specMetaData = new JBoss50MetaData(); if(ejbJarMetaData != null) { specMetaData.merge(null, ejbJarMetaData); if(annotatedMetaData != null) { JBossMetaData specMerged = new JBoss50MetaData(); specMerged.merge(specMetaData, annotatedMetaData); specMetaData = specMerged; } } else specMetaData = annotatedMetaData; // Create a merged view JBossMetaData mergedMetaData = new JBossMetaData(); mergedMetaData.merge(metaData, specMetaData); // Incorporate any ear level overrides DeploymentUnit topUnit = unit.getTopLevel(); if(topUnit != null && topUnit.getAttachment(JBossAppMetaData.class) != null) { JBossAppMetaData earMetaData = topUnit.getAttachment(JBossAppMetaData.class); // Security domain String securityDomain = earMetaData.getSecurityDomain(); if(securityDomain != null && mergedMetaData.getSecurityDomain() == null) mergedMetaData.setSecurityDomain(securityDomain); //Security Roles SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles(); if(earSecurityRolesMetaData != null) { JBossAssemblyDescriptorMetaData jadmd = mergedMetaData.getAssemblyDescriptor(); if( jadmd == null) { jadmd = new JBossAssemblyDescriptorMetaData(); mergedMetaData.setAssemblyDescriptor(jadmd); } SecurityRolesMetaData mergedSecurityRolesMetaData = jadmd.getSecurityRoles(); if(mergedSecurityRolesMetaData == null) jadmd.setSecurityRoles(earSecurityRolesMetaData); //perform a merge to rebuild the principalVersusRolesMap if(mergedSecurityRolesMetaData != null ) { mergedSecurityRolesMetaData.merge(mergedSecurityRolesMetaData, earSecurityRolesMetaData); } } } // Create interceptors metadata by processing interceptor classes (from the merged // jboss metadata) Collection<String> interceptorClassNames = JBossMetaData.getAllInterceptorClasses(mergedMetaData); Collection<Class<?>> interceptorClasses = null; try { interceptorClasses = this.loadClasses(unit.getClassLoader(), interceptorClassNames); } catch (ClassNotFoundException cnfe) { throw new DeploymentException("Exception while loading interceptor classes for unit " + unit.getName(), cnfe); } // Process the interceptor classes AnnotationFinder<AnnotatedElement> annotationFinder = new DefaultAnnotationFinder<AnnotatedElement>(); InterceptorMetaDataCreator interceptorMetaDataCreator = new InterceptorMetaDataCreator(annotationFinder); // create interceptors metadata from the interceptor classes InterceptorsMetaData annotatedInterceptorsMetaData = interceptorMetaDataCreator.create(interceptorClasses); InterceptorsMetaData mergedInterceptorsMetaData = new InterceptorsMetaData(); // merge the interceptors metadata mergedInterceptorsMetaData.merge(mergedMetaData.getInterceptors(), annotatedInterceptorsMetaData); // now set the merged interceptors metadata into the merged jboss metadata mergedMetaData.setInterceptors(mergedInterceptorsMetaData); // Output the merged JBossMetaData unit.getTransientManagedObjects().addAttachment(JBossMetaData.class, mergedMetaData); unit.addAttachment(EJB_MERGED_ATTACHMENT_NAME, mergedMetaData, JBossMetaData.class); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
Override public void deploy(VFSDeploymentUnit unit, JBossMetaData deployment) throws DeploymentException { // If it is a deployment with ejbVersion unknown or 3 if (!deployment.isEJB2x() && !deployment.isEJB1x()) return; // let EJB3 deployer handle this ApplicationMetaData legacyMD = new ApplicationMetaData(deployment); if( verifyDeployments ) { // we have a positive attitude boolean allOK = true; // wrapping this into a try - catch block to prevent errors in // verifier from stopping the deployment try { BeanVerifier verifier = new BeanVerifier(); // add a listener so we can log the results verifier.addVerificationListener(new VerificationListener() { Logger verifierLog = Logger.getLogger(EjbDeployer.class, "verifier"); public void beanChecked(VerificationEvent event) { verifierLog.debug( "Bean checked: " + event.getMessage() ); } public void specViolation(VerificationEvent event) { verifierLog.warn( "EJB spec violation: " + (verifierVerbose ? event.getVerbose() : event.getMessage())); } }); log.debug("Verifying " + unit.getRoot().toURL()); verifier.verify(unit.getRoot().toURL(), legacyMD, unit.getClassLoader()); allOK = verifier.getSuccess(); } catch (Throwable t) { log.warn("Verify failed; continuing", t ); allOK = false; } // If the verifier is in strict mode and an error/warning // was found in the Verification process, throw a Deployment // Exception if( strictVerifier && !allOK ) { throw new DeploymentException("Verification of Enterprise Beans failed, see above for error messages."); } }
// in src/main/java/org/jboss/ejb/deployers/StandardJBossMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { // Get the jboss.xml attachment JBossMetaData metaData = unit.getAttachment(JBossMetaData.class); // Get the standardjboss.xml attachment JBossMetaData stdMetaData = unit.getAttachment("standardjboss.xml", JBossMetaData.class); if(metaData == null || stdMetaData == null) return; JBossMetaDataWrapper wrapper = new JBossMetaDataWrapper(metaData, stdMetaData); // Set the wrapper as the output unit.getTransientManagedObjects().addAttachment(JBossMetaData.class, wrapper); // Keep the raw parsed metadata as well unit.addAttachment(RAW_ATTACHMENT_NAME, metaData, JBossMetaData.class); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
public void deploy(DeploymentUnit unit, JBossMetaData deployment) throws DeploymentException { if (factories.isEmpty()) return; JBossEnterpriseBeansMetaData beans = deployment.getEnterpriseBeans(); if (beans != null && beans.isEmpty() == false) { ArrayList<JBossMessageDrivenBeanMetaData> deployed = new ArrayList<JBossMessageDrivenBeanMetaData>(); for (JBossEnterpriseBeanMetaData bean : beans) { if (bean.isMessageDriven()) { try { JBossMessageDrivenBeanMetaData messageDriven = (JBossMessageDrivenBeanMetaData) bean; if (isCreateDestination(unit, messageDriven)) { deploy(unit, messageDriven); deployed.add(messageDriven); } } catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); } } } } }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
protected void deploy(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException { for (CreateDestination createDestination : factories) { if (createDestination.getMatcher().isMatch(unit, mdb)) { Object attachment = createDestination.getFactory().create(unit, mdb); if (attachment != null) { unit.addAttachment(getAttachmentName(unit, mdb), attachment); return; } } } }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
protected void undeploy(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException { unit.removeAttachment(getAttachmentName(unit, mdb)); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
protected boolean isCreateDestination(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException { return mdb.isCreateDestination(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void resolveMessageListener() throws DeploymentException { String messagingType = metaData.getMessagingType(); try { messagingTypeClass = GetTCLAction.getContextClassLoader().loadClass(messagingType); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Could not load messaging-type class " + messagingType, e); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected String resolveResourceAdapterName() throws DeploymentException { return metaData.getResourceAdapterName(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void resolveResourceAdapter() throws DeploymentException { resourceAdapterName = resolveResourceAdapterName(); try { resourceAdapterObjectName = new ObjectName("jboss.jca:service=RARDeployment,name='" + resourceAdapterName + "'"); int state = ((Integer) server.getAttribute(resourceAdapterObjectName, "State")).intValue(); if (state != STARTED) throw new DeploymentException("The resource adapter is not started " + resourceAdapterName); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Cannot locate resource adapter deployment " + resourceAdapterName, e); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void setupProxyParameters() throws DeploymentException { // Set the interfaces interfaces = new Class[] { MessageEndpoint.class, messagingTypeClass }; // Set the interceptors interceptors = new ArrayList<Class<?>>(); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element endpointInterceptors = MetaData.getOptionalChild(proxyConfig, "endpoint-interceptors", null); if (endpointInterceptors == null) throw new DeploymentException("No endpoint interceptors found"); else { NodeList children = endpointInterceptors.getElementsByTagName("interceptor"); for (int i = 0; i < children.getLength(); ++i) { Node currentChild = children.item(i); if (currentChild.getNodeType() == Node.ELEMENT_NODE) { Element interceptor = (Element) children.item(i); String className = MetaData.getElementContent(interceptor); try { Class<?> clazz = container.getClassLoader().loadClass(className); interceptors.add(clazz); } catch (Throwable t) { DeploymentException.rethrowAsDeploymentException("Error loading interceptor class " + className, t); } } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void augmentActivationConfigProperties() throws DeploymentException { // Allow activation config properties from invoker proxy binding Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element activationConfig = MetaData.getOptionalChild(proxyConfig, "activation-config"); if (activationConfig != null) { Iterator<Element> iterator = MetaData.getChildrenByTagName(activationConfig, "activation-config-property"); while (iterator.hasNext()) { Element xml = iterator.next(); org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData md = new org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData(); ActivationConfigPropertyMetaData metaData = new ActivationConfigPropertyMetaData(md); String name = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-name")); String value = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-value")); if (name == null || name.trim().length() == 0) throw new DeploymentException("activation-config-property doesn't have a name"); if (Strings.isValidJavaIdentifier(name) == false) throw new DeploymentException("activation-config-property '" + name + "' is not a valid java identifier"); md.setName(name); md.setValue(value); if (properties.containsKey(metaData.getName()) == false) properties.put(metaData.getName(), metaData); } } // Message Destination Link String link = metaData.getDestinationLink(); if (link != null) { link = link.trim(); if (link.length() > 0) { if (properties.containsKey("destination")) log.warn("Ignoring message-destination-link '" + link + "' when the destination " + "is already in the activation-config."); else { MessageDestinationMetaData destinationMetaData = container.getMessageDestination(link); if (destinationMetaData == null) throw new DeploymentException("Unresolved message-destination-link '" + link + "' no message-destination in ejb-jar.xml"); String jndiName = destinationMetaData.getJndiName(); if (jndiName == null) throw new DeploymentException("The message-destination '" + link + "' has no jndi-name in jboss.xml"); org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData acpmd = new org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData(); acpmd.setActivationConfigPropertyName("destination"); acpmd.setValue(jndiName); ActivationConfigPropertyMetaData wrapper = new ActivationConfigPropertyMetaData(acpmd); properties.put("destination", wrapper); } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void createActivationSpec() throws DeploymentException { properties = new HashMap(metaData.getActivationConfigProperties()); augmentActivationConfigProperties(); Object[] params = new Object[] { messagingTypeClass, properties.values() }; try { activationSpec = (ActivationSpec) server.invoke(resourceAdapterObjectName, "createActivationSpec", params, createActivationSpecSig); } catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Unable to create activation spec ra=" + resourceAdapterObjectName + " messaging-type=" + messagingTypeClass.getName() + " properties=" + metaData.getActivationConfigProperties(), t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void activate() throws DeploymentException { if (deliveryActive.get() == false) { log.info("Delivery is disabled: " + getServiceName()); return; } Object[] params = new Object[] { this, activationSpec }; try { server.invoke(resourceAdapterObjectName, "endpointActivation", params, activationSig); } catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
Override protected String resolveResourceAdapterName() throws DeploymentException { // No resource adapter specified assume jms String result = super.resolveResourceAdapterName(); if (result == null) { getLog().warn("Metadata is missing JMS resource adpater name. The default will be " + jmsra); result = jmsra; } return result; }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
Override protected void resolveMessageListener() throws DeploymentException { // No messaging type use jms if (metaData.getMessagingType() == null) messagingTypeClass = MessageListener.class; else super.resolveMessageListener(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
protected void augmentActivationConfigProperties() throws DeploymentException { super.augmentActivationConfigProperties(); // Hack for old style deployments (jms) if (messagingTypeClass.equals(MessageListener.class)) { checkActivationConfig("destination", metaData.getDestinationJndiName()); checkActivationConfig("destinationType", metaData.getDestinationType()); checkActivationConfig("messageSelector", metaData.getMessageSelector()); if (Session.DUPS_OK_ACKNOWLEDGE == metaData.getAcknowledgeMode()) checkActivationConfig("acknowledgeMode", "DUPS_OK_ACKNOWLEDGE"); else checkActivationConfig("acknowledgeMode", "AUTO_ACKNOWLEDGE"); if (MessageDrivenMetaData.DURABLE_SUBSCRIPTION == metaData.getSubscriptionDurability()) checkActivationConfig("subscriptionDurability", "Durable"); else checkActivationConfig("subscriptionDurability", "NonDurable"); checkActivationConfig("clientId", metaData.getClientId()); checkActivationConfig("subscriptionName", metaData.getSubscriptionId()); // Only for JBoss's resource adapter if (jmsra.equals(resourceAdapterName)) { checkActivationConfig("user", metaData.getUser()); checkActivationConfig("password", metaData.getPasswd()); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); checkActivationConfig("maxMessages", MetaData.getOptionalChildContent(proxyConfig, "MaxMessages")); checkActivationConfig("minSession", MetaData.getOptionalChildContent(proxyConfig, "MinimumSize")); checkActivationConfig("maxSession", MetaData.getOptionalChildContent(proxyConfig, "MaximumSize")); checkActivationConfig("keepAlive", MetaData.getOptionalChildContent(proxyConfig, "KeepAliveMillis")); Element mdbConfig = MetaData.getOptionalChild(proxyConfig, "MDBConfig"); if (mdbConfig != null) { try { if ("false".equalsIgnoreCase(MetaData.getElementContent(MetaData.getUniqueChild(mdbConfig, "DeliveryActive")))) { setDeliveryActive(false); } } catch (Exception ignore) { } checkActivationConfig("reconnectInterval", MetaData.getOptionalChildContent(proxyConfig, "ReconnectIntervalSec")); checkActivationConfig("deliveryActive", MetaData.getOptionalChildContent(proxyConfig, "DeliveryActive")); checkActivationConfig("providerAdapterJNDI", MetaData.getOptionalChildContent(proxyConfig, "JMSProviderAdapterJNDI")); Element dlqEl = MetaData.getOptionalChild(mdbConfig, "DLQConfig"); if (dlqEl != null) { checkActivationConfig("useDLQ", "true"); checkActivationConfig("DLQJNDIName", MetaData.getElementContent(MetaData.getUniqueChild(dlqEl, "DestinationQueue"))); try { checkActivationConfig("DLQMaxResent", MetaData.getElementContent(MetaData.getUniqueChild(dlqEl, "MaxTimesRedelivered"))); } catch (Exception ignored) { // backwards comaptibility } // TODO TimeToLive checkActivationConfig("DLQUser", MetaData.getElementContent(MetaData.getOptionalChild(dlqEl, "DLQUser"))); checkActivationConfig("DLQPassword", MetaData.getElementContent(MetaData.getOptionalChild(dlqEl, "DLQPassword"))); } else { // backwards compatibility - no DLQConfig in MDBConfig means no DLQ checkActivationConfig("useDLQ", "false"); } } } } }
// in src/main/java/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
protected void setupProxyParameters() throws DeploymentException { // Set the interfaces interfaces = new Class[] { MessageEndpoint.class, MessageListener.class }; // Set the interceptors interceptors = new ArrayList<Class<?>>(); interceptors.add(ClientMethodInterceptor.class); interceptors.add(MessageEndpointInterceptor.class); interceptors.add(TransactionInterceptor.class); interceptors.add(InvokerInterceptor.class); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void initSequence(String tableName, String sequenceColumn, String sequenceName, String idColumnName) throws SQLException, DeploymentException { if(createTable) { createTableIfNotExists(tableName); } Connection con = null; Statement st = null; ResultSet rs = null; try { String sql = "select " + idColumnName + " from " + tableName + " where " + sequenceColumn + "='" + sequenceName + "'"; log.debug("Executing SQL: " + sql); con = ds.getConnection(); st = con.createStatement(); rs = st.executeQuery(sql); if(!rs.next()) { sql = "insert into " + tableName + "(" + sequenceColumn + ", " + idColumnName + ") values ('" + sequenceName + "', 0)"; log.debug("Executing SQL: " + sql); final Statement insertSt = con.createStatement(); try { final int i = insertSt.executeUpdate(sql); if(i != 1) { throw new SQLException("Expected one updated row but got: " + i); } } finally { JDBCUtil.safeClose(insertSt); } } else { HiLoKeyGenerator.setHighestHi(rs.getLong(1)); } } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void createTableIfNotExists(String tableName) throws SQLException, DeploymentException { Connection con = null; Statement st = null; try { if(!SQLUtil.tableExists(tableName, ds)) { log.debug("Executing DDL: " + createTableDdl); con = ds.getConnection(); st = con.createStatement(); st.executeUpdate(createTableDdl); } } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void dropTableIfExists(String tableName) throws SQLException, DeploymentException { Connection con = null; Statement st = null; try { if(SQLUtil.tableExists(tableName, ds)) { final String ddl = "drop table " + tableName; log.debug("Executing DDL: " + ddl); con = ds.getConnection(); st = con.createStatement(); st.executeUpdate(ddl); } } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
public void importXml(Element element) throws DeploymentException { String min = MetaData.getElementContent(MetaData.getOptionalChild(element, "min-capacity")); String max = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-capacity")); String op = MetaData.getElementContent(MetaData.getOptionalChild(element, "overager-period")); String rp = MetaData.getElementContent(MetaData.getOptionalChild(element, "resizer-period")); String ma = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-bean-age")); String map = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-cache-miss-period")); String mip = MetaData.getElementContent(MetaData.getOptionalChild(element, "min-cache-miss-period")); String fa = MetaData.getElementContent(MetaData.getOptionalChild(element, "cache-load-factor")); try { if (min != null) { int s = Integer.parseInt(min); if (s <= 0) { throw new DeploymentException("Min cache capacity can't be <= 0"); } m_minCapacity = s; } if (max != null) { int s = Integer.parseInt(max); if (s <= 0) { throw new DeploymentException("Max cache capacity can't be <= 0"); } m_maxCapacity = s; } if (op != null) { int p = Integer.parseInt(op); if (p <= 0) {throw new DeploymentException("Overager period can't be <= 0");} m_overagerPeriod = p * 1000; } if (rp != null) { int p = Integer.parseInt(rp); if (p <= 0) {throw new DeploymentException("Resizer period can't be <= 0");} m_resizerPeriod = p * 1000; } if (ma != null) { int a = Integer.parseInt(ma); if (a <= 0) {throw new DeploymentException("Max bean age can't be <= 0");} m_maxBeanAge = a * 1000; } if (map != null) { int p = Integer.parseInt(map); if (p <= 0) {throw new DeploymentException("Max cache miss period can't be <= 0");} m_maxPeriod = p * 1000; } if (mip != null) { int p = Integer.parseInt(mip); if (p <= 0) {throw new DeploymentException("Min cache miss period can't be <= 0");} m_minPeriod = p * 1000; } if (fa != null) { double f = Double.parseDouble(fa); if (f <= 0.0) {throw new DeploymentException("Cache load factor can't be <= 0");} m_factor = f; } } catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void importXml(Element element) throws DeploymentException { // This one is mandatory String p = MetaData.getElementContent(MetaData.getUniqueChild(element, "cache-policy")); try { Class cls = SecurityActions.getContextClassLoader().loadClass(p); Constructor ctor = cls.getConstructor(new Class[] {AbstractInstanceCache.class}); m_cache = (CachePolicy)ctor.newInstance(new Object[] {this}); } catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); } Element policyConf = MetaData.getOptionalChild(element, "cache-policy-conf"); if (policyConf != null) { if (m_cache instanceof XmlLoadable) { try { ((XmlLoadable)m_cache).importXml(policyConf); } catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); } } } }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void importXml(Element element) throws DeploymentException { String flushString = MetaData.getElementContent(MetaData.getOptionalChild(element, "flush-enabled")); flushEnabled = Boolean.valueOf(flushString).booleanValue(); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
public void importXml(Element element) throws DeploymentException { Element synch = MetaData.getUniqueChild(element, "Synchronized"); isSynchronized = Boolean.valueOf(MetaData.getElementContent(synch)).booleanValue(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2) manager.getEntityBridge(); log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName()); final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields(); if(pkFields.length > 1) { throw new DeploymentException("This entity-command cannot be used with composite primary keys!"); } this.pkField = (JDBCCMPFieldBridge2) pkFields[0]; JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand(); pkSql = metadata.getAttribute("pk-sql"); if(pkSql == null) { throw new DeploymentException("pk-sql attribute must be set for entity " + entityBridge.getEntityName()); } if(log.isDebugEnabled()) { log.debug("entity-command generate pk sql: " + pkSql); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
public void init() throws DeploymentException { Method findByPkMethod; Class home = entity.getHomeClass(); if(home != null) { try { findByPkMethod = home.getMethod("findByPrimaryKey", new Class[]{entity.getPrimaryKeyClass()}); } catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } FindByPrimaryKeyCommand findByPk = new FindByPrimaryKeyCommand(entity); queriesByMethod.put(findByPkMethod, findByPk); } Class local = entity.getLocalHomeClass(); if(local != null) { try { findByPkMethod = local.getMethod("findByPrimaryKey", new Class[]{entity.getPrimaryKeyClass()}); } catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } FindByPrimaryKeyCommand findByPk = new FindByPrimaryKeyCommand(entity); queriesByMethod.put(findByPkMethod, findByPk); } // // Defined finders - Overrides automatic finders. // Iterator definedFinders = entity.getMetaData().getQueries().iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData q = (JDBCQueryMetaData) definedFinders.next(); if(!queriesByMethod.containsKey(q.getMethod())) { if(q instanceof JDBCJBossQLQueryMetaData) { QueryCommand queryCommand = new JBossQLQueryCommand(entity, (JDBCJBossQLQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCQlQueryMetaData) { QueryCommand queryCommand = new EJBQLQueryCommand(entity, (JDBCQlQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCDeclaredQueryMetaData) { QueryCommand queryCommand = new DeclaredSQLQueryCommand(entity, (JDBCDeclaredQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else if(q instanceof JDBCDynamicQLQueryMetaData) { QueryCommand queryCommand = new DynamicQueryCommand(entity, (JDBCDynamicQLQueryMetaData)q); queriesByMethod.put(q.getMethod(), queryCommand); } else { throw new DeploymentException("Unsupported query metadata: method=" + q.getMethod().getName() + ", metadata=" + q); } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
public EntityTable createEntityTable(JDBCEntityMetaData metadata, JDBCEntityBridge2 entity) throws DeploymentException { if(entityTables == null) { entityTables = new EntityTable[1]; } else { EntityTable[] tmp = entityTables; entityTables = new EntityTable[tmp.length + 1]; System.arraycopy(tmp, 0, entityTables, 0, tmp.length); } EntityTable table = new EntityTable(metadata, entity, this, entityTables.length - 1); entityTables[entityTables.length - 1] = table; return table; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
public RelationTable createRelationTable(JDBCCMRFieldBridge2 leftField, JDBCCMRFieldBridge2 rightField) throws DeploymentException { if(relationTables == null) { relationTables = new RelationTable[1]; } else { RelationTable[] tmp = relationTables; relationTables = new RelationTable[tmp.length + 1]; System.arraycopy(tmp, 0, relationTables, 0, tmp.length); } RelationTable table = new RelationTable(leftField, rightField, this, relationTables.length - 1); relationTables[relationTables.length - 1] = table; return table; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void start() throws DeploymentException { final JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); relationsTotal = (cmrFields != null ? cmrFields.length : 0); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); // DELETE SQL deleteSql = "delete from " + tableName + " where "; deleteSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { deleteSql += " and " + pkFields[i].getColumnName() + "=?"; } log.debug("delete sql: " + deleteSql); // INSERT SQL insertSql = "insert into " + tableName + "("; insertSql += tableFields[0].getColumnName(); for(int i = 1; i < tableFields.length; ++i) { insertSql += ", " + tableFields[i].getColumnName(); } insertSql += ") values (?"; for(int i = 1; i < tableFields.length; ++i) { insertSql += ", ?"; } insertSql += ")"; log.debug("insert sql: " + insertSql); // UPDATE SQL updateSql = "update " + tableName + " set "; int setFields = 0; for(int i = 0; i < tableFields.length; ++i) { JDBCCMPFieldBridge2 field = tableFields[i]; if(!field.isPrimaryKeyMember()) { if(setFields++ > 0) { updateSql += ", "; } updateSql += field.getColumnName() + "=?"; } } updateSql += " where "; updateSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { updateSql += " and " + pkFields[i].getColumnName() + "=?"; } if(entity.getVersionField() != null) { updateSql += " and " + entity.getVersionField().getColumnName() + "=?"; } log.debug("update sql: " + updateSql); // SELECT SQL String selectColumns = tableFields[0].getColumnName(); for(int i = 1; i < tableFields.length; ++i) { JDBCCMPFieldBridge2 field = tableFields[i]; selectColumns += ", " + field.getColumnName(); } String whereColumns = pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { whereColumns += " and " + pkFields[i].getColumnName() + "=?"; } if(entity.getMetaData().hasRowLocking()) { JDBCEntityPersistenceStore manager = entity.getManager(); JDBCTypeFactory typeFactory = manager.getJDBCTypeFactory(); JDBCTypeMappingMetaData typeMapping = typeFactory.getTypeMapping(); JDBCFunctionMappingMetaData rowLockingTemplate = typeMapping.getRowLockingTemplate(); if(rowLockingTemplate == null) { throw new DeploymentException("Row locking template is not defined for mapping: " + typeMapping.getName()); } selectSql = rowLockingTemplate.getFunctionSql(new Object[]{selectColumns, tableName, whereColumns, null}, new StringBuffer()).toString(); } else { selectSql = "select "; selectSql += selectColumns; selectSql += " from " + tableName + " where "; selectSql += whereColumns; } log.debug("select sql: " + selectSql); // DUPLICATE KEY if(dontFlushCreated) { duplicatePkSql = "select "; duplicatePkSql += pkFields[0].getColumnName(); for(int i = 1; i < pkFields.length; ++i) { duplicatePkSql += ", " + pkFields[i].getColumnName(); } duplicatePkSql += " from " + tableName + " where "; duplicatePkSql += pkFields[0].getColumnName() + "=?"; for(int i = 1; i < pkFields.length; ++i) { duplicatePkSql += " and " + pkFields[i].getColumnName() + "=?"; } log.debug("duplicate pk sql: " + duplicatePkSql); } if(cacheName != null) { try { serviceController.start(cacheName); } catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DeclaredSQLQueryCommand.java
private void initResultReader(JDBCEntityBridge2 entity, JDBCDeclaredQueryMetaData metadata) throws DeploymentException { String entityName = metadata.getEJBName(); if(entityName != null) { Catalog catalog = entity.getManager().getCatalog(); JDBCEntityBridge2 otherEntity = (JDBCEntityBridge2) catalog.getEntityByEJBName(entityName); if(otherEntity == null) { throw new DeploymentException("Unknown entity: " + entityName); } this.entity = otherEntity; } else { this.entity = entity; } String fieldName = metadata.getFieldName(); if(fieldName == null) { setEntityReader(this.entity, metadata.isSelectDistinct()); } else { selectedField = (JDBCCMPFieldBridge2) entity.getFieldByName(fieldName); if(selectedField == null) { throw new DeploymentException("Unknown cmp field: " + fieldName); } setFieldReader(selectedField); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DeclaredSQLQueryCommand.java
protected String parseParameters(String sql, JDBCDeclaredQueryMetaData metadata) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); ArrayList params = new ArrayList(); // Replace placeholders {0} with ? if(sql != null) { sql = sql.trim(); StringTokenizer tokens = new StringTokenizer(sql, "{}", true); while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); if(token.equals("{")) { token = tokens.nextToken(); if(Character.isDigit(token.charAt(0))) { QueryParameter parameter = new QueryParameter(entity.getManager(), metadata.getMethod(), token); // of if we are here we can assume that we have // a parameter and not a function sqlBuf.append("?"); params.add(parameter); if(!tokens.nextToken().equals("}")) { throw new DeploymentException("Invalid parameter - missing closing '}' : " + sql); } } else { // ok we don't have a parameter, we have a function // push the tokens on the buffer and continue sqlBuf.append("{").append(token); } } else { // not parameter... just append it sqlBuf.append(token); } } } setParameters(params); return sqlBuf.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
private void startEntity() throws DeploymentException { entityBridge.start(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
private JDBCEntityMetaData loadJDBCEntityMetaData() throws DeploymentException { ApplicationMetaData amd = container.getBeanMetaData().getApplicationMetaData(); // Get JDBC MetaData JDBCApplicationMetaData jamd = (JDBCApplicationMetaData)amd.getPluginData(CMP_JDBC); if(jamd == null) { // we are the first cmp entity to need jbosscmp-jdbc. // Load jbosscmp-jdbc.xml for the whole application JDBCXmlFileLoader jfl = new JDBCXmlFileLoader(container, log); jamd = jfl.load(); amd.addPluginData(CMP_JDBC, jamd); } // Get JDBC Bean MetaData String ejbName = container.getBeanMetaData().getEjbName(); JDBCEntityMetaData metadata = jamd.getBeanByEjbName(ejbName); if(metadata == null) { throw new DeploymentException("No metadata found for bean " + ejbName); } return metadata; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
private static Map createFieldMap(JDBCEntityBridge2 entityBridge) throws DeploymentException { Map abstractAccessors = getAbstractAccessors(entityBridge.getMetaData().getEntityClass()); List fields = entityBridge.getFields(); Map map = new HashMap(fields.size() * 2); for(int i = 0; i < fields.size(); i++) { FieldBridge field = (FieldBridge) fields.get(i); // get the names String fieldName = field.getFieldName(); String fieldBaseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getterName = "get" + fieldBaseName; String setterName = "set" + fieldBaseName; // get the accessor methods Method getterMethod = (Method) abstractAccessors.get(getterName); Method setterMethod = (Method) abstractAccessors.get(setterName); // getters and setters must come in pairs if(getterMethod != null && setterMethod == null) { throw new DeploymentException("Getter was found but, no setter was found for field: " + fieldName); } else if(getterMethod == null && setterMethod != null) { throw new DeploymentException("Setter was found but, no getter was found for field: " + fieldName); } else if(getterMethod != null && setterMethod != null) { // add methods map.put(getterMethod.getName(), new EntityBridgeInvocationHandler.FieldGetInvoker(field)); map.put(setterMethod.getName(), new EntityBridgeInvocationHandler.FieldSetInvoker(field)); // remove the accessors (they have been used) abstractAccessors.remove(getterName); abstractAccessors.remove(setterName); } } return Collections.unmodifiableMap(map); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
private static Map createSelectorMap(JDBCEntityBridge2 entityBridge, QueryFactory queryFactory) throws DeploymentException { Collection queries = entityBridge.getMetaData().getQueries(); Map selectorsByMethod = new HashMap(queries.size()); Iterator definedFinders = queries.iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData metadata = (JDBCQueryMetaData)definedFinders.next(); if(metadata.getMethod().getName().startsWith("ejbSelect")) { try { QueryCommand queryCommand = queryFactory.getQueryCommand(metadata.getMethod()); Schema schema = ((JDBCStoreManager2)entityBridge.getManager()).getSchema(); EJBSelectBridge ejbSelectBridge = new EJBSelectBridge(entityBridge.getContainer(), schema, metadata, queryCommand); selectorsByMethod.put(metadata.getMethod(), ejbSelectBridge); } catch(FinderException e) { throw new DeploymentException(e.getMessage()); } } } return selectorsByMethod; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void resolveRelationship() throws DeploymentException { // // Set handles to the related entity's container, cache, manager, and invoker // // Related Entity Name String relatedEntityName = metadata.getRelatedRole().getEntity().getName(); // Related Entity Catalog catalog = (Catalog)manager.getApplicationData("CATALOG"); relatedEntity = (JDBCEntityBridge2)catalog.getEntityByEJBName(relatedEntityName); if(relatedEntity == null) { throw new DeploymentException("Related entity not found: " + "entity=" + entity.getEntityName() + ", " + "cmrField=" + getFieldName() + ", " + "relatedEntity=" + relatedEntityName ); } // Related CMR Field JDBCCMRFieldBridge2[] cmrFields = (JDBCCMRFieldBridge2[])relatedEntity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge2 cmrField = cmrFields[i]; if(metadata.getRelatedRole() == cmrField.getMetaData()) { relatedCMRField = cmrField; break; } } // if we didn't find the related CMR field throw an exception with a detailed message if(relatedCMRField == null) { String message = "Related CMR field not found in " + relatedEntity.getEntityName() + " for relationship from "; message += entity.getEntityName() + "."; if(getFieldName() != null) { message += getFieldName(); } else { message += "<no-field>"; } message += " to "; message += relatedEntityName + "."; if(metadata.getRelatedRole().getCMRFieldName() != null) { message += metadata.getRelatedRole().getCMRFieldName(); } else { message += "<no-field>"; } throw new DeploymentException(message); } // Related Container relatedContainer = relatedEntity.getContainer(); // // Initialize the key fields // if(metadata.getRelationMetaData().isTableMappingStyle()) { // initialize relation table key fields Collection tableKeys = metadata.getKeyFields(); List keyFieldsList = new ArrayList(tableKeys.size()); // first phase is to create fk fields Map pkFieldsToFKFields = new HashMap(tableKeys.size()); for(Iterator i = tableKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData)i.next(); FieldBridge pkField = entity.getFieldByName(cmpFieldMetaData.getFieldName()); if(pkField == null) { throw new DeploymentException("Primary key not found for key-field " + cmpFieldMetaData.getFieldName()); } pkFieldsToFKFields.put(pkField, new JDBCCMPFieldBridge2(manager, entity, cmpFieldMetaData, -1)); } // second step is to order fk fields to match the order of pk fields JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { Object fkField = pkFieldsToFKFields.get(pkFields[i]); if(fkField == null) { throw new DeploymentException("Primary key " + pkFields[i].getFieldName() + " is not mapped."); } keyFieldsList.add(fkField); } tableKeyFields = (JDBCCMPFieldBridge2[])keyFieldsList.toArray(new JDBCCMPFieldBridge2[keyFieldsList.size()]); } else { initializeForeignKeyFields(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void initLoader() throws DeploymentException { if(metadata.getRelationMetaData().isTableMappingStyle()) { relationTable = relatedCMRField.getRelationTable(); loader = new RelationTableLoader(); } else { if(foreignKeyFields != null) { loader = new ContextForeignKeyLoader(); } else { loader = new ForeignKeyLoader(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private void initializeForeignKeyFields() throws DeploymentException { Collection foreignKeys = metadata.getRelatedRole().getKeyFields(); // temporary map used later to write fk fields in special order Map fkFieldsByRelatedPKFields = new HashMap(); for(Iterator i = foreignKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData fkFieldMetaData = (JDBCCMPFieldMetaData)i.next(); JDBCCMPFieldBridge2 relatedPKField = (JDBCCMPFieldBridge2)relatedEntity.getFieldByName(fkFieldMetaData.getFieldName()); // now determine whether the fk is mapped to a pk column String fkColumnName = fkFieldMetaData.getColumnName(); JDBCCMPFieldBridge2 fkField = null; // look among the CMP fields for the field with the same column name JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[])entity.getTableFields(); for(int tableInd = 0; tableInd < tableFields.length && fkField == null; ++tableInd) { JDBCCMPFieldBridge2 cmpField = tableFields[tableInd]; if(fkColumnName.equals(cmpField.getColumnName())) { // construct the foreign key field fkField = new JDBCCMPFieldBridge2(cmpField, relatedPKField); /* cmpField.getManager(), // this cmpField's manager relatedPKField.getFieldName(), relatedPKField.getFieldType(), cmpField.getJDBCType(), // this cmpField's jdbc type relatedPKField.isReadOnly(), relatedPKField.getReadTimeOut(), relatedPKField.getPrimaryKeyClass(), relatedPKField.getPrimaryKeyField(), cmpField, // CMP field I am mapped to this, fkColumnName ); */ } } // if the fk is not a part of pk then create a new field if(fkField == null) { fkField = entity.addTableField(fkFieldMetaData); } fkFieldsByRelatedPKFields.put(relatedPKField, fkField); // temporary map } // Note: this important to order the foreign key fields so that their order matches // the order of related entity's pk fields in case of complex primary keys. // The order is important in fk-constraint generation and in SELECT when loading if(fkFieldsByRelatedPKFields.size() > 0) { JDBCFieldBridge[] pkFields = relatedEntity.getPrimaryKeyFields(); List fkList = new ArrayList(pkFields.length); List relatedPKList = new ArrayList(pkFields.length); for(int i = 0; i < pkFields.length; ++i) { JDBCFieldBridge relatedPKField = pkFields[i]; JDBCFieldBridge fkField = (JDBCCMPFieldBridge2)fkFieldsByRelatedPKFields.remove(relatedPKField); fkList.add(fkField); relatedPKList.add(relatedPKField); } foreignKeyFields = (JDBCCMPFieldBridge2[])fkList.toArray(new JDBCCMPFieldBridge2[fkList.size()]); relatedPKFields = (JDBCCMPFieldBridge2[])relatedPKList.toArray(new JDBCCMPFieldBridge2[relatedPKList.size()]); if(metadata.hasForeignKeyConstraint()) { fkConstraint = entity.getTable().addFkConstraint(foreignKeyFields, relatedEntity.getTable()); } } else { foreignKeyFields = null; relatedPKFields = null; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private RelationTable getRelationTable() throws DeploymentException { if(relationTable == null) { relationTable = manager.getSchema().createRelationTable(this, relatedCMRField); } return relationTable; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void init() throws DeploymentException { loadCMPFields(metadata); loadCMRFields(metadata); JDBCOptimisticLockingMetaData olMD = metadata.getOptimisticLocking(); if(olMD != null) { if(olMD.getLockingStrategy() != JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY) { throw new DeploymentException( "Only version-column optimistic locking strategy is supported at the moment."); } JDBCCMPFieldMetaData versionMD = olMD.getLockingField(); versionField = (JDBCCMPFieldBridge2) getFieldByName(versionMD.getFieldName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void resolveRelationships() throws DeploymentException { for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].resolveRelationship(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void start() throws DeploymentException { if(versionField != null) { versionField.initVersion(); } table.start(); if(cmrFields != null) { for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].initLoader(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
JDBCCMPFieldBridge2 addTableField(JDBCCMPFieldMetaData metadata) throws DeploymentException { table.addField(); if(tableFields == null) { tableFields = new JDBCCMPFieldBridge2[1]; } else { JDBCCMPFieldBridge2[] tmp = tableFields; tableFields = new JDBCCMPFieldBridge2[tableFields.length + 1]; System.arraycopy(tmp, 0, tableFields, 0, tmp.length); } int tableIndex = tableFields.length - 1; JDBCCMPFieldBridge2 cmpField = new JDBCCMPFieldBridge2(manager, this, metadata, tableIndex); tableFields[tableFields.length - 1] = cmpField; return cmpField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
private void loadCMPFields(JDBCEntityMetaData metadata) throws DeploymentException { // only non pk fields are stored here at first and then later // the pk fields are added to the front (makes sql easier to read) List cmpFieldsList = new ArrayList(metadata.getCMPFields().size()); // primary key cmp fields List pkFieldsList = new ArrayList(metadata.getCMPFields().size()); // create each field Iterator iter = metadata.getCMPFields().iterator(); while(iter.hasNext()) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData) iter.next(); JDBCCMPFieldBridge2 cmpField = addTableField(cmpFieldMetaData); if(cmpFieldMetaData.isPrimaryKeyMember()) { pkFieldsList.add(cmpField); } else { cmpFieldsList.add(cmpField); } } // save the pk fields in the pk field array pkFields = new JDBCCMPFieldBridge2[pkFieldsList.size()]; for(int i = 0; i < pkFieldsList.size(); ++i) { pkFields[i] = (JDBCCMPFieldBridge2) pkFieldsList.get(i); } // add the pk fields to the front of the cmp list, per guarantee above cmpFields = new JDBCCMPFieldBridge2[metadata.getCMPFields().size() - pkFields.length]; int cmpFieldIndex = 0; for(int i = 0; i < cmpFieldsList.size(); ++i) { cmpFields[cmpFieldIndex++] = (JDBCCMPFieldBridge2) cmpFieldsList.get(i); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
private void loadCMRFields(JDBCEntityMetaData metadata) throws DeploymentException { cmrFields = new JDBCCMRFieldBridge2[metadata.getRelationshipRoles().size()]; // create each field int cmrFieldIndex = 0; for(Iterator iter = metadata.getRelationshipRoles().iterator(); iter.hasNext();) { JDBCRelationshipRoleMetaData relationshipRole = (JDBCRelationshipRoleMetaData) iter.next(); JDBCCMRFieldBridge2 cmrField = new JDBCCMRFieldBridge2(this, manager, relationshipRole); cmrFields[cmrFieldIndex++] = cmrField; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2) manager.getEntityBridge(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { this.entityBridge = (JDBCEntityBridge2)manager.getEntityBridge(); this.log = Logger.getLogger(getClass().getName() + "." + entityBridge.getEntityName()); final JDBCFieldBridge[] pkFields = entityBridge.getPrimaryKeyFields(); if(pkFields.length > 1) { throw new DeploymentException("This entity-command cannot be used with composite primary keys!"); } this.pkField = (JDBCCMPFieldBridge2) pkFields[0]; this.pkSql = ""; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/PostgreSQLCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { super.init(manager); JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand(); String sequence = metadata.getAttribute("sequence"); if (sequence == null) { sequence = entityBridge.getQualifiedTableName() + '_' + SQLUtil.getColumnNamesClause(pkField, new StringBuffer(20)) + "_seq"; } pkSql = "SELECT nextval('" + sequence + "')"; if(log.isDebugEnabled()) { log.debug("entity-command generate pk sql: " + pkSql); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/HsqldbCreateCommand.java
public void init(JDBCStoreManager2 manager) throws DeploymentException { super.init(manager); JDBCEntityCommandMetaData metadata = entityBridge.getMetaData().getEntityCommand(); pkSql = metadata.getAttribute("pk-sql"); if(pkSql == null) { pkSql = "CALL IDENTITY()"; } if(log.isDebugEnabled()) { log.debug("entity-command generate pk sql: " + pkSql); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { log = Logger.getLogger(getClass().getName() + '.' + manager.getMetaData().getName()); debug = log.isDebugEnabled(); trace = log.isTraceEnabled(); entity = (JDBCEntityBridge) manager.getEntityBridge(); securityManager = manager.getContainer().getSecurityManager(); insertAfterEjbPostCreate = manager.getContainer() .getBeanMetaData().getContainerConfiguration().isInsertAfterEjbPostCreate(); // set create allowed createAllowed = true; JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; i++) { if(pkFields[i].isReadOnly()) { createAllowed = false; log.debug("Create will not be allowed because pk field " + pkFields[i].getFieldName() + "is read only."); break; } } initGeneratedFields(); JDBCEntityCommandMetaData entityCommand = manager.getMetaData().getEntityCommand(); if(entityCommand == null) { throw new DeploymentException("entity-command is null"); } initEntityCommand(entityCommand); initInsertFields(); initInsertSQL(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { String objectName = entityCommand.getAttribute("SQLExceptionProcessor"); if(objectName != null) { try { exceptionProcessor = (SQLExceptionProcessorMBean) MBeanProxyExt.create(SQLExceptionProcessorMBean.class, objectName); } catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected JDBCCMPFieldBridge getGeneratedPKField() throws DeploymentException { // extract the pk field to be generated JDBCCMPFieldBridge pkField = null; JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { if(pkField != null) throw new DeploymentException("Generation only supported with single PK field"); pkField = (JDBCCMPFieldBridge)pkFields[i]; } return pkField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected void initGeneratedFields() throws DeploymentException { createdPrincipal = entity.getCreatedPrincipalField(); if(securityManager == null && createdPrincipal != null) { throw new DeploymentException("No security-domain configured but created-by specified"); } updatedPrincipal = entity.getUpdatedPrincipalField(); if(securityManager == null && updatedPrincipal != null) { throw new DeploymentException("No security-domain configured but updated-by specified"); } createdTime = entity.getCreatedTimeField(); updatedTime = entity.getUpdatedTimeField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public static CascadeDeleteStrategy getCascadeDeleteStrategy(JDBCCMRFieldBridge cmrField) throws DeploymentException { CascadeDeleteStrategy result; JDBCRelationshipRoleMetaData relatedRole = cmrField.getMetaData().getRelatedRole(); if(relatedRole.isBatchCascadeDelete()) { result = new BatchCascadeDeleteStrategy(cmrField); } else if(relatedRole.isCascadeDelete()) { result = new DefaultCascadeDeleteStrategy(cmrField); } else { result = new NoneCascadeDeleteStrategy(cmrField); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationshipRoleMetaData.java
public void init(JDBCRelationshipRoleMetaData relatedRole) throws DeploymentException { init(relatedRole, null); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationshipRoleMetaData.java
public void init(JDBCRelationshipRoleMetaData relatedRole, Element element) throws DeploymentException { this.relatedRole = relatedRole; if(element == null || "defaults".equals(element.getTagName())) { keyFields = loadKeyFields(); } else { keyFields = loadKeyFields(element); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationshipRoleMetaData.java
private Map loadKeyFields(Element element) throws DeploymentException { Element keysElement = MetaData.getOptionalChild(element, "key-fields"); // no field overrides, we're done if(keysElement == null) { return loadKeyFields(); } // load overrides Iterator iter = MetaData.getChildrenByTagName(keysElement, "key-field"); // if key-fields element empty, no key should be used if(!iter.hasNext()) { return Collections.EMPTY_MAP; } else if(relationMetaData.isForeignKeyMappingStyle() && isMultiplicityMany()) { throw new DeploymentException("Role: " + relationshipRoleName + " with multiplicity many using " + "foreign-key mapping is not allowed to have key-fields"); } // load the default field values Map defaultFields = getPrimaryKeyFields(); // load overrides Map fields = new HashMap(defaultFields.size()); while(iter.hasNext()) { Element keyElement = (Element) iter.next(); String fieldName = MetaData.getUniqueChildContent(keyElement, "field-name"); JDBCCMPFieldMetaData cmpField = (JDBCCMPFieldMetaData) defaultFields.remove(fieldName); if(cmpField == null) { throw new DeploymentException( "Role '" + relationshipRoleName + "' on Entity Bean '" + entity.getName() + "' : CMP field for key not found: field " + "name='" + fieldName + "'"); } String isIndexedtmp = MetaData.getOptionalChildContent(keyElement, "dbindex"); boolean isIndexed; if(isIndexedtmp != null) isIndexed = true; else isIndexed = false; genIndex = isIndexed; cmpField = new JDBCCMPFieldMetaData( entity, keyElement, cmpField, false, relationMetaData.isTableMappingStyle(), relationMetaData.isReadOnly(), relationMetaData.getReadTimeOut(), relationMetaData.isTableMappingStyle()); fields.put(cmpField.getFieldName(), cmpField); } // all fields must be overriden if(!defaultFields.isEmpty()) { throw new DeploymentException("Mappings were not provided for all " + "fields: unmaped fields=" + defaultFields.keySet() + " in role=" + relationshipRoleName); } return Collections.unmodifiableMap(fields); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
private void addDefaultFunctionMapping() throws DeploymentException { JDBCFunctionMappingMetaData function; // concat function = new JDBCFunctionMappingMetaData("concat", new String[]{ "{fn concat(", ", ", ")}" }, new int[]{0, 1}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // substring function = new JDBCFunctionMappingMetaData("substring", new String[]{ "{fn substring(", ", ", ", ", ")}" }, new int[]{0, 1, 2}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // lcase function = new JDBCFunctionMappingMetaData("lcase", new String[]{ "{fn lcase(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // ucase function = new JDBCFunctionMappingMetaData("ucase", new String[]{ "{fn ucase(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // length function = new JDBCFunctionMappingMetaData("length", new String[]{ "{fn length(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // locate function = new JDBCFunctionMappingMetaData("locate", new String[]{ "{fn locate(", ", ", ", ", ")}" }, new int[]{0, 1, 2}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // abs function = new JDBCFunctionMappingMetaData("abs", new String[]{ "{fn abs(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // sqrt function = new JDBCFunctionMappingMetaData("sqrt", new String[]{ "{fn sqrt(", ")}" }, new int[]{0}); functionMappings.put(function.getFunctionName().toLowerCase(), function); // mod function = new JDBCFunctionMappingMetaData("mod", "mod(?1, ?2)"); functionMappings.put(function.getFunctionName().toLowerCase(), function); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private int loadMappingStyle(Element element, JDBCRelationMetaData defaultValues) throws DeploymentException { // if defaults check for preferred-relation-mapping if ("defaults".equals(element.getTagName())) { // set mapping style based on preferred-relation-mapping (if possible) String perferredRelationMapping = MetaData.getOptionalChildContent(element, "preferred-relation-mapping"); if ("relation-table".equals(perferredRelationMapping) || defaultValues.isManyToMany()) { return TABLE; } else { return FOREIGN_KEY; } } // check for table mapping style if (MetaData.getOptionalChild(element, "relation-table-mapping") != null) { return TABLE; } // check for foreign-key mapping style if (MetaData.getOptionalChild(element, "foreign-key-mapping") != null) { if (defaultValues.isManyToMany()) { throw new DeploymentException("Foreign key mapping-style " + "is not allowed for many-to-many relationsips."); } return FOREIGN_KEY; } // no mapping style element, will use defaultValues return defaultValues.mappingStyle; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private static Element getMappingElement(Element element) throws DeploymentException { // if defaults check for preferred-relation-mapping if ("defaults".equals(element.getTagName())) { return element; } // check for table mapping style Element tableMappingElement = MetaData.getOptionalChild(element, "relation-table-mapping"); if (tableMappingElement != null) { return tableMappingElement; } // check for foreign-key mapping style Element foreignKeyMappingElement = MetaData.getOptionalChild(element, "foreign-key-mapping"); if (foreignKeyMappingElement != null) { return foreignKeyMappingElement; } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
private static Element getEJBRelationshipRoleElement(Element element, JDBCRelationshipRoleMetaData defaultRole) throws DeploymentException { String roleName = defaultRole.getRelationshipRoleName(); if (roleName == null) throw new DeploymentException("No ejb-relationship-role-name element found"); Iterator iter = MetaData.getChildrenByTagName(element, "ejb-relationship-role"); if (!iter.hasNext()) { throw new DeploymentException("No ejb-relationship-role " + "elements found"); } Element roleElement = null; for (int i = 0; iter.hasNext(); i++) { // only 2 roles are allowed if (i > 1) { throw new DeploymentException("Expected only 2 " + "ejb-relationship-role but found more then 2"); } Element tempElement = (Element) iter.next(); if (roleName.equals(MetaData.getUniqueChildContent(tempElement, "ejb-relationship-role-name"))) { roleElement = tempElement; } } if (roleElement == null) { throw new DeploymentException("An ejb-relationship-role element was " + "not found for role '" + roleName + "'"); } return roleElement; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCLeftJoinMetaData.java
public static List readLeftJoinList(Iterator leftJoinIterator) throws DeploymentException { List leftJoinList; if(leftJoinIterator.hasNext()) { leftJoinList = new ArrayList(); while(leftJoinIterator.hasNext()) { Element leftJoinElement = (Element)leftJoinIterator.next(); JDBCLeftJoinMetaData leftJoin = new JDBCLeftJoinMetaData(leftJoinElement); leftJoinList.add(leftJoin); } } else { leftJoinList = Collections.EMPTY_LIST; } return leftJoinList; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
private void loadLoadGroupsXml(Element element) throws DeploymentException { Element loadGroupsElement = MetaData.getOptionalChild(element, "load-groups"); if(loadGroupsElement == null) { // no info, default work already done in constructor return; } // only allowed for cmp 2.x if(isCMP1x) { throw new DeploymentException( "load-groups are only allowed " + "for CMP 2.x" ); } // load each group Iterator groups = MetaData.getChildrenByTagName(loadGroupsElement, "load-group"); while(groups.hasNext()) { Element groupElement = (Element) groups.next(); // get the load-group-name String loadGroupName = MetaData.getUniqueChildContent(groupElement, "load-group-name"); if(loadGroups.containsKey(loadGroupName)) { throw new DeploymentException( "Load group already defined: " + " load-group-name=" + loadGroupName ); } if(loadGroupName.equals("*")) { throw new DeploymentException( "The * load group is automatically " + "defined and can't be overriden" ); } ArrayList group = new ArrayList(); // add each field Iterator fields = MetaData.getChildrenByTagName(groupElement, "field-name"); while(fields.hasNext()) { String fieldName = MetaData.getElementContent((Element) fields.next()); // check if the field is a cmp field that it is not a pk memeber JDBCCMPFieldMetaData field = getCMPFieldByName(fieldName); if(field != null && field.isPrimaryKeyMember()) { throw new DeploymentException( "Primary key fields can not be" + " a member of a load group: " + " load-group-name=" + loadGroupName + " field-name=" + fieldName ); } group.add(fieldName); } loadGroups.put(loadGroupName, Collections.unmodifiableList(group)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
private void loadLazyLoadGroupsXml(Element element) throws DeploymentException { Element lazyLoadGroupsElement = MetaData.getOptionalChild(element, "lazy-load-groups"); // If no info, we're done. Default work was already done in constructor. if(lazyLoadGroupsElement == null) { return; } // only allowed for cmp 2.x if(isCMP1x) { throw new DeploymentException("lazy-load-groups is only allowed for CMP 2.x"); } // get the fields Iterator loadGroupNames = MetaData.getChildrenByTagName(lazyLoadGroupsElement, "load-group-name"); while(loadGroupNames.hasNext()) { String loadGroupName = MetaData.getElementContent((Element) loadGroupNames.next()); if(!loadGroupName.equals("*") && !loadGroups.containsKey(loadGroupName)) { throw new DeploymentException( "Lazy load group not found: " + "load-group-name=" + loadGroupName ); } lazyLoadGroups.add(loadGroupName); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public JDBCTypeMappingMetaData getTypeMapping() throws DeploymentException { if(datasourceMapping == null) { throw new DeploymentException("type-mapping is not initialized: " + dataSourceName + " was not deployed or type-mapping was not configured."); } return datasourceMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public List getLoadGroup(String name) throws DeploymentException { List group = (List) loadGroups.get(name); if(group == null) { throw new DeploymentException("Unknown load group: name=" + name); } return group; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
public static JDBCTypeMappingMetaData obtainTypeMappingFromLibrary(String dataSourceName) throws DeploymentException { JDBCTypeMappingMetaData typeMapping = null; String datasource; if(dataSourceName.startsWith("java:")) { datasource = dataSourceName.substring("java:".length()); if(datasource.startsWith("/")) { datasource = datasource.substring(1); } } else { datasource = dataSourceName; } final ObjectName metadataService; final String str = "jboss.jdbc:service=metadata,datasource=" + datasource; try { metadataService = new ObjectName(str); } catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); } try { final MBeanServer server = MBeanServerLocator.locateJBoss(); if(server.isRegistered(metadataService)) { typeMapping = (JDBCTypeMappingMetaData)server.getAttribute(metadataService, "TypeMappingMetaData"); } } catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); } /* if(typeMapping == null) { throw new DeploymentException( "type-mapping for datasource " + datasource + " not found in the library. " + "Check the value of metadata/type-mapping in the -ds.xml file." ); } */ return typeMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
private static byte readCheckDirtyAfterGet(Element element, byte defaultValue) throws DeploymentException { byte checkDirtyAfterGet; String dirtyAfterGetStr = MetaData.getOptionalChildContent(element, "check-dirty-after-get"); if(dirtyAfterGetStr == null) { checkDirtyAfterGet = defaultValue; } else { checkDirtyAfterGet = (Boolean.valueOf(dirtyAfterGetStr).booleanValue() ? CHECK_DIRTY_AFTER_GET_TRUE : CHECK_DIRTY_AFTER_GET_FALSE); } return checkDirtyAfterGet; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
public static byte readCheckDirtyAfterGet(Element element) throws DeploymentException { return readCheckDirtyAfterGet(element, CHECK_DIRTY_AFTER_GET_NOT_PRESENT); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
private Class loadFieldType(JDBCEntityMetaData entity, String fieldName) throws DeploymentException { if(entity.isCMP1x()) { // CMP 1.x field Style try { return entity.getEntityClass().getField(fieldName).getType(); } catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); } } else { // CMP 2.x abstract accessor style String baseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getName = "get" + baseName; String setName = "set" + baseName; Method[] methods = entity.getEntityClass().getMethods(); for(int i = 0; i < methods.length; i++) { // is this a public abstract method? if(Modifier.isPublic(methods[i].getModifiers()) && Modifier.isAbstract(methods[i].getModifiers())) { // get accessor if(getName.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 0 && !methods[i].getReturnType().equals(Void.TYPE)) { return methods[i].getReturnType(); } // set accessor if(setName.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 1 && methods[i].getReturnType().equals(Void.TYPE)) { return methods[i].getParameterTypes()[0]; } } } throw new DeploymentException("No abstract accessors for field " + "named '" + fieldName + "' found in entity class " + entity.getEntityClass().getName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
public JDBCApplicationMetaData load() throws DeploymentException { JDBCApplicationMetaData jamd = new JDBCApplicationMetaData( container.getBeanMetaData().getApplicationMetaData(), container.getClassLoader() ); // Load standardjbosscmp-jdbc.xml from the default classLoader // we always load defaults first URL stdJDBCUrl = container.getClassLoader().getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if (debug) log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); // first create the metadata jamd = new JDBCApplicationMetaData(stdJDBCElement, jamd); // Load jbosscmp-jdbc.xml if provided URL jdbcUrl = null; VirtualFile dd = container.getDeploymentUnit().getMetaDataFile("jbosscmp-jdbc.xml"); if(dd != null) { try { jdbcUrl = dd.toURL(); } catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); } } if(jdbcUrl != null) { if (debug) log.debug(jdbcUrl.toString() + " found. Overriding defaults"); Element jdbcElement = XmlFileLoader.getDocument(jdbcUrl, true).getDocumentElement(); jamd = new JDBCApplicationMetaData(jdbcElement, jamd); } return jamd; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCOptimisticLockingMetaData.java
private JDBCCMPFieldMetaData constructLockingField( JDBCEntityMetaData entity, Element element) throws DeploymentException { // field name String fieldName = MetaData.getOptionalChildContent(element, "field-name"); if(fieldName == null || fieldName.trim().length() < 1) fieldName = (lockingStrategy == VERSION_COLUMN_STRATEGY ? "version_lock" : (lockingStrategy == TIMESTAMP_COLUMN_STRATEGY ? "timestamp_lock" : "generated_lock")); // column name String columnName = MetaData.getOptionalChildContent(element, "column-name"); if(columnName == null || columnName.trim().length() < 1) columnName = (lockingStrategy == VERSION_COLUMN_STRATEGY ? "version_lock" : (lockingStrategy == TIMESTAMP_COLUMN_STRATEGY ? "timestamp_lock" : "generated_lock")); // field type Class fieldType = null; if(lockingStrategy == VERSION_COLUMN_STRATEGY) fieldType = java.lang.Long.class; else if(lockingStrategy == TIMESTAMP_COLUMN_STRATEGY) fieldType = java.util.Date.class; String fieldTypeStr = MetaData.getOptionalChildContent(element, "field-type"); if(fieldTypeStr != null) { try { fieldType = GetTCLAction. getContextClassLoader().loadClass(fieldTypeStr); } catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for optimistic locking field " + fieldName + ": " + fieldTypeStr); } } // JDBC/SQL Type int jdbcType; String sqlType; String jdbcTypeName = MetaData.getOptionalChildContent(element, "jdbc-type"); if(jdbcTypeName != null) { jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcTypeName); sqlType = MetaData.getUniqueChildContent(element, "sql-type"); } else { jdbcType = Integer.MIN_VALUE; sqlType = null; } return new JDBCCMPFieldMetaData( entity, fieldName, fieldType, columnName, jdbcType, sqlType ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCMappingMetaData.java
public static int getJdbcTypeFromName(String name) throws DeploymentException { if(name == null) { throw new DeploymentException("jdbc-type cannot be null"); } try { Integer constant = (Integer)Types.class.getField(name).get(null); return constant.intValue(); } catch(Exception e) { log.warn("Unrecognized jdbc-type: " + name + ", using Types.OTHER", e); return Types.OTHER; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCAuditMetaData.java
private static JDBCCMPFieldMetaData constructAuditField( JDBCEntityMetaData entity, Element element, String defaultName) throws DeploymentException { // field name String fieldName = MetaData.getOptionalChildContent(element, "field-name"); if (fieldName == null || fieldName.trim().length() < 1) fieldName = defaultName; // column name String columnName = MetaData.getOptionalChildContent(element, "column-name"); if (columnName == null || columnName.trim().length() < 1) columnName = defaultName; // field type Class fieldType; String fieldTypeStr = MetaData.getOptionalChildContent(element, "field-type"); if (fieldTypeStr != null) { try { fieldType = GetTCLAction.getContextClassLoader().loadClass(fieldTypeStr); } catch(ClassNotFoundException e) { throw new DeploymentException( "Could not load field type for audit field " + fieldName + ": " + fieldTypeStr); } } else { if (defaultName.endsWith("by")) fieldType = String.class; else fieldType = java.util.Date.class; } // JDBC/SQL Type int jdbcType; String sqlType; String jdbcTypeName = MetaData.getOptionalChildContent(element, "jdbc-type"); if (jdbcTypeName != null) { jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcTypeName); sqlType = MetaData.getUniqueChildContent(element, "sql-type"); } else { jdbcType = Integer.MIN_VALUE; sqlType = null; } // Is the field exposed? JDBCCMPFieldMetaData result = entity.getCMPFieldByName(fieldName); if (result == null) result = new JDBCCMPFieldMetaData(entity, fieldName, fieldType, columnName, jdbcType, sqlType); return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
private void initFromString(String sql) throws DeploymentException { ArrayList chunkList = new ArrayList(); ArrayList parameterList = new ArrayList(); // add a dummy chunk so we can be assured that the sql started with chunk before a number if(sql.charAt(0) == '?') { chunkList.add(""); } // break the sql into chunks and parameters StringBuffer chunk = new StringBuffer(); StringReader reader = new StringReader(sql); try { for(int c = reader.read(); c >= 0; c = reader.read()) { if(c != '?') { chunk.append((char)c); } else { chunkList.add(chunk.toString()); chunk = new StringBuffer(); // read the number StringBuffer number = new StringBuffer(); for(int digit = reader.read(); digit >= 0; digit = reader.read()) { if(Character.isDigit((char)digit)) { number.append((char)digit); } else { if(digit >= 0) { chunk.append((char)digit); } break; } } if(number.length() == 0) { throw new DeploymentException("Invalid parameter in function-sql: " + sql); } Integer parameter; try { parameter = new Integer(number.toString()); } catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); } parameterList.add(parameter); } } } catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); } chunkList.add(chunk.toString()); // save out the chunks sqlChunks = new String[chunkList.size()]; chunkList.toArray(sqlChunks); // save out the parameter order parameters = new int[parameterList.size()]; for(int i = 0; i < parameters.length; i++) { parameters[i] = ((Integer)parameterList.get(i)).intValue() - 1; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
public Map createJDBCQueryMetaData(QueryMetaData queryData) throws DeploymentException { Method[] methods = getQueryMethods(queryData); Map queries = new HashMap(methods.length); for(int i = 0; i < methods.length; i++) { queries.put( methods[i], new JDBCQlQueryMetaData(queryData, methods[i], entity.getQLCompiler(), false) ); } return queries; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
public Map createJDBCQueryMetaData(Element queryElement, Map defaultValues, JDBCReadAheadMetaData readAhead) throws DeploymentException { // get the query methods Method[] methods = getQueryMethods(queryElement); // read-ahead Element readAheadElement = MetaData.getOptionalChild(queryElement, "read-ahead"); if(readAheadElement != null) { readAhead = new JDBCReadAheadMetaData(readAheadElement, readAhead); } Map queries = new HashMap(methods.length); for(int i = 0; i < methods.length; i++) { JDBCQueryMetaData defaultValue = (JDBCQueryMetaData) defaultValues.get(methods[i]); if(defaultValue == null && !entity.isCMP1x() && !methods[i].getName().equals("findByPrimaryKey")) { //throw new DeploymentException("Unknown query method : " + methods[i]); log.warn("The query method is not defined in ejb-jar.xml: " + methods[i]); } JDBCQueryMetaData jdbcQueryData = createJDBCQueryMetaData( defaultValue, queryElement, methods[i], readAhead ); queries.put(methods[i], jdbcQueryData); } return queries; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
public static JDBCQueryMetaData createJDBCQueryMetaData(JDBCQueryMetaData jdbcQueryMetaData, JDBCReadAheadMetaData readAhead, Class qlCompiler) throws DeploymentException { // RAW-SQL if(jdbcQueryMetaData instanceof JDBCRawSqlQueryMetaData) { return new JDBCRawSqlQueryMetaData(jdbcQueryMetaData.getMethod(), qlCompiler, false); } // JBOSS-QL if(jdbcQueryMetaData instanceof JDBCJBossQLQueryMetaData) { return new JDBCJBossQLQueryMetaData( (JDBCJBossQLQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // DYNAMIC-SQL if(jdbcQueryMetaData instanceof JDBCDynamicQLQueryMetaData) { return new JDBCDynamicQLQueryMetaData( (JDBCDynamicQLQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // DECLARED-SQL if(jdbcQueryMetaData instanceof JDBCDeclaredQueryMetaData) { return new JDBCDeclaredQueryMetaData( (JDBCDeclaredQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } // EJB-QL: default if(jdbcQueryMetaData instanceof JDBCQlQueryMetaData) { return new JDBCQlQueryMetaData( (JDBCQlQueryMetaData) jdbcQueryMetaData, readAhead, qlCompiler, false ); } throw new DeploymentException( "Error in query specification for method " + jdbcQueryMetaData.getMethod().getName() ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private JDBCQueryMetaData createJDBCQueryMetaData(JDBCQueryMetaData jdbcQueryMetaData, Element queryElement, Method method, JDBCReadAheadMetaData readAhead) throws DeploymentException { final Class qlCompiler = JDBCQueryManager.getQLCompiler(queryElement, entity); final boolean isResultTypeMappingLocal = (jdbcQueryMetaData == null ? false : jdbcQueryMetaData.isResultTypeMappingLocal()); final boolean lazyResultSetLoading = Collection.class.isAssignableFrom(method.getReturnType()) && MetaData.getOptionalChildBooleanContent(queryElement, "lazy-resultset-loading"); // RAW-SQL Element rawSql = MetaData.getOptionalChild(queryElement, "raw-sql"); if(rawSql != null) { return new JDBCRawSqlQueryMetaData(method, qlCompiler, lazyResultSetLoading); } // JBOSS-QL Element jbossQL = MetaData.getOptionalChild(queryElement, "jboss-ql"); if(jbossQL != null) { return new JDBCJBossQLQueryMetaData( isResultTypeMappingLocal, jbossQL, method, readAhead, qlCompiler, lazyResultSetLoading ); } // DYNAMIC-SQL Element dynamicQL = MetaData.getOptionalChild(queryElement, "dynamic-ql"); if(dynamicQL != null) { return new JDBCDynamicQLQueryMetaData(isResultTypeMappingLocal, method, readAhead, qlCompiler, lazyResultSetLoading); } // DECLARED-SQL Element delcaredSql = MetaData.getOptionalChild(queryElement, "declared-sql"); if(delcaredSql != null) { return new JDBCDeclaredQueryMetaData( isResultTypeMappingLocal, delcaredSql, method, readAhead, qlCompiler, lazyResultSetLoading ); } // EJB-QL: default if(jdbcQueryMetaData instanceof JDBCQlQueryMetaData) { return new JDBCQlQueryMetaData( (JDBCQlQueryMetaData) jdbcQueryMetaData, method, readAhead ); } throw new DeploymentException("Error in query specification for method " + method.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(Element queryElement) throws DeploymentException { // query-method sub-element Element queryMethod = MetaData.getUniqueChild(queryElement, "query-method"); // method name String methodName = MetaData.getUniqueChildContent(queryMethod, "method-name"); // method params ArrayList methodParams = new ArrayList(); Element methodParamsElement = MetaData.getUniqueChild(queryMethod, "method-params"); Iterator iterator = MetaData.getChildrenByTagName(methodParamsElement, "method-param"); while(iterator.hasNext()) { methodParams.add(MetaData.getElementContent((Element) iterator.next())); } try { Class[] parameters = Classes.convertToJavaClasses(methodParams.iterator(), entity.getClassLoader()); return getQueryMethods(methodName, parameters); } catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(QueryMetaData queryData) throws DeploymentException { String methodName = queryData.getMethodName(); try { Class[] parameters = Classes.convertToJavaClasses(queryData.getMethodParams(), entity.getClassLoader()); return getQueryMethods(methodName, parameters); } catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
private Method[] getQueryMethods(String methodName, Class parameters[]) throws DeploymentException { // find the query and load the xml ArrayList methods = new ArrayList(2); if(methodName.startsWith("ejbSelect")) { // bean method Method method = getQueryMethod(methodName, parameters, entity.getEntityClass()); if(method != null) { methods.add(method); } } else { // remote home Class homeClass = entity.getHomeClass(); if(homeClass != null) { Method method = getQueryMethod(methodName, parameters, homeClass); if(method != null) { methods.add(method); } } // local home Class localHomeClass = entity.getLocalHomeClass(); if(localHomeClass != null) { Method method = getQueryMethod(methodName, parameters, localHomeClass); if(method != null) { methods.add(method); } } } if(methods.size() == 0) { StringBuffer sb = new StringBuffer(300); sb.append("Query method not found: ") .append(methodName).append('('); for(int i = 0; i < parameters.length; i++) { if(i > 0) { sb.append(','); } sb.append(parameters[i].getName()); } sb.append(')'); throw new DeploymentException(sb.toString()); } return (Method[]) methods.toArray(new Method[methods.size()]); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); // if no exception processor is defined, we will perform a existance // check before trying the insert to report duplicate key if(exceptionProcessor == null) { initExistsSQL(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected void setSelectEntity(JDBCEntityBridge selectEntity) throws DeploymentException { if(queryMetaData.getMethod().getName().startsWith("find") && this.selectEntity != null && this.selectEntity != selectEntity) { throw new DeploymentException("Finder " + queryMetaData.getMethod().getName() + " defined on " + this.selectEntity.getEntityName() + " should return only instances of " + this.selectEntity.getEntityName() + " but the query results in instances of " + selectEntity.getEntityName()); } this.selectField = null; this.selectFunction = null; this.selectEntity = selectEntity; this.selectManager = (JDBCStoreManager) selectEntity.getManager(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected String parseParameters(String sql) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); ArrayList params = new ArrayList(); // Replace placeholders {0} with ? if(sql != null) { sql = sql.trim(); StringTokenizer tokens = new StringTokenizer(sql, "{}", true); while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); if(token.equals("{")) { token = tokens.nextToken(); if(Character.isDigit(token.charAt(0))) { QueryParameter parameter = new QueryParameter(selectManager, queryMetaData.getMethod(), token); // of if we are here we can assume that we have // a parameter and not a function sqlBuf.append("?"); params.add(parameter); if(!tokens.nextToken().equals("}")) { throw new DeploymentException("Invalid parameter - missing closing '}' : " + sql); } } else { // ok we don't have a parameter, we have a function // push the tokens on the buffer and continue sqlBuf.append("{").append(token); } } else { // not parameter... just append it sqlBuf.append(token); } } } parameters = params; return sqlBuf.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public static List getLeftJoinCMRNodes(JDBCEntityBridge entity, String path, Iterator leftJoinIter, Set declaredPaths) throws DeploymentException { List leftJoinCMRNodes; if(leftJoinIter.hasNext()) { leftJoinCMRNodes = new ArrayList(); while(leftJoinIter.hasNext()) { JDBCLeftJoinMetaData leftJoin = (JDBCLeftJoinMetaData) leftJoinIter.next(); JDBCCMRFieldBridge cmrField = entity.getCMRFieldByName(leftJoin.getCmrField()); if(cmrField == null) { throw new DeploymentException("cmr-field in left-join was not found: cmr-field=" + leftJoin.getCmrField() + ", entity=" + entity.getEntityName()); } List subNodes; JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity(); String childPath = path + '.' + cmrField.getFieldName(); if(declaredPaths != null) { declaredPaths.add(childPath); } subNodes = getLeftJoinCMRNodes(relatedEntity, childPath, leftJoin.getLeftJoins(), declaredPaths); boolean[] mask = relatedEntity.getLoadGroupMask(leftJoin.getEagerLoadGroup()); LeftJoinCMRNode node = new LeftJoinCMRNode(childPath, cmrField, mask, subNodes); leftJoinCMRNodes.add(node); } } else { leftJoinCMRNodes = Collections.EMPTY_LIST; } return leftJoinCMRNodes; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public static final CMPFieldStateFactory getCMPFieldStateFactory(JDBCTypeFactory factory, String implClassName, Class clazz) throws DeploymentException { CMPFieldStateFactory stateFactory; // if the state factory is not provided on the field level use the one from the user type mapping if any if(implClassName == null) { JDBCUserTypeMappingMetaData userMapping = (JDBCUserTypeMappingMetaData)factory.userTypeMappings.get(clazz.getName()); if(userMapping != null) { implClassName = userMapping.getStateFactory(); } } if(implClassName != null) { try { Class implClass = TCLAction.UTIL.getContextClassLoader().loadClass(implClassName); stateFactory = (CMPFieldStateFactory)implClass.newInstance(); } catch(ClassNotFoundException e) { throw new DeploymentException("Could not load state factory class: " + implClassName); } catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); } } else if(Map.class.isAssignableFrom(clazz)) { stateFactory = MAP; } else if(List.class.isAssignableFrom(clazz)) { stateFactory = LIST; } else if(Set.class.isAssignableFrom(clazz)) { stateFactory = SET; } else if(clazz.isArray()) { stateFactory = ARRAY; } else if(usedWithEqualsStateFactory(clazz)) { stateFactory = EQUALS; } else { stateFactory = INVALID_UNLESS_NULL; } return stateFactory; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public JDBCType getJDBCType(JDBCCMPFieldMetaData cmpField) throws DeploymentException { JDBCType fieldJDBCType; final Class fieldType = cmpField.getFieldType(); if(complexTypes.containsKey(fieldType)) { fieldJDBCType = createTypeComplex(cmpField); } else { fieldJDBCType = createTypeSimple(cmpField); } return fieldJDBCType; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private JDBCTypeSimple createTypeSimple(JDBCCMPFieldMetaData cmpField) throws DeploymentException { String columnName = cmpField.getColumnName(); Class javaType = cmpField.getFieldType(); JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType); String paramSetter = typeMappingMD.getParamSetter(); String resultReader = typeMappingMD.getResultReader(); int jdbcType; String sqlType = cmpField.getSQLType(); if(sqlType != null) { jdbcType = cmpField.getJDBCType(); } else { // get jdbcType and sqlType from typeMapping sqlType = typeMappingMD.getSqlType(); jdbcType = typeMappingMD.getJdbcType(); } boolean notNull = cmpField.isNotNull(); boolean autoIncrement = cmpField.isAutoIncrement(); Mapper mapper = null; JDBCUserTypeMappingMetaData userTypeMapping = (JDBCUserTypeMappingMetaData)userTypeMappings.get(javaType.getName()); if(userTypeMapping != null) { String mappedTypeStr = userTypeMapping.getMappedType(); try { final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader(); Class mapperClass = contextClassLoader.loadClass(userTypeMapping.getMapper()); mapper = (Mapper)mapperClass.newInstance(); javaType = contextClassLoader.loadClass(mappedTypeStr); if(cmpField.getSQLType() == null) { JDBCMappingMetaData mappingMD = typeMapping.getTypeMappingMetaData(javaType); sqlType = mappingMD.getSqlType(); jdbcType = mappingMD.getJdbcType(); paramSetter = mappingMD.getParamSetter(); resultReader = mappingMD.getResultReader(); } } catch(ClassNotFoundException e) { throw new DeploymentException("Class not found for mapper: " + userTypeMapping.getMapper(), e); } catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); } } JDBCParameterSetter paramSetterImpl; if(paramSetter == null) { paramSetterImpl = JDBCUtil.getParameterSetter(jdbcType, javaType); } else { paramSetterImpl = (JDBCParameterSetter)newInstance(paramSetter); } JDBCResultSetReader resultReaderImpl; if(resultReader == null) { resultReaderImpl = JDBCUtil.getResultSetReader(jdbcType, javaType); } else { resultReaderImpl = (JDBCResultSetReader)newInstance(resultReader); } return new JDBCTypeSimple( columnName, javaType, jdbcType, sqlType, notNull, autoIncrement, mapper, paramSetterImpl, resultReaderImpl ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private Object newInstance(String className) throws DeploymentException { Class clazz = loadClass(className); try { return clazz.newInstance(); } catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private Class loadClass(String className) throws DeploymentException { try { final ClassLoader contextClassLoader = TCLAction.UTIL.getContextClassLoader(); return contextClassLoader.loadClass(className); } catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load class: " + className, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCreateBeanClassInstanceCommand.java
private Map createFieldMap() throws DeploymentException { Map abstractAccessors = getAbstractAccessors(); List fields = entityBridge.getFields(); Map map = new HashMap(fields.size() * 2); for(int i = 0; i < fields.size(); i++) { FieldBridge field = (FieldBridge) fields.get(i); // get the names String fieldName = field.getFieldName(); String fieldBaseName = Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1); String getterName = "get" + fieldBaseName; String setterName = "set" + fieldBaseName; // get the accessor methods Method getterMethod = (Method) abstractAccessors.get(getterName); Method setterMethod = (Method) abstractAccessors.get(setterName); // getters and setters must come in pairs if(getterMethod != null && setterMethod == null) { throw new DeploymentException("Getter was found but no setter was found for field " + fieldName + " in entity " + entityBridge.getEntityName()); } else if(getterMethod == null && setterMethod != null) { throw new DeploymentException("Setter was found but no getter was found for field " + fieldName + " in entity " + entityBridge.getEntityName()); } else if(getterMethod != null && setterMethod != null) { // add methods map.put(getterMethod.getName(), new EntityBridgeInvocationHandler.FieldGetInvoker(field)); map.put(setterMethod.getName(), new EntityBridgeInvocationHandler.FieldSetInvoker(field)); // remove the accessors (they have been used) abstractAccessors.remove(getterName); abstractAccessors.remove(setterName); } } return Collections.unmodifiableMap(map); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
public void execute() throws DeploymentException { Set existedTables = getExistedTables(manager); boolean tableExisted = SQLUtil.tableExists(entity.getQualifiedTableName(), entity.getDataSource()); if(tableExisted) { existedTables.add(entity.getEntityName()); } if(tableExisted) { if(entityMetaData.getAlterTable()) { SQLUtil.OldColumns oldColumns = SQLUtil.getOldColumns(entity.getQualifiedTableName(), entity.getDataSource()); ArrayList oldNames = oldColumns.getColumnNames(); ArrayList oldTypes = oldColumns.getTypeNames(); ArrayList oldSizes = oldColumns.getColumnSizes(); SQLUtil.OldIndexes oldIndexes = null; ArrayList newNames = new ArrayList(); JDBCFieldBridge fields[] = entity.getTableFields(); String tableName = entity.getQualifiedTableName(); for(int i = 0; i < fields.length; i++) { JDBCFieldBridge field = fields[i]; JDBCType jdbcType = field.getJDBCType(); String[] columnNames = jdbcType.getColumnNames(); String[] sqlTypes = jdbcType.getSQLTypes(); boolean[] notNull = jdbcType.getNotNull(); for(int j = 0; j < columnNames.length; j++) { String name = columnNames[j]; String ucName = name.toUpperCase(); newNames.add( ucName ); int oldIndex = oldNames.indexOf( ucName ); if(oldIndex == -1) { // add new column StringBuffer buf = new StringBuffer( sqlTypes[j] ); if( notNull[j] ) { buf.append(SQLUtil.NOT).append(SQLUtil.NULL); } alterTable(entity.getDataSource(), entityMetaData.getTypeMapping().getAddColumnTemplate(), tableName, name, buf.toString()); } else { // alter existing columns // only CHAR and VARCHAR fields are altered, and only when they are longer then before String type = (String) oldTypes.get(oldIndex); if(type.equals("CHAR") || type.equals("VARCHAR")) { try { // get new length String l = sqlTypes[j]; l = l.substring(l.indexOf('(') + 1, l.length() - 1); Integer oldLength = (Integer) oldSizes.get(oldIndex); if(Integer.parseInt(l) > oldLength.intValue()) { alterTable(entity.getDataSource(), entityMetaData.getTypeMapping().getAlterColumnTemplate(), tableName, name, sqlTypes[j] ); } } catch(Exception e) { log.warn("EXCEPTION ALTER :" + e.toString()); } } } } // see if we have to add an index for the field JDBCCMPFieldMetaData fieldMD = entity.getMetaData().getCMPFieldByName(field.getFieldName()); if(fieldMD != null && fieldMD.isIndexed()) { if(oldIndexes == null) { oldIndexes = SQLUtil.getOldIndexes(entity.getQualifiedTableName(), entity.getDataSource()); idxCount = oldIndexes.getIndexNames().size(); } if(!hasIndex(oldIndexes, field)) { createCMPIndex( entity.getDataSource(), field, oldIndexes.getIndexNames() ); } } } // for int i; // delete old columns Iterator it = oldNames.iterator(); while(it.hasNext()) { String name = (String) (it.next()); if(!newNames.contains(name)) { alterTable(entity.getDataSource(), entityMetaData.getTypeMapping().getDropColumnTemplate(), tableName, name, ""); } } } } // Create table if necessary Set createdTables = getCreatedTables(manager); if(entityMetaData.getCreateTable() && !createdTables.contains(entity.getEntityName())) { DataSource dataSource = entity.getDataSource(); createTable(dataSource, entity.getQualifiedTableName(), getEntityCreateTableSQL(dataSource)); // create indices only if table did not yet exist. if(!tableExisted) { createCMPIndices( dataSource, SQLUtil.getOldIndexes( entity.getQualifiedTableName(), entity.getDataSource() ).getIndexNames() ); } else { if(log.isDebugEnabled()) { log.debug("Indices for table " + entity.getQualifiedTableName() + "not created as table existed"); } } // issue extra (user-defined) sql for table if(!tableExisted) { issuePostCreateSQL(dataSource, entity.getMetaData().getDefaultTablePostCreateCmd(), entity.getQualifiedTableName()); } createdTables.add(entity.getEntityName()); } else { log.debug("Table not create as requested: " + entity.getQualifiedTableName()); } // create relation tables JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCAbstractCMRFieldBridge cmrField = cmrFields[i]; JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData(); DataSource dataSource = relationMetaData.getDataSource(); // if the table for the related entity has been created final EntityBridge relatedEntity = cmrField.getRelatedEntity(); if(relationMetaData.isTableMappingStyle() && createdTables.contains(relatedEntity.getEntityName())) { boolean relTableExisted = SQLUtil.tableExists(cmrField.getQualifiedTableName(), entity.getDataSource()); if(relTableExisted) { if(relationMetaData.getAlterTable()) { ArrayList oldNames = SQLUtil.getOldColumns(cmrField.getQualifiedTableName(), dataSource).getColumnNames(); ArrayList newNames = new ArrayList(); JDBCFieldBridge[] leftKeys = cmrField.getTableKeyFields(); JDBCFieldBridge[] rightKeys = cmrField.getRelatedCMRField().getTableKeyFields(); JDBCFieldBridge[] fields = new JDBCFieldBridge[leftKeys.length + rightKeys.length]; System.arraycopy(leftKeys, 0, fields, 0, leftKeys.length); System.arraycopy(rightKeys, 0, fields, leftKeys.length, rightKeys.length); // have to append field names to leftKeys, rightKeys... boolean different = false; for(int j = 0; j < fields.length; j++) { JDBCFieldBridge field = fields[j]; String name = field.getJDBCType().getColumnNames()[0].toUpperCase(); newNames.add(name); if(!oldNames.contains(name)) { different = true; break; } } // for int j; if(!different) { Iterator it = oldNames.iterator(); while(it.hasNext()) { String name = (String) (it.next()); if(!newNames.contains(name)) { different = true; break; } } } if(different) { // only log, don't drop table is this can cause data loss log.error("CMR table structure is incorrect for " + cmrField.getQualifiedTableName()); //SQLUtil.dropTable(entity.getDataSource(), cmrField.getQualifiedTableName()); } } // if alter-table } // if existed // create the relation table if(relationMetaData.isTableMappingStyle() && !relationMetaData.isTableCreated()) { if(relationMetaData.getCreateTable()) { createTable(dataSource, cmrField.getQualifiedTableName(), getRelationCreateTableSQL(cmrField, dataSource)); } else { log.debug("Relation table not created as requested: " + cmrField.getQualifiedTableName()); } // create Indices if needed createCMRIndex(dataSource, cmrField); if(relationMetaData.getCreateTable()) { issuePostCreateSQL(dataSource, relationMetaData.getDefaultTablePostCreateCmd(), cmrField.getQualifiedTableName()); } } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
public void addForeignKeyConstraints() throws DeploymentException { Set createdTables = getCreatedTables(manager); JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCAbstractCMRFieldBridge cmrField = cmrFields[i]; EntityBridge relatedEntity = cmrField.getRelatedEntity(); JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData(); if(relationMetaData.isForeignKeyMappingStyle() && (createdTables.contains(relatedEntity.getEntityName()))) { createCMRIndex(((JDBCAbstractEntityBridge)relatedEntity).getDataSource(), cmrField); } // Create fk constraint addForeignKeyConstraint(cmrField); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void alterTable(DataSource dataSource, JDBCFunctionMappingMetaData mapping, String tableName, String fieldName, String fieldStructure) throws DeploymentException { StringBuffer sqlBuf = new StringBuffer(); mapping.getFunctionSql( new String[]{tableName, fieldName, fieldStructure}, sqlBuf ); String sql = sqlBuf.toString(); if(log.isDebugEnabled()) log.debug("Executing: " + sql); // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); } try { Connection con = null; Statement statement = null; try { con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); } } // success if ( log.isDebugEnabled() ) log.debug("Table altered successfully."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createTable(DataSource dataSource, String tableName, String sql) throws DeploymentException { // does this table already exist if(SQLUtil.tableExists(tableName, dataSource)) { log.debug("Table '" + tableName + "' already exists"); return; } // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); } try { Connection con = null; Statement statement = null; try { // execute sql if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } // success Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); createdTables.add(tableName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createIndex(DataSource dataSource, String tableName, String indexName, String sql) throws DeploymentException { // we are only called directly after creating a table // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); } try { Connection con = null; Statement statement = null; try { // execute sql if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void issuePostCreateSQL(DataSource dataSource, List sql, String table) throws DeploymentException { if(sql == null) { // no work to do. log.trace("issuePostCreateSQL: sql is null"); return; } log.debug("issuePostCreateSQL::sql: " + sql.toString() + " on table " + table); TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); } String currentCmd = ""; try { Connection con = null; Statement statement = null; try { con = dataSource.getConnection(); statement = con.createStatement(); // execute sql for(int i = 0; i < sql.size(); i++) { currentCmd = (String) sql.get(i); /* * Replace %%t in the sql command with the current table name */ currentCmd = replaceTable(currentCmd, table); currentCmd = replaceIndexCounter(currentCmd); log.debug("Executing SQL: " + currentCmd); statement.executeUpdate(currentCmd); } } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); } } // success log.debug("Issued SQL " + sql + " successfully."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private String getEntityCreateTableSQL(DataSource dataSource) throws DeploymentException { StringBuffer sql = new StringBuffer(); sql.append(SQLUtil.CREATE_TABLE).append(entity.getQualifiedTableName()).append(" ("); // add fields boolean comma = false; JDBCFieldBridge[] fields = entity.getTableFields(); for(int i = 0; i < fields.length; ++i) { JDBCFieldBridge field = fields[i]; JDBCType type = field.getJDBCType(); if(comma) { sql.append(SQLUtil.COMMA); } else { comma = true; } addField(type, sql); } // add a pk constraint if(entityMetaData.hasPrimaryKeyConstraint()) { JDBCFunctionMappingMetaData pkConstraint = manager.getMetaData().getTypeMapping().getPkConstraintTemplate(); if(pkConstraint == null) { throw new IllegalStateException("Primary key constraint is " + "not allowed for this type of data source"); } String defTableName = entity.getManager().getMetaData().getDefaultTableName(); String name = "pk_" + SQLUtil.unquote(defTableName, dataSource); name = SQLUtil.fixConstraintName(name, dataSource); String[] args = new String[]{ name, SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), new StringBuffer(100)).toString() }; sql.append(SQLUtil.COMMA); pkConstraint.getFunctionSql(args, sql); } return sql.append(')').toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createCMPIndices(DataSource dataSource, ArrayList indexNames) throws DeploymentException { // Only create indices on CMP fields JDBCFieldBridge[] cmpFields = entity.getTableFields(); for(int i = 0; i < cmpFields.length; ++i) { JDBCFieldBridge field = cmpFields[i]; JDBCCMPFieldMetaData fieldMD = entity.getMetaData().getCMPFieldByName(field.getFieldName()); if(fieldMD != null && fieldMD.isIndexed()) { createCMPIndex(dataSource, field, indexNames); } } final JDBCAbstractCMRFieldBridge[] cmrFields = entity.getCMRFields(); if(cmrFields != null) { for(int i = 0; i < cmrFields.length; ++i) { JDBCAbstractCMRFieldBridge cmrField = cmrFields[i]; if(cmrField.getRelatedCMRField().getMetaData().isIndexed()) { final JDBCFieldBridge[] fkFields = cmrField.getForeignKeyFields(); if(fkFields != null) { for(int fkInd = 0; fkInd < fkFields.length; ++fkInd) { createCMPIndex(dataSource, fkFields[fkInd], indexNames); } } } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createCMPIndex(DataSource dataSource, JDBCFieldBridge field, ArrayList indexNames) throws DeploymentException { StringBuffer sql; log.debug("Creating index for field " + field.getFieldName()); sql = new StringBuffer(); sql.append(SQLUtil.CREATE_INDEX); String indexName; boolean indexExists; do { indexName = entity.getQualifiedTableName() + IDX_POSTFIX + idxCount; idxCount++; indexExists = false; if ( indexNames != null ) { for ( int i = 0 ; i < indexNames.size() && !indexExists ; i++ ) { indexExists = indexName.equalsIgnoreCase( ( (String) indexNames.get( i ) ) ); } } } while ( indexExists ); sql.append( indexName ); sql.append(SQLUtil.ON); sql.append(entity.getQualifiedTableName() + " ("); SQLUtil.getColumnNamesClause(field, sql); sql.append(")"); createIndex(dataSource, entity.getQualifiedTableName(), indexName, sql.toString()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createCMRIndex(DataSource dataSource, JDBCAbstractCMRFieldBridge field) throws DeploymentException { JDBCRelationMetaData rmd; String tableName; rmd = field.getMetaData().getRelationMetaData(); if(rmd.isTableMappingStyle()) { tableName = rmd.getDefaultTableName(); createFKIndex(rmd.getLeftRelationshipRole(), dataSource, tableName); createFKIndex(rmd.getRightRelationshipRole(), dataSource, tableName); } else if(field.hasForeignKey()) { tableName = field.getEntity().getQualifiedTableName(); createFKIndex(field.getRelatedCMRField().getMetaData(), dataSource, tableName); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void createFKIndex(JDBCRelationshipRoleMetaData metadata, DataSource dataSource, String tableName) throws DeploymentException { Collection kfl = metadata.getKeyFields(); Iterator it = kfl.iterator(); while(it.hasNext()) { JDBCCMPFieldMetaData fi = (JDBCCMPFieldMetaData) it.next(); if(metadata.isIndexed()) { createIndex(dataSource, tableName, fi.getFieldName(), createIndexSQL(fi, tableName)); idxCount++; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addField(JDBCType type, StringBuffer sqlBuffer) throws DeploymentException { // apply auto-increment template if(type.getAutoIncrement()[0]) { String columnClause = SQLUtil.getCreateTableColumnsClause(type); JDBCFunctionMappingMetaData autoIncrement = manager.getMetaData().getTypeMapping().getAutoIncrementTemplate(); if(autoIncrement == null) { throw new IllegalStateException("auto-increment template not found"); } String[] args = new String[]{columnClause}; autoIncrement.getFunctionSql(args, sqlBuffer); } else { sqlBuffer.append(SQLUtil.getCreateTableColumnsClause(type)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private String getRelationCreateTableSQL(JDBCAbstractCMRFieldBridge cmrField, DataSource dataSource) throws DeploymentException { JDBCFieldBridge[] leftKeys = cmrField.getTableKeyFields(); JDBCFieldBridge[] rightKeys = cmrField.getRelatedCMRField().getTableKeyFields(); JDBCFieldBridge[] fieldsArr = new JDBCFieldBridge[leftKeys.length + rightKeys.length]; System.arraycopy(leftKeys, 0, fieldsArr, 0, leftKeys.length); System.arraycopy(rightKeys, 0, fieldsArr, leftKeys.length, rightKeys.length); StringBuffer sql = new StringBuffer(); sql.append(SQLUtil.CREATE_TABLE).append(cmrField.getQualifiedTableName()) .append(" (") // add field declaration .append(SQLUtil.getCreateTableColumnsClause(fieldsArr)); // add a pk constraint final JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData(); if(relationMetaData.hasPrimaryKeyConstraint()) { JDBCFunctionMappingMetaData pkConstraint = manager.getMetaData().getTypeMapping().getPkConstraintTemplate(); if(pkConstraint == null) { throw new IllegalStateException("Primary key constraint is not allowed for this type of data store"); } String name = "pk_" + relationMetaData.getDefaultTableName(); name = SQLUtil.fixConstraintName(name, dataSource); String[] args = new String[]{ name, SQLUtil.getColumnNamesClause(fieldsArr, new StringBuffer(100).toString(), new StringBuffer()).toString() }; sql.append(SQLUtil.COMMA); pkConstraint.getFunctionSql(args, sql); } sql.append(')'); return sql.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addForeignKeyConstraint(JDBCAbstractCMRFieldBridge cmrField) throws DeploymentException { JDBCRelationshipRoleMetaData metaData = cmrField.getMetaData(); if(metaData.hasForeignKeyConstraint()) { if(metaData.getRelationMetaData().isTableMappingStyle()) { addForeignKeyConstraint(metaData.getRelationMetaData().getDataSource(), cmrField.getQualifiedTableName(), cmrField.getFieldName(), cmrField.getTableKeyFields(), cmrField.getEntity().getQualifiedTableName(), cmrField.getEntity().getPrimaryKeyFields()); } else if(cmrField.hasForeignKey()) { JDBCAbstractEntityBridge relatedEntity = (JDBCAbstractEntityBridge) cmrField.getRelatedEntity(); addForeignKeyConstraint(cmrField.getEntity().getDataSource(), cmrField.getEntity().getQualifiedTableName(), cmrField.getFieldName(), cmrField.getForeignKeyFields(), relatedEntity.getQualifiedTableName(), relatedEntity.getPrimaryKeyFields()); } } else { log.debug("Foreign key constraint not added as requested: relationshipRolename=" + metaData.getRelationshipRoleName()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addForeignKeyConstraint(DataSource dataSource, String tableName, String cmrFieldName, JDBCFieldBridge[] fields, String referencesTableName, JDBCFieldBridge[] referencesFields) throws DeploymentException { // can only alter tables we created Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); if(!createdTables.contains(tableName)) { return; } JDBCFunctionMappingMetaData fkConstraint = manager.getMetaData().getTypeMapping().getFkConstraintTemplate(); if(fkConstraint == null) { throw new IllegalStateException("Foreign key constraint is not allowed for this type of datastore"); } String a = SQLUtil.getColumnNamesClause(fields, new StringBuffer(50)).toString(); String b = SQLUtil.getColumnNamesClause(referencesFields, new StringBuffer(50)).toString(); String[] args = new String[]{ tableName, SQLUtil.fixConstraintName("fk_" + tableName + "_" + cmrFieldName, dataSource), a, referencesTableName, b}; String sql = fkConstraint.getFunctionSql(args, new StringBuffer(100)).toString(); // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); } try { Connection con = null; Statement statement = null; try { if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private JDBCEntityMetaData loadJDBCEntityMetaData() throws DeploymentException { ApplicationMetaData amd = container.getBeanMetaData().getApplicationMetaData(); // Get JDBC MetaData JDBCApplicationMetaData jamd = (JDBCApplicationMetaData)amd.getPluginData(CMP_JDBC); if(jamd == null) { // we are the first cmp entity to need jbosscmp-jdbc. // Load jbosscmp-jdbc.xml for the whole application JDBCXmlFileLoader jfl = new JDBCXmlFileLoader(container, log); jamd = jfl.load(); amd.addPluginData(CMP_JDBC, jamd); } // Get JDBC Bean MetaData String ejbName = container.getBeanMetaData().getEjbName(); JDBCEntityMetaData metadata = jamd.getBeanByEjbName(ejbName); if(metadata == null) { throw new DeploymentException("No metadata found for bean " + ejbName); } return metadata; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeclaredSQLQuery.java
private void initSelectObject(JDBCStoreManager manager) throws DeploymentException { String entityName = metadata.getEJBName(); // if no name is specified we are done if(entityName == null) { return; } Catalog catalog = manager.getCatalog(); JDBCEntityBridge entity = (JDBCEntityBridge)catalog.getEntityByEJBName(entityName); if(entity == null) { throw new DeploymentException("Unknown entity: " + entityName); } String fieldName = metadata.getFieldName(); if(fieldName == null) { setSelectEntity(entity); } else { JDBCCMPFieldBridge field = entity.getCMPFieldByName(fieldName); if(field == null) { throw new DeploymentException("Unknown cmp field: " + fieldName); } setSelectField(field); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
protected void initGeneratedFields() throws DeploymentException { super.initGeneratedFields(); pkField = getGeneratedPKField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createFindByPrimaryKeyQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCFindByPrimaryKeyQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createFindAllQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCFindAllQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createDeclaredSQLQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCDeclaredSQLQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createEJBQLQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCEJBQLQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createDynamicQLQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCDynamicQLQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createJBossQLQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCJBossQLQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCQueryCommand createFindByQuery(JDBCQueryMetaData q) throws DeploymentException { return new JDBCFindByQuery(manager, q); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCCreateCommand createCreateEntityCommand() throws DeploymentException { JDBCCreateCommand cec; try { cec = (JDBCCreateCommand)manager.getMetaData(). getEntityCommand().getCommandClass().newInstance(); cec.init(manager); } catch(DeploymentException de) { throw de; } catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); } if(log.isDebugEnabled()) log.debug("entity-command: " + manager.getMetaData().getEntityCommand()); return cec; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCRemoveEntityCommand createRemoveEntityCommand() throws DeploymentException { return new JDBCRemoveEntityCommand(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCLoadEntityCommand createLoadEntityCommand() throws DeploymentException { return new JDBCLoadEntityCommand(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public static final Class getQLCompiler(Element query, JDBCEntityMetaData entity) throws DeploymentException { String compiler = MetaData.getOptionalChildContent(query, "ql-compiler"); Class impl; if(compiler == null || compiler.trim().length() == 0) { impl = entity.getQLCompiler(); } else { try { impl = TCLAction.UTIL.getContextClassLoader().loadClass(compiler); } catch(ClassNotFoundException e) { throw new DeploymentException("Failed to load compiler implementation: " + compiler); } } return impl; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public static final QLCompiler getInstance(Class impl, Catalog catalog) throws DeploymentException { if(impl == null) { throw new DeploymentException("ql-compiler is not specified."); } final Constructor constructor; try { constructor = impl.getConstructor(new Class[]{Catalog.class}); } catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); } try { return (QLCompiler)constructor.newInstance(new Object[]{catalog}); } catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public void start() throws DeploymentException { Logger log = Logger.getLogger( this.getClass().getName() + "." + manager.getMetaData().getName()); JDBCCommandFactory factory = manager.getCommandFactory(); Class homeClass = manager.getContainer().getHomeClass(); Class localHomeClass = manager.getContainer().getLocalHomeClass(); // // findByPrimaryKey // JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge(); if(homeClass != null) { try { // try to get the finder method on the home interface Method method = homeClass.getMethod(FIND_BY_PK, new Class[]{entity.getPrimaryKeyClass()}); JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method); JDBCReadAheadMetaData readAhead = (findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead()); // got it add it to known finders JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData( method, readAhead, entity.getMetaData().getQLCompiler(), false ); knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q)); if(log.isDebugEnabled()) log.debug("Added findByPrimaryKey query command for home interface"); } catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); } } if(localHomeClass != null) { Method method; try { // try to get the finder method on the local home interface method = localHomeClass.getMethod(FIND_BY_PK, new Class[] { entity.getPrimaryKeyClass() }); } catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); } // got it add it to known finders JDBCQueryMetaData findByPKMD = manager.getMetaData().getQueryMetaDataForMethod(method); JDBCReadAheadMetaData readAhead = (findByPKMD == null ? entity.getMetaData().getReadAhead() : findByPKMD.getReadAhead()); JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData(method, readAhead, entity.getMetaData().getQLCompiler(), false); knownQueries.put(method, factory.createFindByPrimaryKeyQuery(q)); if(log.isDebugEnabled()) log.debug("Added findByPrimaryKey query command for local home interface"); } // // Custom finders - Overrides defined and automatic finders. // Class ejbClass = manager.getMetaData().getEntityClass(); Method[] customMethods = ejbClass.getMethods(); for (int i = 0; i < customMethods.length; i++) { Method m = customMethods[i]; String methodName = m.getName(); if(methodName.startsWith(EJB_FIND)) { String interfaceName = 'f' + methodName.substring(4); if(homeClass != null) { try { // try to get the finder method on the home interface Method interfaceMethod = homeClass.getMethod( interfaceName, m.getParameterTypes()); // got it add it to known finders knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m)); if(log.isDebugEnabled()) log.debug("Added custom finder " + methodName + " on home interface"); } catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface } } if(localHomeClass != null) { try { // try to get the finder method on the local home interface Method interfaceMethod = localHomeClass.getMethod( interfaceName, m.getParameterTypes()); // got it add it to known finders knownQueries.put(interfaceMethod, new JDBCCustomFinderQuery(manager, m)); if(log.isDebugEnabled()) log.debug("Added custom finder " + methodName + " on local home interface"); } catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface } } } } // // Defined finders - Overrides automatic finders. // Iterator definedFinders = manager.getMetaData().getQueries().iterator(); while(definedFinders.hasNext()) { JDBCQueryMetaData q = (JDBCQueryMetaData)definedFinders.next(); if(!knownQueries.containsKey(q.getMethod()) ) { if(q instanceof JDBCJBossQLQueryMetaData) { knownQueries.put(q.getMethod(), factory.createJBossQLQuery(q)); } else if(q instanceof JDBCDynamicQLQueryMetaData) { knownQueries.put(q.getMethod(), factory.createDynamicQLQuery(q)); } else if(q instanceof JDBCDeclaredQueryMetaData) { knownQueries.put(q.getMethod(), factory.createDeclaredSQLQuery(q)); } else if(q instanceof JDBCQlQueryMetaData) { knownQueries.put(q.getMethod(), factory.createEJBQLQuery(q)); } } } // // Automatic finders - The last resort // if(homeClass != null) { addAutomaticFinders(manager, homeClass.getMethods(), log); } if(localHomeClass != null) { addAutomaticFinders(manager, localHomeClass.getMethods(), log); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
private void addAutomaticFinders( JDBCStoreManager manager, Method[] homeMethods, Logger log) throws DeploymentException { JDBCCommandFactory factory = manager.getCommandFactory(); JDBCEntityBridge entity = (JDBCEntityBridge) manager.getEntityBridge(); for (int i = 0; i < homeMethods.length; i++) { Method method = homeMethods[i]; if(!knownQueries.containsKey(method)) { String name = method.getName(); if(name.equals(FIND_ALL)) { JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData( method, entity.getMetaData().getReadAhead(), entity.getMetaData().getQLCompiler(), false ); knownQueries.put(method, factory.createFindAllQuery(q)); } else if(name.startsWith(FIND_BY) && !name.equals(FIND_BY_PK)) { try { JDBCQueryMetaData q = new JDBCAutomaticQueryMetaData( method, entity.getMetaData().getReadAhead(), entity.getMetaData().getQLCompiler(), false); knownQueries.put(method, factory.createFindByQuery(q)); } catch (IllegalArgumentException e) { log.debug("Could not create the finder " + name + ", because no matching CMP field was found."); } } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String fixTableName(String tableName, DataSource dataSource) throws DeploymentException { // don't fix the quited table name char firstChar = tableName.charAt(0); if(firstChar == '"' || firstChar == '\'') { return tableName; } // Separate schema name and table name String strSchema = ""; int iIndex; if((iIndex = tableName.indexOf('.')) != -1) { strSchema = tableName.substring(0, iIndex); tableName = tableName.substring(iIndex + 1); } // check for SQL reserved word and escape it with prepending a "X" // IMHO one should reject reserved words and throw a // DeploymentException - pilhuhn if(rwords != null) { for(int i = 0; i < rwords.size(); i++) { if(((String)rwords.elementAt(i)).equalsIgnoreCase(tableName)) { tableName = "X" + tableName; break; } } } Connection con = null; try { con = dataSource.getConnection(); DatabaseMetaData dmd = con.getMetaData(); // fix length int maxLength = dmd.getMaxTableNameLength(); if(maxLength > 0 && tableName.length() > maxLength) { CRC32 crc = new CRC32(); crc.update(tableName.getBytes()); String nameCRC = Long.toString(crc.getValue(), 36); tableName = tableName.substring( 0, maxLength - nameCRC.length() - 2); tableName += "_" + nameCRC; } // fix case if(dmd.storesLowerCaseIdentifiers()) { tableName = tableName.toLowerCase(); } else if(dmd.storesUpperCaseIdentifiers()) { tableName = tableName.toUpperCase(); } // now put the schema name back on the table name if(strSchema.length() > 0) { tableName = strSchema + "." + tableName; } return tableName; } catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); } finally { JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String fixConstraintName(String name, DataSource dataSource) throws DeploymentException { return fixTableName(name, dataSource).replace('.', '_'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static boolean tableExists(String tableName, DataSource dataSource) throws DeploymentException { Connection con = null; ResultSet rs = null; try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; String quote = dmd.getIdentifierQuoteString(); if(tableName.startsWith(quote)) { if(tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); if(dmd.storesLowerCaseQuotedIdentifiers()) tableName = tableName.toLowerCase(); else if(dmd.storesUpperCaseQuotedIdentifiers()) tableName = tableName.toUpperCase(); } else { if(dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if(dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); } // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getTables(catalog, schema, tableName, null); return rs.next(); } catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static OldColumns getOldColumns(String tableName, DataSource dataSource) throws DeploymentException { Connection con = null; ResultSet rs = null; ArrayList columnNames = new ArrayList(); ArrayList typeNames = new ArrayList(); ArrayList columnSizes = new ArrayList(); try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; String quote = dmd.getIdentifierQuoteString(); if (tableName.startsWith(quote)) { if (tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); if (dmd.storesLowerCaseQuotedIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseQuotedIdentifiers()) tableName = tableName.toUpperCase(); } else { if (dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); } // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getColumns(catalog, schema, tableName, null); while (rs.next()) { String columnName = rs.getString("COLUMN_NAME"); columnNames.add(columnName == null ? null : columnName.toUpperCase()); typeNames.add(rs.getString("TYPE_NAME")); columnSizes.add(new Integer(rs.getInt("COLUMN_SIZE"))); } return new OldColumns(columnNames, typeNames, columnSizes); } catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static OldIndexes getOldIndexes(String tableName, DataSource dataSource) throws DeploymentException { tableName = unquote(tableName, dataSource); Connection con = null; ResultSet rs = null; ArrayList indexNames = new ArrayList(); ArrayList columnNames = new ArrayList(); ArrayList ascDesc = new ArrayList(); try { con = dataSource.getConnection(); // (a j2ee spec compatible jdbc driver has to fully // implement the DatabaseMetaData) DatabaseMetaData dmd = con.getMetaData(); String catalog = con.getCatalog(); String schema = null; if (dmd.storesLowerCaseIdentifiers()) tableName = tableName.toLowerCase(); else if (dmd.storesUpperCaseIdentifiers()) tableName = tableName.toUpperCase(); // Patch #927759: Split tablename into "schema" and "table" separated by '.' int dotIndex; if ((dotIndex = tableName.indexOf('.')) != -1) { // Yank out schema name ... schema = tableName.substring(0, dotIndex); tableName = tableName.substring(dotIndex + 1); } rs = dmd.getIndexInfo(catalog, schema, tableName, false, false); while (rs.next()) { indexNames.add(rs.getString("INDEX_NAME")); columnNames.add(rs.getString("COLUMN_NAME")); ascDesc.add(rs.getString("ASC_OR_DESC")); } return new OldIndexes(indexNames, columnNames, ascDesc); } catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static String unquote(String tableName, DataSource ds) throws DeploymentException { Connection con = null; try { con = ds.getConnection(); String quote = con.getMetaData().getIdentifierQuoteString(); if (tableName.startsWith(quote)) { if (tableName.endsWith(quote) == false) { throw new DeploymentException("Mismatched quote in table name: " + tableName); } int quoteLength = quote.length(); tableName = tableName.substring(quoteLength, tableName.length() - quoteLength); } } catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); } finally { JDBCUtil.safeClose(con); } return tableName; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static void dropTable(DataSource dataSource, String tableName) throws DeploymentException { Logger log = Logger.getLogger("CLEANER"); String sql = "DROP TABLE " + tableName; try { Connection con = null; Statement statement = null; try { // execute sql con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); } log.info("Dropped table "+tableName+" succesfuly"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void init() throws DeploymentException { try { InitialContext ic = new InitialContext(); dataSource = (DataSource)ic.lookup(metadata.getDataSourceName()); } catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); } qualifiedTableName = SQLUtil.fixTableName(metadata.getDefaultTableName(), dataSource); int dotIndex = qualifiedTableName.indexOf('.'); tableName = dotIndex == -1 ? qualifiedTableName : qualifiedTableName.substring(dotIndex + 1); // CMP fields loadCMPFields(metadata); // CMR fields loadCMRFields(metadata); // create locking field JDBCOptimisticLockingMetaData lockMetaData = metadata.getOptimisticLocking(); if(lockMetaData != null && lockMetaData.getLockingField() != null) { Integer strategy = lockMetaData.getLockingStrategy(); JDBCCMPFieldMetaData versionMD = lockMetaData.getLockingField(); versionField = getCMPFieldByName(versionMD.getFieldName()); boolean hidden = versionField == null; if(strategy == JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCLongVersionFieldBridge(manager, versionMD); else versionField = new JDBCLongVersionFieldBridge((JDBCCMP2xFieldBridge)versionField); } else if(strategy == JDBCOptimisticLockingMetaData.TIMESTAMP_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCTimestampVersionFieldBridge(manager, versionMD); else versionField = new JDBCTimestampVersionFieldBridge((JDBCCMP2xFieldBridge)versionField); } else if(strategy == JDBCOptimisticLockingMetaData.KEYGENERATOR_COLUMN_STRATEGY) { if(hidden) versionField = new JDBCKeyGenVersionFieldBridge( manager, versionMD, lockMetaData.getKeyGeneratorFactory()); else versionField = new JDBCKeyGenVersionFieldBridge( (JDBCCMP2xFieldBridge)versionField, lockMetaData.getKeyGeneratorFactory()); } if(hidden) addCMPField(versionField); else tableFields[versionField.getTableIndex()] = versionField; } // audit fields JDBCAuditMetaData auditMetaData = metadata.getAudit(); if(auditMetaData != null) { JDBCCMPFieldMetaData auditField = auditMetaData.getCreatedPrincipalField(); if(auditField != null) { createdPrincipalField = getCMPFieldByName(auditField.getFieldName()); if(createdPrincipalField == null) { createdPrincipalField = new JDBCCMP2xFieldBridge(manager, auditField); addCMPField(createdPrincipalField); } } else { createdPrincipalField = null; } auditField = auditMetaData.getCreatedTimeField(); if(auditField != null) { createdTimeField = getCMPFieldByName(auditField.getFieldName()); if(createdTimeField == null) { createdTimeField = new JDBCCMP2xFieldBridge(manager, auditField, JDBCTypeFactory.EQUALS, false); addCMPField(createdTimeField); } else { // just to override state factory and check-dirty-after-get createdTimeField = new JDBCCMP2xFieldBridge( (JDBCCMP2xFieldBridge)createdTimeField, JDBCTypeFactory.EQUALS, false); tableFields[createdTimeField.getTableIndex()] = createdTimeField; } } else { createdTimeField = null; } auditField = auditMetaData.getUpdatedPrincipalField(); if(auditField != null) { updatedPrincipalField = getCMPFieldByName(auditField.getFieldName()); if(updatedPrincipalField == null) { updatedPrincipalField = new JDBCCMP2xUpdatedPrincipalFieldBridge(manager, auditField); addCMPField(updatedPrincipalField); } else { updatedPrincipalField = new JDBCCMP2xUpdatedPrincipalFieldBridge( (JDBCCMP2xFieldBridge)updatedPrincipalField); tableFields[updatedPrincipalField.getTableIndex()] = updatedPrincipalField; } } else { updatedPrincipalField = null; } auditField = auditMetaData.getUpdatedTimeField(); if(auditField != null) { updatedTimeField = getCMPFieldByName(auditField.getFieldName()); if(updatedTimeField == null) { updatedTimeField = new JDBCCMP2xUpdatedTimeFieldBridge(manager, auditField); addCMPField(updatedTimeField); } else { updatedTimeField = new JDBCCMP2xUpdatedTimeFieldBridge((JDBCCMP2xFieldBridge)updatedTimeField); tableFields[updatedTimeField.getTableIndex()] = updatedTimeField; } } else { updatedTimeField = null; } } // ejbSelect methods loadSelectors(metadata); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void resolveRelationships() throws DeploymentException { for(int i = 0; i < cmrFields.length; ++i) cmrFields[i].resolveRelationship(); // load groups: cannot be created until relationships have // been resolved because loadgroups must check for foreign keys loadLoadGroups(metadata); loadEagerLoadGroup(metadata); loadLazyLoadGroups(metadata); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void start() throws DeploymentException { for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].start(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private void loadCMPFields(JDBCEntityMetaData metadata) throws DeploymentException { // only non pk fields are stored here at first and then later // the pk fields are added to the front (makes sql easier to read) List cmpFieldsMD = metadata.getCMPFields(); List cmpFieldsList = new ArrayList(cmpFieldsMD.size()); // primary key cmp fields List pkFieldsList = new ArrayList(cmpFieldsMD.size()); // create pk fields for(int i = 0; i < cmpFieldsMD.size(); ++i) { JDBCCMPFieldMetaData fieldMD = (JDBCCMPFieldMetaData)cmpFieldsMD.get(i); if(fieldMD.isPrimaryKeyMember()) { JDBCCMPFieldBridge cmpField = createCMPField(metadata, fieldMD); pkFieldsList.add(cmpField); } } // create non-pk cmp fields for(int i = 0; i < cmpFieldsMD.size(); ++i) { JDBCCMPFieldMetaData fieldMD = (JDBCCMPFieldMetaData)cmpFieldsMD.get(i); if(!fieldMD.isPrimaryKeyMember()) { JDBCCMPFieldBridge cmpField = createCMPField(metadata, fieldMD); cmpFieldsList.add(cmpField); } } // save the pk fields in the pk field array primaryKeyFields = new JDBCCMPFieldBridge[pkFieldsList.size()]; for(int i = 0; i < pkFieldsList.size(); ++i) primaryKeyFields[i] = (JDBCCMPFieldBridge)pkFieldsList.get(i); // add the pk fields to the front of the cmp list, per guarantee above cmpFields = new JDBCCMPFieldBridge[cmpFieldsMD.size() - primaryKeyFields.length]; int cmpFieldIndex = 0; for(int i = 0; i < cmpFieldsList.size(); ++i) cmpFields[cmpFieldIndex++] = (JDBCCMPFieldBridge)cmpFieldsList.get(i); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private void loadCMRFields(JDBCEntityMetaData metadata) throws DeploymentException { cmrFields = new JDBCCMRFieldBridge[metadata.getRelationshipRoles().size()]; // create each field int cmrFieldIndex = 0; for(Iterator iter = metadata.getRelationshipRoles().iterator(); iter.hasNext();) { JDBCRelationshipRoleMetaData relationshipRole = (JDBCRelationshipRoleMetaData)iter.next(); JDBCCMRFieldBridge cmrField = new JDBCCMRFieldBridge(this, manager, relationshipRole); cmrFields[cmrFieldIndex++] = cmrField; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private void loadLoadGroups(JDBCEntityMetaData metadata) throws DeploymentException { loadGroupMasks = new HashMap(); // load optimistic locking mask and add it to all the load group masks JDBCOptimisticLockingMetaData olMD = metadata.getOptimisticLocking(); if(olMD != null) { if(versionField != null) { defaultLockGroupMask = new boolean[tableFields.length]; defaultLockGroupMask[versionField.getTableIndex()] = true; versionField.setLockingStrategy(LockingStrategy.VERSION); } else if(olMD.getGroupName() != null) { defaultLockGroupMask = loadGroupMask(olMD.getGroupName(), null); for(int i = 0; i < tableFields.length; ++i) { if(defaultLockGroupMask[i]) { JDBCCMPFieldBridge tableField = tableFields[i]; tableField.setLockingStrategy(LockingStrategy.GROUP); tableField.addDefaultFlag(ADD_TO_WHERE_ON_UPDATE); } } } else // read or modified strategy { LockingStrategy strategy = (olMD.getLockingStrategy() == JDBCOptimisticLockingMetaData.READ_STRATEGY ? LockingStrategy.READ : LockingStrategy.MODIFIED ); for(int i = 0; i < tableFields.length; ++i) { JDBCCMPFieldBridge field = tableFields[i]; if(!field.isPrimaryKeyMember()) field.setLockingStrategy(strategy); } } } // add the * load group boolean[] defaultLoadGroup = new boolean[tableFields.length]; Arrays.fill(defaultLoadGroup, true); for(int i = 0; i < primaryKeyFields.length; ++i) { int tableIndex = primaryKeyFields[i].getTableIndex(); defaultLoadGroup[tableIndex] = false; } loadGroupMasks.put(DEFAULT_LOADGROUP_NAME, defaultLoadGroup); // put each group in the load groups map by group name Iterator groupNames = metadata.getLoadGroups().keySet().iterator(); while(groupNames.hasNext()) { // get the group name String groupName = (String)groupNames.next(); boolean[] loadGroup = loadGroupMask(groupName, defaultLockGroupMask); loadGroupMasks.put(groupName, loadGroup); } loadGroupMasks = Collections.unmodifiableMap(loadGroupMasks); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private boolean[] loadGroupMask(String groupName, boolean[] defaultGroup) throws DeploymentException { List fieldNames = metadata.getLoadGroup(groupName); boolean[] group = new boolean[tableFields.length]; if(defaultGroup != null) System.arraycopy(defaultGroup, 0, group, 0, group.length); for(Iterator iter = fieldNames.iterator(); iter.hasNext();) { String fieldName = (String)iter.next(); JDBCFieldBridge field = (JDBCFieldBridge)getFieldByName(fieldName); if(field == null) throw new DeploymentException( "Field " + fieldName + " not found for entity " + getEntityName()); if(field instanceof JDBCCMRFieldBridge) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)field; if(cmrField.hasForeignKey()) { JDBCCMPFieldBridge[] fkFields = (JDBCCMPFieldBridge[]) cmrField.getForeignKeyFields(); for(int i = 0; i < fkFields.length; ++i) { group[fkFields[i].getTableIndex()] = true; } } else { throw new DeploymentException("Only CMR fields that have " + "a foreign-key may be a member of a load group: " + "fieldName=" + fieldName); } } else { group[((JDBCCMPFieldBridge)field).getTableIndex()] = true; } } return group; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private JDBCCMPFieldBridge createCMPField(JDBCEntityMetaData metadata, JDBCCMPFieldMetaData cmpFieldMetaData) throws DeploymentException { JDBCCMPFieldBridge cmpField; if(metadata.isCMP1x()) cmpField = new JDBCCMP1xFieldBridge(manager, cmpFieldMetaData); else cmpField = new JDBCCMP2xFieldBridge(manager, cmpFieldMetaData); return cmpField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void resolveRelationship() throws DeploymentException { // // Set handles to the related entity's container, cache, // manager, and invoker // // Related Entity Name String relatedEntityName = metadata.getRelatedRole().getEntity().getName(); // Related Entity Catalog catalog = (Catalog) manager.getApplicationData("CATALOG"); relatedEntity = (JDBCEntityBridge) catalog.getEntityByEJBName(relatedEntityName); if(relatedEntity == null) { throw new DeploymentException("Related entity not found: " + "entity=" + entity.getEntityName() + ", " + "cmrField=" + getFieldName() + ", " + "relatedEntity=" + relatedEntityName); } // Related CMR Field JDBCCMRFieldBridge[] cmrFields = (JDBCCMRFieldBridge[]) relatedEntity.getCMRFields(); for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge cmrField = cmrFields[i]; if(metadata.getRelatedRole() == cmrField.getMetaData()) { relatedCMRField = cmrField; break; } } // if we didn't find the related CMR field throw an exception // with a detailed message if(relatedCMRField == null) { String message = "Related CMR field not found in " + relatedEntity.getEntityName() + " for relationship from"; message += entity.getEntityName() + "."; if(getFieldName() != null) { message += getFieldName(); } else { message += "<no-field>"; } message += " to "; message += relatedEntityName + "."; if(metadata.getRelatedRole().getCMRFieldName() != null) { message += metadata.getRelatedRole().getCMRFieldName(); } else { message += "<no-field>"; } throw new DeploymentException(message); } // Related Manager relatedManager = (JDBCStoreManager) relatedEntity.getManager(); // Related Container EntityContainer relatedContainer = relatedManager.getContainer(); this.relatedContainerRef = new WeakReference(relatedContainer); // related findByPrimaryKey Class homeClass = (relatedContainer.getLocalHomeClass() != null ? relatedContainer.getLocalHomeClass() : relatedContainer.getHomeClass()); try { relatedFindByPrimaryKey = homeClass.getMethod("findByPrimaryKey", new Class[]{relatedEntity.getPrimaryKeyClass()}); } catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); } // // Initialize the key fields // if(metadata.getRelationMetaData().isTableMappingStyle()) { // initialize relation table key fields Collection tableKeys = metadata.getKeyFields(); List keyFieldsList = new ArrayList(tableKeys.size()); // first phase is to create fk fields Map pkFieldsToFKFields = new HashMap(tableKeys.size()); for(Iterator i = tableKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData cmpFieldMetaData = (JDBCCMPFieldMetaData) i.next(); FieldBridge pkField = entity.getFieldByName(cmpFieldMetaData.getFieldName()); if(pkField == null) { throw new DeploymentException("Primary key not found for key-field " + cmpFieldMetaData.getFieldName()); } pkFieldsToFKFields.put(pkField, new JDBCCMP2xFieldBridge(manager, cmpFieldMetaData)); } // second step is to order fk fields to match the order of pk fields JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { Object fkField = pkFieldsToFKFields.get(pkFields[i]); if(fkField == null) { throw new DeploymentException("Primary key " + pkFields[i].getFieldName() + " is not mapped."); } keyFieldsList.add(fkField); } tableKeyFields = (JDBCCMP2xFieldBridge[]) keyFieldsList.toArray( new JDBCCMP2xFieldBridge[keyFieldsList.size()]); dataSource = metadata.getRelationMetaData().getDataSource(); } else { initializeForeignKeyFields(); dataSource = hasForeignKey() ? entity.getDataSource() : relatedEntity.getDataSource(); } // Fix table name // // This code doesn't work here... The problem each side will generate // the table name and this will only work for simple generation. qualifiedTableName = SQLUtil.fixTableName(metadata.getRelationMetaData().getDefaultTableName(), dataSource); tableName = SQLUtil.getTableNameWithoutSchema(qualifiedTableName); relationManager = relatedCMRField.initRelationManager(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void start() throws DeploymentException { cascadeDeleteStrategy = CascadeDeleteStrategy.getCascadeDeleteStrategy(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void initializeForeignKeyFields() throws DeploymentException { Collection foreignKeys = metadata.getRelatedRole().getKeyFields(); // temporary map used later to write fk fields in special order Map fkFieldsByRelatedPKFields = new HashMap(); for(Iterator i = foreignKeys.iterator(); i.hasNext();) { JDBCCMPFieldMetaData fkFieldMetaData = (JDBCCMPFieldMetaData) i.next(); JDBCCMP2xFieldBridge relatedPKField = (JDBCCMP2xFieldBridge) relatedEntity.getFieldByName(fkFieldMetaData.getFieldName()); // now determine whether the fk is mapped to a pk column String fkColumnName = fkFieldMetaData.getColumnName(); JDBCCMP2xFieldBridge fkField = null; // look among the CMP fields for the field with the same column name JDBCFieldBridge[] tableFields = entity.getTableFields(); for(int tableInd = 0; tableInd < tableFields.length && fkField == null; ++tableInd) { JDBCCMP2xFieldBridge cmpField = (JDBCCMP2xFieldBridge) tableFields[tableInd]; if(fkColumnName.equals(cmpField.getColumnName())) { hasFKFieldsMappedToCMPFields = true; // construct the foreign key field fkField = new JDBCCMP2xFieldBridge((JDBCStoreManager) cmpField.getManager(), // this cmpField's manager relatedPKField.getFieldName(), relatedPKField.getFieldType(), cmpField.getJDBCType(), // this cmpField's jdbc type relatedPKField.isReadOnly(), relatedPKField.getReadTimeOut(), relatedPKField.getPrimaryKeyClass(), relatedPKField.getPrimaryKeyField(), cmpField, // CMP field I am mapped to this, fkColumnName); if(cmpField.isPrimaryKeyMember()) { relatedPKFieldsByMyPKFields.put(cmpField, relatedPKField); } } } // if the fk is not a part of pk then create a new field if(fkField == null) { fkField = new JDBCCMP2xFieldBridge(manager, fkFieldMetaData, manager.getJDBCTypeFactory().getJDBCType(fkFieldMetaData)); } fkFieldsByRelatedPKFields.put(relatedPKField, fkField); // temporary map relatedPKFieldsByMyFKFields.put(fkField, relatedPKField); } // Note: this important to order the foreign key fields so that their order matches // the order of related entity's pk fields in case of complex primary keys. // The order is important in fk-constraint generation and in SELECT when loading if(fkFieldsByRelatedPKFields.size() > 0) { JDBCFieldBridge[] relatedPKFields = relatedEntity.getPrimaryKeyFields(); List fkList = new ArrayList(relatedPKFields.length); for(int i = 0; i < relatedPKFields.length; ++i) { JDBCCMPFieldBridge fkField = (JDBCCMPFieldBridge) fkFieldsByRelatedPKFields.remove(relatedPKFields[i]); fkList.add(fkField); } foreignKeyFields = (JDBCCMP2xFieldBridge[]) fkList.toArray(new JDBCCMP2xFieldBridge[fkList.size()]); } else { foreignKeyFields = null; } // are all FK fields mapped to PK fields? allFKFieldsMappedToPKFields = relatedPKFieldsByMyPKFields.size() > 0 && relatedPKFieldsByMyPKFields.size() == foreignKeyFields.length; if(foreignKeyFields != null) { jdbcType = new CMRJDBCType(Arrays.asList(foreignKeyFields)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
private KeyGenerator initKeyGenerator(String keygenFactoryName) throws DeploymentException { try { InitialContext ctx = new InitialContext(); KeyGeneratorFactory keygenFactory = (KeyGeneratorFactory)ctx.lookup(keygenFactoryName); return keygenFactory.getKeyGenerator(); } catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); } catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
private String getSQL(JDBCCMRFieldBridge cmrField, boolean[] preloadMask, int keyCount) throws DeploymentException { JDBCCMPFieldBridge[] myKeyFields = getMyKeyFields(cmrField); JDBCCMPFieldBridge[] relatedKeyFields = getRelatedKeyFields(cmrField); String relationTable = getQualifiedRelationTable(cmrField); JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity(); String relatedTable = relatedEntity.getQualifiedTableName(); // do we need to join the relation table and the related table boolean join = ((preloadMask != null) || cmrField.allFkFieldsMappedToPkFields()) && (relatedKeyFields != relatedEntity.getPrimaryKeyFields()); // aliases for the tables, only required if we are joining the tables String relationTableAlias; String relatedTableAlias; if(join) { relationTableAlias = getRelationTable(cmrField); relatedTableAlias = ( relatedTable.equals(relationTable) ? getRelationTable(cmrField) + '_' + cmrField.getFieldName() : relatedEntity.getTableName() ); } else { relationTableAlias = ""; relatedTableAlias = ""; } JDBCFunctionMappingMetaData selectTemplate = getSelectTemplate(cmrField); return selectTemplate == null ? getPlainSQL( keyCount, myKeyFields, relationTableAlias, relatedKeyFields, preloadMask, cmrField, relatedTableAlias, relationTable, join, relatedTable) : getSQLByTemplate( keyCount, myKeyFields, relationTableAlias, relatedKeyFields, preloadMask, cmrField, relatedTableAlias, relationTable, join, relatedTable, selectTemplate); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
private JDBCFunctionMappingMetaData getSelectTemplate(JDBCCMRFieldBridge cmrField) throws DeploymentException { JDBCFunctionMappingMetaData selectTemplate = null; if(cmrField.getRelationMetaData().isTableMappingStyle()) { // relation table if(cmrField.getRelationMetaData().hasRowLocking()) { selectTemplate = cmrField.getRelationMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } else if(cmrField.getRelatedCMRField().hasForeignKey()) { // related has foreign key if(cmrField.getRelatedJDBCEntity().getMetaData().hasRowLocking()) { selectTemplate = cmrField.getRelatedJDBCEntity().getMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } else { // i have foreign key if(entity.getMetaData().hasRowLocking()) { selectTemplate = entity.getMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } return selectTemplate; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { pkSQL = "SELECT SCOPE_IDENTITY()"; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); ClassLoader loader = GetTCLAction.getContextClassLoader(); try { Class psClass = loader.loadClass(className); method = psClass.getMethod(methodName, null); } catch(ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); } catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); } try { Class wrapperClass = loader.loadClass("org.jboss.resource.adapter.jdbc.StatementAccess"); getUnderlyingStatement = wrapperClass.getMethod("getUnderlyingStatement", null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); } catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); className = entityCommand.getAttribute(NAME); if(className == null) { className = DEFAULT_CLASS; } methodName = entityCommand.getAttribute(METHOD); if(methodName == null) { methodName = DEFAULT_METHOD; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { if (CONNECTION_PREPARE == null) { throw new DeploymentException("Create command requires JDBC 3.0 (JDK1.4+)"); } super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); pkField = getGeneratedPKField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); String factoryName = entityCommand.getAttribute("key-generator-factory"); if(factoryName == null) { throw new DeploymentException("key-generator-factory attribute must be set for entity " + entity.getEntityName()); } try { KeyGeneratorFactory keyGeneratorFactory = (KeyGeneratorFactory) new InitialContext().lookup(factoryName); keyGenerator = keyGeneratorFactory.getKeyGenerator(); } catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); } catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); pkField = getGeneratedPKField(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { throw new DeploymentException("pk-sql attribute must be set for entity " + entity.getEntityName()); } if(debug) { log.debug("Generate PK sql is: " + pkSQL); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); ClassLoader loader = GetTCLAction.getContextClassLoader(); try { Class psClass = loader.loadClass(className); method = psClass.getMethod(methodName, null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load driver class: " + className, e); } catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); } try { Class wrapperClass = loader.loadClass("org.jboss.resource.adapter.jdbc.StatementAccess"); getUnderlyingStatement = wrapperClass.getMethod("getUnderlyingStatement", null); } catch (ClassNotFoundException e) { throw new DeploymentException("Could not load org.jboss.resource.adapter.jdbc.StatementAccess", e); } catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); className = entityCommand.getAttribute("class-name"); if (className == null) { className = "com.mysql.jdbc.PreparedStatement"; } methodName = entityCommand.getAttribute("method"); if (methodName == null) { methodName = "getGeneratedKeys"; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence = entityCommand.getAttribute("sequence"); if (sequence == null) { sequence = entity.getQualifiedTableName() + '_' + SQLUtil.getColumnNamesClause(pkField, new StringBuffer(20)) + "_seq"; } sequenceSQL = "SELECT currval('"+sequence+"')"; if (debug) { log.debug("SEQUENCE SQL is :"+sequenceSQL); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence = entityCommand.getAttribute("sequence"); if (sequence == null) { throw new DeploymentException("Sequence must be specified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSybaseCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { pkSQL = "SELECT @@IDENTITY"; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
public void init(JDBCStoreManager manager) throws DeploymentException { super.init(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); sequence_name = entityCommand.getAttribute("sequence_name"); if (sequence_name == null) { throw new DeploymentException("sequence_name attribute must be specified inside <entity-command>"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCHsqldbCreateCommand.java
protected void initEntityCommand(JDBCEntityCommandMetaData entityCommand) throws DeploymentException { super.initEntityCommand(entityCommand); pkSQL = entityCommand.getAttribute("pk-sql"); if(pkSQL == null) { pkSQL = "CALL IDENTITY()"; } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
public void importXml(Element element) throws DeploymentException { String maximumSize = MetaData.getElementContent(MetaData.getUniqueChild(element, "MaximumSize")); try { this.maxSize = Integer.parseInt(maximumSize); } catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); } // Get whether the pool will block when MaximumSize instances are active String strictValue = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictMaximumSize")); this.isStrict = Boolean.valueOf(strictValue); String delay = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictTimeout")); try { if( delay != null ) this.strictTimeout = Long.parseLong(delay); } catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); } }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
public void importXml(Element element) throws DeploymentException { super.importXml(element); String rp = MetaData.getElementContent(MetaData.getOptionalChild(element, "remover-period")); String ml = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-bean-life")); try { if (rp != null) { int p = Integer.parseInt(rp); if (p <= 0) { throw new DeploymentException("Remover period can't be <= 0"); } m_removerPeriod = p * 1000; } if (ml != null) { int a = Integer.parseInt(ml); if (a <= 0) { throw new DeploymentException("Max bean life can't be <= 0"); } m_maxBeanLife = a * 1000; } } catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); } }
// in src/main/java/org/jboss/web/deployers/WarSecurityDeployer.java
Override public void deploy(DeploymentUnit unit) throws DeploymentException { ClassLoader oldCL = null; // Set the TCL try { //JBAS-6607: JBossXACML needs the tcl to locate the xacml policies //The TCL would be the CL for VFS for the security deployer beans //Deployment Unit CL would be the war CL. Hence pick the DU CL as TCL. oldCL = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(unit.getClassLoader()); super.deploy(unit); } finally { SecurityActions.setContextClassLoader(oldCL); } }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { synchronized (this) { if ((sharedWebMetaData == null && webXml != null) || (sharedJBossWebMetaData == null && jbossWebXml != null)) { UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); SchemaBindingResolver resolver = SingletonSchemaResolverFactory .getInstance().getSchemaBindingResolver(); if (webXml != null) { try { sharedWebMetaData = (WebMetaData) unmarshaller.unmarshal(webXml, resolver); } catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); } } if (jbossWebXml != null) { try { sharedJBossWebMetaData = (JBossWebMetaData) unmarshaller.unmarshal(jbossWebXml, resolver); } catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); } } } } if (sharedWebMetaData != null || sharedJBossWebMetaData != null) { JBossWebMetaData clone = new JBoss60WebMetaData(); clone.merge(sharedJBossWebMetaData, sharedWebMetaData); unit.addAttachment(SHARED_JBOSSWEB_ATTACHMENT_NAME, clone); } }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public synchronized void stopModule() throws DeploymentException { String warURL = unit.getName(); try { WebApplication webApp = container.removeDeployedApp(warURL); if (deployment != null && webApp != null) { deployment.stop(unit, webApp); } else { log.debug("Failed to find deployer/deployment for war: " + warURL); } } catch (Exception e) { throw new DeploymentException("Error during stop", e); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
Override public void deploy(DeploymentUnit unit, JBossWebMetaData metaData) throws DeploymentException { log.debug("Begin deploy, " + metaData); // Merge any settings from the ear level JBossAppMetaData earMetaData = AttachmentLocator.search(unit, JBossAppMetaData.class); if (earMetaData != null) { String path = unit.getRelativePath(); ModuleMetaData webModule = earMetaData.getModule(path); if (webModule != null) { // Check for a context-root setting String contextRoot = metaData.getContextRoot(); if (contextRoot == null) { WebModuleMetaData wmodule = (WebModuleMetaData)webModule.getValue(); contextRoot = wmodule.getContextRoot(); metaData.setContextRoot(contextRoot); } // Add any alt-dd setting metaData.setAlternativeDD(webModule.getAlternativeDD()); } // Merge security domain/roles if (metaData.getSecurityDomain() == null && earMetaData.getSecurityDomain() != null) metaData.setSecurityDomain(earMetaData.getSecurityDomain()); // TODO metaData.mergeSecurityRoles(earMetaData.getSecurityRoles()); } try { /* Unpack wars to the tmp directory for now until tomcat can use the vfs directly. Since * the vfs deals with the distinction between a true directory, the only way we can tell from * this level of the api is to look for a url that ends in '/'. Here we assume that the name is * the root url. */ String warName = unit.getName(); /** * Ignore the jacc policy service bean */ if (warName.startsWith("jboss:") && warName.contains("id=")) return; if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit; VirtualFile root = vfsUnit.getRoot(); final URL expandedWarURL = root.getPhysicalFile().toURI().toURL(); // Map String warPathName = root.getPathName(); if (warPathName.endsWith("/") == false) warPathName += "/"; List<VirtualFile> classpathVFs = vfsUnit.getClassPath(); if (classpathVFs != null) { List<URL> classpath = new ArrayList<URL>(); for (VirtualFile vf : classpathVFs) { try { String path = vf.getPathName(); if (path.startsWith(warPathName)) { path = path.substring(warPathName.length()); URL pathURL = new URL(expandedWarURL, path); classpath.add(pathURL); } else { log.debug("Ignoring path element: " + vf); } } catch (Exception e) { log.debug("Ignoring path element: " + vf, e); } } unit.addAttachment("org.jboss.web.expandedWarClasspath", classpath); } // Indicate that an expanded URL exists unit.addAttachment("org.jboss.web.expandedWarURL", expandedWarURL, URL.class); // Resolve any ear relative alt-dd path to an expWarUrl/WEB-INF/alt-dd.xml file String altDDPath = metaData.getAlternativeDD(); if (altDDPath != null) { // First see if this is already a war local dd VirtualFile altDD = vfsUnit.getMetaDataFile(altDDPath); if (altDD == null) { // Pass absolute paths through File file = new File(altDDPath); if (!file.exists() || !file.isAbsolute()) { // Should be an relative to the top deployment VFSDeploymentUnit topUnit = vfsUnit.getTopLevel(); if (topUnit == unit) throw new DeploymentException("Unable to resolve " + altDDPath + " as WEB-INF path"); altDD = topUnit.getFile(altDDPath); if (altDD == null) throw new DeploymentException("Unable to resolve " + altDDPath + " as a deployment path"); VirtualFile altDDFile = root.getChild("WEB-INF/" + altDD.getName()); log.debug("Copying the altDD to: " + altDDFile); VFSUtils.writeFile(altDDFile, altDD.openStream()); metaData.setAlternativeDD(altDDFile.getPathName()); } } } } ClassLoadingMetaData classLoading = metaData.getClassLoading(); if (classLoading == null) classLoading = new ClassLoadingMetaData(); // pass in the java2ClassLoadingCompliance if it was not set at the war level if (classLoading.wasJava2ClassLoadingComplianceSet() == false) classLoading.setJava2ClassLoadingCompliance(this.java2ClassLoadingCompliance); metaData.setClassLoading(classLoading); // Build the context root if its not been set or is specified at the ear String webContext = metaData.getContextRoot(); webContext = buildWebContext(webContext, warName, metaData, unit); metaData.setContextRoot(webContext); AbstractWarDeployment deployment = getDeployment(unit, metaData); deployment.setMainDeployer(mainDeployer); // TODO: until deployment is a MC bean deployment.setPersistenceUnitDependencyResolver(persistenceUnitDependencyResolver); deployWebModule(unit, metaData, deployment); } catch (Exception e) { throw new DeploymentException("Failed to create web module", e); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
public void build(DeploymentUnit unit, Set<String> outputs, Map<String, ManagedObject> managedObjects) throws DeploymentException { JBossWebMetaData meta = unit.getAttachment(JBossWebMetaData.class); if (meta == null) return; ManagedObject mo = ManagedObjectFactory.getInstance().createManagedObject(ContextMO.class); if (mo == null) throw new DeploymentException("could not create managed object"); mo.getProperty("contextRoot").setValue(SimpleValueSupport.wrap(meta.getContextRoot())); managedObjects.put("ContextMO", mo); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (unit instanceof VFSDeploymentUnit == false) return; VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; deploy(vfsDeploymentUnit); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
protected void deploy(VFSDeploymentUnit unit) throws DeploymentException { if (!unit.getSimpleName().endsWith(".war")) { return; } VirtualFile root = unit.getRoot(); if(root.isFile()) return; List<VirtualFile> classpath = unit.getClassPath(); if(classpath == null || classpath.isEmpty()) return; if (log.isTraceEnabled()) log.trace("Deploying annotations for unit: " + unit + ", classpath: " + classpath); try { processMetaData(unit, classpath); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); } }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataHackDeployer.java
Override public void deploy(DeploymentUnit unit) throws DeploymentException { // let the MergedJBossWebMetaDataDeployer do all its usual work super.deploy(unit); // if we don't have any DataSource references in our ENC, then nothing to hack! JBossWebMetaData mergedJBossWebMetaData = unit.getAttachment(JBossWebMetaData.class); if (mergedJBossWebMetaData == null || !this.hasDataSources(mergedJBossWebMetaData)) { return; } // we only hack if this web unit contains EJB deployments (i.e. Java EE6 shared ENC) if (!this.isSharedENC(unit)) { return; } JBossMetaData jbossMetaData = unit.getAttachment(MergedJBossMetaDataDeployer.EJB_MERGED_ATTACHMENT_NAME, JBossMetaData.class); JBossEnterpriseBeansMetaData enterpriseBeans = jbossMetaData.getEnterpriseBeans(); if (enterpriseBeans == null || enterpriseBeans.isEmpty()) { // no beans, no hack! return; } // process each EJB for (JBossEnterpriseBeanMetaData enterpriseBean : enterpriseBeans) { this.removeCommonDataResourceReference(mergedJBossWebMetaData, enterpriseBean); } // attach the updated merged JBossWebMetaData to the unit unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, mergedJBossWebMetaData); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
public void deploy(final DeploymentUnit unit) throws DeploymentException { // we require a VFSDeploymentUnit, to be able to pick up context relative // config files if (unit instanceof VFSDeploymentUnit == false) { return; } final VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; // get hold of the parsed web.xml metadata WebMetaData webMetaData = unit.getAttachment(WebMetaData.class); // shouldn't really happen, because we have set WebMetaData as a required input. if (webMetaData == null) { return; } List<ParamValueMetaData> contextParams = webMetaData.getContextParams(); if (contextParams == null || contextParams.isEmpty()) { return; } JSFDeployment jsfDeployment = vfsDeploymentUnit.getAttachment(JSFDeployment.class); if (jsfDeployment == null) { // create and attach jsfDeployment = new JSFDeployment(); vfsDeploymentUnit.addAttachment(JSFDeployment.class, jsfDeployment); } for (ParamValueMetaData contextParam : contextParams) { if (contextParam == null) { continue; } if (JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME.equals(contextParam.getParamName())) { try { logger.debug("Found " + JAVAX_FACES_CONFIG_FILES_CONTEXT_PARAM_NAME + " param with values: " + contextParam.getParamValue() + " in unit " + vfsDeploymentUnit); // process each of the paths specified in the context param value this.processConfigFilesContextParamValue(vfsDeploymentUnit, jsfDeployment, contextParam.getParamValue()); } catch (Exception e) { throw new DeploymentException(e); } } } }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { if (!unit.getSimpleName().endsWith(".war")) { return; } synchronized (this) { if (sharedTldMetaData == null && tldJars != null) { UnmarshallerFactory factory = UnmarshallerFactory.newInstance(); Unmarshaller unmarshaller = factory.newUnmarshaller(); SchemaBindingResolver resolver = SingletonSchemaResolverFactory .getInstance().getSchemaBindingResolver(); // Parse shared JARs for TLDs sharedTldMetaData = new ArrayList<TldMetaData>(); if (tldJars != null) { VirtualFileFilter tldFilter = new SuffixMatchFilter(".tld", VisitorAttributes.DEFAULT); for (URL tldJar : tldJars) { try { VirtualFile virtualFile = VFS.getChild(tldJar); VirtualFile metaInf = virtualFile.getChild("META-INF"); if (metaInf != null) { List<VirtualFile> tlds = metaInf.getChildren(tldFilter); for (VirtualFile tld : tlds) { TldMetaData tldMetaData = (TldMetaData) unmarshaller.unmarshal(tld.toURL().toString(), resolver); sharedTldMetaData.add(tldMetaData); } } } catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); } } } } } if (sharedTldMetaData != null) { List<TldMetaData> clone = new ArrayList<TldMetaData>(); clone.addAll(sharedTldMetaData); unit.addAttachment(SHARED_TLDS_ATTACHMENT_NAME, clone); } }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { WebMetaData specMetaData = unit.getAttachment(WebMetaData.class); JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); if(specMetaData == null && metaData == null) return; // Check metadata-complete (see AnnotationMetaDataDeployer) boolean isComplete = this.isMetaDataCompleteIsDefault(); if(specMetaData != null) { if (specMetaData instanceof Web25MetaData) { isComplete |= ((Web25MetaData)specMetaData).isMetadataComplete(); } else if (specMetaData instanceof Web30MetaData) { isComplete |= ((Web30MetaData)specMetaData).isMetadataComplete(); } else { // Any web.xml 2.4 or earlier deployment is metadata complete isComplete = true; } } // Find all fragments that have been processed by deployers, and place them in a map keyed by location LinkedList<String> order = new LinkedList<String>(); List<WebOrdering> orderings = new ArrayList<WebOrdering>(); HashSet<String> jarsSet = new HashSet<String>(); Set<VirtualFile> overlays = new HashSet<VirtualFile>(); Map<String, VirtualFile> scis = new HashMap<String, VirtualFile>(); VirtualFile webInfLib = null; boolean fragmentFound = false; HashMap<String, WebFragmentMetaData> webFragments = new HashMap<String, WebFragmentMetaData>(); if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit; webInfLib = vfsUnit.getFile("WEB-INF/lib"); if (webInfLib != null) { List<VirtualFile> jars = webInfLib.getChildren(); for (VirtualFile jar : jars) { jarsSet.add(jar.getName()); // Find overlays VirtualFile overlay = jar.getChild("META-INF/resources"); if (overlay.exists()) { overlays.add(overlay); } // Find ServletContainerInitializer services VirtualFile sci = jar.getChild("META-INF/services/javax.servlet.ServletContainerInitializer"); if (sci.exists()) { scis.put(jar.getName(), sci); } } } if (!isComplete) { String base = unit.getName(); int pos = base.indexOf(':'); if (pos > 0) { base = base.substring(pos); } Iterator<String> attachementNames = unit.getAttachments().keySet().iterator(); HashSet<String> jarsWithoutFragmentsSet = new HashSet<String>(); jarsWithoutFragmentsSet.addAll(jarsSet); while (attachementNames.hasNext()) { String location = attachementNames.next(); Object attachement = unit.getAttachment(location); if (attachement != null && attachement instanceof WebFragmentMetaData) { if (!location.startsWith(WebFragmentMetaData.class.getName() + ":")) { // If there is only one fragment, it will also get mapped as this attachement continue; } String relativeLocation = "/" + location.substring(WebFragmentMetaData.class.getName().length() + 1); String jarName = null; if (relativeLocation.startsWith("/WEB-INF/lib/")) { jarName = relativeLocation.substring("/WEB-INF/lib/".length()); pos = jarName.indexOf('/'); if (pos > 0) jarName = jarName.substring(0, pos); } if (jarName == null) { continue; } fragmentFound = true; WebFragmentMetaData fragmentMetaData = (WebFragmentMetaData) attachement; webFragments.put(jarName, fragmentMetaData); WebOrdering webOrdering = new WebOrdering(); webOrdering.setName(fragmentMetaData.getName()); webOrdering.setJar(jarName); jarsWithoutFragmentsSet.remove(jarName); if (fragmentMetaData.getOrdering() != null) { if (fragmentMetaData.getOrdering().getAfter() != null) { for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getAfter().getOrdering()) { if (orderingElementMetaData.isOthers()) { webOrdering.setAfterOthers(true); } else { webOrdering.addAfter(orderingElementMetaData.getName()); } } } if (fragmentMetaData.getOrdering().getBefore() != null) { for (OrderingElementMetaData orderingElementMetaData : fragmentMetaData.getOrdering().getBefore().getOrdering()) { if (orderingElementMetaData.isOthers()) { webOrdering.setBeforeOthers(true); } else { webOrdering.addBefore(orderingElementMetaData.getName()); } } } } orderings.add(webOrdering); } } // If there is no fragment, still consider it for ordering as a // fragment specifying no name and no order for (String jarName : jarsWithoutFragmentsSet) { WebOrdering ordering = new WebOrdering(); ordering.setJar(jarName); orderings.add(ordering); } } } if (!fragmentFound) { // Drop the order as there is no fragment in the webapp orderings.clear(); } // Generate web fragments parsing order AbsoluteOrderingMetaData absoluteOrderingMetaData = null; if (!isComplete && specMetaData instanceof Web30MetaData) { absoluteOrderingMetaData = ((Web30MetaData) specMetaData).getAbsoluteOrdering(); } if (absoluteOrderingMetaData != null) { // Absolute ordering from web.xml, any relative fragment ordering is ignored int otherPos = -1; int i = 0; for (OrderingElementMetaData orderingElementMetaData : absoluteOrderingMetaData.getOrdering()) { if (orderingElementMetaData.isOthers()) { if (otherPos >= 0) { throw new DeploymentException("Duplicate others in absolute ordering"); } otherPos = i; } else { for (WebOrdering ordering : orderings) { if (orderingElementMetaData.getName().equals(ordering.getName())) { order.add(ordering.getJar()); jarsSet.remove(ordering.getJar()); break; } } } i++; } if (otherPos >= 0) { order.addAll(otherPos, jarsSet); jarsSet.clear(); } } else if (orderings.size() > 0) { // Resolve relative ordering try { resolveOrder(orderings, order); } catch (IllegalStateException e) { DeploymentException.rethrowAsDeploymentException("Invalid ordering", e); } jarsSet.clear(); } else { // No order specified order.addAll(jarsSet); jarsSet.clear(); unit.addAttachment(WEB_NOORDER_ATTACHMENT_NAME, Boolean.TRUE); } if (log.isDebugEnabled()) { StringBuilder builder = new StringBuilder(); builder.append("Resolved order: [ "); for (String jar : order) { builder.append(jar).append(' '); } builder.append(']'); log.debug(builder.toString()); } unit.addAttachment(WEB_ORDER_ATTACHMENT_NAME, order); unit.addAttachment(WEB_OVERLAYS_ATTACHMENT_NAME, overlays); unit.addAttachment(WEB_SCIS_ATTACHMENT_NAME, scis); // The fragments and corresponding annotations will need to be merged in order // For each JAR in the order: // - Merge the annotation metadata into the fragment meta data // (unless the fragment exists and is meta data complete) // - Merge the fragment metadata into merged fragment meta data WebCommonMetaData mergedFragmentMetaData = new WebCommonMetaData(); if (specMetaData == null) { // If there is no web.xml, it has to be considered to be the latest version specMetaData = new Web30MetaData(); specMetaData.setVersion("3.0"); } String key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":classes"; // Augment with meta data from annotations in /WEB-INF/classes WebMetaData classesAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if (classesAnnotatedMetaData != null) { if (isComplete) { // Discard @WebFilter, @WebListener and @WebServlet classesAnnotatedMetaData.setFilters(null); classesAnnotatedMetaData.setFilterMappings(null); classesAnnotatedMetaData.setListeners(null); classesAnnotatedMetaData.setServlets(null); classesAnnotatedMetaData.setServletMappings(null); } specMetaData.augment(classesAnnotatedMetaData, null, true); } // Augment with meta data from fragments and annotations from the corresponding JAR for (String jar : order) { WebFragmentMetaData webFragmentMetaData = webFragments.get(jar); if (webFragmentMetaData == null) { webFragmentMetaData = new WebFragmentMetaData(); // Add non overriding default distributable flag webFragmentMetaData.setDistributable(new EmptyMetaData()); } key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":" + jar; WebMetaData jarAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if ((isComplete || webFragmentMetaData.isMetadataComplete()) && jarAnnotatedMetaData != null) { // Discard @WebFilter, @WebListener and @WebServlet jarAnnotatedMetaData.setFilters(null); jarAnnotatedMetaData.setFilterMappings(null); jarAnnotatedMetaData.setListeners(null); jarAnnotatedMetaData.setServlets(null); jarAnnotatedMetaData.setServletMappings(null); } if (jarAnnotatedMetaData != null) { // Merge annotations corresponding to the JAR webFragmentMetaData.augment(jarAnnotatedMetaData, null, true); } // Merge fragment meta data according to the conflict rules try { mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); } } // Augment with meta data from annotations from JARs excluded from the order for (String jar : jarsSet) { WebFragmentMetaData webFragmentMetaData = new WebFragmentMetaData(); // Add non overriding default distributable flag webFragmentMetaData.setDistributable(new EmptyMetaData()); key = AnnotationMetaDataDeployer.WEB_ANNOTATED_ATTACHMENT_NAME + ":" + jar; WebMetaData jarAnnotatedMetaData = unit.getAttachment(key, WebMetaData.class); if (jarAnnotatedMetaData != null) { // Discard @WebFilter, @WebListener and @WebServlet jarAnnotatedMetaData.setFilters(null); jarAnnotatedMetaData.setFilterMappings(null); jarAnnotatedMetaData.setListeners(null); jarAnnotatedMetaData.setServlets(null); jarAnnotatedMetaData.setServletMappings(null); } if (jarAnnotatedMetaData != null) { // Merge annotations corresponding to the JAR webFragmentMetaData.augment(jarAnnotatedMetaData, null, true); } // Merge fragment meta data according to the conflict rules try { mergedFragmentMetaData.augment(webFragmentMetaData, specMetaData, false); } catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); } } specMetaData.augment(mergedFragmentMetaData, null, true); // Override with meta data (JBossWebMetaData) // Create a merged view JBossWebMetaData mergedMetaData = new JBossWebMetaData(); mergedMetaData.merge(metaData, specMetaData); // Incorporate any ear level overrides DeploymentUnit topUnit = unit.getTopLevel(); if(topUnit != null && topUnit.getAttachment(JBossAppMetaData.class) != null) { JBossAppMetaData earMetaData = topUnit.getAttachment(JBossAppMetaData.class); // Security domain String securityDomain = earMetaData.getSecurityDomain(); if(securityDomain != null && mergedMetaData.getSecurityDomain() == null) mergedMetaData.setSecurityDomain(securityDomain); //Security Roles SecurityRolesMetaData earSecurityRolesMetaData = earMetaData.getSecurityRoles(); if(earSecurityRolesMetaData != null) { SecurityRolesMetaData mergedSecurityRolesMetaData = mergedMetaData.getSecurityRoles(); if(mergedSecurityRolesMetaData == null) mergedMetaData.setSecurityRoles(earSecurityRolesMetaData); //perform a merge to rebuild the principalVersusRolesMap if(mergedSecurityRolesMetaData != null ) { mergedSecurityRolesMetaData.merge(mergedSecurityRolesMetaData, earSecurityRolesMetaData); } } } // Output the merged JBossWebMetaData unit.getTransientManagedObjects().addAttachment(JBossWebMetaData.class, mergedMetaData); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException { ContextInfo context = null; VirtualFile file = structureContext.getFile(); try { boolean trace = log.isTraceEnabled(); // the WEB-INF VirtualFile webinf; // We require either a WEB-INF or the name ends in .war if (hasValidSuffix(file.getName()) == false) { webinf = file.getChild("WEB-INF"); if (webinf.exists()) { if (trace) log.trace("... ok - directory has a WEB-INF subdirectory"); } else { if (trace) log.trace("... no - doesn't look like a war and no WEB-INF subdirectory."); return false; } } else if (trace) { log.trace("... ok - name ends in .war."); } // Check for a META-INF for metadata // FIXME: This is not spec legal, descriptors could be loaded from this location String[] metaDataLocations = new String[]{"WEB-INF", "WEB-INF/classes/META-INF"}; // Create a context for this war file and all its metadata locations context = createContext(structureContext, metaDataLocations); // Add all children as locations for TLDs (except classes and lib), recursively webinf = file.getChild("WEB-INF"); boolean webinfExists = webinf.exists(); if (webinfExists) { List<VirtualFile> children = webinf.getChildren(); for (VirtualFile child : children) { if (!isLeaf(child) && (!"lib".equals(child.getName())) && (!"classes".equals(child.getName()))) { addMetaDataPath(structureContext, context, "WEB-INF/" + child.getName(), MetaDataType.ALTERNATIVE); addPathsRecursively(structureContext, context, child, "WEB-INF/" + child.getName()); } } } // Check for jars in WEB-INF/lib List<VirtualFile> archives = null; try { VirtualFile webinfLib = file.getChild("WEB-INF/lib"); if (webinfLib.exists()) { archives = webinfLib.getChildren(webInfLibFilter); // Add the jars' META-INF for metadata for (VirtualFile jar : archives) { Automounter.mount(file, jar); // either same as plain lib filter, null or accepts the jar if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar)) { VirtualFile metaInf = jar.getChild("META-INF"); if (metaInf.exists() && !isLeaf(metaInf)) { addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF", MetaDataType.ALTERNATIVE); List<VirtualFile> children = metaInf.getChildren(); for (VirtualFile child : children) { if (!isLeaf(child) && (!"resources".equals(child.getName()))) { addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName(), MetaDataType.ALTERNATIVE); addPathsRecursively(structureContext, context, child, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName()); } } } } } } } catch (IOException e) { log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e); } // Add the war manifest classpath entries addClassPath(structureContext, file, false, true, context); // Check for WEB-INF/classes VirtualFile classes = file.getChild("WEB-INF/classes"); // Add WEB-INF/classes if present if (classes.exists()) addClassPath(structureContext, classes, true, false, context); else if (trace) log.trace("No WEB-INF/classes for: " + file.getPathName()); // and the top level jars in WEB-INF/lib if (archives != null) { for (VirtualFile jar : archives) addClassPath(structureContext, jar, true, true, context); } else if (trace) { log.trace("No WEB-INF/lib for: " + file.getPathName()); } // do we include WEB-INF in classpath if (includeWebInfInClasspath && webinfExists) { addClassPath(structureContext, webinf, true, false, context); } // There are no subdeployments for wars return true; } catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); } }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
private ServletContainerInitializer loadSci(DeploymentUnit unit, VirtualFile sci, String jar, boolean error) throws DeploymentException { ServletContainerInitializer service = null; InputStream is = null; try { // Get the ServletContainerInitializer class name is = sci.openStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String servletContainerInitializerClassName = reader.readLine(); int pos = servletContainerInitializerClassName.indexOf('#'); if (pos > 0) { servletContainerInitializerClassName = servletContainerInitializerClassName.substring(0, pos); } servletContainerInitializerClassName = servletContainerInitializerClassName.trim(); // Instantiate the ServletContainerInitializer service = (ServletContainerInitializer) unit.getClassLoader() .loadClass(servletContainerInitializerClassName).newInstance(); } catch (Exception e) { if (error) { DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jar, e); } else { log.info("Skipped SCI for JAR: " + jar, e); } } finally { try { if (is != null) is.close(); } catch (IOException e) { ; } } return service; }
8
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (DeploymentException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(DeploymentException de) { throw de; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(DeploymentException e) { throw new FinderException(e.getMessage()); }
8
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (DeploymentException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(DeploymentException de) { throw de; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(DeploymentException e) { throw new FinderException(e.getMessage()); }
5
unknown (Lib) DuplicateKeyException 6
            
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object createEntity (Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get (ctx.getInstance ()); // Check exist if (this.beans.containsKey (id)) throw new javax.ejb.DuplicateKeyException ("Already exists: "+id); // Store to file storeEntity (id, ctx.getInstance ()); return id; } catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object createEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get(ctx.getInstance()); // Check exist if (getFile(id).exists()) throw new DuplicateKeyException("Already exists: "+id); // Store to file storeEntity(id, ctx.getInstance()); return id; } catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { pk = entityBridge.extractPrimaryKeyFromInstance(ctx); if(pk == null) { throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException { Object pk; PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + pkSql); } con = entityBridge.getDataSource().getConnection(); ps = con.prepareStatement(pkSql); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("pk-sql " + pkSql + " returned no results!"); } pk = pkField.loadArgumentResults(rs, 1); pctx.setFieldValue(pkField.getRowIndex(), pk); pk = entityBridge.extractPrimaryKeyFromInstance(ctx); } catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } if(pk == null) { log.error("Primary key for created instance is null."); throw new CreateException("Primary key for created instance is null."); } pctx.setPk(pk); } else { // insert-after-ejb-post-create try { pctx.flush(); } catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } } pk = ctx.getId(); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
protected void beforeInsert(EntityEnterpriseContext ctx) throws CreateException { // are we checking existance by query? if(existsSQL != null) { Connection c = null; PreparedStatement ps = null; ResultSet rs = null; try { if(debug) log.debug("Executing SQL: " + existsSQL); c = entity.getDataSource().getConnection(); ps = c.prepareStatement(existsSQL); // bind PK // @todo add a method to EntityBridge that binds pk fields directly Object pk = entity.extractPrimaryKeyFromInstance(ctx); entity.setPrimaryKeyParameters(ps, 1, pk); rs = ps.executeQuery(); if(!rs.next()) { throw new CreateException("Error checking if entity with primary pk " + pk + "exists: SQL returned no rows"); } if(rs.getInt(1) > 0) { throw new DuplicateKeyException("Entity with primary key " + pk + " already exists"); } } catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(c); } } }
3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
5
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void addCreated(Row row) throws DuplicateKeyException { //if(getRowByPk(row.pk, false) != null) //{ // throw new DuplicateKeyException("Table " + tableName + ", key=" + row.pk); //} if(created != null) { row.next = created; created.prev = row; } created = row; row.state = CREATED; rowByPk.put(row.pk, row); JDBCCMPFieldBridge2 versionField = entity.getVersionField(); if(versionField != null) { row.fields[versionField.getVersionIndex()] = row.fields[versionField.getRowIndex()]; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void insert(Object pk) throws DuplicateKeyException { this.pk = pk; view.addCreated(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flush() throws SQLException, DuplicateKeyException { // todo needs refactoring if(state != CREATED) { if(log.isTraceEnabled()) { log.trace("The row is already inserted: pk=" + pk); } return; } Connection con = null; PreparedStatement duplicatePkPs = null; PreparedStatement insertPs = null; ResultSet rs = null; try { int paramInd; con = dataSource.getConnection(); // check for duplicate key /* if(log.isDebugEnabled()) { log.debug("executing : " + duplicatePkSql); } duplicatePkPs = con.prepareStatement(duplicatePkSql); paramInd = 1; JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object fieldValue = fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(duplicatePkPs, paramInd, fieldValue); } rs = duplicatePkPs.executeQuery(); if(rs.next()) { throw new DuplicateKeyException("Table " + tableName + ", pk=" + pk); } */ // insert if(log.isDebugEnabled()) { log.debug("executing : " + insertSql); } insertPs = con.prepareStatement(insertSql); paramInd = 1; JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); for(int fInd = 0; fInd < tableFields.length; ++fInd) { JDBCCMPFieldBridge2 field = tableFields[fInd]; Object fieldValue = fields[field.getRowIndex()]; paramInd = field.setArgumentParameters(insertPs, paramInd, fieldValue); } insertPs.executeUpdate(); flushStatus(); } catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(duplicatePkPs); JDBCUtil.safeClose(insertPs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PersistentContext.java
public void setPk(Object pk) throws DuplicateKeyException { if(pk == null) { throw new IllegalArgumentException("Primary key is null!"); } row.insert(pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PersistentContext.java
public void flush() throws SQLException, DuplicateKeyException { row.flush(); }
0 0 0
unknown (Lib) EJBException 195
            
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } try { return mi.performCall(StatelessSessionContainer.this, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // wire the transaction on the context, this is how the instance remember the tx EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); // Get method and instance to invoke upon Method miMethod = mi.getMethod(); Map map = getBeanMapping(); Method m = (Method) map.get(miMethod); // The Invocation might contain the actual bean method // e.g. For an invocation based on a JSR-181 @WebMethod annotation if (m == null && map.values().contains(miMethod)) { m = miMethod; } if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } //If we have a method that needs to be done by the container (EJBObject methods) if (m.getDeclaringClass().equals(StatelessSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { try { return mi.performCall(StatelessSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else // we have a method that needs to be done by a bean instance { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
private void createSession(final Method m, final Object[] args, final StatefulSessionEnterpriseContext ctx) throws Exception { // Create a new ID and set it Object id = getPersistenceManager().createId(ctx); log.debug("Created new session ID: " + id); ctx.setId(id); // Invoke ejbCreate<METHOD>() try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); // Build the ejbCreate<METHOD> from the home create<METHOD> sig String createName = m.getName(); Object instance = ctx.getInstance(); String ejbCreateName = "ejbC" + createName.substring(1); Method createMethod = instance.getClass().getMethod(ejbCreateName, m.getParameterTypes()); log.debug("Using create method for session: " + createMethod); createMethod.invoke(instance, args); createCount++; } catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); } catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // call back to the PM to let it know that ejbCreate has been called with success getPersistenceManager().createdSession(ctx); // Insert in cache getInstanceCache().insert(ctx); // Create EJBObject if (getProxyFactory() != null) ctx.setEJBObject((EJBObject) getProxyFactory().getStatefulSessionEJBObject(id)); // Create EJBLocalObject if (getLocalHomeClass() != null) ctx.setEJBLocalObject(getLocalProxyFactory().getStatefulSessionEJBLocalObject(id)); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("HOMEMETHOD coming in "); log.trace("" + mi.getMethod()); log.trace("HOMEMETHOD coming in hashcode" + mi.getMethod().hashCode()); log.trace("HOMEMETHOD coming in classloader" + mi.getMethod().getDeclaringClass().getClassLoader().hashCode()); log.trace("CONTAINS " + getHomeMapping().containsKey(mi.getMethod())); } Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // Invoke and handle exceptions if (trace) { log.trace("HOMEMETHOD m " + m); java.util.Iterator iterator = getHomeMapping().keySet().iterator(); while (iterator.hasNext()) { Method me = (Method) iterator.next(); if (me.getName().endsWith("create")) { log.trace(me.toString()); log.trace("" + me.hashCode()); log.trace("" + me.getDeclaringClass().getClassLoader().hashCode()); log.trace("equals " + me.equals(mi.getMethod()) + " " + mi.getMethod().equals(me)); } } } try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) getBeanMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // wire the transaction on the context, this is how the instance remember the tx // Unlike Entity beans we can't do that in the previous interceptors (ordering) EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); else if(ejbObjectRemove.equals(miMethod) || ejbLocalObjectRemove.equals(miMethod)) { throw new RemoveException("An attempt to remove a session " + "object while the object is in a transaction " + "(EJB2.1, 7.6.4 Restrictions for Transactions): ejb-name=" + metaData.getEjbName() + ", method=" + mi.getMethod() + ", tx=" + ctx.getTransaction()); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(StatefulSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { // Invoke and handle exceptions try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/Container.java
public TimerService getTimerService(Object pKey) throws IllegalStateException { if (this instanceof StatefulSessionContainer) throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService"); // Validate that the bean implements the TimedObject interface if (TimedObject.class.isAssignableFrom(beanClass) == false) { // jbcts-381 return EJBTimerServiceImpl.FOR_NON_TIMED_OBJECT; } TimerService timerService = null; try { timerService = this.timerService.createTimerService(getJmxName(), pKey, this); } catch (Exception e) { throw new EJBException("Could not create timer service", e); } return timerService; }
// in src/main/java/org/jboss/ejb/Container.java
public Object invoke(Invocation mi) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); long start = System.currentTimeMillis(); Method m = null; Object type = null; String contextID = getJaccContextID(); try { pushENC(); // JBAS-3732 - Remove classloader.equals optimization SecurityActions.setContextClassLoader(this.classLoader); // Set the JACC context id mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID); contextID = SecurityActions.setContextID(contextID); // Set the standard JACC policy context handler data is not a SEI msg if (mi.getType() != InvocationType.SERVICE_ENDPOINT) { EJBArgsPolicyContextHandler.setArgs(mi.getArguments()); } else { SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE); SOAPMsgPolicyContextHandler.setMessage(msg); } // Set custom JACC policy handlers BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData()); // Check against home, remote, localHome, local, getHome, // getRemote, getLocalHome, getLocal type = mi.getType(); // stat gathering: concurrent calls this.invokeStats.callIn(); if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || // web service calls come in as "ordinary" application invocations type == InvocationType.SERVICE_ENDPOINT) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD REMOTE INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||"); } } m = mi.getMethod(); Object obj = internalInvoke(mi); return obj; } else if (type == InvocationType.HOME || type == InvocationType.LOCALHOME) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD HOME INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||" + mi.getArguments().toString()); } } m = mi.getMethod(); Object obj = internalInvokeHome(mi); return obj; } else { throw new MBeanException(new IllegalArgumentException("Unknown invocation type: " + type)); } } /** * Having to catch this exception here in case can not * unmarshall arguments, values, etc. Then, convert to * UnmarshalException as defined by spec (JBAS-2999) */ catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } } finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); } }
// in src/main/java/org/jboss/ejb/Container.java
protected void rethrow(Exception e) throws Exception { if (e instanceof IllegalAccessException) { // Throw this as a bean exception...(?) throw new EJBException(e); } else if (e instanceof InvocationTargetException) { Throwable t = ((InvocationTargetException)e).getTargetException(); if (t instanceof EJBException) { throw (EJBException)t; } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new NestedError("Unexpected Throwable", t); } } throw e; }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); // wire the transaction on the context, // this is how the instance remember the tx if (ctx.getTransaction() == null) { ctx.setTransaction(mi.getTransaction()); } // Get method and instance to invoke upon Method m = (Method) beanMapping.get(mi.getMethod()); if( m == null ) { // This is a configuration error that should have been caught earlier String msg = MessageDrivenContainer.this.getBeanMetaData().getEjbName() + " Invalid invocation, check your deployment packaging, interfaces, method=" + mi.getMethod(); throw new EJBException(msg); } // we have a method that needs to be done by a bean instance try { messageCount++; return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public Identity getCallerIdentity() { throw new EJBException("Deprecated"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public EJBLocalHome getEJBLocalHome() { if (con.getLocalHomeClass() == null) throw new IllegalStateException("No local home defined."); if (con instanceof EntityContainer) return ((EntityContainer) con).getLocalProxyFactory().getEJBLocalHome(); else if (con instanceof StatelessSessionContainer) return ((StatelessSessionContainer) con).getLocalProxyFactory().getEJBLocalHome(); else if (con instanceof StatefulSessionContainer) return ((StatefulSessionContainer) con).getLocalProxyFactory().getEJBLocalHome(); // Should never get here throw new EJBException("No EJBLocalHome available (BUG!)"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public Properties getEnvironment() { throw new EJBException("Deprecated"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public boolean isCallerInRole(Identity id) { throw new EJBException("Deprecated"); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public void initEntity (EntityEnterpriseContext ctx) { // first get cmp metadata of this entity Object instance = ctx.getInstance (); Class ejbClass = instance.getClass (); Field cmpField; Class cmpFieldType; EntityMetaData metaData = (EntityMetaData)con.getBeanMetaData (); Iterator i= metaData.getCMPFields (); while(i.hasNext ()) { // get the field declaration try { cmpField = ejbClass.getField ((String)i.next ()); cmpFieldType = cmpField.getType (); // find the type of the field and resets it // to the default value if (cmpFieldType.equals (boolean.class)) { cmpField.setBoolean (instance,false); } else if (cmpFieldType.equals (byte.class)) { cmpField.setByte (instance,(byte)0); } else if (cmpFieldType.equals (int.class)) { cmpField.setInt (instance,0); } else if (cmpFieldType.equals (long.class)) { cmpField.setLong (instance,0L); } else if (cmpFieldType.equals (short.class)) { cmpField.setShort (instance,(short)0); } else if (cmpFieldType.equals (char.class)) { cmpField.setChar (instance,'\u0000'); } else if (cmpFieldType.equals (double.class)) { cmpField.setDouble (instance,0d); } else if (cmpFieldType.equals (float.class)) { cmpField.setFloat (instance,0f); } else { cmpField.set (instance,null); } } catch (NoSuchFieldException e) { // will be here with dependant value object's private attributes // should not be a problem } catch (Exception e) { throw new EJBException (e); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public void loadEntity (EntityEnterpriseContext ctx) { try { // Read fields java.io.ObjectInputStream in = new CMPObjectInputStream (new java.io.ByteArrayInputStream ((byte[])this.beans.get (ctx.getId ()))); Object obj = ctx.getInstance (); Field[] f = obj.getClass ().getFields (); for (int i = 0; i < f.length; i++) { f[i].set (obj, in.readObject ()); } in.close (); } catch (Exception e) { throw new EJBException ("Load failed", e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected void storeEntity (Object id, Object obj) { try { // Store fields java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream (); java.io.ObjectOutputStream out = new CMPObjectOutputStream (baos); try { Field[] f = obj.getClass ().getFields (); for (int i = 0; i < f.length; i++) { out.writeObject (f[i].get (obj)); } } finally { out.close(); } this.beans.put (id, baos.toByteArray ()); } catch (Exception e) { throw new EJBException ("Store failed", e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void createEntity( Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { Object id = null; try { // Call ejbCreate<METHOD) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); Method createMethod = (Method)createMethods.get(m); id = createMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } // set the id ctx.setId(id); // Create a new CacheKey Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id ); // Give it to the context ctx.setCacheKey(cacheKey); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void postCreateEntity( Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_POST_CREATE); Method postCreateMethod = (Method)postCreateMethods.get(m); postCreateMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { // call the finder method Object result; try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); result = callFinderMethod(finderMethod, args, ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } if (result == null) { // for EJB 1.0 compliance // if the bean couldn't find any matching entities // it returns null, so we return an empty collection return new ArrayList(); } if (result instanceof java.util.Enumeration) { // to preserve 1.0 spec compatiblity ArrayList array = new ArrayList(); Enumeration e = (Enumeration) result; while (e.hasMoreElements() == true) { // Wrap a cache key around the given object id/primary key final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(e.nextElement()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o); } return array; } else if (result instanceof java.util.Collection) { ArrayList array = new ArrayList(((Collection) result).size()); Iterator i = ((Collection) result).iterator(); while (i.hasNext()) { // Wrap a cache key around the given object id/primary key final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(i.next()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o); } return array; } else { // so we received something that's not valid // throw an exception reporting it throw new EJBException("result of finder method is not a valid " + "return type: " + result.getClass()); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void activateEntity(EntityEnterpriseContext ctx) throws RemoteException { // Create a new CacheKey Object id = ctx.getId(); Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id ); // Give it to the context ctx.setCacheKey(cacheKey); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); ejbActivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void loadEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_LOAD); ejbLoad.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void invokeEjbStore(EntityEnterpriseContext ctx) throws RemoteException { try { if(!isStoreRequired(ctx)) { return; } } catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); } try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE); ejbStore.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void passivateEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); ejbPassivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } ctx.setEJBObject(null); ctx.setEJBLocalObject(null); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); ejbRemove.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
private Object callFinderMethod(Method finderMethod, Object[] args, EntityEnterpriseContext ctx) throws Exception { // get the finder method Method callMethod = (Method)finderMethods.get(finderMethod); if (callMethod == null) { throw new EJBException("couldn't find finder method in bean class. " + finderMethod.toString()); } // invoke the finder method Object result = null; try { result = callMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } return result; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void activateSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to activate; ctx=" + ctx); } Object id = ctx.getId(); // Load state File file = getFile(id); if (trace) { log.trace("Reading session state from: " + file); } try { FileInputStream fis = FISAction.open(file); SessionObjectInputStream in = new SessionObjectInputStream(ctx, new BufferedInputStream(fis)); try { Object obj = in.readObject(); if (trace) { log.trace("Session state: " + obj); } ctx.setInstance(obj); } finally { in.close(); } } catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); } removePassivated(id); try { // Instruct the bean to perform activation logic AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbActivate(); } finally { AllowedOperationsAssociation.popInMethodFlag(); } if (trace) { log.trace("Activation complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void passivateSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to passivate; ctx=" + ctx); } try { // Instruct the bean to perform passivation logic AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbPassivate(); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Store state File file = getFile(ctx.getId()); if (trace) { log.trace("Saving session state to: " + file); } try { FileOutputStream fos = FOSAction.open(file); SessionObjectOutputStream out = new SessionObjectOutputStream( new BufferedOutputStream(fos)); Object obj = ctx.getInstance(); if (trace) { log.trace("Writing session state: " + obj); } try { out.writeObject(obj); } finally { out.close(); } } catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); } if (trace) { log.trace("Passivation complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private Object runWithTransactions(Invocation invocation) throws Exception { // Old transaction is the transaction that comes with the MI Transaction oldTransaction = invocation.getTransaction(); // New transaction is the new transaction this might start Transaction newTransaction = null; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Current transaction in MI is " + oldTransaction); InvocationType type = invocation.getType(); byte transType = container.getBeanMetaData().getTransactionMethod(invocation.getMethod(), type); if ( trace ) printMethod(invocation.getMethod(), transType); // Thread arriving must be clean (jboss doesn't set the thread // previously). However optimized calls come with associated // thread for example. We suspend the thread association here, and // resume in the finally block of the following try. Transaction threadTx = tm.suspend(); if( trace ) log.trace("Thread came in with tx " + threadTx); try { switch (transType) { case MetaData.TX_NOT_SUPPORTED: { // Do not set a transaction on the thread even if in MI, just run try { invocation.setTransaction(null); return invokeNext(invocation, false); } finally { invocation.setTransaction(oldTransaction); } } case MetaData.TX_REQUIRED: { int oldTimeout = 0; Transaction theTransaction = oldTransaction; if (oldTransaction == null) { // No tx running // Create tx oldTimeout = startTransaction(invocation); // get the tx newTransaction = tm.getTransaction(); if( trace ) log.trace("Starting new tx " + newTransaction); // Let the method invocation know invocation.setTransaction(newTransaction); theTransaction = newTransaction; } else { // We have a tx propagated // Associate it with the thread tm.resume(oldTransaction); } // Continue invocation try { Object result = invokeNext(invocation, oldTransaction != null); checkTransactionStatus(theTransaction, type); return result; } finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); } } case MetaData.TX_SUPPORTS: { // Associate old transaction with the thread // Some TMs cannot resume a null transaction and will throw // an exception (e.g. Tyrex), so make sure it is not null if (oldTransaction != null) { tm.resume(oldTransaction); } try { Object result = invokeNext(invocation, oldTransaction != null); if (oldTransaction != null) checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } // Even on error we don't do anything with the tx, // we didn't start it } case MetaData.TX_REQUIRES_NEW: { // Always begin a transaction int oldTimeout = startTransaction(invocation); // get it newTransaction = tm.getTransaction(); // Set it on the method invocation invocation.setTransaction(newTransaction); // Continue invocation try { Object result = invokeNext(invocation, false); checkTransactionStatus(newTransaction, type); return result; } finally { // We started the transaction for sure so we commit or roll back endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); } } case MetaData.TX_MANDATORY: { if (oldTransaction == null) { if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new TransactionRequiredLocalException( "Transaction Required"); } else { throw new TransactionRequiredException( "Transaction Required"); } } // Associate it with the thread tm.resume(oldTransaction); try { Object result = invokeNext(invocation, true); checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } } case MetaData.TX_NEVER: { if (oldTransaction != null) { throw new EJBException("Transaction not allowed"); } return invokeNext(invocation, false); } default: log.error("Unknown TX attribute "+transType+" for method"+invocation.getMethod()); } } finally { // IN case we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } return null; }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void getReadLock(Transaction tx) { boolean done = false; while(!done) { if(tx == null) { done = writer == null; } else if(readers.contains(tx)) { done = true; } else if(writer == null && promotingReader == null && writersWaiting == 0) { try { ReadLockReliever reliever = getReliever(); reliever.setup(this, tx); tx.registerSynchronization(reliever); } catch (Exception e) { throw new EJBException(e); } readers.add(tx); done = true; } else if (writer != null && writer.equals(tx)) { done = true; } if(!done) { if(trace) trace(tx, "READ (WT) writer:" + writer + " writers waiting: " + writersWaiting + " reader count: " + readers.size()); waitAWhile(tx); } } }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void getWriteLock(Transaction tx) { boolean done = false; boolean isReader; if(tx == null) throw new EJBException("Write lock requested without transaction."); isReader = readers.contains(tx); writersWaiting++; while(!done) { if(writer == null && (readers.isEmpty() || (readers.size() == 1 && isReader))) { writersWaiting--; promotingReader = null; writer = tx; done = true; } else if (writer != null && writer.equals(tx)) { writersWaiting--; done = true; } else { if(isReader) { if(promotingReader != null && !promotingReader.equals(tx)) { writersWaiting--; throw new EJBException("Contention on read lock promotion for bean. Exception in second transaction"); } promotingReader = tx; } if(trace) trace(tx, "WRITE (WT) writer:" + writer + " writers waiting: " + writersWaiting + " reader count: " + readers.size()); waitAWhile(tx); } } }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void checkTransaction(Transaction tx) { try { if(TxUtils.isRollback(tx)) throw new EJBException ("Transaction marked for rollback - probably a timeout."); } catch (Exception e) { throw new EJBException(e); } }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context MessageDrivenContainer mdc = (MessageDrivenContainer) container; InstancePool pool = mdc.getInstancePool(); EnterpriseContext ctx = null; try { ctx = pool.get(); } catch (EJBException e) { throw e; } catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Use this context mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); // There is no need for synchronization since the instance is always // fresh also there should never be a tx associated with the instance. try { // Invoke through interceptors Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free((EnterpriseContext) mi.getEnterpriseContext()); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
protected void register(EntityEnterpriseContext ctx, Transaction tx) { boolean trace = log.isTraceEnabled(); if(trace) log.trace("register, ctx=" + ctx + ", tx=" + tx); EntityContainer ctxContainer = null; try { ctxContainer = (EntityContainer)ctx.getContainer(); if(!ctx.hasTxSynchronization()) { // Create a new synchronization Synchronization synch = createSynchronization(tx, ctx); // We want to be notified when the transaction commits tx.registerSynchronization(synch); ctx.hasTxSynchronization(true); } //mark it dirty in global tx entity map if it is not read only if(!ctxContainer.isReadOnly()) { ctx.getTxAssociation().scheduleSync(tx, ctx); } } catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); } catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
private void checkSecurityAssociation(Invocation mi) throws Exception { Principal principal = mi.getPrincipal(); boolean trace = log.isTraceEnabled(); if (realmMapping == null) { throw new EJBException("checkSecurityAssociation", new SecurityException("Role mapping manager has not been set")); } // Get the method permissions InvocationType iface = mi.getType(); Set methodRoles = container.getMethodPermissions(mi.getMethod(), iface); if (methodRoles == null) { String method = mi.getMethod().getName(); String msg = "No method permissions assigned to method=" + method + ", interface=" + iface; log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } else if (trace) { log.trace("method=" + mi.getMethod() + ", interface=" + iface + ", requiredRoles=" + methodRoles); } // Check if the caller is allowed to access the method RunAsIdentity callerRunAsIdentity = SecurityAssociation.peekRunAsIdentity(); if (methodRoles.contains(AnybodyPrincipal.ANYBODY_PRINCIPAL) == false) { // The caller is using a the caller identity if (callerRunAsIdentity == null) { // Now actually check if the current caller has one of the required method roles if (realmMapping.doesUserHaveRole(principal, methodRoles) == false) { Set userRoles = realmMapping.getUserRoles(principal); String method = mi.getMethod().getName(); String msg = "Insufficient method permissions, principal=" + principal + ", method=" + method + ", interface=" + iface + ", requiredRoles=" + methodRoles + ", principalRoles=" + userRoles; log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } } // The caller is using a run-as identity else { // Check that the run-as role is in the set of method roles if (callerRunAsIdentity.doesUserHaveRole(methodRoles) == false) { String method = mi.getMethod().getName(); String msg = "Insufficient method permissions, runAsPrincipal=" + callerRunAsIdentity.getName() + ", method=" + method + ", interface=" + iface + ", requiredRoles=" + methodRoles + ", runAsRoles=" + callerRunAsIdentity.getRunAsRoles(); log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
protected Object invokeNext(Invocation invocation, boolean inheritedTx) throws Exception { InvocationType type = invocation.getType(); try { if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || type == InvocationType.SERVICE_ENDPOINT) { // register the Timer with the transaction if (ejbTimeout.equals(invocation.getMethod())) registerTimer(invocation); return getNext().invoke(invocation); } else { return getNext().invokeHome(invocation); } } catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); boolean nonReentrant = !(reentrant || isReentrantMethod(mi)); // Not a reentrant method like getPrimaryKey NonReentrantLock methodLock = ctx.getMethodLock(); Transaction miTx = ctx.getTransaction(); boolean locked = false; try { while (!locked) { if (methodLock.attempt(5000, miTx, nonReentrant)) { locked = true; } else { if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } } } catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } } try { ctx.lock(); return getNext().invoke(mi); } finally { ctx.unlock(); methodLock.release(nonReentrant); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { // Deligate initialization of bean to persistence store store.initEntity(ctx); // Call ejbCreate on the target bean try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); Method createMethod = (Method) createMethods.get(m); createMethod.invoke(ctx.getInstance(), args); } catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // if insertAfterEjbPostCreate == true, this will INSERT entity // otherwise, primary key is extracted from the context and returned Object id; try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); id = store.createEntity(m, args, ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Set the key on the target context ctx.setId(id); // Create a new CacheKey Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id); // Give it to the context ctx.setCacheKey(cacheKey); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void postCreateEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { // this call should go first as it sets up relationships // for fk fields mapped to pk fields store.postCreateEntity(m, args, ctx); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_POST_CREATE); Method postCreateMethod = (Method) postCreateMethods.get(m); postCreateMethod.invoke(ctx.getInstance(), args); if(insertAfterEjbPostCreate) { store.createEntity(m, args, ctx); } } catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void activateEntity(EntityEnterpriseContext ctx) throws RemoteException { // Create a new CacheKey Object id = ctx.getId(); Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id); // Give it to the context ctx.setCacheKey(cacheKey); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbActivate(); } catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // The implementation of the call can be left absolutely empty, the // propagation of the call is just a notification for stores that would // need to know that an instance is being activated store.activateEntity(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void throwRemoteException(Exception e) throws RemoteException { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
public synchronized EnterpriseContext get() throws Exception { boolean intr = false; try { // Wait while someone else is using it while(inUse && isSynchronized) { try { this.wait(); } catch (InterruptedException e) { intr = true; } } // Create if not already created (or it has been discarded) if (ctx == null) { try { ctx = create(getContainer().createBeanClassInstance()); } catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); } catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); } } else { } // Lock and return instance inUse = true; return ctx; } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context InstancePool pool = container.getInstancePool(); StatelessSessionEnterpriseContext ctx = null; try { ctx = (StatelessSessionEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Use this context mi.setEnterpriseContext(ctx); // JAXRPC/JAXWS message context Object msgContext = mi.getValue(InvocationKey.SOAP_MESSAGE_CONTEXT); // Timer invocation if (ejbTimeout.equals(mi.getMethod())) { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); } // Service Endpoint invocation else if (msgContext != null) { if (msgContext instanceof javax.xml.rpc.handler.MessageContext) ctx.setMessageContext((javax.xml.rpc.handler.MessageContext)msgContext); AllowedOperationsAssociation.pushInMethodFlag(IN_SERVICE_ENDPOINT_METHOD); } // Business Method Invocation else { AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); } // There is no need for synchronization since the instance is always fresh also there should // never be a tx associated with the instance. try { Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public void initEntity(final EntityEnterpriseContext ctx) { // first get cmp metadata of this entity Object instance = ctx.getInstance(); Class ejbClass = instance.getClass(); Field cmpField; Class cmpFieldType; EntityMetaData metaData = (EntityMetaData)con.getBeanMetaData(); Iterator i = metaData.getCMPFields(); while (i.hasNext()) { // get the field declaration try { cmpField = ejbClass.getField((String)i.next()); cmpFieldType = cmpField.getType(); // find the type of the field and reset it // to the default value if (cmpFieldType.equals(boolean.class)) { cmpField.setBoolean(instance,false); } else if (cmpFieldType.equals(byte.class)) { cmpField.setByte(instance,(byte)0); } else if (cmpFieldType.equals(int.class)) { cmpField.setInt(instance,0); } else if (cmpFieldType.equals(long.class)) { cmpField.setLong(instance,0L); } else if (cmpFieldType.equals(short.class)) { cmpField.setShort(instance,(short)0); } else if (cmpFieldType.equals(char.class)) { cmpField.setChar(instance,'\u0000'); } else if (cmpFieldType.equals(double.class)) { cmpField.setDouble(instance,0d); } else if (cmpFieldType.equals(float.class)) { cmpField.setFloat(instance,0f); } else { cmpField.set(instance,null); } } catch (NoSuchFieldException e) { // will be here with dependant value object's private attributes // should not be a problem } catch (Exception e) { throw new EJBException(e); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public void loadEntity(final EntityEnterpriseContext ctx) { try { Object obj = ctx.getInstance(); // Read fields ObjectInputStream in = new CMPObjectInputStream (new BufferedInputStream(new FileInputStream(getFile(ctx.getId())))); try { Field[] f = obj.getClass().getFields(); for (int i = 0; i < f.length; i++) { f[i].set(obj, in.readObject()); } } finally { in.close(); } } catch (Exception e) { throw new EJBException("Load failed", e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
private void storeEntity(Object id, Object obj) { try { // Store fields ObjectOutputStream out = new CMPObjectOutputStream (new BufferedOutputStream(new FileOutputStream(getFile(id)))); try { Field[] f = obj.getClass().getFields(); for (int i = 0; i < f.length; i++) { out.writeObject(f[i].get(obj)); } } finally { out.close(); } } catch (Exception e) { throw new EJBException("Store failed", e); } }
// in src/main/java/org/jboss/ejb/plugins/local/StatefulSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { if (args == null) args = EMPTY_ARGS; // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (m.equals(GET_PRIMARY_KEY)) { if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } Object retValue = super.invoke( proxy, m, args ); if (retValue == null) { // If not taken care of, go on and call the container retValue = factory.invoke(id, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/local/StatelessSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { Object retValue = null; if (args == null) args = EMPTY_ARGS; // Implement local methods if (m.equals(TO_STRING)) { retValue = jndiName + ":Stateless"; } else if (m.equals(EQUALS)) { retValue = invoke(proxy, IS_IDENTICAL, args); } else if (m.equals(HASH_CODE)) { // We base the stateless hash on the hash of the proxy... // MF XXX: it could be that we want to return the hash of the name? retValue = new Integer(this.hashCode()); } else if (m.equals(GET_PRIMARY_KEY)) { // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } else if (m.equals(GET_EJB_HOME)) { InitialContext ctx = new InitialContext(); return ctx.lookup(jndiName); } else if (m.equals(IS_IDENTICAL)) { // All stateless beans are identical within a home, // if the names are equal we are equal retValue = isIdentical(args[0], jndiName + ":Stateless"); } // If not taken care of, go on and call the container else { retValue = factory.invoke(jndiName, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/RelationInterceptor.java
public Object invoke(Invocation mi) throws Exception { if(!(mi instanceof CMRInvocation)) { return getNext().invoke(mi); } org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage msg = ((CMRInvocation)mi).getCmrMessage(); // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); JDBCCMRFieldBridge2 cmrField = (JDBCCMRFieldBridge2)mi.getArguments()[0]; if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.ADD_RELATION == msg) { Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Add relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.addRelatedId(ctx, relatedId); } else if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.REMOVE_RELATION == msg) { // call removeRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Remove relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.removeRelatedId(ctx, relatedId); } else { // this should not be possible we are using a type safe enum throw new EJBException("Unknown cmp2.0-relationship-message=" + msg); } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
public void flush() { Views views = getViews(); Table.View[] relationViews = views.relationViews; if(relationViews != null) { for(int i = 0; i < relationViews.length; ++i) { final Table.View view = relationViews[i]; if(view != null) { try { view.flushDeleted(views); } catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); } } } } final Table.View[] entityViews = views.entityViews; for(int i = 0; i < entityViews.length; ++i) { Table.View view = entityViews[i]; if(view != null) { try { view.flushDeleted(views); } catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); } } } for(int i = 0; i < entityViews.length; ++i) { Table.View view = entityViews[i]; if(view != null) { try { view.flushCreated(views); } catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); } } } for(int i = 0; i < entityViews.length; ++i) { Table.View view = entityViews[i]; if(view != null) { try { view.flushUpdated(); } catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); } } } if(relationViews != null) { for(int i = 0; i < relationViews.length; ++i) { final Table.View view = relationViews[i]; if(view != null) { try { view.flushCreated(views); } catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); } } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
private Views getViews() { Transaction tx = txLocal.getTransaction(); GlobalTxSynchronization globalSync; try { globalSync = txLocal.getGlobalSynchronization(tx); } catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); } catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); } if(globalSync == null) throw new IllegalStateException("Global transaction synchronization is not available for transaction " + tx); Views views = (Views) globalSync.getTxLocal(viewsTxLocalKey); if(views == null) { views = new Views(tx); globalSync.putTxLocal(viewsTxLocalKey, views); globalSync.addSynchronization(new SchemaSynchronization(views)); } return views; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void nullifyForeignKeys() throws SQLException { if(log.isTraceEnabled()) { log.trace("nullifying foreign keys"); } Connection con = null; PreparedStatement[] ps = new PreparedStatement[fkConstraints.length]; try { final JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); con = dataSource.getConnection(); for(int i = 0; i < rowsWithNullFks.size(); ++i) { final Row row = (Row) rowsWithNullFks.get(i); final ForeignKeyConstraint[] cons = row.fkUpdates; for (int c = 0; c < fkConstraints.length; ++c) { if (cons[c] == null || row.state == DELETED && !cons[c].selfReference) continue; PreparedStatement s = ps[c]; if (s == null) { if (log.isDebugEnabled()) { log.debug("nullifying fk: " + cons[c].nullFkSql); } s = con.prepareStatement(cons[c].nullFkSql); ps[c] = s; } int paramInd = 1; for (int fInd = 0; fInd < pkFields.length; ++fInd) { JDBCCMPFieldBridge2 pkField = pkFields[fInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(s, paramInd, fieldValue); } final int affected = s.executeUpdate(); if (affected != 1) { throw new EJBException("Affected " + affected + " rows while expected just one"); } } } } finally { for(int i = 0; i < ps.length; ++i) { JDBCUtil.safeClose(ps[i]); } JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private Object loadField(int i) { JDBCCMPFieldBridge2 field = (JDBCCMPFieldBridge2)entity.getFields().get(i); StringBuffer query = new StringBuffer(); query.append("select ") .append(field.getColumnName()) .append(" from ") .append(tableName) .append(" where "); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[])entity.getPrimaryKeyFields(); for(int pkI = 0; pkI < pkFields.length; ++pkI) { if(pkI > 0) { query.append(" and "); } query.append(pkFields[pkI].getColumnName()).append("=?"); } if(log.isDebugEnabled()) { log.debug("executing: " + query.toString()); } Object value = null; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = dataSource.getConnection(); ps = con.prepareStatement(query.toString()); for(int pkI = 0; pkI < pkFields.length; ++pkI) { JDBCCMPFieldBridge2 pkField = pkFields[pkI]; Object fieldValue = fields[pkField.getRowIndex()]; pkField.setArgumentParameters(ps, pkI + 1, fieldValue); } rs = ps.executeQuery(); if(!rs.next()) { throw new NoSuchEntityException("Row not found: " + pk); } value = field.loadArgumentResults(rs, 1); } catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } fields[field.getRowIndex()] = value; return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeBatch(PreparedStatement ps) throws SQLException { int[] updates = ps.executeBatch(); for(int i = 0; i < updates.length; ++i) { int status = updates[i]; if(status != 1 && status != -2 /* java.sql.Statement.SUCCESS_NO_INFO since jdk1.4*/) { String msg = (status == -3 /* java.sql.Statement.EXECUTE_FAILED since jdk1.4 */ ? "One of the commands in the batch failed to execute" : "Each command in the batch should update exactly 1 row but " + "one of the commands updated " + updates[i] + " rows."); throw new EJBException(msg); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeUpdate(PreparedStatement ps) throws SQLException { int rows = ps.executeUpdate(); if(rows != 1) { throw new EJBException("Expected one updated row but got: " + rows); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public void loadEntity(EntityEnterpriseContext ctx) { try { EntityTable.Row row = entityBridge.getTable().loadRow(ctx.getId()); PersistentContext pctx = new PersistentContext(entityBridge, row); ctx.setPersistenceContext(pctx); } catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; } catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object setPrimaryKeyValue(Object primaryKey, Object value) throws IllegalArgumentException { try { if(pkField != null) { // if we are trying to set a null value into a null pk, we are already done. if(value == null && primaryKey == null) { return null; } // if we don't have a pk object yet create one if(primaryKey == null) { primaryKey = pkClass.newInstance(); } // Set this field's value into the primary key object. pkField.set(primaryKey, value); return primaryKey; } else { // This field is the primary key, so no extraction is necessary. return value; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public int setArgumentParameters(PreparedStatement ps, int parameterIndex, Object arg) { try { int[] jdbcTypes = jdbcType.getJDBCTypes(); for(int i = 0; i < jdbcTypes.length; i++) { Object columnValue = jdbcType.getColumnValue(i, arg); jdbcType.getParameterSetter()[i].set(ps, parameterIndex++, jdbcTypes[i], columnValue, log); //JDBCUtil.setParameter(log, ps, parameterIndex++, jdbcTypes[i], columnValue); } return parameterIndex; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object loadArgumentResults(ResultSet rs, int parameterIndex) throws IllegalArgumentException { try { // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); if(javaTypes.length > 1) { throw new IllegalStateException("Complex types are not supported yet."); } JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); Object columnValue = null; for(int i = 0; i < javaTypes.length; i++) { columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); columnValue = jdbcType.setColumnValue(i, null, columnValue); } // retrun the updated parameterIndex return columnValue; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object getPrimaryKeyValue(Object primaryKey) throws IllegalArgumentException { try { if(pkField != null) { if(primaryKey == null) { return null; } return pkField.get(primaryKey); } else { return primaryKey; } } catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private void invokeRemoveRelatedId(Object myId, Object relatedId) { try { Transaction tx = getTransaction(); EntityCache instanceCache = (EntityCache)manager.getContainer().getInstanceCache(); /* RelationInterceptor.RelationInvocation invocation = new RelationInterceptor.RelationInvocation(RelationInterceptor.CMRMessage.REMOVE_RELATED_ID); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(SecurityAssociation.getPrincipal()); invocation.setCredential(SecurityAssociation.getCredential()); invocation.setType(InvocationType.LOCAL); */ SecurityActions actions = SecurityActions.UTIL.getSecurityActions(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.REMOVE_RELATION); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(actions.getPrincipal()); invocation.setCredential(actions.getCredential()); invocation.setType(InvocationType.LOCAL); manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in invokeRemoveRelatedId()", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private void invokeAddRelatedId(Object myId, Object relatedId) { try { Transaction tx = getTransaction(); EntityCache instanceCache = (EntityCache)manager.getContainer().getInstanceCache(); /* RelationInterceptor.RelationInvocation invocation = new RelationInterceptor.RelationInvocation(RelationInterceptor.CMRMessage.ADD_RELATED_ID); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(SecurityAssociation.getPrincipal()); invocation.setCredential(SecurityAssociation.getCredential()); invocation.setType(InvocationType.LOCAL); */ SecurityActions actions = SecurityActions.UTIL.getSecurityActions(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.ADD_RELATION); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(actions.getPrincipal()); invocation.setCredential(actions.getCredential()); invocation.setType(InvocationType.LOCAL); manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in invokeAddRelatedId()", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private void loadOnlyFromCache(EntityEnterpriseContext ctx) { PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext(); if(pctx == null) { throw new EJBException("Persistence context is not available! Make sure the CMR collection is accessed in the transaction it was obtained."); } pctx.loadCachedRelations(cmrIndex, this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void load(EntityEnterpriseContext ctx, FieldState state) { Object value; EntityTable relatedTable = relatedEntity.getTable(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing: " + loadSql); } con = relatedTable.getDataSource().getConnection(); ps = con.prepareStatement(loadSql); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[])entity.getPrimaryKeyFields(); Object myPk = ctx.getId(); int paramInd = 1; for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object fieldValue = pkField.getPrimaryKeyValue(myPk); JDBCCMPFieldBridge2 relatedFkField = tableKeyFields[i]; relatedFkField.setArgumentParameters(ps, paramInd++, fieldValue); } rs = ps.executeQuery(); while(rs.next()) { value = relatedTable.loadRow(rs, false); state.addLoadedPk(value); } } catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void load(EntityEnterpriseContext ctx, FieldState state) { Object value; EntityTable relatedTable = relatedEntity.getTable(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing: " + loadSql); } con = relatedTable.getDataSource().getConnection(); ps = con.prepareStatement(loadSql); JDBCCMPFieldBridge2[] relatedFkFields = relatedCMRField.foreignKeyFields; JDBCCMPFieldBridge2[] myPkFields = relatedCMRField.relatedPKFields; Object myPk = ctx.getId(); int paramInd = 1; for(int i = 0; i < relatedFkFields.length; ++i) { JDBCCMPFieldBridge2 myPkField = myPkFields[i]; Object fieldValue = myPkField.getPrimaryKeyValue(myPk); JDBCCMPFieldBridge2 relatedFkField = relatedFkFields[i]; relatedFkField.setArgumentParameters(ps, paramInd++, fieldValue); } rs = ps.executeQuery(); while(rs.next()) { value = relatedTable.loadRow(rs, false); state.addLoadedPk(value); } } catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public Object extractPrimaryKeyFromInstance(EntityEnterpriseContext ctx) { try { Object pk = null; for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object fieldValue = pkField.getValue(ctx); pk = pkField.setPrimaryKeyValue(pk, fieldValue); } return pk; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Internal error extracting primary key from instance", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public void setContext(EntityEnterpriseContext ctx) { if(ctx != null && !beanClass.isInstance(ctx.getInstance())) { throw new EJBException("Instance must be an instance of beanClass"); } this.ctx = ctx; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public Object invoke(Object proxy, Method method, Object[] args) throws FinderException { // todo find a better workaround // CMP/CMR field bridges are mapped to its abstract method names because of the bug // in reflection introduced in Sun's 1.4 JVM, i.e. when an abstract class C1 extends a super class C2 // and implements interface I and C2 and I both declare method with the same signature M, // C1.getMethods() will contain M twice. // ejbSelect methods are mapped to Method objects instead. Because ejbSelect methods having the same name // might have different signatures. Hopefully, the probability of an ejbSelect method to appear in an interface // is lower. String methodName = method.getName(); BridgeInvoker invoker = (BridgeInvoker) fieldMap.get(methodName); if(invoker == null) { //invoker = (BridgeInvoker) selectorMap.get(methodName); invoker = (BridgeInvoker) selectorMap.get(method); if(invoker == null) { throw new EJBException("Method is not a known CMP field " + "accessor, CMR field accessor, or ejbSelect method: " + "methodName=" + methodName); } } try { return invoker.invoke(ctx, method, args); } catch(RuntimeException e) { throw e; } catch(FinderException e) { throw e; } catch(Exception e) { throw new EJBException("Internal error", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public Object invoke(EntityEnterpriseContext ctx, Method method, Object[] args) { // In the case of ejbHome methods there is no context, but ejb home // methods are only allowed to call selectors. if(ctx == null) { throw new EJBException("EJB home methods are not allowed to " + "access CMP or CMR fields: methodName=" + method.getName()); } return field.getValue(ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public Object invoke(EntityEnterpriseContext ctx, Method method, Object[] args) { // In the case of ejbHome methods there is no context, but ejb home // methods are only allowed to call selectors. if(ctx == null) { throw new EJBException("EJB home methods are not allowed to " + "access CMP or CMR fields: methodName=" + method.getName()); } field.setValue(ctx, args[0]); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRelationInterceptor.java
public Object invoke(Invocation mi) throws Exception { if(!(mi instanceof CMRInvocation)) return getNext().invoke(mi); CMRMessage relationshipMessage = ((CMRInvocation)mi).getCmrMessage(); if(relationshipMessage == null) { // Not a relationship message. Invoke down the chain return getNext().invoke(mi); } // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)mi.getArguments()[0]; if(CMRMessage.GET_RELATED_ID == relationshipMessage) { // call getRelateId if(log.isTraceEnabled()) { log.trace("Getting related id: field=" + cmrField.getFieldName() + " id=" + ctx.getId()); } return cmrField.getRelatedId(ctx); } else if(CMRMessage.ADD_RELATION == relationshipMessage) { // call addRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Add relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.addRelation(ctx, relatedId); return null; } else if(CMRMessage.REMOVE_RELATION == relationshipMessage) { // call removeRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Remove relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.removeRelation(ctx, relatedId); return null; } else if(CMRMessage.SCHEDULE_FOR_CASCADE_DELETE == relationshipMessage) { JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity(); entity.scheduleForCascadeDelete(ctx); return null; } else if(CMRMessage.SCHEDULE_FOR_BATCH_CASCADE_DELETE == relationshipMessage) { JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity(); entity.scheduleForBatchCascadeDelete(ctx); return null; } else { // this should not be possible we are using a type safe enum throw new EJBException("Unknown cmp2.0-relationship-message=" + relationshipMessage); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
public void execute(EntityEnterpriseContext ctx) { // scheduled for batch cascade-delete instance should not be updated // because foreign key fields could be updated to null and cascade-delete will fail. JDBCEntityBridge.FieldIterator dirtyIterator = entity.getDirtyIterator(ctx); if(!dirtyIterator.hasNext() || entity.isBeingRemoved(ctx) || entity.isScheduledForBatchCascadeDelete(ctx)) { if(log.isTraceEnabled()) { log.trace("Store command NOT executed. Entity is not dirty " + ", is being removed or scheduled for *batch* cascade delete: pk=" + ctx.getId()); } return; } // generate sql StringBuffer sql = new StringBuffer(200); sql.append(SQLUtil.UPDATE) .append(entity.getQualifiedTableName()) .append(SQLUtil.SET); SQLUtil.getSetClause(dirtyIterator, sql) .append(SQLUtil.WHERE); SQLUtil.getWhereClause(primaryKeyFields, sql); boolean hasLockedFields = entity.hasLockedFields(ctx); JDBCEntityBridge.FieldIterator lockedIterator = null; if(hasLockedFields) { lockedIterator = entity.getLockedIterator(ctx); while(lockedIterator.hasNext()) { sql.append(SQLUtil.AND); JDBCCMPFieldBridge field = lockedIterator.next(); if(field.getLockedValue(ctx) == null) { SQLUtil.getIsNullClause(false, field, "", sql); lockedIterator.remove(); } else { SQLUtil.getWhereClause(field, sql); } } } Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { // create the statement if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql.toString()); // SET: set the dirty fields parameters int index = 1; dirtyIterator.reset(); while(dirtyIterator.hasNext()) { index = dirtyIterator.next().setInstanceParameters(ps, index, ctx); } // WHERE: set primary key fields index = entity.setPrimaryKeyParameters(ps, index, ctx.getId()); // WHERE: set optimistically locked field values if(hasLockedFields) { lockedIterator.reset(); while(lockedIterator.hasNext()) { JDBCCMPFieldBridge field = lockedIterator.next(); Object value = field.getLockedValue(ctx); index = field.setArgumentParameters(ps, index, value); } } // execute statement rowsAffected = ps.executeUpdate(); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Store failed", e); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected != 1) { throw new EJBException("Update failed. Expected one affected row: rowsAffected=" + rowsAffected + ", id=" + ctx.getId()); } // Mark the updated fields as clean. dirtyIterator.reset(); while(dirtyIterator.hasNext()) { dirtyIterator.next().setClean(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
public synchronized DataSource getDataSource() { if (dataSource == null) { try { InitialContext context = new InitialContext(); dataSource = (DataSource) context.lookup(dataSourceName); } catch (NamingException e) { throw new EJBException("Data source for relationship named " + relationName + " not found " + dataSourceName); } } return dataSource; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
private boolean hasNextResult() { try { boolean has = (limit == 0 || count-- > 0) && rs.next(); if(!has) { if(log.isTraceEnabled()) { log.trace("first iterator exhausted!"); } firstIterator = null; closeResources(); } return has; } catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
private Object readNext() { try { if(selectEntity != null) { ReadAheadCache selectReadAheadCache = selectManager.getReadAheadCache(); // first one is size int index = 2; // get the pk index = selectEntity.loadPrimaryKeyResults(rs, index, ref); curPk = ref[0]; boolean addPk = (loadOnFindCmr ? !curPk.equals(prevPk) : true); if(addPk) { prevPk = curPk; currentResult = factory.getEntityEJBObject(curPk); } // read the preload fields if(eagerLoadMask != null) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < eagerLoadMask.length; i++) { if(eagerLoadMask[i]) { JDBCFieldBridge field = tableFields[i]; ref[0] = null; // read the value and store it in the readahead cache index = field.loadArgumentResults(rs, index, ref); if(addPk) { selectReadAheadCache.addPreloadData(curPk, field, ref[0]); } } } if(!onFindCMRList.isEmpty()) { index = loadOnFindCMRFields(curPk, onFindCMRList, rs, index, log); } } } else if(selectField != null) { // load the field selectField.loadArgumentResults(rs, 2, ref); currentResult = ref[0]; } else { currentResult = selectFunction.readResult(rs); } if(log.isTraceEnabled() && limit != 0 && count == 0) { log.trace("Query result was limited to " + limit + " row(s)"); } return currentResult; } catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private JDBCTypeComplex createTypeComplex(JDBCCMPFieldMetaData cmpField) { // get the default properties for a field of its type JDBCTypeComplex type = (JDBCTypeComplex)complexTypes.get(cmpField.getFieldType()); JDBCTypeComplexProperty[] defaultProperties = type.getProperties(); // create a map of the overrides based on flat property name HashMap overrides = new HashMap(); for(int i = 0; i < cmpField.getPropertyOverrides().size(); ++i) { JDBCCMPFieldPropertyMetaData p = (JDBCCMPFieldPropertyMetaData)cmpField.getPropertyOverrides().get(i); overrides.put(p.getPropertyName(), p); } // array that will hold the final properites after overrides JDBCTypeComplexProperty[] finalProperties = new JDBCTypeComplexProperty[defaultProperties.length]; // override property default values for(int i = 0; i < defaultProperties.length; i++) { // pop off the override, if present JDBCCMPFieldPropertyMetaData override; override = (JDBCCMPFieldPropertyMetaData)overrides.remove(defaultProperties[i].getPropertyName()); if(override == null) { finalProperties[i] = defaultProperties[i]; finalProperties[i] = new JDBCTypeComplexProperty( defaultProperties[i], cmpField.getColumnName() + "_" + defaultProperties[i].getColumnName(), defaultProperties[i].getJDBCType(), defaultProperties[i].getSQLType(), cmpField.isNotNull() || defaultProperties[i].isNotNull()); } else { // columnName String columnName = override.getColumnName(); if(columnName == null) { columnName = cmpField.getColumnName() + "_" + defaultProperties[i].getColumnName(); } // sql and jdbc type String sqlType = override.getSQLType(); int jdbcType; if(sqlType != null) { jdbcType = override.getJDBCType(); } else { sqlType = defaultProperties[i].getSQLType(); jdbcType = defaultProperties[i].getJDBCType(); } boolean notNull = cmpField.isNotNull() || override.isNotNull() || defaultProperties[i].isNotNull(); finalProperties[i] = new JDBCTypeComplexProperty( defaultProperties[i], columnName, jdbcType, sqlType, notNull); } } // did we find all overriden properties if(overrides.size() > 0) { String propertyName = (String)overrides.keySet().iterator().next(); throw new EJBException("Property " + propertyName + " in field " + cmpField.getFieldName() + " is not a property of value object " + cmpField.getFieldType().getName()); } // return the new complex type return new JDBCTypeComplex(finalProperties, cmpField.getFieldType()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public final void pushPropertyMetaData( JDBCValuePropertyMetaData propertyMetaData) { propertyNames.add(propertyMetaData.getPropertyName()); columnNames.add(propertyMetaData.getColumnName()); notNulls.add(new Boolean(propertyMetaData.isNotNull())); getters.add(propertyMetaData.getGetter()); setters.add(propertyMetaData.getSetter()); if(properties.contains(propertyMetaData)) { throw new EJBException("Circular reference discoverd at " + "property: " + getPropertyName()); } properties.add(propertyMetaData); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private Map getApplicationTxDataMap() { try { Transaction tx = tm.getTransaction(); if(tx == null) { return null; } // get the txDataMap from the txMap Map txMap = (Map)txDataMap.get(tx); // do we have an existing map if(txMap == null) { int status = tx.getStatus(); if(status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARING) { // create and add the new map txMap = new HashMap(); txDataMap.set(tx, txMap); } } return txMap; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error getting application tx data map.", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
public void execute(RelationData relationData) { if(relationData.addedRelations.size() == 0) { return; } Connection con = null; PreparedStatement ps = null; JDBCCMRFieldBridge cmrField = relationData.getLeftCMRField(); try { // get the sql String sql = getSQL(relationData); boolean debug = log.isDebugEnabled(); if(debug) log.debug("Executing SQL: " + sql); // get the connection DataSource dataSource = cmrField.getDataSource(); con = dataSource.getConnection(); // get a prepared statement ps = con.prepareStatement(sql); Iterator pairs = relationData.addedRelations.iterator(); while(pairs.hasNext()) { RelationPair pair = (RelationPair)pairs.next(); // set the parameters setParameters(ps, relationData, pair); int rowsAffected = ps.executeUpdate(); } } catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); Connection c; Statement s = null; ResultSet rs = null; try { c = ps.getConnection(); s = c.createStatement(); rs = s.executeQuery(pkSQL); if (!rs.next()) { throw new EJBException("ResultSet was empty"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
public void execute(RelationData relationData) { if(relationData.removedRelations.size() == 0) { return; } Iterator pairs = relationData.removedRelations.iterator(); int i = 0; while(i < relationData.removedRelations.size()) { String sql = getSQL(relationData, relationData.removedRelations.size() - i); Connection con = null; PreparedStatement ps = null; JDBCCMRFieldBridge cmrField = relationData.getLeftCMRField(); try { // create the statement if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } // get the connection DataSource dataSource = cmrField.getDataSource(); con = dataSource.getConnection(); ps = con.prepareStatement(sql); // set the parameters setParameters(ps, relationData, pairs); // execute statement int rowsAffected = ps.executeUpdate(); if(log.isDebugEnabled()) { log.debug("Rows affected = " + rowsAffected); } i += (maxKeysInDelete > 0 ? maxKeysInDelete : relationData.removedRelations.size()); } catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
private boolean execute(JDBCCMPFieldBridge requiredField, EntityEnterpriseContext ctx, boolean failIfNotFound) { // load the instance primary key fields into the context Object id = ctx.getId(); // TODO: when exactly do I need to do the following? entity.injectPrimaryKeyIntoInstance(ctx, id); // get the read ahead cache ReadAheadCache readAheadCache = manager.getReadAheadCache(); // load any preloaded fields into the context if(readAheadCache.load(ctx)) { if(requiredField == null || (requiredField != null && requiredField.isLoaded(ctx))) { return true; } } // get the finder results associated with this context, if it exists ReadAheadCache.EntityReadAheadInfo info = readAheadCache.getEntityReadAheadInfo(id); // determine the fields to load JDBCEntityBridge.FieldIterator loadIter = entity.getLoadIterator(requiredField, info.getReadAhead(), ctx); if(!loadIter.hasNext()) return true; // get the keys to load List loadKeys = info.getLoadKeys(); // generate the sql String sql = (rowLockingTemplate != null ? getRawLockingSQL(loadIter, loadKeys.size()) : getSQL(loadIter, loadKeys.size())); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { // create the statement if (log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql); // Set the fetch size of the statement if (entity.getFetchSize() > 0) { ps.setFetchSize(entity.getFetchSize()); } // set the parameters int paramIndex = 1; for (int i = 0; i < loadKeys.size(); i++) { paramIndex = entity.setPrimaryKeyParameters(ps, paramIndex, loadKeys.get(i)); } // execute statement rs = ps.executeQuery(); // load results boolean mainEntityLoaded = false; Object[] ref = new Object[1]; while (rs.next()) { // reset the column index for this row int index = 1; // ref must be reset to null before load ref[0] = null; // if we are loading more then one entity, load the pk from the row Object pk = null; if (loadKeys.size() > 1) { // load the pk index = entity.loadPrimaryKeyResults(rs, index, ref); pk = ref[0]; } // is this the main entity or a preload entity if (loadKeys.size() == 1 || pk.equals(id)) { // main entity; load the values into the context loadIter.reset(); while(loadIter.hasNext()) { JDBCCMPFieldBridge field = loadIter.next(); index = field.loadInstanceResults(rs, index, ctx); field.setClean(ctx); } mainEntityLoaded = true; } else { // preload entity; load the values into the read ahead cahce loadIter.reset(); while(loadIter.hasNext()) { JDBCCMPFieldBridge field = loadIter.next(); // ref must be reset to null before load ref[0] = null; // load the result of the field index = field.loadArgumentResults(rs, index, ref); // cache the field value readAheadCache.addPreloadData(pk, field, ref[0]); } } } // clear LOAD_REQUIRED flag loadIter.removeAll(); // did we load the main results if (!mainEntityLoaded) { if (failIfNotFound) throw new NoSuchEntityException("Entity not found: primaryKey=" + ctx.getId()); else return false; } else return true; } catch (EJBException e) { throw e; } catch (Exception e) { throw new EJBException("Load failed", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
public JDBCTypeComplexProperty getProperty(String propertyName) { JDBCTypeComplexProperty prop = (JDBCTypeComplexProperty)propertiesByName.get(propertyName); if(prop == null) { throw new EJBException(fieldType.getName() + " does not have a property named " + propertyName); } return prop; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
private static Object getColumnValue(JDBCTypeComplexProperty property, Object value) { try { return property.getColumnValue(value); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error getting column value", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
private Object setColumnValue( JDBCTypeComplexProperty property, Object value, Object columnValue) { if(value==null && columnValue==null) { // nothing to do return null; } try { if(value == null) { value = fieldType.newInstance(); } return property.setColumnValue(value, columnValue); } catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/RelationData.java
private RelationPair createRelationPair(JDBCCMRFieldBridge leftCMRField, Object leftId, JDBCCMRFieldBridge rightCMRField, Object rightId) { if(this.leftCMRField == leftCMRField && this.rightCMRField == rightCMRField) { return new RelationPair(leftCMRField, leftId, rightCMRField, rightId); } if(this.leftCMRField == rightCMRField && this.rightCMRField == leftCMRField) { return new RelationPair(rightCMRField, rightId, leftCMRField, leftId); } throw new EJBException("Error: cmrFields are of wrong type"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public Object createPrimaryKeyInstance() { if(primaryKeyFieldName == null) { try { return primaryKeyClass.newInstance(); } catch(Exception e) { throw new EJBException("Error creating primary key instance: ", e); } } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public Object extractPrimaryKeyFromInstance(EntityEnterpriseContext ctx) { try { Object pk = null; for(int i = 0; i < primaryKeyFields.length; ++i) { JDBCCMPFieldBridge pkField = primaryKeyFields[i]; Object fieldValue = pkField.getInstanceValue(ctx); // updated pk object with return form set primary key value to // handle single valued non-composit pks and more complicated behivors. pk = pkField.setPrimaryKeyValue(pk, fieldValue); } return pk; } catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error extracting primary key from " + "instance", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP2xFieldBridge.java
private FieldState getLoadedState(EntityEnterpriseContext ctx) { FieldState fieldState = getFieldState(ctx); if(!fieldState.isLoaded()) { manager.loadField(this, ctx); if(!fieldState.isLoaded()) throw new EJBException("Could not load field value: " + getFieldName()); } return fieldState; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMR field cannot be set " + "in ejbCreate; this should be done in the ejbPostCreate " + "method instead [EJB 2.0 Spec. 10.5.2]."); } if(isCollectionValued() && value == null) { throw new IllegalArgumentException("null cannot be assigned to a " + "collection-valued cmr-field [EJB 2.0 Spec. 10.3.8]."); } /* if(allFKFieldsMappedToPKFields) { throw new IllegalStateException( "Can't modify relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]."); } */ setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Object getInstanceValue(EntityEnterpriseContext myCtx) { load(myCtx); FieldState fieldState = getFieldState(myCtx); if(isCollectionValued()) { return fieldState.getRelationSet(); } // only return one try { List value = fieldState.getValue(); if(!value.isEmpty()) { Object fk = value.get(0); return getRelatedEntityByFK(fk); } else if(foreignKeyFields != null) { // for those completely mapped to CMP fields and created in this current tx !!! Object relatedId = getRelatedIdFromContext(myCtx); if(relatedId != null) { return getRelatedEntityByFK(relatedId); } } return null; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException(e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setInstanceValue(EntityEnterpriseContext myCtx, Object newValue) { // validate new value first List newPks; if(newValue instanceof Collection) { Collection col = (Collection) newValue; if(!col.isEmpty()) { newPks = new ArrayList(col.size()); for(Iterator iter = col.iterator(); iter.hasNext();) { Object localObject = iter.next(); if(localObject != null) { Object relatedId = getRelatedPrimaryKey(localObject); // check whether new value modifies the primary key if there are FK fields mapped to PK fields if(relatedPKFieldsByMyPKFields.size() > 0) { checkSetForeignKey(myCtx, relatedId); } newPks.add(relatedId); } } } else { newPks = Collections.EMPTY_LIST; } } else { if(newValue != null) { newPks = Collections.singletonList(getRelatedPrimaryKey(newValue)); } else { newPks = Collections.EMPTY_LIST; } } // load the current value load(myCtx); FieldState fieldState = getFieldState(myCtx); // is this just setting our own relation set back if(newValue == fieldState.getRelationSet()) { return; } try { // Remove old value(s) List value = fieldState.getValue(); if(!value.isEmpty()) { Object[] curPks = value.toArray(new Object[value.size()]); for(int i = 0; i < curPks.length; ++i) { destroyRelationLinks(myCtx, curPks[i]); } } // Add new value(s) for(int i = 0; i < newPks.size(); ++i) { createRelationLinks(myCtx, newPks.get(i)); } } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new EJBException(e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void createRelationLinks(EntityEnterpriseContext myCtx, Object relatedId, boolean updateForeignKey) { if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } // If my multiplicity is one, then we need to free the new related context // from its old relationship. Transaction tx = getTransaction(); if(metadata.isMultiplicityOne()) { Object oldRelatedId = relatedCMRField.invokeGetRelatedId(tx, relatedId); if(oldRelatedId != null) { invokeRemoveRelation(tx, oldRelatedId, relatedId); relatedCMRField.invokeRemoveRelation(tx, relatedId, oldRelatedId); } } addRelation(myCtx, relatedId, updateForeignKey); relatedCMRField.invokeAddRelation(tx, relatedId, myCtx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void destroyRelationLinks(EntityEnterpriseContext myCtx, Object relatedId, boolean updateValueCollection, boolean updateForeignKey) { if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } removeRelation(myCtx, relatedId, updateValueCollection, updateForeignKey); relatedCMRField.invokeRemoveRelation(getTransaction(), relatedId, myCtx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Object invokeScheduleForCascadeDelete(Transaction tx, Object myId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.SCHEDULE_FOR_CASCADE_DELETE); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); return manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Object invokeScheduleForBatchCascadeDelete(Transaction tx, Object myId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.SCHEDULE_FOR_BATCH_CASCADE_DELETE); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); return manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Object invokeGetRelatedId(Transaction tx, Object myId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.GET_RELATED_ID); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); return manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in getRelatedId", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void invokeAddRelation(Transaction tx, Object myId, Object relatedId) { try { SecurityContext sc = SecurityActions.getSecurityContext(); EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.ADD_RELATION); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in addRelation", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void invokeRemoveRelation(Transaction tx, Object myId, Object relatedId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.REMOVE_RELATION); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in removeRelation", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Object getRelatedId(EntityEnterpriseContext myCtx) { if(isCollectionValued()) { throw new EJBException("getRelatedId may only be called on a cmr-field with a multiplicity of one."); } load(myCtx); List value = getFieldState(myCtx).getValue(); return value.isEmpty() ? null : value.get(0); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void addRelation(EntityEnterpriseContext myCtx, Object fk, boolean updateForeignKey) { checkSetForeignKey(myCtx, fk); if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(myCtx)) { throw new IllegalStateException("A CMR field cannot be set or added " + "to a relationship in ejbCreate; this should be done in the " + "ejbPostCreate method instead [EJB 2.0 Spec. 10.5.2]."); } // add to current related set FieldState myState = getFieldState(myCtx); myState.addRelation(fk); // set the foreign key, if we have one. if(hasForeignKey() && updateForeignKey) { setForeignKey(myCtx, fk); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void removeRelation(EntityEnterpriseContext myCtx, Object fk, boolean updateValueCollection, boolean updateForeignKey) { if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } // remove from current related set if(updateValueCollection) { FieldState myState = getFieldState(myCtx); myState.removeRelation(fk); } // set the foreign key to null, if we have one. if(hasForeignKey() && updateForeignKey) { setForeignKey(myCtx, null); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void load(EntityEnterpriseContext myCtx, Collection values) { // did we get more then one value for a single valued field if(isSingleValued() && values.size() > 1) { throw new EJBException("Data contains multiple values, but this cmr field is single valued: " + values); } // add the new values FieldState fieldState = getFieldState(myCtx); fieldState.loadRelations(values); // set the foreign key, if we have one. if(hasForeignKey()) { // update the states and locked values of FK fields if(!values.isEmpty()) { Object loadedValue = values.iterator().next(); for(int i = 0; i < foreignKeyFields.length; ++i) { JDBCCMP2xFieldBridge fkField = foreignKeyFields[i]; Object fieldValue = fkField.getPrimaryKeyValue(loadedValue); fkField.updateState(myCtx, fieldValue); } } // set the real FK value List realValue = fieldState.getValue(); Object fk = realValue.isEmpty() ? null : realValue.get(0); setForeignKey(myCtx, fk); } JDBCEntityBridge.setCreated(myCtx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setForeignKey(EntityEnterpriseContext myCtx, Object fk) { if(!hasForeignKey()) { throw new EJBException(getFieldName() + " CMR field does not have a foreign key to set."); } for(int i = 0; i < foreignKeyFields.length; ++i) { JDBCCMP2xFieldBridge fkField = foreignKeyFields[i]; Object fieldValue = fkField.getPrimaryKeyValue(fk); fkField.setInstanceValue(myCtx, fieldValue); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] fkRef) { if(foreignKeyFields == null) { return parameterIndex; } boolean fkIsNull = false; // value of this field, will be filled in below Object[] argumentRef = new Object[1]; for(int i = 0; i < foreignKeyFields.length; ++i) { JDBCCMPFieldBridge field = foreignKeyFields[i]; parameterIndex = field.loadArgumentResults(rs, parameterIndex, argumentRef); if(fkIsNull) { continue; } if(field.getPrimaryKeyField() != null) { // if there is a null field among FK fields, the whole FK field is considered null. // NOTE: don't throw exception in this case, it's ok if FK is partly mapped to a PK // NOTE2: we still need to iterate through foreign key fields and 'load' them to // return correct parameterIndex. if(argumentRef[0] == null) { fkRef[0] = null; fkIsNull = true; } else { // if we don't have a pk object yet create one if(fkRef[0] == null) { fkRef[0] = relatedEntity.createPrimaryKeyInstance(); } try { // Set this field's value into the primary key object. field.getPrimaryKeyField().set(fkRef[0], argumentRef[0]); } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); } } } else { // This field is the primary key, so no extraction is necessary. fkRef[0] = argumentRef[0]; } } return parameterIndex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Transaction getTransaction() { try { EntityContainer container = getJDBCStoreManager().getContainer(); TransactionManager tm = container.getTransactionManager(); return tm.getTransaction(); } catch(SystemException e) { throw new EJBException("Error getting transaction from the transaction manager", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public List getValue() { if(!isLoaded) { throw new EJBException("CMR field value not loaded yet"); } return Collections.unmodifiableList(setHandle[0]); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void loadRelations(Collection values) { // check if we are aleready loaded if(isLoaded) { throw new EJBException("CMR field value is already loaded"); } // just in the case where there are lingering values setHandle[0].clear(); // add the new values setHandle[0].addAll(values); if(removedRelations != null) { // remove the already removed values setHandle[0].removeAll(removedRelations); removedRelations = null; } if(addedRelations != null) { // add the already added values // but remove FKs we are going to add to avoid duplication setHandle[0].removeAll(addedRelations); setHandle[0].addAll(addedRelations); addedRelations = null; } // mark the field loaded isLoaded = true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Set getRelationSet() { if(!isLoaded) { throw new EJBException("CMR field value not loaded yet"); } if(ctx.isReadOnly()) { // we are in a read-only invocation, so return a snapshot set return new RelationSet(JDBCCMRFieldBridge.this, ctx, new List[]{new ArrayList(setHandle[0])}, true); } // if we already have a relationset use it if(relationSet != null) { return relationSet; } // construct a new relationshet try { // get the curent transaction EntityContainer container = getJDBCStoreManager().getContainer(); TransactionManager tm = container.getTransactionManager(); Transaction tx = tm.getTransaction(); // if whe have a valid transaction... if(tx != null && (tx.getStatus() == Status.STATUS_ACTIVE || tx.getStatus() == Status.STATUS_PREPARING)) { // crete the relation set and register for a tx callback relationSet = new RelationSet(JDBCCMRFieldBridge.this, ctx, setHandle, false); TxSynchronization sync = new TxSynchronization(FieldState.this); tx.registerSynchronization(sync); } else { // if there is no transaction create a pre-failed list relationSet = new RelationSet(JDBCCMRFieldBridge.this, ctx, new List[1], false); } return relationSet; } catch(SystemException e) { throw new EJBException("Error while creating RelationSet", e); } catch(RollbackException e) { throw new EJBException("Error while creating RelationSet", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
public Object getInstanceValue(EntityEnterpriseContext ctx) { FieldState fieldState = getFieldState(ctx); if(!fieldState.isLoaded()) { throw new EJBException("CMP 1.1 field not loaded: " + getFieldName()); } try { return field.get(ctx.getInstance()); } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
public void setInstanceValue(EntityEnterpriseContext ctx, Object value) { try { field.set(ctx.getInstance(), value); FieldState fieldState = getFieldState(ctx); fieldState.setLoaded(); fieldState.setCheckDirty(); } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean add(Object o) { if(o == null) { throw new IllegalArgumentException("Null cannot be added to a CMR " + "relationship collection"); } checkForPKChange(); List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } if(!relatedLocalInterface.isInstance(o)) { String msg = "Object must be an instance of " + relatedLocalInterface.getName() + ", but is an isntance of ["; Class[] classes = o.getClass().getInterfaces(); for(int i = 0; i < classes.length; i++) { if(i > 0) msg += ", "; msg += classes[i].getName(); } msg += "]"; throw new IllegalArgumentException(msg); } Object id = getPrimaryKey((EJBLocalObject) o); if(idList.contains(id)) { return false; } cmrField.createRelationLinks(ctx, id); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean addAll(Collection c) { if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } if(c == null) { return false; } boolean isModified = false; Iterator iterator = (new HashSet(c)).iterator(); while(iterator.hasNext()) { isModified = add(iterator.next()) || isModified; } return isModified; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean remove(Object o) { List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); if(!relatedLocalInterface.isInstance(o)) { throw new IllegalArgumentException("Object must be an instance of " + relatedLocalInterface.getName()); } Object id = getPrimaryKey((EJBLocalObject) o); if(!idList.contains(id)) { return false; } cmrField.destroyRelationLinks(ctx, id); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean removeAll(Collection c) { if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } if(c == null) { return false; } boolean isModified = false; Iterator iterator = (new HashSet(c)).iterator(); while(iterator.hasNext()) { isModified = remove(iterator.next()) || isModified; } return isModified; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public void clear() { checkForPKChange(); List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } Iterator iterator = (new ArrayList(idList)).iterator(); while(iterator.hasNext()) { cmrField.destroyRelationLinks(ctx, iterator.next()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean retainAll(Collection c) { List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); if(c == null) { if(idList.size() == 0) { return false; } clear(); return true; } // get a set of the argument collection's ids List argIds = new ArrayList(); Iterator iterator = c.iterator(); while(iterator.hasNext()) { EJBLocalObject localObject = (EJBLocalObject) iterator.next(); Object relatedId = getPrimaryKey(localObject); argIds.add(relatedId); } boolean isModified = false; iterator = (new ArrayList(idList)).iterator(); while(iterator.hasNext()) { Object id = iterator.next(); if(!argIds.contains(id)) { cmrField.destroyRelationLinks(ctx, id); isModified = true; } } return isModified; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public void remove() { verifyIteratorIsValid(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); try { idIterator.remove(); cmrField.destroyRelationLinks(ctx, currentId, false); } catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + fieldName); } if(primaryKeyMember && JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMP field that is a member " + "of the primary key can only be set in ejbCreate " + "[EJB 2.0 Spec. 10.3.5]."); } if(ctx.isValid()) { if(!isLoaded(ctx)) { // the field must be loaded for dirty cheking to work properly manager.loadField(this, ctx); } lockingStrategy.changed(this, ctx); } setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public Object getPrimaryKeyValue(Object primaryKey) throws IllegalArgumentException { try { if(primaryKeyField != null) { if(primaryKey == null) { return null; } // Extract this field's value from the primary key. return primaryKeyField.get(primaryKey); } else { // This field is the primary key, so no extraction is necessary. return primaryKey; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public Object setPrimaryKeyValue(Object primaryKey, Object value) throws IllegalArgumentException { try { if(primaryKeyField != null) { // if we are tring to set a null value // into a null pk, we are already done. if(value == null && primaryKey == null) { return null; } // if we don't have a pk object yet create one if(primaryKey == null) { primaryKey = primaryKeyClass.newInstance(); } // Set this field's value into the primary key object. primaryKeyField.set(primaryKey, value); return primaryKey; } else { // This field is the primary key, so no extraction is necessary. return value; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int setArgumentParameters(PreparedStatement ps, int parameterIndex, Object arg) { try { int[] jdbcTypes = jdbcType.getJDBCTypes(); for(int i = 0; i < jdbcTypes.length; i++) { Object columnValue = jdbcType.getColumnValue(i, arg); jdbcType.getParameterSetter()[i].set(ps, parameterIndex++, jdbcTypes[i], columnValue, log); //JDBCUtil.setParameter(log, ps, parameterIndex++, jdbcTypes[i], columnValue); } return parameterIndex; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int loadInstanceResults(ResultSet rs, int parameterIndex, EntityEnterpriseContext ctx) { try { // value of this field, will be filled in below Object[] argumentRef = new Object[1]; // load the cmp field value from the result set parameterIndex = loadArgumentResults(rs, parameterIndex, argumentRef); // set the value into the context setInstanceValue(ctx, argumentRef[0]); lockingStrategy.loaded(this, ctx); return parameterIndex; } catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
private int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef, boolean nullColumnNullifiesResult) throws IllegalArgumentException { try { // value of this field, will be filled in below // set the value of this field into the pk argumentRef[0] = null; // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); for(int i = 0; i < javaTypes.length; i++) { Object columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); if(nullColumnNullifiesResult && columnValue == null) { argumentRef[0] = null; parameterIndex += javaTypes.length - i - 1; break; } argumentRef[0] = jdbcType.setColumnValue(i, argumentRef[0], columnValue); } // retrun the updated parameterIndex return parameterIndex; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object execute(Object[] args) throws FinderException { Collection retVal; Method method = getMethod(); try { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(method); EntityContainer selectedContainer = query.getSelectManager().getContainer(); GenericEntityObjectFactory factory; if(queryMetaData.isResultTypeMappingLocal() && selectedContainer.getLocalHomeClass() != null) { factory = selectedContainer.getLocalProxyFactory(); } else { factory = selectedContainer.getProxyFactory(); } retVal = query.execute(method, args, null, factory); } catch(FinderException e) { throw e; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); } if(!Collection.class.isAssignableFrom(getReturnType())) { // single object if(retVal.size() == 0) { throw new ObjectNotFoundException(); } if(retVal.size() > 1) { throw new FinderException(getSelectorName() + " returned " + retVal.size() + " objects"); } Object o = retVal.iterator().next(); if(o == null && method.getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + method.getReturnType().getName() ); } return o; } else { // collection or set if(Set.class.isAssignableFrom(getReturnType())) { return new HashSet(retVal); } else { return retVal; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
public Collection execute(JDBCCMRFieldBridge cmrField, Object pk) { JDBCCMRFieldBridge relatedCMRField = (JDBCCMRFieldBridge) cmrField.getRelatedCMRField(); // get the read ahead cahces ReadAheadCache readAheadCache = manager.getReadAheadCache(); ReadAheadCache relatedReadAheadCache = cmrField.getRelatedManager().getReadAheadCache(); // get the finder results associated with this context, if it exists ReadAheadCache.EntityReadAheadInfo info = readAheadCache.getEntityReadAheadInfo(pk); List loadKeys = info.getLoadKeys(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { // generate the sql boolean[] preloadMask = getPreloadMask(cmrField); String sql = getSQL(cmrField, preloadMask, loadKeys.size()); // create the statement if(log.isDebugEnabled()) log.debug("load relation SQL: " + sql); // get the connection con = cmrField.getDataSource().getConnection(); ps = con.prepareStatement(sql.toString()); // Set the fetch size of the statement if(entity.getFetchSize() > 0) { ps.setFetchSize(entity.getFetchSize()); } // get the load fields JDBCCMPFieldBridge[] myKeyFields = getMyKeyFields(cmrField); JDBCCMPFieldBridge[] relatedKeyFields = getRelatedKeyFields(cmrField); // set the parameters int paramIndex = 1; for(int i = 0; i < loadKeys.size(); i++) { Object key = loadKeys.get(i); for(int j = 0; j < myKeyFields.length; ++j) paramIndex = myKeyFields[j].setPrimaryKeyParameters(ps, paramIndex, key); } // execute statement rs = ps.executeQuery(); // initialize the results map Map resultsMap = new HashMap(loadKeys.size()); for(int i = 0; i < loadKeys.size(); ++i) { resultsMap.put(loadKeys.get(i), new ArrayList()); } // load the results Object[] ref = new Object[1]; while(rs.next()) { // reset the column index for this row int index = 1; // ref must be reset to null before each load ref[0] = null; // if we are loading more then one entity, load the pk from the row Object loadedPk = pk; if(loadKeys.size() > 1) { // load the pk for(int i = 0; i < myKeyFields.length; ++i) { index = myKeyFields[i].loadPrimaryKeyResults(rs, index, ref); if(ref[0] == null) { break; } } loadedPk = ref[0]; } // load the fk ref[0] = null; for(int i = 0; i < relatedKeyFields.length; ++i) { index = relatedKeyFields[i].loadPrimaryKeyResults(rs, index, ref); if(ref[0] == null) { break; } } Object loadedFk = ref[0]; if(loadedFk != null) { // add this value to the list for loadedPk List results = (List)resultsMap.get(loadedPk); results.add(loadedFk); // if the related cmr field is single valued we can pre-load // the reverse relationship if(relatedCMRField.isSingleValued()) { relatedReadAheadCache.addPreloadData( loadedFk, relatedCMRField, Collections.singletonList(loadedPk)); } // read the preload fields if(preloadMask != null) { JDBCFieldBridge[] relatedFields = cmrField.getRelatedJDBCEntity().getTableFields(); for(int i = 0; i < relatedFields.length; ++i) { if(preloadMask[i]) { JDBCFieldBridge field = relatedFields[i]; ref[0] = null; // read the value and store it in the readahead cache index = field.loadArgumentResults(rs, index, ref); relatedReadAheadCache.addPreloadData(loadedFk, field, ref[0]); } } } } } // set all of the preloaded values JDBCReadAheadMetaData readAhead = relatedCMRField.getReadAhead(); for(Iterator iter = resultsMap.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); // get the results for this key List results = (List)resultsMap.get(key); // store the results list for readahead on-load relatedReadAheadCache.addFinderResults(results, readAhead); // store the preloaded relationship (unless this is the realts we // are actually after) if(!key.equals(pk)) { readAheadCache.addPreloadData(key, cmrField, results); } } // success, return the results return (List)resultsMap.get(pk); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Load relation failed", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
protected int executeInsert(int index, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { ps.execute(); ResultSet rs = null; try { int rows = ps.getUpdateCount(); if(rows != 1) { throw new EJBException("Expected updateCount of 1, got " + rows); } if(ps.getMoreResults() == false) { throw new EJBException("Expected ResultSet but got an updateCount. Is NOCOUNT set for all triggers?"); } rs = ps.getResultSet(); if(!rs.next()) { throw new EJBException("ResultSet was empty"); } pkField.loadInstanceResults(rs, 1, ctx); return rows; } catch(RuntimeException e) { throw e; } catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); // remove any JCA wrappers Statement stmt = ps; do { try { Object[] args = {}; stmt = (Statement) getUnderlyingStatement.invoke(stmt, args); } catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } } while (stmt != null && method.getDeclaringClass().isInstance(stmt) == false); try { Number pk = (Number)method.invoke(stmt, null); pkField.setInstanceValue(ctx, pk); return rows; } catch(RuntimeException e) { throw e; } catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); ResultSet rs = null; try { rs = (ResultSet) GET_GENERATED_KEYS.invoke(ps, null); if (!rs.next()) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("getGeneratedKeys returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); // remove any JCA wrappers Statement stmt = ps; do { try { Object[] args = {}; stmt = (Statement) getUnderlyingStatement.invoke(stmt, args); } catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } } while (stmt != null && method.getDeclaringClass().isInstance(stmt) == false); ResultSet rs = null; try { rs = (ResultSet) method.invoke(stmt, null); if (!rs.next()) { throw new EJBException("getGeneratedKeys returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx ) throws SQLException { int rows = ps.executeUpdate(); ResultSet results = null; try { Connection conn = ps.getConnection(); results = conn.prepareStatement( SQL ).executeQuery(); if( !results.next() ) { throw new EJBException( "identity_val_local() returned an empty ResultSet" ); } pkField.loadInstanceResults( results, 1, ctx ); } catch( RuntimeException e ) { throw e; } catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); } finally { JDBCUtil.safeClose( results ); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
protected int executeInsert(int index, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); Statement s = null; ResultSet rs = null; try { if (trace) { log.trace("Executing SQL :"+sequenceSQL); } Connection c = ps.getConnection(); s = c.createStatement(); rs = s.executeQuery(sequenceSQL); if (!rs.next()) { throw new EJBException("sequence sql returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
public EnterpriseContext get() throws Exception { boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Get instance "+this+"#"+pool.size()+"#"+getContainer().getBeanClass()); if( strictMaxSize != null ) { // Block until an instance is available boolean acquired = strictMaxSize.attempt(strictTimeout); if( trace ) log.trace("Acquired("+acquired+") strictMaxSize semaphore, remaining="+strictMaxSize.permits()); if( acquired == false ) throw new EJBException("Failed to acquire the pool semaphore, strictTimeout="+strictTimeout); } synchronized (pool) { if ( pool.isEmpty() == false ) { return (EnterpriseContext) pool.removeFirst(); } } // Pool is empty, create an instance try { Object instance = container.createBeanClassInstance(); return create(instance); } catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // The key Object key = mi.getId(); EntityEnterpriseContext ctx = null; EntityContainer ec = (EntityContainer) container; if (mi.getTransaction() != null) { //ctx = ec.getTxEntityMap().getCtx(mi.getTransaction(), key); } if (ctx == null) { InstancePool pool = ec.getInstancePool(); try { ctx = (EntityEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } ctx.setCacheKey(key); ctx.setId(key); EntityPersistenceManager pm = ec.getPersistenceManager(); pm.activateEntity(ctx); } boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Begin invoke, key="+key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); try { Object ret = getNext().invoke(mi); return ret; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenTxInterceptorBMT.java
public Object invokeHome(Invocation mi) { throw new EJBException("No home methods for message beans."); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
protected void register(EnterpriseContext ctx, Transaction tx, BeanLock lock) { // Create a new synchronization InstanceSynchronization synch = new InstanceSynchronization(ctx, lock); try { // OSH: An extra check to avoid warning. // Can go when we are sure that we no longer get // the JTA violation warning. if (TxUtils.isRollback(tx.getStatus())) { return; } // We want to be notified when the transaction commits try { tx.registerSynchronization(synch); } catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; } // EJB 1.1, 6.5.3 synch.afterBegin(); } catch (RollbackException e) { } catch (Exception e) { throw new EJBException(e); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { InstanceCache cache = container.getInstanceCache(); InstancePool pool = container.getInstancePool(); Object methodID = mi.getId(); EnterpriseContext ctx = null; BeanLock lock = container.getLockManager().getLock(methodID); boolean callerRunAsIdentityPresent = SecurityActions.peekRunAsIdentity() != null; boolean pushSecurityContext = SecurityActions.getSecurityContext() == null; try { /* The security context must be established before the cache lookup because the activation of a session should have the caller's security context as ejbActivate is allowed to call other secured resources. Since the pm makes the ejbActivate call, we need to set the caller's security context. The only reason this shows up for stateful session is that we moved the SecurityInterceptor to after the instance interceptor to allow security exceptions to result in invalidation of the session. This may be too literal an interpretation of the ejb spec requirement that runtime exceptions should invalidate the session. */ if(!callerRunAsIdentityPresent && pushSecurityContext) { AuthenticationManager am = container.getSecurityManager(); String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(am != null) securityDomain = am.getSecurityDomain(); SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain , null); //SecurityActions.pushSubjectContext(mi.getPrincipal(), mi.getCredential(), null); } lock.sync(); try { // Get context try { ctx = cache.get(methodID); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } // Associate it with the method invocation mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // BMT beans will lock and replace tx no matter what, CMT do work on transaction boolean isBMT = ((SessionMetaData)container.getBeanMetaData()).isBeanManagedTx(); if (isBMT == false) { // Do we have a running transaction with the context if (ctx.getTransaction() != null && // And are we trying to enter with another transaction !ctx.getTransaction().equals(mi.getTransaction())) { // Calls must be in the same transaction StringBuffer msg = new StringBuffer("Application Error: " + "tried to enter Stateful bean with different tx context"); msg.append(", contextTx: " + ctx.getTransaction()); msg.append(", methodTx: " + mi.getTransaction()); throw new EJBException(msg.toString()); } //If the instance will participate in a new transaction we register a sync for it if (ctx.getTransaction() == null && mi.getTransaction() != null) { register(ctx, mi.getTransaction(), lock); } } if (!ctx.isLocked()) { //take it! ctx.lock(); } else { if (!isCallAllowed(mi)) { // Concurent calls are not allowed throw new EJBException("Application Error: no concurrent " + "calls on stateful beans"); } else { ctx.lock(); } } } finally { lock.releaseSync(); } // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); boolean validContext = true; try { // Invoke through interceptors Object ret = getNext().invoke(mi); return ret; } catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } } } finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
protected void setProxyFactory(String invokerBinding, Invocation mi) throws Exception { // if (BeanMetaData.LOCAL_INVOKER_PROXY_BINDING.equals(invokerBinding)) return; if (invokerBinding == null) { log.trace("invokerBInding is null in ProxyFactoryFinder"); return; } /* if (invokerBinding == null) { log.error("***************** invokerBinding is null ********"); log.error("Method name: " + mi.getMethod().getName()); log.error("jmx name: " + container.getJmxName().toString()); new Throwable().printStackTrace(); log.error("*************************"); throw new EJBException("Couldn't insert proxy factory, " + "invokerBinding was null"); } */ Object proxyFactory = container.lookupProxyFactory(invokerBinding); if (proxyFactory == null) { String methodName; if(mi.getMethod() != null) { methodName = mi.getMethod().getName(); } else { methodName ="<no method>"; } log.error("***************** proxyFactory is null ********"); log.error("Method name: " + methodName); log.error("jmx name: " + container.getJmxName().toString()); log.error("invokerBinding: " + invokerBinding); log.error("Stack trace", new Throwable()); log.error("*************************"); throw new EJBException("Couldn't find proxy factory"); } container.setProxyFactory(proxyFactory); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { EntityContainer container = (EntityContainer)instance.getContainer(); if(container.getPersistenceManager().isStoreRequired(instance)) { throw new EJBException("The instance of " + container.getBeanMetaData().getEjbName() + " with pk=" + instance.getId() + " was not stored to prevent potential inconsistency of data in the database:" + " the instance was evicted from the cache during the transaction" + " and the database was possibly updated by another process."); } }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize() { if(synchronizing || instances.isEmpty()) { return; } synchronizing = true; // This is an independent point of entry. We need to make sure the // thread is associated with the right context class loader Thread currentThread = Thread.currentThread(); ClassLoader oldCl = SecurityActions.getContextClassLoader(); EntityEnterpriseContext instance = null; try { for(int i = 0; i < instances.size(); i++) { // any one can mark the tx rollback at any time so check // before continuing to the next store if(TxUtils.isRollback(tx)) { return; } instance = (EntityEnterpriseContext) instances.get(i); instance.getTxAssociation().invokeEjbStore(currentThread, instance); } for(int i = 0; i < instances.size(); i++) { // any one can mark the tx rollback at any time so check // before continuing to the next store if(TxUtils.isRollback(tx)) { return; } // read-only instances will never get into this list. instance = (EntityEnterpriseContext) instances.get(i); instance.getTxAssociation().synchronize(currentThread, tx, instance); } } catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); } finally { SecurityActions.setContextClassLoader(oldCl); synchronizing = false; } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke and handle exceptions Method miMethod = mi.getMethod(); Method m = (Method) homeMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } if (m.getDeclaringClass().equals(EntityContainer.class)) { try { return mi.performCall(EntityContainer.this, m, new Object[] { mi }); } catch (Exception e) { rethrow(e); } } else // Home method { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); try { AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_EJB_HOME); return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } finally{ AllowedOperationsAssociation.popInMethodFlag(); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) beanMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(EntityContainer.class)) { // Invoke container try { return mi.performCall(EntityContainer.this, m, new Object[]{ mi }); } catch (Exception e) { rethrow(e); } } else { // Invoke bean instance try { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); Object instance = ctx.getInstance(); return mi.performCall(instance, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
public EJBHome getEJBHome() { try { return homeHandle.getEJBHome(); } catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); } }
113
            
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { throw new EJBException("Failed to create timer", e); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
catch (InvocationTargetException e) { Throwable ex = e.getTargetException(); if (ex instanceof EJBException) throw (Exception)ex; else if (ex instanceof RuntimeException) throw new EJBException((Exception)ex); // Transform runtime exception into what a bean *should* have thrown else if (ex instanceof Exception) throw (Exception)ex; else throw (Error)ex; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { throw new EJBException("Could not create timer service", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException (e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeRemoveRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeAddRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(Exception e) { throw new EJBException("Internal error extracting primary key from instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(Exception e) { throw new EJBException("Internal error", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NamingException e) { throw new EJBException("Data source for relationship named " + relationName + " not found " + dataSourceName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(SQLException e) { throw new EJBException("Failed to read ResultSet.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { throw new EJBException("Failed to obtain current transaction", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(Exception e) { throw new EJBException("Error getting application tx data map.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { throw new EJBException("Error getting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { throw new EJBException("Error creating primary key instance: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error extracting primary key from " + "instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in getRelatedId", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in addRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in removeRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error getting transaction from the transaction manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error while creating RelationSet", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RollbackException e) { throw new EJBException("Error while creating RelationSet", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(Exception e) { throw new EJBException("Load relation failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); }
57
            
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (duration < 0) throw new IllegalArgumentException("duration is negative"); return createTimer(new Date(System.currentTimeMillis() + duration), 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialDuration < 0) throw new IllegalArgumentException("initial duration is negative"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); return createTimer(new Date(System.currentTimeMillis() + initialDuration), intervalDuration, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (expiration == null) throw new IllegalArgumentException("expiration is null"); return createTimer(expiration, 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Collection getTimers() throws IllegalStateException, EJBException { ArrayList activeTimers = new ArrayList(); synchronized (timers) { Iterator it = timers.values().iterator(); while (it.hasNext()) { TimerImpl timer = (TimerImpl)it.next(); if (timer.isActive()) activeTimers.add(timer); } } return activeTimers; }
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
public Timer getTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { EJBTimerService ejbTimerService = EJBTimerServiceLocator.getEjbTimerService(); ObjectName containerId = timedObjectId.getContainerId(); Object instancePk = timedObjectId.getInstancePk(); TimerServiceImpl timerService = (TimerServiceImpl)ejbTimerService.getTimerService(containerId, instancePk); if (timerService == null) throw new NoSuchObjectLocalException("TimerService not available: " + timedObjectId); TimerImpl timer = (TimerImpl)timerService.getTimer(this); if (timer == null || timer.isActive() == false) throw new NoSuchObjectLocalException("Timer not available: " + timedObjectId); return timer; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public void cancel() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.cancel"); registerTimerWithTx(); cancelInTx(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public long getTimeRemaining() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getTimeRemaining"); return nextExpire - System.currentTimeMillis(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Date getNextTimeout() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getNextTimeout"); return new Date(nextExpire); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Serializable getInfo() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getInfo"); return info; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public TimerHandle getHandle() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getHandle"); return new TimerHandleImpl(this); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { return Collections.EMPTY_LIST; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
23
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
23
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(EJBException e) { log.error("Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(EJBException e) { // to avoid double wrap of EJBExceptions throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (EJBException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (EJBException e) { throw e; }
0
runtime (Lib) Error 21
            
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { throw new Error("invokeHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBObject createHome() throws java.rmi.RemoteException, CreateException { throw new Error("createHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Handle handle) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Object primaryKey) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBMetaData getEJBMetaDataHome() throws java.rmi.RemoteException { // TODO //return null; throw new Error("getEJBMetaDataHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public HomeHandle getHomeHandleHome() throws java.rmi.RemoteException { // TODO //return null; throw new Error("getHomeHandleHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invokeHome(Invocation mi) throws Exception { throw new Error("invokeHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public boolean isIdentical(Container container, Invocation mi) { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Object getEJBHome() { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public EJBMetaData getEJBMetaData() { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Collection getEntityCollection(Collection collection) { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Object getEntityEJBObject(Object id) { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Object getStatefulSessionEJBObject(Object id) { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public Object getStatelessSessionEJBObject() { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Handle getHandle(Invocation mi) throws RemoteException { // TODO throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public HomeHandle getHomeHandleHome(Invocation mi) throws RemoteException { // TODO throw new Error("Not yet implemented"); }
0 0 8
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Error e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
8
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Error e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
0
checked (Lib) Exception 6
            
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { Object response = null; // Earlier versions of InvokerLocator don't have a findSerializationType() method. try { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE",locator.findSerializationType()); } catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); } try { response = client.invoke(invocation, null); if(response instanceof Exception) { throw ((Exception) response); } if(response instanceof MarshalledObject) { return ((MarshalledObject) response).get(); } if (response instanceof IMarshalledValue) { return ((IMarshalledValue)response).get(); } return response; } catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } } catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private DataSource lookupDataSource(ObjectName dataSource) throws Exception { try { String dsJndi = (String) server.getAttribute(dataSource, "BindName"); return (DataSource)new InitialContext().lookup(dsJndi); } catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void lockForUpdate(Transaction tx, Object pk) throws Exception { CachedRow row = (CachedRow) rowsById.get(pk); if(row != null) { if(row.locker != null && !tx.equals(row.locker)) { throw new Exception("lock acquisition rejected for " + tx + ", the entry is locked for update by " + row.locker + ", id=" + pk); } row.locker = tx; } // else?! }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void releaseLock(Transaction tx, Object pk) throws Exception { CachedRow row = (CachedRow) rowsById.get(pk); if(row != null) { if(!tx.equals(row.locker)) { throw new Exception("rejected to release lock for " + tx + ", the entry is locked for update by " + row.locker + ", id=" + pk); } row.locker = null; } // else?! }
// in src/main/java/org/jboss/web/WebServer.java
public void start() throws Exception { if (executor == null) throw new IllegalArgumentException("Required property 'executor' not specified"); try { server = new ServerSocket(port, backlog, bindAddress); log.debug("Started server: " + server); listen(); } catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); } catch (IOException e) { throw e; } }
// in src/main/java/org/jboss/web/WebServer.java
public void run() { // Return if the server has been stopped if (server == null) return; // Accept a connection Socket socket = null; try { socket = server.accept(); } catch (IOException e) { // If the server is not null meaning we were not stopped report the err if (server != null) log.error("Failed to accept connection", e); return; } // Create a new thread to accept the next connection listen(); try { // Get the request socket output stream DataOutputStream out = new DataOutputStream(socket.getOutputStream()); try { String httpCode = "200 OK"; // Get the requested item from the HTTP header BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String rawPath = getPath(in); // Parse the path into the class loader key and file path. // // The class loader key is a string whose format is // "ClassName[oid]", where the oid substring may contain '/' // chars. The expected form of the raw path is: // // "SomeClassName[some/object/id]/some/file/path" // // The class loader key is "SomeClassName[some/object/id]" // and the file path is "some/file/path" int endOfKey = rawPath.indexOf(']'); String filePath = rawPath.substring(endOfKey + 2); String loaderKey = rawPath.substring(0, endOfKey + 1); log.trace("loaderKey = " + loaderKey); log.trace("filePath = " + filePath); ClassLoader loader = (ClassLoader) loaderMap.get(loaderKey); /* If we did not find a class loader check to see if the raw path begins with className + '[' + class loader key + ']' by looking for an '[' char. If it does not and downloadServerClasses is true use the thread context class loader and set filePath to the rawPath */ if (loader == null && rawPath.indexOf('[') < 0 && downloadServerClasses) { filePath = rawPath; log.trace("No loader, reset filePath = " + filePath); loader = Thread.currentThread().getContextClassLoader(); } log.trace("loader = " + loader); byte[] bytes = {}; SwitchContext tclSwitchContext = null; try { tclSwitchContext = this.tclSwitcher.getSwitchContext(this.getClass().getClassLoader()); if (loader != null && filePath.endsWith(".class")) { // A request for a class file String className = filePath.substring(0, filePath.length() - 6).replace('/', '.'); log.trace("loading className = " + className); Class<?> clazz = loader.loadClass(className); URL clazzUrl = clazz.getProtectionDomain().getCodeSource().getLocation(); log.trace("clazzUrl = " + clazzUrl); if (clazzUrl == null) { // Does the WebClassLoader of clazz // have the ability to obtain the bytecodes of clazz? bytes = ((WebClassLoader) clazz.getClassLoader()).getBytes(clazz); if (bytes == null) throw new Exception("Class not found: " + className); } else { if (clazzUrl.getFile().endsWith("/") == false) { clazzUrl = new URL("jar:" + clazzUrl + "!/" + filePath); } // this is a hack for the AOP ClassProxyFactory else if (clazzUrl.getFile().indexOf("/org_jboss_aop_proxy$") < 0) { clazzUrl = new URL(clazzUrl, filePath); } // Retrieve bytecodes log.trace("new clazzUrl: " + clazzUrl); bytes = getBytes(clazzUrl); } } else if (loader != null && filePath.length() > 0 && downloadServerClasses && downloadResources) { // Try getting resource log.trace("loading resource = " + filePath); URL resourceURL = loader.getResource(filePath); if (resourceURL == null) httpCode = "404 Resource not found:" + filePath; else { // Retrieve bytes log.trace("resourceURL = " + resourceURL); bytes = getBytes(resourceURL); } } else { httpCode = "404 Not Found"; } } finally { if (tclSwitchContext != null) { tclSwitchContext.reset(); } } // Send bytecodes/resource data in response (assumes HTTP/1.0 or later) try { log.trace("HTTP code=" + httpCode + ", Content-Length: " + bytes.length); // The HTTP 1.0 header out.writeBytes("HTTP/1.0 " + httpCode + "\r\n"); out.writeBytes("Content-Length: " + bytes.length + "\r\n"); out.writeBytes("Content-Type: " + getMimeType(filePath)); out.writeBytes("\r\n\r\n"); // The response body out.write(bytes); out.flush(); } catch (IOException ie) { return; } } catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } } finally { } } catch (IOException ex) { log.error("error writting response", ex); } finally { // Close the client request socket try { socket.close(); } catch (IOException e) { } } }
3
            
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); }
// in src/main/java/org/jboss/web/WebServer.java
catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); }
464
            
// in src/main/java/org/jboss/invocation/MarshallingInvokerInterceptor.java
public Object invoke(Invocation invocation) throws Exception { /* if(isLocal(invocation)) return invokeLocalMarshalled(invocation); else return invokeInvoker(invocation); invokeLocalMarshalled is an optimized method for call-by-values. we don't need to serialize the entire Invocation for having call-by-value. */ if(isLocal(invocation)) return invokeLocalMarshalled(invocation); else return invokeInvoker(invocation); }
// in src/main/java/org/jboss/invocation/Invocation.java
public Object performCall(Object instance, Method m, Object[] arguments) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Exception { return m.invoke(instance,arguments); }
// in src/main/java/org/jboss/invocation/ByValueInvokerInterceptor.java
public Object invoke(Invocation invocation) throws Exception { // local interface if (isLocal(invocation)) // The payload as is is good return localInvoker.invoke(invocation); else // through the invoker return invocation.getInvocationContext().getInvoker().invoke(invocation); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
public static Object invoke(URL externalURL, Invocation mi) throws Exception { if( log.isTraceEnabled() ) log.trace("invoke, externalURL="+externalURL); /* Post the MarshalledInvocation data. This is using the URL class for now but this should be improved to a cluster aware layer with full usage of HTTP 1.1 features, pooling, etc. */ HttpURLConnection conn = (HttpURLConnection) externalURL.openConnection(); configureHttpsHostVerifier(conn); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestProperty("ContentType", REQUEST_CONTENT_TYPE); conn.setRequestMethod("POST"); // @todo this should be configurable conn.setRequestProperty("Accept-Encoding", "x-gzip,x-deflate,gzip,deflate"); OutputStream os = conn.getOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(os); try { oos.writeObject(mi); oos.flush(); } catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); } // Get the response MarshalledValue object InputStream is = conn.getInputStream(); // Check the headers for gzip Content-Encoding String encoding = conn.getHeaderField("Content-Encoding"); if( encoding != null && encoding.indexOf("gzip") >= 0 ) is = new GZIPInputStream(is); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); // A hack for jsse connection pooling (see patch ). ois.read(); ois.close(); oos.close(); // If the encoded value is an exception throw it Object value = mv.get(); if( value instanceof Exception ) { throw (Exception) value; } return value; }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public String getServerHostName() throws Exception { if( externalURL == null ) externalURL = Util.resolveURL(externalURLValue); return externalURL.getHost(); }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { // We are going to go through a Remote invocation, switch to a Marshalled Invocation MarshalledInvocation mi = new MarshalledInvocation(invocation); if( externalURL == null ) externalURL = Util.resolveURL(externalURLValue); try { Object value = Util.invoke(externalURL, mi); return value; } catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); } catch (IOException e) { throw new ServerException("IOE", e); } }
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
protected void startService() throws Exception { checkInvokerURL(); Invoker delegateInvoker = new HttpInvokerProxy(invokerURL); // Export the Invoker interface ObjectName name = super.getServiceName(); Registry.bind(name, delegateInvoker); log.debug("Bound Http invoker for JMX node"); }
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
public Object invoke(Invocation invocation) throws Exception { ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); try { // Deserialize the transaction if it is there MarshalledInvocation mi = (MarshalledInvocation) invocation; Object tpc = mi.getTransactionPropagationContext(); Transaction tx = importTPC(tpc); invocation.setTransaction(tx); Integer nameHash = (Integer) invocation.getObjectName(); ObjectName mbean = (ObjectName) Registry.lookup(nameHash); // The cl on the thread should be set in another interceptor Object[] args = {invocation}; String[] sig = {"org.jboss.invocation.Invocation"}; Object obj = super.getServer().invoke(mbean, "invoke", args, sig); // Return the raw object and let the http layer marshall it return obj; } catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; } finally { Thread.currentThread().setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/invocation/http/server/HttpProxyFactory.java
public void setClientInterceptors(Element config) throws Exception { this.interceptorConfig = config; Iterator interceptorElements = MetaData.getChildrenByTagName(interceptorConfig, "interceptor"); ClassLoader loader = Thread.currentThread().getContextClassLoader(); if( interceptorClasses != null ) interceptorClasses.clear(); else interceptorClasses = new ArrayList(); while( interceptorElements != null && interceptorElements.hasNext() ) { Element ielement = (Element) interceptorElements.next(); String className = null; className = MetaData.getElementContent(ielement); Class clazz = loader.loadClass(className); interceptorClasses.add(clazz); } }
// in src/main/java/org/jboss/invocation/http/server/HttpProxyFactory.java
protected void startService() throws Exception { /** Create an HttpInvokerProxy that posts invocations to the externalURL. This proxy will be associated with a naming JMX invoker given by the jmxInvokerName. */ Invoker delegateInvoker = createInvoker(); Integer nameHash = new Integer(jmxInvokerName.hashCode()); log.debug("Bound delegate: "+delegateInvoker +" for invoker="+jmxInvokerName); /* Create a binding betweeh the invoker name hash and the jmx name This is used by the HttpInvoker to map from the Invocation ObjectName hash value to the target JMX ObjectName. */ Registry.bind(nameHash, jmxInvokerName); Object cacheID = null; String proxyBindingName = null; Class[] ifaces = {exportedInterface}; /* Initialize interceptorClasses with default client interceptor list if no client interceptor configuration was provided */ if( interceptorClasses == null ) interceptorClasses = defineDefaultInterceptors(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); GenericProxyFactory proxyFactory = new GenericProxyFactory(); theProxy = proxyFactory.createProxy(cacheID, jmxInvokerName, delegateInvoker, jndiName, proxyBindingName, interceptorClasses, loader, ifaces); log.debug("Created HttpInvokerProxy for invoker="+jmxInvokerName +", nameHash="+nameHash); if( jndiName != null ) { InitialContext iniCtx = new InitialContext(); Util.bind(iniCtx, jndiName, theProxy); log.debug("Bound proxy under jndiName="+jndiName); } }
// in src/main/java/org/jboss/invocation/http/server/HttpProxyFactory.java
protected void stopService() throws Exception { Integer nameHash = new Integer(jmxInvokerName.hashCode()); Registry.unbind(jmxInvokerName); Registry.unbind(nameHash); if( jndiName != null ) { InitialContext iniCtx = new InitialContext(); Util.unbind(iniCtx, jndiName); } }
// in src/main/java/org/jboss/invocation/http/server/HttpProxyFactory.java
protected Invoker createInvoker() throws Exception { checkInvokerURL(); HttpInvokerProxy delegateInvoker = new HttpInvokerProxy(invokerURL); return delegateInvoker; }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
public void setClientInterceptors(Element config) throws Exception { this.interceptorConfig = config; Iterator interceptorElements = MetaData.getChildrenByTagName(interceptorConfig, "interceptor"); ClassLoader loader = Thread.currentThread().getContextClassLoader(); interceptorClasses.clear(); while( interceptorElements != null && interceptorElements.hasNext() ) { Element ielement = (Element) interceptorElements.next(); String className = null; className = MetaData.getElementContent(ielement); Class clazz = loader.loadClass(className); interceptorClasses.add(clazz); log.debug("added interceptor type: "+clazz); } }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
public Object invoke(Invocation mi) throws Exception { final boolean remoteInvocation = mi instanceof MarshalledInvocation; if(remoteInvocation) { ((MarshalledInvocation)mi).setMethodMap(methodMap); } final Object result; if(invokeTargetMethod) { String signature[] = (String[])signatureMap.get(mi.getMethod()); result = server.invoke(targetName, mi.getMethod().getName(), mi.getArguments(), signature); } else { result = server.invoke(targetName, "invoke", new Object[]{mi}, Invocation.INVOKE_SIGNATURE); } return result; }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
protected void startService() throws Exception { /* Create a binding between the invoker name hash and the jmx name This is used by the Invoker to map from the Invocation ObjectName hash value to the target JMX ObjectName. */ Integer nameHash = new Integer(getServiceName().hashCode()); Registry.bind(nameHash, getServiceName()); // Create the service proxy Object cacheID = null; String proxyBindingName = null; Class[] ifaces = exportedInterfaces; ClassLoader loader = Thread.currentThread().getContextClassLoader(); createProxy(cacheID, proxyBindingName, loader, ifaces); log.debug("Created JRMPPRoxy for service="+targetName +", nameHash="+nameHash+", invoker="+invokerName); if( jndiName != null ) { InitialContext iniCtx = new InitialContext(); Util.rebind(iniCtx, jndiName, theProxy); log.debug("Bound proxy under jndiName="+jndiName); } for(int i = 0; i < exportedInterfaces.length; ++i) { final Method[] methods = exportedInterfaces[i].getMethods(); for(int j = 0; j < methods.length; ++j) { methodMap.put(new Long(MarshalledInvocation.calculateHash(methods[j])), methods[j]); String signature[]; final Class[] types = methods[j].getParameterTypes(); if(types == null || types.length == 0) { signature = null; } else { signature = new String[types.length]; for(int typeInd = 0; typeInd < types.length; ++typeInd) { signature[typeInd] = types[typeInd].getName(); } } signatureMap.put(methods[j], signature); } } }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
protected void stopService() throws Exception { Integer nameHash = new Integer(getServiceName().hashCode()); Registry.unbind(nameHash); if( jndiName != null ) { InitialContext iniCtx = new InitialContext(); Util.unbind(iniCtx, jndiName); } this.theProxy = null; }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
protected void destroyService() throws Exception { interceptorClasses.clear(); }
// in src/main/java/org/jboss/invocation/jrmp/server/JRMPProxyFactory.java
protected void rebind() throws Exception { log.debug("(re-)Binding " + jndiName); Util.rebind(new InitialContext(), jndiName, theProxy); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
public Object invoke(Invocation invocation) throws Exception { // optimize if calling another bean in same server VM if (isLocal(invocation)) return invokeLocal(invocation); else return invokeInvoker(invocation); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeLocal(Invocation invocation) throws Exception { return localInvoker.invoke(invocation); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeMarshalled(Invocation invocation) throws Exception { MarshalledInvocation mi = new MarshalledInvocation(invocation); MarshalledValue copy = new MarshalledValue(mi); Invocation invocationCopy = (Invocation) copy.get(); // copy the Tx Transaction tx = invocation.getTransaction(); invocationCopy.setTransaction(tx); try { Object rtnValue = localInvoker.invoke(invocationCopy); MarshalledValue mv = new MarshalledValue(rtnValue); return mv.get(); } catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); } }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeLocalMarshalled(Invocation invocation) throws Exception { IMarshalledValue value = createMarshalledValueForCallByValue(invocation.getArguments()); MarshalledInvocation invocationCopy = createInvocationCopy(invocation, value); // copy the Tx Transaction tx = invocation.getTransaction(); invocationCopy.setTransaction(tx); try { Object rtnValue = localInvoker.invoke(invocationCopy); IMarshalledValue mv = createMarshalledValueForCallByValue(rtnValue); return mv.get(); } catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); } }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeInvoker(Invocation invocation) throws Exception { InvocationContext ctx = invocation.getInvocationContext(); Invoker invoker = ctx.getInvoker(); return invoker.invoke(invocation); }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
protected void createService() throws Exception { // note on design: We need to call it ourselves as opposed to // letting the client InvokerInterceptor look it // up through the use of Registry, the reason being including // the classes in the client. // If we move to a JNDI format (with local calls) for the // registry we could remove the call below InvokerInterceptor.setLocal(this); Registry.bind(serviceName, this); }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
protected void startService() throws Exception { InitialContext ctx = new InitialContext(); try { /** * FIXME marcf: what is this doing here? */ TransactionManager tm = (TransactionManager) ctx.lookup("java:/TransactionManager"); TransactionInterceptor.setTransactionManager(tm); } finally { ctx.close(); } log.debug("Local invoker for JMX node started"); }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
public Object invoke(Invocation invocation) throws Exception { ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); ObjectName mbean = (ObjectName) Registry.lookup((Integer) invocation.getObjectName()); try { Object[] args = {invocation}; Object rtnValue = serverAction.invoke(mbean, "invoke", args, Invocation.INVOKE_SIGNATURE); return rtnValue; } catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; } finally { TCLAction.UTIL.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
public Object run() throws Exception { Object rtnValue = server.invoke(target, method, args, sig); return rtnValue; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
Object invoke(ObjectName target, String method, Object[] args, String[] sig) throws Exception { SecurityManager sm = System.getSecurityManager(); Object rtnValue = null; if( sm == null ) { // Direct invocation on MBeanServer rtnValue = server.invoke(target, method, args, sig); } else { try { // Encapsulate the invocation in a PrivilegedExceptionAction MBeanServerAction action = new MBeanServerAction(target, method, args, sig); rtnValue = AccessController.doPrivileged(action); } catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; } } return rtnValue; }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public String getServerHostName() throws Exception { if(locator != null) { return locator.getHost(); } else { return null; } }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { Object response = null; // Earlier versions of InvokerLocator don't have a findSerializationType() method. try { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE",locator.findSerializationType()); } catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); } try { response = client.invoke(invocation, null); if(response instanceof Exception) { throw ((Exception) response); } if(response instanceof MarshalledObject) { return ((MarshalledObject) response).get(); } if (response instanceof IMarshalledValue) { return ((IMarshalledValue)response).get(); } return response; } catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } } catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); } }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
protected Client createClient(InvokerLocator locator, String subSystem) throws Exception { return new Client(locator, subSystem); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
protected void createService() throws Exception { if(connector != null) { try { connector.addInvocationHandler(getSubSystem(), this); } catch(Exception e) { log.error("Error adding unified invoker as handler upon connector being set.", e); } } }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
protected void startService() throws Exception { log.debug("Starting unified invoker service."); InvokerLocator locator = null; if(serverInvoker != null) { locator = serverInvoker.getLocator(); if(!serverInvoker.isStarted()) { serverInvoker.start(); } } else if(connector != null) { locator = connector.getLocator(); } else { /** * This will happen in one of two scenarios. One, the unified invoker was not declared in as * service before the connector AND was not specified as the handler within the connector config. * Two, the unified invoker service config did not use the proxy-type attribute within the depends * tag to have the container set the connector upon creating the unified invoker. */ log.error("Error referencing either remoting connector or server invoker to be used. " + "Please check configuration to make sure proper dependancies are set."); throw new RuntimeException("Error getting locator because server invoker is null."); } proxy = new UnifiedInvokerProxy(locator, strictRMIException); jmxBind(); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
public void stopService() throws Exception { // JBAS-5590 -- the serverInvoker is a shared resource and shouldn't // be stopped just because we don't want it any more // if(serverInvoker != null) // { // serverInvoker.stop(); // } }
// in src/main/java/org/jboss/client/AppClientMain.java
public static void main(String[] args) throws Exception { log.debug("System Properties"); Properties sysprops = System.getProperties(); for (Object key : sysprops.keySet()) log.debug(" " + key + "=" + sysprops.getProperty((String) key)); // read the client class from args String clientClass = null; String clientName = null; ArrayList<String> newArgs = new ArrayList<String>(); String[] launchers = DEFAULT_LAUNCHERS; for (int i = 0; i < args.length; i++) { String arg = args[i]; log.debug("arg=" + arg); if( arg.equals(JBOSS_CLIENT_PARAM) ) { clientClass = args[i+1]; i ++; } else if( arg.equals(J2EE_CLIENT_PARAM) ) { /* Set the j2ee.client system property so the AppContextFactory sees what name the client app JNDI enc is bound under */ clientName = args[i+1]; System.setProperty(javaURLContextFactory.J2EE_CLIENT_NAME_PROP, clientName); log.info(javaURLContextFactory.J2EE_CLIENT_NAME_PROP + "=" + clientName); i ++; } else if( arg.equals(LAUNCHERS_PARAM) ) { launchers = args[i+1].split(","); log.info(LAUNCHERS_PARAM + "=" + args[i+1]); i ++; } else { newArgs.add(args[i]); } } ClassLoader loader = Thread.currentThread().getContextClassLoader(); if( loader == null ) loader = AppClientMain.class.getClassLoader(); // Look for a manifest Main-Class if (clientClass == null) { clientClass = getMainClassName(loader); throw new IllegalArgumentException("Neither a Main-Class was found in the manifest, " +"nor was a " + JBOSS_CLIENT_PARAM + " specified"); } // If J2EE_CLIENT_NAME_PROP was not specified, look in the jar descriptors if (clientName == null) { clientName = getClientName(loader); } String[] mainArgs = new String [newArgs.size()]; newArgs.toArray(mainArgs); // Try each launcher in the order specified for(String launcherName : launchers) { try { Class<AppClientLauncher> launcherClass = (Class<AppClientLauncher>) loader.loadClass(launcherName); AppClientLauncher launcher = launcherClass.newInstance(); launcher.launch(clientClass, clientName, mainArgs); break; } catch(Throwable t) { log.warn("Failed to launch using: "+launcherName, t); } } }
// in src/main/java/org/jboss/client/AppClientMain.java
private static String getClientName(ClassLoader loader) throws Exception { String clientName = null; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); // Try META-INF/application-client.xml application-client@id first URL appXmlURL = loader.getResource("META-INF/application-client.xml"); if( appXmlURL != null ) { InputStream is = appXmlURL.openStream(); Document appXml = builder.parse(is); is.close(); Element root = appXml.getDocumentElement(); clientName = root.getAttribute("id"); if( clientName != null ) return clientName; } // Try META-INF/jboss-client.xml jndi-name URL jbossXmlURL = loader.getResource("META-INF/jboss-client.xml"); if( appXmlURL != null ) { InputStream is = jbossXmlURL.openStream(); Document jbossXml = builder.parse(is); is.close(); Element root = jbossXml.getDocumentElement(); NodeList children = root.getChildNodes(); for(int n = 0; n < children.getLength(); n ++) { Node node = children.item(n); if( node.getLocalName().equals("jndi-name") ) { clientName = node.getNodeValue(); return clientName; } } } // TODO: annotations on main class return null; }
// in src/main/java/org/jboss/client/AppClientMain.java
private static String getMainClassName(ClassLoader loader) throws Exception { URL mfURL = loader.getResource("META-INF/MANIFEST.MF"); if(mfURL == null) { return null; } InputStream is = mfURL.openStream(); Manifest mf; try { mf = new Manifest(is); } finally { is.close(); } Attributes attrs = mf.getMainAttributes(); String mainClassName = attrs.getValue(Attributes.Name.MAIN_CLASS); return mainClassName; }
// in src/main/java/org/jboss/jmx/adaptor/rmi/RMIRemoteMBeanProxy.java
protected RMIAdaptor getRmiAdaptor () throws Exception { InitialContext ctx = new InitialContext(); return (RMIAdaptor) ctx.lookup("jmx/invoker/RMIAdaptor"); }
// in src/main/java/org/jboss/jmx/adaptor/rmi/RMIRemoteMBeanProxy.java
public static Object create (final Class intf, final String name, final javax.management.MBeanServer server) throws Exception { return create(intf, new ObjectName(name), server); }
// in src/main/java/org/jboss/jmx/adaptor/rmi/RMIRemoteMBeanProxy.java
public static Object create (final Class intf, final ObjectName name, final javax.management.MBeanServer server) throws Exception { return java.lang.reflect.Proxy.newProxyInstance(Thread.currentThread ().getContextClassLoader (), new Class[] { intf }, new RMIRemoteMBeanProxy(name, server)); }
// in src/main/java/org/jboss/jmx/connector/invoker/SecurityActions.java
static SecurityContext createSecurityContext(final String domain) throws PrivilegedActionException { return (SecurityContext)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return SecurityContextFactory.createSecurityContext(domain); }}); }
// in src/main/java/org/jboss/jmx/connector/invoker/SecurityActions.java
public Object run() throws Exception { return SecurityContextFactory.createSecurityContext(domain); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
protected void startService() throws Exception { // Build the interface method map HashMap tmpMap = new HashMap(61); for(int n = 0; n < exportedInterfaces.length; n ++) { Class iface = exportedInterfaces[n]; Method[] methods = iface.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } /* Look for a void addNotificationListener(ObjectName name, RMINotificationListener listener, NotificationFilter filter, Object handback) */ try { Class[] sig = {ObjectName.class, RMINotificationListener.class, NotificationFilter.class, Object.class}; Method addNotificationListener = iface.getMethod( "addNotificationListener", sig); addNotificationListeners.add(addNotificationListener); } catch(Exception e) { log.debug(iface+"No addNotificationListener(ObjectName, RMINotificationListener)"); } /* Look for a void removeNotificationListener(ObjectName, RMINotificationListener) */ try { Class[] sig = {ObjectName.class, RMINotificationListener.class}; Method removeNotificationListener = iface.getMethod( "removeNotificationListener", sig); removeNotificationListeners.add(removeNotificationListener); } catch(Exception e) { log.debug(iface+"No removeNotificationListener(ObjectName, RMINotificationListener)"); } } marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap); // Place our ObjectName hash into the Registry so invokers can resolve it Registry.bind(new Integer(serviceName.hashCode()), serviceName); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
protected void stopService() throws Exception { // Remove the method hashses if( exportedInterfaces != null ) { for(int n = 0; n < exportedInterfaces.length; n ++) MarshalledInvocation.removeHashes(exportedInterfaces[n]); } marshalledInvocationMapping = null; remoteListeners.clear(); Registry.unbind(new Integer(serviceName.hashCode())); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public Object invoke(Invocation invocation) throws Exception { try { // Make sure we have the correct classloader before unmarshalling ClassLoader oldCL = SecurityActions.getContextClassLoader(); ClassLoader newCL = null; // Get the MBean this operation applies to ObjectName objectName = (ObjectName) invocation.getValue("JMX_OBJECT_NAME"); if (objectName != null) { newCL = server.getClassLoaderFor(objectName); } if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(newCL); //JBAS-6449: Cache the incoming security context to be retained on exit SecurityContext previousSecurityContext = SecurityActions.getSecurityContext(); try { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the MBeanServer method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Principal principal = invocation.getPrincipal(); Object credential = invocation.getCredential(); Object value = null; SecurityContext sc = SecurityActions.createSecurityContext(SecurityConstants.DEFAULT_APPLICATION_POLICY); SecurityActions.setSecurityContext(sc); // Associate the method SecurityActions.pushSubjectContext(principal, credential, null); try { if( addNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; NotificationFilter filter = (NotificationFilter) args[2]; Object handback = args[3]; addNotificationListener(name, listener, filter, handback); } else if( removeNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; removeNotificationListener(name, listener); } else { String name = method.getName(); Class[] paramTypes = method.getParameterTypes(); Method mbeanServerMethod = MBeanServer.class.getMethod(name, paramTypes); value = mbeanServerMethod.invoke(server, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; } finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); } } catch (Throwable t) { throw new InvokerAdaptorException(t); } }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
public void setPolicyClass(String policyClass) throws Exception { try { // try to load the policy Class Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
public void setAuthorizingClass(Class clazz) throws Exception { authenticator = clazz.newInstance(); log.debug("Loaded authenticator: "+authenticator); Class[] sig = {Principal.class, Subject.class, String.class, String.class}; authorize = clazz.getMethod("authorize", sig); log.debug("Found authorize(Principal, Subject, String, String)"); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
private void checkAuthorization(Principal caller, String objname, String opname) throws Exception { // Get the active Subject Subject subject = SecurityActions.getActiveSubject(); if( subject == null ) throw new SecurityException("No active Subject found, add th AuthenticationInterceptor"); //We will try to use the authorizing class try { Object[] args = {caller, subject, objname, opname}; authorize.invoke(authenticator, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthenticationInterceptor.java
public void setSecurityDomain(String securityDomain) throws Exception { this.securityDomain = securityDomain; }
// in src/main/java/org/jboss/jmx/connector/invoker/MBeanProxyRemote.java
protected void startService() throws Exception { if (MBeanProxyExt.remote != null) throw new IllegalStateException("Remote MBeanServerConnection is already set " + MBeanProxyExt.remote); Object o = server.getAttribute(mbeanServerConnection, "Proxy"); if (o instanceof MBeanServerConnection == false) throw new DeploymentException(mbeanServerConnection + " does not define an MBeanServerConnection"); MBeanProxyExt.remote = (MBeanServerConnection) o; }
// in src/main/java/org/jboss/jmx/connector/invoker/MBeanProxyRemote.java
protected void stopService() throws Exception { MBeanProxyExt.remote = null; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
public ApplicationMetaData load(URL alternativeDD) throws Exception { URL ejbjarUrl = null; if (alternativeDD != null) { log.debug("Using alternativeDD: " + alternativeDD); ejbjarUrl = alternativeDD; } else { ejbjarUrl = getClassLoader().getResource("META-INF/ejb-jar.xml"); } if (ejbjarUrl == null) { throw new DeploymentException("no ejb-jar.xml found"); } // create the metadata JBossMetaData realMetaData = new JBossMetaData(); metaData = new ApplicationMetaData(realMetaData); Document ejbjarDocument = getDocumentFromURL(ejbjarUrl); // the url may be used to report errors metaData.setUrl(ejbjarUrl); metaData.importEjbJarXml(ejbjarDocument.getDocumentElement()); // Load jbossdefault.xml from the default classLoader // we always load defaults first // we use the context classloader, because this guy has to know where // this file is URL defaultJbossUrl = Thread.currentThread().getContextClassLoader().getResource("standardjboss.xml"); if (defaultJbossUrl == null) { throw new DeploymentException("no standardjboss.xml found"); } Document defaultJbossDocument = null; try { defaultJbossDocument = getDocumentFromURL(defaultJbossUrl); metaData.setUrl(defaultJbossUrl); metaData.importJbossXml(defaultJbossDocument.getDocumentElement()); } catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; } // Load jboss.xml // if this file is provided, then we override the defaults try { URL jbossUrl = getClassLoader().getResource("META-INF/jboss.xml"); if (jbossUrl != null) { Document jbossDocument = getDocumentFromURL(jbossUrl); metaData.setUrl(jbossUrl); metaData.importJbossXml(jbossDocument.getDocumentElement()); } } catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; } return metaData; }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
protected void startService() throws Exception { // validate the configuration if (queueFactoryRef == null) throw new DeploymentException("missing required attribute: QueueFactoryRef"); if (topicFactoryRef == null) throw new DeploymentException("missing required attribute: TopicFactoryRef"); Class cls = Thread.currentThread().getContextClassLoader().loadClass(providerAdapterClass); providerAdapter = (JMSProviderAdapter) cls.newInstance(); providerAdapter.setName(providerName); providerAdapter.setProperties(properties); providerAdapter.setFactoryRef(factoryRef); providerAdapter.setQueueFactoryRef(queueFactoryRef); providerAdapter.setTopicFactoryRef(topicFactoryRef); InitialContext context = new InitialContext(); try { // Bind in JNDI if (jndiName == null) { String name = providerAdapter.getName(); jndiName = "java:/" + name; } bind(context, jndiName, providerAdapter); log.debug("Bound adapter to " + jndiName); } finally { context.close(); } }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
protected void stopService() throws Exception { InitialContext context = new InitialContext(); try { // Unbind from JNDI String name = providerAdapter.getName(); String jndiname = "java:/" + name; context.unbind(jndiname); log.debug("unbound adapter " + name + " from " + jndiname); } finally { context.close(); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected XAResource connect() throws Exception { // Do we already have a valid delegate? synchronized (lock) { if (delegate != null) return delegate; } // Create the connection XAConnection xaConnection = getConnectionFactory().createXAConnection(); synchronized (lock) { connection = xaConnection; } // Retrieve the delegate XAResource try { XASession session = connection.createXASession(); XAResource result = session.getXAResource(); synchronized (lock) { delegate = result; } return delegate; } catch (Exception e) { close(); throw e; } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected XAConnectionFactory getConnectionFactory() throws Exception { // Get the JMS Provider Adapter if (providerName == null) throw new IllegalArgumentException("Null provider name"); String providerAdapterJNDI = providerName; if (providerAdapterJNDI.startsWith("java:") == false) providerAdapterJNDI = "java:" + providerAdapterJNDI; Context ctx = new InitialContext(); JMSProviderAdapter adapter = (JMSProviderAdapter) Util.lookup(providerAdapterJNDI, JMSProviderAdapter.class); // Determine the XAConnectionFactory name String connectionFactoryRef = adapter.getFactoryRef(); if (connectionFactoryRef == null) throw new IllegalStateException("Provider '" + providerName + "' has no FactoryRef"); // Lookup the connection factory ctx = adapter.getInitialContext(); try { return (XAConnectionFactory) Util.lookup(ctx, connectionFactoryRef, XAConnectionFactory.class); } finally { ctx.close(); } }
// in src/main/java/org/jboss/deployment/OptAnnotationMetaDataDeployer.java
protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception { AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>(); // don't do webMetaData anymore (rev 96033) String mainClassName = getMainClassName(unit); if (mainClassName != null && mainClassName.length() > 0) processJBossClientMetaData(unit, finder, mainClassName); else processJBossMetaData(unit, finder); }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
protected void init(VFSDeploymentUnit unit, WebFragmentMetaData metaData, VirtualFile file) throws Exception { unit.addAttachment(WebFragmentMetaData.class.getName() + ":" + file.getPathNameRelativeTo(unit.getRoot()), metaData, getOutput()); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolve(ContainerDependencyMetaData cdmd, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, Environment env, DeploymentEndpointResolver resolver, List<String> unresolvedRefs) throws Exception { if(env == null) return; AnnotatedEJBReferencesMetaData annotatedRefs = env.getAnnotatedEjbReferences(); resolveEjbAnnotatedRefs(cdmd, unit, endpointMap, annotatedRefs, resolver, unresolvedRefs); EJBLocalReferencesMetaData localRefs = env.getEjbLocalReferences(); resolveEjbLocalRefs(cdmd, unit, endpointMap, localRefs, resolver, unresolvedRefs); EJBReferencesMetaData ejbRefs = env.getEjbReferences(); resolveEjbRefs(cdmd, unit, endpointMap, ejbRefs, resolver, unresolvedRefs); MessageDestinationReferencesMetaData msgRefs = env.getMessageDestinationReferences(); resolveMsgRefs(cdmd, unit, endpointMap, msgRefs, resolver, unresolvedRefs); // TODO, other references }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolve(DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, JBossEnterpriseBeansMetaData beans, DeploymentEndpointResolver resolver, List<String> unresolvedPaths) throws Exception { if(beans == null || beans.size() == 0) return; String vfsPath = unit.getRelativePath(); for(JBossEnterpriseBeanMetaData bean : beans) { // Find the container dependency metadata String ejbCompID = "ejb/" + vfsPath + "#" + bean.getEjbName(); ContainerDependencyMetaData cdmd = endpointMap.get(ejbCompID); if(cdmd == null) throw new IllegalStateException("Failed to find ContainerDependencyMetaData for: "+ejbCompID); Environment env = bean.getJndiEnvironmentRefsGroup(); resolve(cdmd, unit, endpointMap, env, resolver, unresolvedPaths); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolveEjbLocalRefs(ContainerDependencyMetaData cdmd, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, EJBLocalReferencesMetaData localRefs, DeploymentEndpointResolver resolver, List<String> unresolvedRefs) throws Exception { if(localRefs == null) return; String vfsContext = unit.getRelativePath(); ClassLoader loader = unit.getClassLoader(); for(EJBLocalReferenceMetaData ref : localRefs) { if (ref.getIgnoreDependency() != null) { log.debug("IGNORING <ejb-ref> DEPENDENCY: " + ref); return; } String link = ref.getLink(); String mappedName = ref.getMappedName(); // Use mapped name first if(mappedName == null || mappedName.length() == 0) { ContainerDependencyMetaData target = null; if(link != null) { EndpointInfo info = resolver.getEndpointInfo(link, EndpointType.EJB, vfsContext); if(info != null) { target = endpointMap.get(info.getComponentKey()); } else { /* A non-local link without a # jar target. This is allowed for java ee clients so we have to search all ejb deployments. First get the vfspaths of the ejb deploymens. */ List<String> ejbPaths = getEjbDeploymentPaths(unit); for(String path : ejbPaths) { EndpointInfo altInfo = resolver.getEndpointInfo(link, EndpointType.EJB, path); if(altInfo != null) target = endpointMap.get(altInfo.getComponentKey()); if(target != null) break; } } } if(target == null && ref.getLocal() != null) { // Try the local interface type target = resolveEjbInterface(ref.getLocal(), unit, endpointMap, resolver); } if(target == null) unresolvedRefs.add(cdmd.getComponentID()+":"+ref); else { // Need to look at the local jndi name String localInterface = ref.getLocal(); JBossEnterpriseBeanMetaData md = target.getBeanMetaData(); /* * If for a Session bean we've got a reference to an EJB2.x * Local Component interface, stop processing because these * are not bound in JNDI (only accessible via LocalHome.create() */ // Session EJB? boolean useDefaultProxy = false; if(md.isSession()) { // Cast JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData)md; // Get the name of the Component Local Interface String ejb2xLocalInterface = smd.getLocal(); // If the ejb-ref is to a EJB2.x Local Component Interface if(localInterface.equals(ejb2xLocalInterface)) { // Use the default proxy useDefaultProxy = true; } } // Get ejb-jar Metadata JBossMetaData ejbJarMd = md.getEnterpriseBeansMetaData().getEjbJarMetaData(); // Resolve a local JNDI Name based on Spec type String localJndiName = null; if (ejbJarMd.isEJB3x()) { if (md.isSession() || md.isService()) { SessionBeanJNDINameResolver sessionBeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver((JBossSessionBeanMetaData) md, this.defaultJNDIBindingPolicy); if (useDefaultProxy) { localJndiName = sessionBeanJNDINameResolver .resolveLocalBusinessDefaultJNDIName((JBossSessionBeanMetaData) md); } else { localJndiName = sessionBeanJNDINameResolver.resolveJNDIName((JBossSessionBeanMetaData) md, localInterface); } } else if (md.isEntity()) { EntityBeanJNDINameResolver entityBeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver((JBossEntityBeanMetaData) md, this.defaultJNDIBindingPolicy); localJndiName = entityBeanJNDINameResolver.resolveJNDIName((JBossEntityBeanMetaData) md, localInterface); } } else { localJndiName = md.determineLocalJndiName(); } // If we've got a resolved JNDI Name if (localJndiName != null) { // Set it and forget it! // http://en.wikipedia.org/wiki/Ron_Popeil ref.setResolvedJndiName(localJndiName); } // Add the dependency cdmd.addDependency(target); } } else { // Create a JNDI dependency ref.setResolvedJndiName(mappedName); JndiDependencyMetaData jdmd = new JndiDependencyMetaData(mappedName, loader); cdmd.addJndiDependency(jdmd); } } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolveEjbRefs(ContainerDependencyMetaData cdmd, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, EJBReferencesMetaData ejbRefs, DeploymentEndpointResolver resolver, List<String> unresolvedRefs) throws Exception { if(ejbRefs == null) return; String vfsContext = unit.getRelativePath(); ClassLoader loader = unit.getClassLoader(); for(EJBReferenceMetaData ref : ejbRefs) { if (ref.getIgnoreDependency() != null) { log.debug("IGNORING <ejb-ref> DEPENDENCY: " + ref); return; } String link = ref.getLink(); String mappedName = ref.getMappedName(); // Use mapped name first if(mappedName == null || mappedName.length() == 0) { ContainerDependencyMetaData target = null; if(link != null) { EndpointInfo info = resolver.getEndpointInfo(link, EndpointType.EJB, vfsContext); if(info != null) { target = endpointMap.get(info.getComponentKey()); } else { /* A non-local link without a # jar target. This is allowed for java ee clients so we have to search all ejb deployments. First get the vfspaths of the ejb deploymens. */ List<String> ejbPaths = getEjbDeploymentPaths(unit); for(String path : ejbPaths) { EndpointInfo altInfo = resolver.getEndpointInfo(link, EndpointType.EJB, path); if(altInfo != null) target = endpointMap.get(altInfo.getComponentKey()); if(target != null) break; } } if(target == null) { unresolvedRefs.add(cdmd.getComponentID()+":"+ref); continue; } } if(target == null && ref.getRemote() != null) { // Try the local interface type target = resolveEjbInterface(ref.getRemote(), unit, endpointMap, resolver); } if(target == null) unresolvedRefs.add(cdmd.getComponentID()+":"+ref); else { // Obtain remote interface name String remoteInterface = ref.getRemote(); // Get Metadata JBossEnterpriseBeanMetaData md = target.getBeanMetaData(); /* * If for a Session bean we've got a reference to an EJB2.x * Remote Component interface, stop processing because these * are not bound in JNDI (only accessible via Home.create() */ // Session EJB? boolean useDefaultProxy = false; if(md.isSession()) { // Cast JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData)md; // Get the name of the Component Remote Interface String ejb2xRemoteInterface = smd.getRemote(); // If the ejb-ref is to a EJB2.x Remote Component Interface if(remoteInterface.equals(ejb2xRemoteInterface)) { // Use the default proxy useDefaultProxy = true; } } // Get ejb-jar metadata JBossMetaData ejbMarMd = md.getEnterpriseBeansMetaData().getEjbJarMetaData(); // Resolve a JNDI name String remoteJNDIName = null; if (ejbMarMd.isEJB3x()) { if (md.isSession() || md.isService()) { SessionBeanJNDINameResolver sessionBeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver((JBossSessionBeanMetaData) md, this.defaultJNDIBindingPolicy); if (useDefaultProxy) { remoteJNDIName = sessionBeanJNDINameResolver.resolveRemoteBusinessDefaultJNDIName((JBossSessionBeanMetaData) md); } else { remoteJNDIName = sessionBeanJNDINameResolver.resolveJNDIName((JBossSessionBeanMetaData) md, remoteInterface); } } else if (md.isEntity()) { EntityBeanJNDINameResolver entityBeanJNDINameResolver = JNDIPolicyBasedJNDINameResolverFactory.getJNDINameResolver((JBossEntityBeanMetaData) md, this.defaultJNDIBindingPolicy); remoteJNDIName = entityBeanJNDINameResolver.resolveJNDIName((JBossEntityBeanMetaData) md, remoteInterface); } } else { remoteJNDIName = md.determineJndiName(); } // If we've got a resolved name if(remoteJNDIName != null) { // Set it ref.setResolvedJndiName(remoteJNDIName); } // Add the dependency cdmd.addDependency(target); } } else { // Create a JNDI dependency ref.setResolvedJndiName(mappedName); JndiDependencyMetaData jdmd = new JndiDependencyMetaData(mappedName, loader); cdmd.addJndiDependency(jdmd); } } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected ContainerDependencyMetaData resolveEjbInterface(String iface, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, DeploymentEndpointResolver resolver) throws Exception { ClassLoader loader = unit.getClassLoader(); Class<?> ifaceClass = loader.loadClass(iface); String vfsContext = unit.getRelativePath(); EndpointInfo info = resolver.getEndpointInfo(ifaceClass, EndpointType.EJB, vfsContext); if(info == null) throw new IllegalStateException("Failed to find ContainerDependencyMetaData for interface: "+ iface); ContainerDependencyMetaData cdmd = endpointMap.get(info.getComponentKey()); return cdmd; }
// in src/main/java/org/jboss/deployment/AppParsingDeployer.java
protected EarMetaData parse(VFSDeploymentUnit unit, VirtualFile file, EarMetaData root) throws Exception { EarMetaData ear = super.parse(unit,file, root); List<DeploymentUnit> children = unit.getChildren(); ModulesMetaData modules = ear.getModules(); if(children != null && modules != null) { for(DeploymentUnit child : children) { String moduleName = child.getSimpleName(); ModuleMetaData module = modules.get(moduleName); if(module != null && module.getAlternativeDD() != null) { VirtualFile altDDFile = unit.getRoot().getChild(module.getAlternativeDD()); if(altDDFile == null) throw new IllegalStateException("Failed to locate alternative DD '" + module.getAlternativeDD() + "' in " + unit.getRoot().getPathName()); String attachmentName; if(module.getType() == ModuleMetaData.ModuleType.Ejb) attachmentName = EjbJarMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Web) attachmentName = WebMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Client) attachmentName = ApplicationClientMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Connector) attachmentName = "org.jboss.resource.metadata.ConnectorMetaData"; else throw new IllegalStateException("Expected module types in an EAR are ejb, web, java and connector but got " + module.getType() + " for " + child.getName() + " in " + unit.getName()); child.addAttachment(attachmentName + ".altDD", altDDFile); if(log.isTraceEnabled()) log.trace("attached alt-dd " + altDDFile + " for module " + child.getSimpleName()); } } } return ear; }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
protected void processMetaData(VFSDeploymentUnit unit, WebMetaData webMetaData, ApplicationClientMetaData clientMetaData, List<VirtualFile> classpath) throws Exception { String mainClassName = getMainClassName(unit); Collection<Class<?>> classes = new HashSet<Class<?>>(); Map<VirtualFile, Collection<Class<?>>> classesPerJar = new HashMap<VirtualFile, Collection<Class<?>>>(); for (VirtualFile path : classpath) { Collection<Class<?>> currentClasses = getClasses(unit, mainClassName, path); classesPerJar.put(path, currentClasses); classes.addAll(currentClasses); } if (classes.size() > 0) { AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>(); if (webMetaData != null) processJBossWebMetaData(unit, finder, classesPerJar); else if (clientMetaData != null || mainClassName != null) processJBossClientMetaData(unit, finder, classes); else processJBossMetaData(unit, finder, classes); } }
// in src/main/java/org/jboss/deployment/TldParsingDeployer.java
protected void init(VFSDeploymentUnit unit, TldMetaData metaData, VirtualFile file) throws Exception { unit.addAttachment(TldMetaData.class.getName() + ":" + file.getPathNameRelativeTo(unit.getRoot()), metaData, getOutput()); }
// in src/main/java/org/jboss/deployment/TldParsingDeployer.java
protected TldMetaData parse(VirtualFile file) throws Exception { if (file == null) throw new IllegalArgumentException("Null file"); // Implicit TLDs are reserved as the "implicit.tld" name if (file.getName().equals("implicit.tld")) { return new TldMetaData(); } else { return super.parse(file); } }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception { // Get the j2ee.clientName value String clientName = (String) env.get(J2EE_CLIENT_NAME_PROP); if (clientName == null) { // Look for the name as a system property clientName = (String) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { try { return System.getProperty(J2EE_CLIENT_NAME_PROP); } catch (SecurityException e) { return null; } } } ); if (clientName == null) throw new NamingException("Failed to find j2ee.clientName in jndi env"); }
// in src/main/java/org/jboss/naming/NamingAlias.java
protected void startService() throws Exception { if( fromName == null ) throw new IllegalStateException("fromName is null"); if( toName == null ) throw new IllegalStateException("toName is null"); createLinkRef(); }
// in src/main/java/org/jboss/naming/NamingAlias.java
protected void stopService() throws Exception { removeLinkRef(fromName); }
// in src/main/java/org/jboss/naming/ExternalContext.java
protected void startService() throws Exception { rebind(); }
// in src/main/java/org/jboss/naming/ExternalContext.java
protected void stopService() throws Exception { if( contextInfo.getCacheContext() ) unbind(contextInfo.getJndiName()); }
// in src/main/java/org/jboss/naming/ExternalContext.java
private void rebind() throws Exception { Context ctx = contextInfo.newContext(); Context rootCtx = (Context) new InitialContext(); log.debug("ctx="+ctx+", env="+ctx.getEnvironment()); // Get the parent context into which we are to bind String jndiName = contextInfo.getJndiName(); Name fullName = rootCtx.getNameParser("").parse(jndiName); log.debug("fullName="+fullName); Name parentName = fullName; if( fullName.size() > 1 ) parentName = fullName.getPrefix(fullName.size()-1); else parentName = new CompositeName(); log.debug("parentName="+parentName); Context parentCtx = createContext(rootCtx, parentName); log.debug("parentCtx="+parentCtx); Name atomName = fullName.getSuffix(fullName.size()-1); String atom = atomName.get(0); boolean cacheContext = contextInfo.getCacheContext(); if( remoteAccess == true ) { // Bind contextInfo as a Referenceable parentCtx.rebind(atom, contextInfo); // Cache the context using NonSerializableFactory to avoid creating // more than one context for in VM lookups if( cacheContext == true ) { // If cacheContext is true we need to wrap the Context in a // proxy that allows the user to issue close on the lookup // Context without closing the inmemory Context. ctx = CachedContext.createProxyContext(ctx); NonSerializableFactory.rebind(jndiName, ctx); } } else if( cacheContext == true ) { // Bind a reference to the extern context using // NonSerializableFactory as the ObjectFactory. The Context must // be wrapped in a proxy that allows the user to issue close on the // lookup Context without closing the inmemory Context. Context proxyCtx = CachedContext.createProxyContext(ctx); NonSerializableFactory.rebind(rootCtx, jndiName, proxyCtx); } else { // Bind the contextInfo so that each lookup results in the creation // of a new Context object. The returned Context must be closed // by the user to prevent resource leaks. parentCtx.rebind(atom, contextInfo); } }
// in src/main/java/org/jboss/naming/ExternalContext.java
Context newContext() throws Exception { // First check the NonSerializableFactory cache initialContext = (Context) NonSerializableFactory.lookup(jndiName); // Create the context from the contextClass and contextProps if( initialContext == null ) initialContext = newContext(contextClass, contextProps); return initialContext; }
// in src/main/java/org/jboss/naming/ExternalContext.java
static Context newContext(Class contextClass, Properties contextProps) throws Exception { Context ctx = null; try { ctx = newDefaultContext(contextClass, contextProps); } catch(NoSuchMethodException e) { ctx = newLdapContext(contextClass, contextProps); } return ctx; }
// in src/main/java/org/jboss/naming/ExternalContext.java
private static Context newDefaultContext(Class contextClass, Properties contextProps) throws Exception { Context ctx = null; Class[] types = {Hashtable.class}; Constructor ctor = contextClass.getConstructor(types); Object[] args = {contextProps}; ctx = (Context) ctor.newInstance(args); return ctx; }
// in src/main/java/org/jboss/naming/ExternalContext.java
private static Context newLdapContext(Class contextClass, Properties contextProps) throws Exception { Context ctx = null; Class[] types = {Hashtable.class, Control[].class}; Constructor ctor = contextClass.getConstructor(types); Object[] args = {contextProps, null}; ctx = (Context) ctor.newInstance(args); return ctx; }
// in src/main/java/org/jboss/naming/ExternalContext.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { Reference ref = (Reference) obj; SerializableInitialContext sic = (SerializableInitialContext) ref.get(0); return sic.newContext(); }
// in src/main/java/org/jboss/naming/LinkRefPairService.java
protected void startService() throws Exception { if (jndiName == null) throw new DeploymentException("The jndiName is null for LinkRefPair " + getServiceName()); if (remoteJndiName == null) throw new DeploymentException("The remoteJndiName is null for LinkRefPair " + getServiceName()); if (localJndiName == null) throw new DeploymentException("The localJndiName is null for LinkRefPair " + getServiceName()); LinkRefPair pair = new LinkRefPair(remoteJndiName, localJndiName); InitialContext ctx = new InitialContext(); try { Util.bind(ctx, jndiName, pair); } finally { ctx.close(); } }
// in src/main/java/org/jboss/naming/LinkRefPairService.java
protected void stopService() throws Exception { LinkRefPair pair = new LinkRefPair(remoteJndiName, localJndiName); InitialContext ctx = new InitialContext(); try { Util.unbind(ctx, jndiName); } finally { ctx.close(); } }
// in src/main/java/org/jboss/naming/java/javaURLContextFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { return new NamingContext(environment, name, root); }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
public void start() throws Exception { establishBootStrapURL(); if (bootstrapUrl != null) { File base = null; if (outputDir == null) { if (server != null) { base = new File(server.getConfiguration().getServerDataLocation().toURI()); outputDir = base.toURI(); } } else { base = new File(outputDir); } if (base != null) { base.mkdirs(); File file = new File(base, getOutputFileName()); if (file.exists()) { file.delete(); } PrintWriter writer = null; try { if (log.isTraceEnabled()) { log.trace("Creating file " + file); } file.createNewFile(); file.deleteOnExit(); writer = new PrintWriter(file); writer.println(bootstrapUrl); writer.flush(); } catch (Exception e) { handleOutputFileCreationException(file.toURI(), e); } finally { if (writer != null) { writer.close(); } } } else { log.warn("No directory specified for " + getOutputFileName() + " cannot write the naming service url. Please configure either " + "the 'server' property or the 'outputDir' property."); } } else { log.debug("No URLs to write"); } }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
public void stop() throws Exception { if (outputDir != null) { String outputFile = ""; try { File f = new File(new File(outputDir), getOutputFileName()); outputFile = f.getAbsolutePath(); f.delete(); } catch (Exception e) { log.warn("Failed to delete JNP URL file " + outputFile + " due to " + e); } } }
// in src/main/java/org/jboss/naming/LinkRefPairObjectFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { LinkRefPair pair = (LinkRefPair) obj; String jndiName; // Local or remote? boolean local = false; if (guid.equals(pair.getGUID())) { jndiName = pair.getLocalLinkName(); local = true; } else jndiName = pair.getRemoteLinkName(); InitialContext ctx; if (local || environment == null) ctx = new InitialContext(); else ctx = new InitialContext(environment); return ctx.lookup(jndiName); }
// in src/main/java/org/jboss/naming/JNDIBinding.java
public Object getValue() throws Exception { if( value == null && text != null ) { // If there is a property editor set, transform text to value if( editor != null ) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class editorClass = loader.loadClass(editor); PropertyEditor pe = (PropertyEditor) editorClass.newInstance(); pe.setAsText(text); value = pe.getValue(); } else if( type != null ) { PropertyEditor pe = PropertyEditors.getEditor(type); pe.setAsText(text); value = pe.getValue(); } else { value = text; } } return value; }
// in src/main/java/org/jboss/naming/JNDIBindingServiceMgr.java
protected void startService() throws Exception { service.addBindings(); }
// in src/main/java/org/jboss/naming/JNDIBindingServiceMgr.java
protected void stopService() throws Exception { service.removeBindings(); }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception { Context ctx = getInitialContext(env); Reference ref = (Reference) obj; RefAddr addr = ref.get("URL"); String path = (String) addr.getContent(); return ctx.lookup(path); }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
public void start() throws Exception { addBindings(); }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
public void stop() throws Exception { removeBindings(); }
// in src/main/java/org/jboss/naming/NamingService.java
public Object getNamingProxy() throws Exception { Object proxy = null; if(proxyFactory != null) proxy = proxyFactory.getProxy(); else proxy = namingMain.getNamingProxy(); return proxy; }
// in src/main/java/org/jboss/naming/NamingService.java
protected void startService() throws Exception { boolean debug = log.isDebugEnabled(); // Read jndi.properties into system properties ClassLoader loader = Thread.currentThread().getContextClassLoader(); InputStream is = loader.getResourceAsStream("jndi.properties"); if (is == null) throw new RuntimeException("Cannot find jndi.properties, it should be at conf/jndi.properties by default."); Properties props = new Properties(); try { props.load(is); } finally { is.close(); } for (Enumeration keys = props.propertyNames(); keys.hasMoreElements(); ) { String key = (String) keys.nextElement(); String value = props.getProperty(key); if (debug) { log.debug("System.setProperty, key="+key+", value="+value); } System.setProperty(key, value); } if( proxyFactory != null ) namingMain.setNamingProxy(proxyFactory.getProxy()); if( startNamingBean ) namingMain.start(); // Build the Naming interface method map HashMap tmpMap = new HashMap(13); Method[] methods = Naming.class.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap); }
// in src/main/java/org/jboss/naming/NamingService.java
protected void stopService() throws Exception { if(startNamingBean) { namingMain.stop(); log.debug("JNP server stopped"); } }
// in src/main/java/org/jboss/naming/NamingService.java
public void createAlias(String fromName, String toName) throws Exception { Util.createLinkRef(fromName, toName); log.info("Created alias " + fromName + "->" + toName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void removeAlias(String name) throws Exception { log.info("Removing alias " + name); Util.removeLinkRef(name); }
// in src/main/java/org/jboss/naming/NamingService.java
public Object invoke(Invocation invocation) throws Exception { Naming theServer = namingMain.getNamingInstance(); // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the Naming method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Object value = null; try { value = method.invoke(theServer, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; }
// in src/main/java/org/jboss/naming/interceptors/ProxyFactoryInterceptor.java
private void initNamingProxy() throws Exception { if( proxy != null ) return; ObjectName proxyFactory = new ObjectName(proxyName); MBeanServer server = MBeanServerLocator.locateJBoss(); proxy = (Naming) server.getAttribute(proxyFactory, "Proxy"); }
// in src/main/java/org/jboss/naming/JndiBinder.java
public void start() throws Exception { InitialContext ctx1 = null; if (properties != null) { ctx1 = new InitialContext(properties); } else ctx1 = new InitialContext(); InitialContext ctx = ctx1; try { if (serializable) { Util.rebind(ctx, bindTo, target); } else { NonSerializableFactory.rebind(ctx, bindTo, target); } } catch (NamingException e) { NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo); namingException.setRootCause(e); throw namingException; } }
// in src/main/java/org/jboss/naming/JndiBinder.java
public void stop() throws Exception { InitialContext ctx1 = null; if (properties != null) { ctx1 = new InitialContext(properties); } else ctx1 = new InitialContext(); InitialContext ctx = ctx1; if (serializable) { Util.unbind(ctx, bindTo); } else { NonSerializableFactory.unbind(bindTo); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransactionObjectFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { Reference ref = (Reference)obj; if (!ref.getClassName().equals(ClientUserTransaction.class.getName())) return null; return getUserTransaction(); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
public Object invoke(Invocation invocation) throws Exception { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Object value = null; try { if( UserTransactionSessionFactory.class.isAssignableFrom(method.getDeclaringClass()) ) { // Just return the UserTransactionSession proxy as its stateless value = txProxy; } else if( method.getName().equals("begin") ) { // Begin a new transaction Integer timeout = (Integer) args[0]; UserTransactionSession session = UserTransactionSessionImpl.getInstance(); value = session.begin(timeout.intValue()); } else if( method.getName().equals("destroy")) { /* We do nothing as the tx will timeout and the tx map is shared across all sessions as we have no association with the txs a given client has started. */ } else { UserTransactionSession session = UserTransactionSessionImpl.getInstance(); value = method.invoke(session, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
protected void startService() throws Exception { Context ctx = new InitialContext(); // Bind the in VM UserTransaction interface ctx.bind(JNDI_NAME, ClientUserTransaction.getSingleton()); // Get the UserTransactionSession proxy txProxy = getServer().getAttribute(txProxyName, "Proxy"); // Build the UserTransactionSession interface method map HashMap tmpMap = new HashMap(13); Method[] methods = UserTransactionSession.class.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } // Add the UserTransactionSessionFactory interface method map methods = UserTransactionSessionFactory.class.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap); // Place our ObjectName hash into the Registry so invokers can resolve it. // We need this for the HA Proxy case where the only the target service // is added to the registry, which is how it should be. // In the non HA Proxy case, JRMPProxyFactory acts both as a proxy factory // and proxy which is conceptually wrong, hence this is an extra step in // that case. Registry.bind(new Integer(serviceName.hashCode()), serviceName); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
static SecurityContext createSecurityContext(final String securityDomain) throws PrivilegedActionException { return (SecurityContext)AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(securityDomain); SecurityContextAssociation.setSecurityContext(sc); return sc; } }); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(securityDomain); SecurityContextAssociation.setSecurityContext(sc); return sc; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
public void startService() throws Exception { // Get the persistence plugin if (dbpPluginClassName != null) { Class dbpPolicyClass = Thread.currentThread().getContextClassLoader().loadClass(dbpPluginClassName); dbpPlugin = (DatabasePersistencePlugin)dbpPolicyClass.newInstance(); } else { dbpPlugin = new GeneralPurposeDatabasePersistencePlugin(); } // init the plugin if (dbpPlugin instanceof DatabasePersistencePluginExt) { // if using the extended plugin interface, initialize the timers table name ((DatabasePersistencePluginExt)dbpPlugin).init(server, dataSource, timersTable); } else { dbpPlugin.init(server, dataSource); } // warn if timers table cannot be set if (dbpPlugin.getTableName().equals(timersTable) == false) { log.warn("Database persistence plugin '" + dbpPluginClassName + "' uses hardcoded timers table name: '" + dbpPlugin.getTableName()); } // create the table if needed dbpPlugin.createTableIfNotExists(); }
// in src/main/java/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java
public void callTimeout(Timer timer) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(container.getClassLoader()); container.pushENC(); try { Invocation inv = new Invocation(timedObjectId.getInstancePk(), method, new Object[]{timer}, null, null, null); inv.setValue(InvocationKey.INVOKER_PROXY_BINDING, null, PayloadKey.AS_IS); inv.setType(InvocationType.LOCAL); BeanMetaData bmd = container.getBeanMetaData(); SecurityIdentityMetaData ejbTimeoutIdentity = bmd.isEntity() ? null : bmd.getEjbTimeoutIdentity(); if( ejbTimeoutIdentity != null && ejbTimeoutIdentity.getUseCallerIdentity() == false ) { ApplicationMetaData applicationMetaData = bmd.getApplicationMetaData(); AssemblyDescriptorMetaData assemblyDescriptor = applicationMetaData.getAssemblyDescriptor(); String roleName = ejbTimeoutIdentity.getRunAsRoleName(); String principalName = ejbTimeoutIdentity.getRunAsPrincipalName(); // the run-as principal might have extra roles mapped in the assembly-descriptor Set extraRoleNames = assemblyDescriptor.getSecurityRoleNamesByPrincipal(principalName); RunAs runAsIdentity = new RunAsIdentity(roleName, principalName, extraRoleNames); SecurityActions.pushRunAsIdentity(runAsIdentity); pushedRunAs = true; } container.invoke(inv); } finally { container.popENC(); if(pushedRunAs) SecurityActions.popRunAsIdentity(); SecurityActions.setContextClassLoader(callerClassLoader); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
protected void startService() throws Exception { // Setup plugins, fall back to safe defaults // Get the TransactionManager from the factory, fall-back to the locator if (transactionManagerFactory != null) transactionManager = transactionManagerFactory.getTransactionManager(); else transactionManager = TransactionManagerLocator.getInstance().locate(); // Get a proxy to the retry policy try { retryPolicy = (RetryPolicy)MBeanProxyExt.create(RetryPolicy.class, getRetryPolicy(), server); } catch (Exception e) { log.error("Cannot obtain the implementation of a RetryPolicy", e); } // Get a proxy to the persistence policy try { persistencePolicy = (PersistencePolicy)MBeanProxyExt.create(PersistencePolicy.class, persistencePolicyName, server); } catch (Exception e) { log.warn("Cannot obtain the implementation of a PersistencePolicy, using NoopPersistencePolicy: " + e.toString()); persistencePolicy = new NoopPersistencePolicy(); } // Get the timerId generator try { Class<?> timerIdGeneratorClass = getClass().getClassLoader().loadClass(timerIdGeneratorClassName); timerIdGenerator = (TimerIdGenerator)timerIdGeneratorClass.newInstance(); } catch (Exception e) { log.warn("Cannot obtain the implementation of a TimerIdGenerator, using BigIntegerTimerIdGenerator: " + e.toString()); timerIdGenerator = new BigIntegerTimerIdGenerator(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Acquire classes from CL if (metaData.getHome() != null) homeInterface = classLoader.loadClass(metaData.getHome()); if (metaData.getRemote() != null) remoteInterface = classLoader.loadClass(metaData.getRemote()); if (((SessionMetaData) metaData).getServiceEndpoint() != null) { serviceEndpoint = classLoader.loadClass(((SessionMetaData) metaData).getServiceEndpoint()); } // Call default init super.createService(); // Make some additional validity checks with regards to the container configuration checkCoherency(); // Map the bean methods setupBeanMapping(); // Map the home methods setupHomeMapping(); // Map the interfaces to Long setupMarshalledInvocationMapping(); createInvokers(); createInstanceCache(); createInstancePool(); createPersistenceManager(); createInterceptors(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void setupMarshalledInvocationMapping() throws Exception { // Create method mappings for container invoker if (homeInterface != null) { Method[] m = homeInterface.getMethods(); for (int i = 0; i < m.length; i++) { marshalledInvocationMapping.put(new Long(MarshalledInvocation.calculateHash(m[i])), m[i]); } } if (remoteInterface != null) { Method[] m = remoteInterface.getMethods(); for (int j = 0; j < m.length; j++) { marshalledInvocationMapping.put(new Long(MarshalledInvocation.calculateHash(m[j])), m[j]); } } // Get the getEJBObjectMethod Method getEJBObjectMethod = Class.forName("javax.ejb.Handle").getMethod("getEJBObject", new Class[0]); // Hash it marshalledInvocationMapping.put(new Long(MarshalledInvocation.calculateHash(getEJBObjectMethod)), getEJBObjectMethod); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void checkCoherency() throws Exception { // Check clustering cohrency wrt metadata // if (metaData.isClustered()) { boolean clusteredProxyFactoryFound = false; Iterator it = proxyFactories.keySet().iterator(); while (it.hasNext()) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); if (ci instanceof org.jboss.proxy.ejb.ClusterProxyFactory) clusteredProxyFactoryFound = true; } if (!clusteredProxyFactoryFound) { log.warn("*** EJB '" + this.metaData.getEjbName() + "' deployed as CLUSTERED but not a single clustered-invoker is bound to container ***"); } } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createInstancePool() throws Exception { // Try to register the instance pool as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instancePool, poolName); } catch (Throwable t) { log.debug("Failed to register pool as mbean", t); } // Initialize pool instancePool.setContainer(this); instancePool.create(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createInstanceCache() throws Exception { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createInvokers() throws Exception { // Init container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.create(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createInterceptors() throws Exception { Interceptor in = interceptor; while (in != null) { in.setContainer(this); in.create(); in = in.getNext(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void createPersistenceManager() throws Exception { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default start super.startService(); startInvokers(); startInstanceCache(); startInstancePool(); startPersistenceManager(); startInterceptors(); // Restore persisted ejb timers restoreTimers(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startPersistenceManager() throws Exception { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startInstanceCache() throws Exception { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startInvokers() throws Exception { for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.start(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startInstancePool() throws Exception { instancePool.start(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void startInterceptors() throws Exception { Interceptor in = interceptor; while (in != null) { in.start(); in = in.getNext(); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void stopService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default stop super.stopService(); stopInvokers(); stopInstanceCache(); stopInstancePool(); stopPersistenceManager(); stopInterceptors(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void destroyService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { destroyInvokers(); destroyInstanceCache(); destroyInstancePool(); destroyPersistenceManager(); destroyInterceptors(); destroyMarshalledInvocationMapping(); homeInterface = null; remoteInterface = null; serviceEndpoint = null; beanMapping.clear(); // Call default destroy super.destroyService(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); ejbObject.remove(); return null; } else throw new RemoveException("EJBHome.remove(Object) not allowed for session beans"); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object internalInvoke(Invocation mi) throws Exception { // Invoke through interceptors return getInterceptor().invoke(mi); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } try { return mi.performCall(StatelessSessionContainer.this, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // wire the transaction on the context, this is how the instance remember the tx EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); // Get method and instance to invoke upon Method miMethod = mi.getMethod(); Map map = getBeanMapping(); Method m = (Method) map.get(miMethod); // The Invocation might contain the actual bean method // e.g. For an invocation based on a JSR-181 @WebMethod annotation if (m == null && map.values().contains(miMethod)) { m = miMethod; } if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } //If we have a method that needs to be done by the container (EJBObject methods) if (m.getDeclaringClass().equals(StatelessSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { try { return mi.performCall(StatelessSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else // we have a method that needs to be done by a bean instance { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Object run() throws Exception { Object proxy = MBeanProxy.get(iface, name, server); Class[] ifaces = {iface}; InvocationHandler secureHandler = new InvocationHandlerAction(proxy); Object secureProxy = Proxy.newProxyInstance(iface.getClassLoader(), ifaces, secureHandler); return secureProxy; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Object run() throws Exception { Object value = method.invoke(mbean, args); return value; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
static Object getMBeanProxy(Class iface, ObjectName name, MBeanServer server) throws Exception { Object proxy; if( System.getSecurityManager() == null ) { proxy = MBeanProxy.get(iface, name, server); } else { MBeanProxyAction action = new MBeanProxyAction(iface, name, server); proxy = AccessController.doPrivileged(action); } return proxy; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Object run() throws Exception { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
static boolean isCallerInRole(final SecurityContext sc, final String roleName, final String ejbName, final Principal principal, final Subject contextSubject, final String jaccContextID, final Set<SecurityRoleRef> securityRoleRefs) throws PrivilegedActionException { return AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() { public Boolean run() throws Exception { AbstractEJBAuthorizationHelper helper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); return helper.isCallerInRole(roleName, ejbName, principal, contextSubject, jaccContextID, securityRoleRefs); } }); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Boolean run() throws Exception { AbstractEJBAuthorizationHelper helper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); return helper.isCallerInRole(roleName, ejbName, principal, contextSubject, jaccContextID, securityRoleRefs); }
// in src/main/java/org/jboss/ejb/EjbModule.java
Override protected void createService() throws Exception { serviceController = (ServiceControllerMBean) MBeanProxyExt.create(ServiceControllerMBean.class, ServiceControllerMBean.OBJECT_NAME, server); log.debug("createService, begin"); // Set up the beans in this module. try { Iterator beans = appMetaData.getEnterpriseBeans(); String contextID = appMetaData.getJaccContextID(); if (contextID == null) contextID = deploymentUnit.getSimpleName(); // appMetaData.gsetJaccContextID(contextID); /* PolicyConfiguration pc = null; */ while (beans.hasNext()) { BeanMetaData bean = (BeanMetaData) beans.next(); log.info("Deploying " + bean.getEjbName()); Container con = createContainer(bean, deploymentUnit); addContainer(con); // @todo support overriding the context id via metadata is needed con.setJaccContextID(contextID); } // only one iteration should be necessary, but we won't sweat it. // 2 iterations are needed by cmp...jdbc/bridge/JDBCCMRFieldBridge which // assumes persistence managers are all set up for every // bean in the relationship! ListIterator iter = containerOrdering.listIterator(); while (iter.hasNext()) { Container con = (Container) iter.next(); ObjectName jmxName = con.getJmxName(); /* * Add the container mbean to the deployment mbeans so the state of the deployment can be tracked. */ server.registerMBean(con, jmxName); // deploymentUnit.mbeans.add(jmxName); BeanMetaData metaData = con.getBeanMetaData(); Collection<ObjectName> depends = new ArrayList<ObjectName>(); for (String dependsName : metaData.getDepends()) { depends.add(ObjectName.getInstance(dependsName)); } Iterator<String> invokerBindings = metaData.getInvokerBindings(); while (invokerBindings != null && invokerBindings.hasNext()) { String invokerBindingName = invokerBindings.next(); InvokerProxyBindingMetaData ipbmd = appMetaData.getInvokerProxyBindingMetaDataByName(invokerBindingName); if (ipbmd != null) { String invokerName = ipbmd.getInvokerMBean(); if (invokerName != null) { try { ObjectName invokerMBean = ObjectName.getInstance(invokerName); if (depends.contains(invokerMBean) == false) depends.add(invokerMBean); } catch (MalformedObjectNameException e) { log.trace("Ignored malformed invoker mbean '" + invokerName + "' " + e.toString()); } } } } serviceController.create(jmxName, depends); // We keep the hashCode around for fast creation of proxies int jmxHash = jmxName.hashCode(); Registry.bind(new Integer(jmxHash), jmxName); log.debug("Bound jmxName=" + jmxName + ", hash=" + jmxHash + "into Registry"); } } catch (Exception e) { destroyService(); throw e; } // end of try-catch }
// in src/main/java/org/jboss/ejb/EjbModule.java
Override protected void startService() throws Exception { // before EntityContainer returns from the startService, its PM should be usable ListIterator iter = containerOrdering.listIterator(); while (iter.hasNext()) { Container con = (Container) iter.next(); if (con.getBeanMetaData().isEntity()) { ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(con.getClassLoader()); con.pushENC(); try { ((EntityContainer) con).getPersistenceManager().start(); } finally { con.popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } } } iter = containerOrdering.listIterator(); while (iter.hasNext()) { Container con = (Container) iter.next(); log.debug("startService, starting container: " + con.getBeanMetaData().getEjbName()); serviceController.start(con.getJmxName()); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
Override protected void stopService() throws Exception { ListIterator iter = containerOrdering.listIterator(containerOrdering.size()); while (iter.hasPrevious()) { Container con = (Container) iter.previous(); try { ObjectName jmxName = con.getJmxName(); // The container may already be destroyed so validate metaData BeanMetaData metaData = con.getBeanMetaData(); String ejbName = metaData != null ? metaData.getEjbName() : "Unknown"; log.debug("stopService, stopping container: " + ejbName); serviceController.stop(jmxName); } catch (Exception e) { log.error("unexpected exception stopping Container: " + con.getJmxName(), e); } // end of try-catch } }
// in src/main/java/org/jboss/ejb/EjbModule.java
Override protected void destroyService() throws Exception { WebServiceMBean webServer = null; if (webServiceName != null) { webServer = (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName); } ListIterator iter = containerOrdering.listIterator(containerOrdering.size()); while (iter.hasPrevious()) { Container con = (Container) iter.previous(); ObjectName jmxName = con.getJmxName(); int conState = con.getState(); boolean destroyContainer = true; log.debug("Looking to destroy container: " + jmxName + ", state: " + con.getStateString() + ", destroy: " + destroyContainer); // always unregister from Registry int jmxHash = jmxName.hashCode(); Registry.unbind(new Integer(jmxHash)); // Unregister the web classloader // Removing the wcl should probably be done in stop of the container, // but I don't want to look for errors today. if (webServer != null) { ClassLoader wcl = con.getWebClassLoader(); if (wcl != null) { try { webServer.removeClassLoader(wcl); } catch (Throwable e) { log.warn("Failed to unregister webClassLoader", e); } } } // Only destroy containers that have been created or started if (destroyContainer) { try { serviceController.destroy(jmxName); serviceController.remove(jmxName); log.info("Undeployed " + con.getBeanMetaData().getEjbName()); if (server.isRegistered(jmxName)) server.unregisterMBean(jmxName); } catch (Throwable e) { log.error("unexpected exception destroying Container: " + jmxName, e); } // end of try-catch } // Destroy proxy factories if (destroyContainer) { if (con.getBeanMetaData() != null && con.getBeanMetaData().getInvokerBindings() != null) { Iterator<String> invokerBindings = con.getBeanMetaData().getInvokerBindings(); while (invokerBindings.hasNext()) { String invoker = invokerBindings.next(); EJBProxyFactory ci = con.lookupProxyFactory(invoker); if (ci != null) { ci.setContainer(null); ci.setInvokerBinding(null); ci.setInvokerMetaData(null); } } } } // cleanup container con.setBeanMetaData(null); con.setWebClassLoader(null); con.setClassLoader(null); con.setEjbModule(null); con.setTransactionManager(null); con.setSecurityManager(null); con.setRealmMapping(null); con.setSecurityProxy(null); con.setSecurityManagement(null); con.setPolicyRegistration(null); con.proxyFactories.clear(); } this.containers.clear(); this.localHomes.clear(); this.containerOrdering.clear(); this.moduleData.clear(); this.serviceController = null; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private Container createContainer(BeanMetaData bean, VFSDeploymentUnit unit) throws Exception { Container container = null; // Added message driven deployment if (bean.isMessageDriven()) { container = createMessageDrivenContainer(bean, unit); } else if (bean.isSession()) // Is session? { if (((SessionMetaData) bean).isStateless()) // Is stateless? { container = createStatelessSessionContainer((SessionMetaData) bean, unit); } else // Stateful { container = createStatefulSessionContainer((SessionMetaData) bean, unit); } } else // Entity { container = createEntityContainer(bean, unit); } container.setDeploymentUnit(unit); return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private MessageDrivenContainer createMessageDrivenContainer(BeanMetaData bean, DeploymentUnit unit) throws Exception { // get the container configuration for this bean // a default configuration is now always provided ConfigurationMetaData conf = bean.getContainerConfiguration(); // Stolen from Stateless deploy // Create container MessageDrivenContainer container = new MessageDrivenContainer(); int transType = bean.isContainerManagedTx() ? CMT : BMT; initializeContainer(container, conf, bean, transType, unit); createProxyFactories(bean, container); container.setInstancePool(createInstancePool(conf, unit.getClassLoader())); return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private StatelessSessionContainer createStatelessSessionContainer(SessionMetaData bean, DeploymentUnit unit) throws Exception { // get the container configuration for this bean // a default configuration is now always provided ConfigurationMetaData conf = bean.getContainerConfiguration(); // Create container StatelessSessionContainer container = new StatelessSessionContainer(); int transType = bean.isContainerManagedTx() ? CMT : BMT; initializeContainer(container, conf, bean, transType, unit); if (bean.getHome() != null || bean.getServiceEndpoint() != null) { createProxyFactories(bean, container); } container.setInstancePool(createInstancePool(conf, unit.getClassLoader())); return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private StatefulSessionContainer createStatefulSessionContainer(SessionMetaData bean, DeploymentUnit unit) throws Exception { // get the container configuration for this bean // a default configuration is now always provided ConfigurationMetaData conf = bean.getContainerConfiguration(); // Create container StatefulSessionContainer container = new StatefulSessionContainer(); int transType = bean.isContainerManagedTx() ? CMT : BMT; initializeContainer(container, conf, bean, transType, unit); if (bean.getHome() != null || bean.getServiceEndpoint() != null) { createProxyFactories(bean, container); } ClassLoader cl = unit.getClassLoader(); container.setInstanceCache(createInstanceCache(conf, cl)); // No real instance pool, use the shadow class StatefulSessionInstancePool ip = new StatefulSessionInstancePool(); ip.importXml(conf.getContainerPoolConf()); container.setInstancePool(ip); // Set persistence manager container.setPersistenceManager((StatefulSessionPersistenceManager) cl.loadClass(conf.getPersistenceManager()) .newInstance()); // Set the bean Lock Manager container.setLockManager(createBeanLockManager(container, false, conf.getLockClass(), cl)); return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private EntityContainer createEntityContainer(BeanMetaData bean, DeploymentUnit unit) throws Exception { // get the container configuration for this bean // a default configuration is now always provided ConfigurationMetaData conf = bean.getContainerConfiguration(); // Create container EntityContainer container = new EntityContainer(); int transType = CMT; initializeContainer(container, conf, bean, transType, unit); if (bean.getHome() != null) { createProxyFactories(bean, container); } ClassLoader cl = unit.getClassLoader(); container.setInstanceCache(createInstanceCache(conf, cl)); container.setInstancePool(createInstancePool(conf, cl)); // Set the bean Lock Manager boolean reentrant = ((EntityMetaData) bean).isReentrant(); BeanLockManager lockMgr = createBeanLockManager(container, reentrant, conf.getLockClass(), cl); container.setLockManager(lockMgr); // Set persistence manager if (((EntityMetaData) bean).isBMP()) { Class pmClass = cl.loadClass(conf.getPersistenceManager()); EntityPersistenceManager pm = (EntityPersistenceManager) pmClass.newInstance(); container.setPersistenceManager(pm); } else { // CMP takes a manager and a store org.jboss.ejb.plugins.CMPPersistenceManager persistenceManager = new org.jboss.ejb.plugins.CMPPersistenceManager(); // Load the store from configuration Class pmClass = cl.loadClass(conf.getPersistenceManager()); EntityPersistenceStore pm = (EntityPersistenceStore) pmClass.newInstance(); persistenceManager.setPersistenceStore(pm); // Set the manager on the container container.setPersistenceManager(persistenceManager); } return container; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static void createProxyFactories(BeanMetaData conf, Container container) throws Exception { ClassLoader cl = container.getClassLoader(); Iterator it = conf.getInvokerBindings(); boolean foundOne = false; while (it.hasNext()) { String invoker = (String) it.next(); String jndiBinding = conf.getInvokerBinding(invoker); log.debug("creating binding for " + jndiBinding + ":" + invoker); InvokerProxyBindingMetaData imd = conf.getApplicationMetaData().getInvokerProxyBindingMetaDataByName(invoker); EJBProxyFactory ci = null; // create a ProxyFactory instance try { ci = (EJBProxyFactory) cl.loadClass(imd.getProxyFactory()).newInstance(); ci.setContainer(container); ci.setInvokerMetaData(imd); ci.setInvokerBinding(jndiBinding); if (ci instanceof XmlLoadable) { // the container invoker can load its configuration from the jboss.xml element ((XmlLoadable) ci).importXml(imd.getProxyFactoryConfig()); } container.addProxyFactory(invoker, ci); foundOne = true; } catch (Exception e) { log.warn("The Container Invoker " + invoker + " (in jboss.xml or standardjboss.xml) could not be created because of " + e + " We will ignore this error, but you may miss a transport for this bean."); } } if (!foundOne) { throw new DeploymentException("Missing or invalid Container Invokers (in jboss.xml or standardjboss.xml)."); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static BeanLockManager createBeanLockManager(Container container, boolean reentrant, String beanLock, ClassLoader cl) throws Exception { // The bean lock manager BeanLockManager lockManager = new BeanLockManager(container); Class lockClass = null; try { if (beanLock == null) beanLock = "org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock"; lockClass = cl.loadClass(beanLock); } catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); } lockManager.setLockCLass(lockClass); lockManager.setReentrant(reentrant); return lockManager; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static InstancePool createInstancePool(ConfigurationMetaData conf, ClassLoader cl) throws Exception { // Set instance pool InstancePool ip = null; try { ip = (InstancePool) cl.loadClass(conf.getInstancePool()).newInstance(); } catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); } if (ip instanceof XmlLoadable) ((XmlLoadable) ip).importXml(conf.getContainerPoolConf()); return ip; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private static InstanceCache createInstanceCache(ConfigurationMetaData conf, ClassLoader cl) throws Exception { // Set instance cache InstanceCache ic = null; try { ic = (InstanceCache) cl.loadClass(conf.getInstanceCache()).newInstance(); } catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); } if (ic instanceof XmlLoadable) ((XmlLoadable) ic).importXml(conf.getContainerCacheConf()); return ic; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void createService() throws Exception { super.createService(); // Get the Handle.getEJBObject method for permission checks try { getEJBObject = Handle.class.getMethod("getEJBObject", new Class[0]); } catch (Exception e) { log.warn("Failed to grant access to the Handle.getEJBObject method"); } ejbObjectRemove = EJBObject.class.getMethod("remove", null); ejbLocalObjectRemove = EJBLocalObject.class.getMethod("remove", null); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void createInstanceCache() throws Exception { // Try to register the instance cache as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "cache"); ObjectName cacheName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instanceCache, cacheName); } catch (Throwable t) { log.debug("Failed to register cache as mbean", t); } // Init instance cache instanceCache.setContainer(this); instanceCache.create(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void createPersistenceManager() throws Exception { persistenceManager.setContainer(this); persistenceManager.create(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void startPersistenceManager() throws Exception { persistenceManager.start(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void startInstanceCache() throws Exception { instanceCache.start(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
private void createSession(final Method m, final Object[] args, final StatefulSessionEnterpriseContext ctx) throws Exception { // Create a new ID and set it Object id = getPersistenceManager().createId(ctx); log.debug("Created new session ID: " + id); ctx.setId(id); // Invoke ejbCreate<METHOD>() try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); // Build the ejbCreate<METHOD> from the home create<METHOD> sig String createName = m.getName(); Object instance = ctx.getInstance(); String ejbCreateName = "ejbC" + createName.substring(1); Method createMethod = instance.getClass().getMethod(ejbCreateName, m.getParameterTypes()); log.debug("Using create method for session: " + createMethod); createMethod.invoke(instance, args); createCount++; } catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); } catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // call back to the PM to let it know that ejbCreate has been called with success getPersistenceManager().createdSession(ctx); // Insert in cache getInstanceCache().insert(ctx); // Create EJBObject if (getProxyFactory() != null) ctx.setEJBObject((EJBObject) getProxyFactory().getStatefulSessionEJBObject(id)); // Create EJBLocalObject if (getLocalHomeClass() != null) ctx.setEJBLocalObject(getLocalProxyFactory().getStatefulSessionEJBLocalObject(id)); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBObject createHome(Invocation mi) throws Exception { StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); createSession(mi.getMethod(), mi.getArguments(), ctx); return ctx.getEJBObject(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBLocalObject createLocalHome(Invocation mi) throws Exception { StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); createSession(mi.getMethod(), mi.getArguments(), ctx); return ctx.getEJBLocalObject(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
protected void setupHomeMapping() throws Exception { // Adrian Brock: This should go away when we don't support EJB1x boolean isEJB1x = metaData.getApplicationMetaData().isEJB1x(); Map map = new HashMap(); if (homeInterface != null) { Method[] m = homeInterface.getMethods(); for (int i = 0; i < m.length; i++) { try { // Implemented by container if (isEJB1x == false && m[i].getName().startsWith("create")) { map.put(m[i], getClass().getMethod("createHome", new Class[]{Invocation.class})); } else { map.put(m[i], getClass().getMethod(m[i].getName() + "Home", new Class[]{Invocation.class})); } } catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); } } } if (localHomeInterface != null) { Method[] m = localHomeInterface.getMethods(); for (int i = 0; i < m.length; i++) { try { // Implemented by container if (isEJB1x == false && m[i].getName().startsWith("create")) { map.put(m[i], getClass().getMethod("createLocalHome", new Class[]{Invocation.class})); } else { map.put(m[i], getClass().getMethod(m[i].getName() + "LocalHome", new Class[]{Invocation.class})); } } catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); } } } try { // Get getEJBObject from on Handle, first get the class Class handleClass = Class.forName("javax.ejb.Handle"); //Get only the one called handle.getEJBObject Method getEJBObjectMethod = handleClass.getMethod("getEJBObject", new Class[0]); //Map it in the home stuff map.put(getEJBObjectMethod, getClass().getMethod("getEJBObject", new Class[]{Invocation.class})); } catch (NoSuchMethodException e) { log.debug("Couldn't find getEJBObject method on container"); } homeMapping = map; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("HOMEMETHOD coming in "); log.trace("" + mi.getMethod()); log.trace("HOMEMETHOD coming in hashcode" + mi.getMethod().hashCode()); log.trace("HOMEMETHOD coming in classloader" + mi.getMethod().getDeclaringClass().getClassLoader().hashCode()); log.trace("CONTAINS " + getHomeMapping().containsKey(mi.getMethod())); } Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // Invoke and handle exceptions if (trace) { log.trace("HOMEMETHOD m " + m); java.util.Iterator iterator = getHomeMapping().keySet().iterator(); while (iterator.hasNext()) { Method me = (Method) iterator.next(); if (me.getName().endsWith("create")) { log.trace(me.toString()); log.trace("" + me.hashCode()); log.trace("" + me.getDeclaringClass().getClassLoader().hashCode()); log.trace("equals " + me.equals(mi.getMethod()) + " " + mi.getMethod().equals(me)); } } } try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) getBeanMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // wire the transaction on the context, this is how the instance remember the tx // Unlike Entity beans we can't do that in the previous interceptors (ordering) EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); else if(ejbObjectRemove.equals(miMethod) || ejbLocalObjectRemove.equals(miMethod)) { throw new RemoveException("An attempt to remove a session " + "object while the object is in a transaction " + "(EJB2.1, 7.6.4 Restrictions for Transactions): ejb-name=" + metaData.getEjbName() + ", method=" + mi.getMethod() + ", tx=" + ctx.getTransaction()); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(StatefulSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { // Invoke and handle exceptions try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/Container.java
public Object createBeanClassInstance() throws Exception { return getBeanClass().newInstance(); }
// in src/main/java/org/jboss/ejb/Container.java
protected void createService() throws Exception { // Acquire classes from CL beanClass = classLoader.loadClass(metaData.getEjbClass()); if (metaData.getLocalHome() != null) localHomeInterface = classLoader.loadClass(metaData.getLocalHome()); if (metaData.getLocal() != null) localInterface = classLoader.loadClass(metaData.getLocal()); localProxyFactory.setContainer(this); localProxyFactory.create(); if (localHomeInterface != null) ejbModule.addLocalHome(this, localProxyFactory.getEJBLocalHome()); ejbModule.createMissingPermissions(this, metaData); // Allow the policy to incorporate the policy configs Policy.getPolicy().refresh(); }
// in src/main/java/org/jboss/ejb/Container.java
protected void startService() throws Exception { // Setup "java:comp/env" namespace setupEnvironment(); localProxyFactory.start(); }
// in src/main/java/org/jboss/ejb/Container.java
protected void stopService() throws Exception { localProxyFactory.stop(); removeTimerService(null); teardownEnvironment(); }
// in src/main/java/org/jboss/ejb/Container.java
protected void destroyService() throws Exception { cleanENC(); localProxyFactory.destroy(); ejbModule.removeLocalHome(this); beanClass = null; homeInterface = null; remoteInterface = null; localHomeInterface = null; localInterface = null; methodPermissionsCache.clear(); // InvocationStatistics holds refs to Methods from // application classes, so to avoid a classloader // leak, lets not just resetStats() but also replace // the object invokeStats.resetStats(); // in case someone else has a ref invokeStats = new InvocationStatistics(); marshalledInvocationMapping.clear(); }
// in src/main/java/org/jboss/ejb/Container.java
public Object invoke(Invocation mi) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); long start = System.currentTimeMillis(); Method m = null; Object type = null; String contextID = getJaccContextID(); try { pushENC(); // JBAS-3732 - Remove classloader.equals optimization SecurityActions.setContextClassLoader(this.classLoader); // Set the JACC context id mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID); contextID = SecurityActions.setContextID(contextID); // Set the standard JACC policy context handler data is not a SEI msg if (mi.getType() != InvocationType.SERVICE_ENDPOINT) { EJBArgsPolicyContextHandler.setArgs(mi.getArguments()); } else { SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE); SOAPMsgPolicyContextHandler.setMessage(msg); } // Set custom JACC policy handlers BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData()); // Check against home, remote, localHome, local, getHome, // getRemote, getLocalHome, getLocal type = mi.getType(); // stat gathering: concurrent calls this.invokeStats.callIn(); if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || // web service calls come in as "ordinary" application invocations type == InvocationType.SERVICE_ENDPOINT) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD REMOTE INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||"); } } m = mi.getMethod(); Object obj = internalInvoke(mi); return obj; } else if (type == InvocationType.HOME || type == InvocationType.LOCALHOME) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD HOME INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||" + mi.getArguments().toString()); } } m = mi.getMethod(); Object obj = internalInvokeHome(mi); return obj; } else { throw new MBeanException(new IllegalArgumentException("Unknown invocation type: " + type)); } } /** * Having to catch this exception here in case can not * unmarshall arguments, values, etc. Then, convert to * UnmarshalException as defined by spec (JBAS-2999) */ catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } } finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); } }
// in src/main/java/org/jboss/ejb/Container.java
private void setupEnvironment() throws Exception { BeanMetaData beanMetaData = getBeanMetaData(); // debug log.debug("Begin java:comp/env for EJB: " + beanMetaData.getEjbName()); ClassLoader tcl = SecurityActions.getContextClassLoader(); log.debug("TCL: " + tcl); ORB orb = null; HandleDelegate hd = null; try { orb = (ORB)server.getAttribute(ORB_NAME, "ORB"); hd = (HandleDelegate)server.getAttribute(ORB_NAME, "HandleDelegate"); } catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); } // Since the BCL is already associated with this thread we can start // using the java: namespace directly Context ctx = (Context)new InitialContext().lookup("java:comp"); Object id = ENCFactory.getCurrentId(); log.debug("Using java:comp using id=" + id); // Bind the orb if (orb != null) { NonSerializableFactory.rebind(ctx, "ORB", orb); log.debug("Bound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName()); NonSerializableFactory.rebind(ctx, "HandleDelegate", hd); log.debug("Bound java:comp/HandleDelegate for EJB: " + getBeanMetaData().getEjbName()); } // JTA links ctx.bind("TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry")); log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry"); Context envCtx = ctx.createSubcontext("env"); // Bind environment properties { Iterator i = beanMetaData.getEnvironmentEntries(); while (i.hasNext()) { EnvEntryMetaData entry = (EnvEntryMetaData)i.next(); log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue()); EnvEntryBinder.bindEnvEntry(envCtx, entry); } } // Bind EJB references { Iterator i = beanMetaData.getEjbReferences(); while (i.hasNext()) { EjbRefMetaData ref = (EjbRefMetaData)i.next(); log.debug("Binding an EJBReference " + ref.getName()); if (ref.getLink() != null) { // Internal link String linkName = ref.getLink(); String jndiName = ref.getJndiName(); log.debug("Binding " + ref.getName() + " to ejb-link: " + linkName + " -> " + jndiName); if (jndiName == null) { String msg = "Failed to resolve ejb-link: " + linkName + " from ejb-ref: " + ref.getName() + " in ejb: " + beanMetaData.getEjbName(); throw new DeploymentException(msg); } Util.bind(envCtx, ref.getName(), new LinkRef(jndiName)); } else { // Get the invoker specific ejb-ref mappings Iterator it = beanMetaData.getInvokerBindings(); Reference reference = null; while (it.hasNext()) { String invokerBinding = (String)it.next(); // Check for an invoker level jndi-name String name = ref.getInvokerBinding(invokerBinding); // Check for an global jndi-name if (name == null) name = ref.getJndiName(); if (name == null) { throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml or " + "jndi-name in jboss.xml"); } StringRefAddr addr = new StringRefAddr(invokerBinding, name); log.debug("adding " + invokerBinding + ":" + name + " to Reference"); if (reference == null) { reference = new Reference("javax.naming.LinkRef", ENCThreadLocalKey.class.getName(), null); } reference.add(addr); } // If there were invoker bindings create bind the reference if (reference != null) { if (ref.getJndiName() != null) { // Add default for the bean level ejb-ref/jndi-name StringRefAddr addr = new StringRefAddr("default", ref.getJndiName()); reference.add(addr); } if (reference.size() == 1 && reference.get("default") == null) { /* There is only one invoker binding and its not default so create a default binding to allow the link to have a value when accessed without an invoker active. */ StringRefAddr addr = (StringRefAddr)reference.get(0); String target = (String)addr.getContent(); StringRefAddr addr1 = new StringRefAddr("default", target); reference.add(addr1); } Util.bind(envCtx, ref.getName(), reference); } else { // Bind the bean level ejb-ref/jndi-name if (ref.getJndiName() == null) { throw new DeploymentException("ejb-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or jndi-name in jboss.xml"); } Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } } // Bind Local EJB references { Iterator i = beanMetaData.getEjbLocalReferences(); while (i.hasNext()) { EjbLocalRefMetaData ref = (EjbLocalRefMetaData)i.next(); String refName = ref.getName(); log.debug("Binding an EJBLocalReference " + ref.getName()); if (ref.getLink() != null) { // Internal link log.debug("Binding " + refName + " to bean source: " + ref.getLink()); String jndiName = ref.getJndiName(); Util.bind(envCtx, ref.getName(), new LinkRef(jndiName)); } else { // Bind the bean level ejb-local-ref/local-jndi-name if (ref.getJndiName() == null) { throw new DeploymentException("ejb-local-ref " + ref.getName() + ", expected either ejb-link in ejb-jar.xml " + "or local-jndi-name in jboss.xml"); } Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } // Bind service references { ClassLoader loader = unit.getClassLoader(); UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot()); Iterator<ServiceReferenceMetaData> serviceReferences = beanMetaData.getServiceReferences(); if (serviceReferences != null) { while (serviceReferences.hasNext()) { ServiceReferenceMetaData sref = serviceReferences.next(); String refName = sref.getServiceRefName(); new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref); } } } // Bind resource references { Iterator i = beanMetaData.getResourceReferences(); // let's play guess the cast game ;) New metadata should fix this. ApplicationMetaData application = beanMetaData.getApplicationMetaData(); while (i.hasNext()) { ResourceRefMetaData ref = (ResourceRefMetaData)i.next(); String resourceName = ref.getResourceName(); String finalName = application.getResourceByName(resourceName); String resType = ref.getType(); // If there was no resource-manager specified then an immeadiate // jndi-name or res-url name should have been given if (finalName == null) finalName = ref.getJndiName(); if (finalName == null && resType.equals("java.net.URL") == false) { // the application assembler did not provide a resource manager // if the type is javax.sql.Datasoure use the default one if (ref.getType().equals("javax.sql.DataSource")) { // Go through JNDI and look for DataSource - use the first one Context dsCtx = new InitialContext(); try { // Check if it is available in JNDI dsCtx.lookup("java:/DefaultDS"); finalName = "java:/DefaultDS"; } catch (Exception e) { log.debug("failed to lookup DefaultDS; ignoring", e); } finally { dsCtx.close(); } } // Default failed? Warn user and move on // POTENTIALLY DANGEROUS: should this be a critical error? if (finalName == null) { log.warn("No resource manager found for " + ref.getResourceName()); continue; } } if (resType.equals("java.net.URL")) { // URL bindings if (ref.getResURL() != null) { // The URL string was given by the res-url log.debug("Binding URL: " + ref.getRefName() + " to JDNI ENC as: " + ref.getResURL()); URL resURL = new URL(ref.getResURL()); Util.bind(envCtx, ref.getRefName(), resURL); } else { log.debug("Binding URL: " + ref.getRefName() + " to: " + finalName); Object bind = null; if (ref.getJndiName() != null) { // Was the url given as a jndi-name reference to link to it bind = new LinkRef(finalName); } else { // The url string was given via a resource-name mapping bind = new URL(finalName); } Util.bind(envCtx, ref.getRefName(), bind); } } else { // Resource Manager bindings, should validate the type... log.debug("Binding resource manager: " + ref.getRefName() + " to JDNI ENC as: " + finalName); Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName)); } } } // Bind resource env references { Iterator i = beanMetaData.getResourceEnvReferences(); while (i.hasNext()) { ResourceEnvRefMetaData resRef = (ResourceEnvRefMetaData)i.next(); String encName = resRef.getRefName(); String jndiName = resRef.getJndiName(); // Should validate the type... log.debug("Binding env resource: " + encName + " to JDNI ENC as: " + jndiName); Util.bind(envCtx, encName, new LinkRef(jndiName)); } } // Bind message destination references { Iterator i = beanMetaData.getMessageDestinationReferences(); while (i.hasNext()) { MessageDestinationRefMetaData ref = (MessageDestinationRefMetaData)i.next(); String refName = ref.getRefName(); String jndiName = ref.getJNDIName(); String link = ref.getLink(); if (link != null) { if (jndiName == null) { MessageDestinationMetaData messageDestination = getMessageDestination(link); if (messageDestination == null) throw new DeploymentException("message-destination-ref '" + refName + "' message-destination-link '" + link + "' not found and no jndi-name in jboss.xml"); else { String linkJNDIName = messageDestination.getJndiName(); if (linkJNDIName == null) log.warn("message-destination '" + link + "' has no jndi-name in jboss.xml"); else jndiName = linkJNDIName; } } else log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss.xml"); } else if (jndiName == null) throw new DeploymentException("message-destination-ref '" + refName + "' has no message-destination-link in ejb-jar.xml and no jndi-name in jboss.xml"); Util.bind(envCtx, refName, new LinkRef(jndiName)); } } // Create a java:comp/env/security/security-domain link to the container // or application security-domain if one exists so that access to the // security manager can be made without knowing the global jndi name. String securityDomain = metaData.getContainerConfiguration().getSecurityDomain(); if (securityDomain == null) securityDomain = metaData.getApplicationMetaData().getSecurityDomain(); if (securityDomain != null) { //JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix if(securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false) securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain; log.debug("Binding securityDomain: " + securityDomain + " to JDNI ENC as: security/security-domain"); Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain)); Util.bind(envCtx, "security/subject", new LinkRef(securityDomain + "/subject")); Util.bind(envCtx, "security/realmMapping", new LinkRef(securityDomain + "/realmMapping")); Util.bind(envCtx, "security/authorizationMgr", new LinkRef(securityDomain + "/authorizationMgr")); } log.debug("End java:comp/env for EJB: " + beanMetaData.getEjbName()); }
// in src/main/java/org/jboss/ejb/Container.java
private void teardownEnvironment() throws Exception { Context ctx = (Context)new InitialContext().lookup("java:comp"); ctx.unbind("env"); log.debug("Removed bindings from java:comp/env for EJB: " + getBeanMetaData().getEjbName()); ctx.unbind("TransactionSynchronizationRegistry"); log.debug("Unbound java:comp/TransactionSynchronizationRegistry for EJB: " + getBeanMetaData().getEjbName()); try { NonSerializableFactory.unbind("ORB"); log.debug("Unbound java:comp/ORB for EJB: " + getBeanMetaData().getEjbName()); NonSerializableFactory.unbind("HandleDelegate"); log.debug("Unbound java:comp/HandleDelegate for EJB: " + getBeanMetaData().getEjbName()); } catch (NamingException ignored) { } }
// in src/main/java/org/jboss/ejb/Container.java
protected void rethrow(Exception e) throws Exception { if (e instanceof IllegalAccessException) { // Throw this as a bean exception...(?) throw new EJBException(e); } else if (e instanceof InvocationTargetException) { Throwable t = ((InvocationTargetException)e).getTargetException(); if (t instanceof EJBException) { throw (EJBException)t; } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new NestedError("Unexpected Throwable", t); } } throw e; }
// in src/main/java/org/jboss/ejb/Container.java
public Object run() throws Exception { Object rtnValue = server.invoke(target, method, args, sig); return rtnValue; }
// in src/main/java/org/jboss/ejb/Container.java
Object invoke(ObjectName target, String method, Object[] args, String[] sig) throws Exception { SecurityManager sm = System.getSecurityManager(); Object rtnValue = null; if (sm == null) { // Direct invocation on MBeanServer rtnValue = server.invoke(target, method, args, sig); } else { try { // Encapsulate the invocation in a PrivilegedExceptionAction MBeanServerAction action = new MBeanServerAction(target, method, args, sig); rtnValue = AccessController.doPrivileged(action); } catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; } } return rtnValue; }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
private BeanLock createLock(Object id) throws Exception { BeanLock lock = (BeanLock) lockClass.newInstance(); lock.setId(id); lock.setTimeout(txTimeout); lock.setContainer(container); return lock; }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
protected void createService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default init super.createService(); // Map the bean methods Map map = new HashMap(); MessageDrivenMetaData mdMetaData = (MessageDrivenMetaData)metaData; String type = mdMetaData.getMessagingType(); if(type == null || type.length() == 0) type = MessageDrivenMetaData.DEFAULT_MESSAGING_TYPE; Class clazz = getClassLoader().loadClass(type); Method[] methods = clazz.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { Method m = methods[i]; map.put(m, beanClass.getMethod(m.getName(), m.getParameterTypes())); log.debug("Mapped " + m.getName() + " " + m.hashCode() + " to " + map.get(m)); } if( TimedObject.class.isAssignableFrom( beanClass ) ) { // Map ejbTimeout map.put( TimedObject.class.getMethod( "ejbTimeout", new Class[] { Timer.class } ), beanClass.getMethod( "ejbTimeout", new Class[] { Timer.class } ) ); } beanMapping = map; // Try to register the instance pool as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instancePool, poolName); } catch(Throwable t) { log.debug("Failed to register pool as mbean", t); } // Initialize pool instancePool.setContainer(this); instancePool.create(); for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); // Try to register the container invoker as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "invoker"); props.put("binding", invokerBinding); ObjectName invokerName = new ObjectName(containerName.getDomain(), props); server.registerMBean(ci, invokerName); } catch(Throwable t) { log.debug("Failed to register invoker binding as mbean", t); } ci.create(); } // Initialize the interceptor by calling the chain Interceptor in = interceptor; while (in != null) { in.setContainer(this); in.create(); in = in.getNext(); } } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
protected void startService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default start super.startService(); // Start the instance pool instancePool.start(); // Start all interceptors in the chain Interceptor in = interceptor; while (in != null) { in.start(); in = in.getNext(); } // Start container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.start(); } // Restore persisted ejb timers restoreTimers(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
protected void stopService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default stop super.stopService(); // Stop container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.stop(); } // Stop the instance pool instancePool.stop(); // Stop all interceptors in the chain Interceptor in = interceptor; while (in != null) { in.stop(); in = in.getNext(); } } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
protected void destroyService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Destroy container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext();) { String invokerBinding = (String) it.next(); EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding); ci.destroy(); try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "invoker"); props.put("binding", invokerBinding); ObjectName invokerName = new ObjectName(containerName.getDomain(), props); server.unregisterMBean(invokerName); } catch(Throwable ignore) { } } // Destroy the pool instancePool.destroy(); instancePool.setContainer(null); try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.unregisterMBean(poolName); } catch(Throwable ignore) { } // Destroy all the interceptors in the chain Interceptor in = interceptor; while (in != null) { in.destroy(); in.setContainer(null); in = in.getNext(); } // Call default destroy super.destroyService(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { throw new Error("invokeHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object internalInvoke(Invocation mi) throws Exception { SecurityContext cachedContext = null; try { cachedContext = SecurityActions.getSecurityContext(); //For message driven beans, there is no security context SecurityActions.setSecurityContext(null); // Invoke through interceptors return getInterceptor().invoke(mi); } finally { SecurityActions.setSecurityContext(cachedContext); } }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invokeHome(Invocation mi) throws Exception { throw new Error("invokeHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); // wire the transaction on the context, // this is how the instance remember the tx if (ctx.getTransaction() == null) { ctx.setTransaction(mi.getTransaction()); } // Get method and instance to invoke upon Method m = (Method) beanMapping.get(mi.getMethod()); if( m == null ) { // This is a configuration error that should have been caught earlier String msg = MessageDrivenContainer.this.getBeanMetaData().getEjbName() + " Invalid invocation, check your deployment packaging, interfaces, method=" + mi.getMethod(); throw new EJBException(msg); } // we have a method that needs to be done by a bean instance try { messageCount++; return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Get context EntityContainer container = (EntityContainer) getContainer(); EntityEnterpriseContext ctx = (EntityEnterpriseContext) container.getInstancePool().get(); ctx.setTxAssociation(GlobalTxEntityMap.NOT_READY); InstancePool pool = container.getInstancePool(); // Pass it to the method invocation mi.setEnterpriseContext(ctx); // Give it the transaction ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME); // Invoke through interceptors Object obj = null; Exception exception = null; try { obj = getNext().invokeHome(mi); // Is the context now with an identity? in which case we need to insert if (ctx.getId() != null) { BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey()); lock.sync(); // lock all access to BeanLock try { // Check there isn't a context already in the cache // e.g. commit-option B where the entity was // created then removed externally InstanceCache cache = container.getInstanceCache(); cache.remove(ctx.getCacheKey()); // marcf: possible race on creation and usage // insert instance in cache, cache.insert(ctx); } finally { lock.releaseSync(); container.getLockManager().removeLockRef(ctx.getCacheKey()); } // we are all done return obj; } } catch (Exception e) { exception = e; } finally { AllowedOperationsAssociation.popInMethodFlag(); } ctx.setTransaction(null); // EntityCreateInterceptor will access ctx if it is not null and call postCreate mi.setEnterpriseContext(null); // if we get to here with a null exception then our invocation is // just a home invocation. Return our instance to the instance pool if (exception == null) { container.getInstancePool().free(ctx); return obj; } if (exception instanceof RuntimeException) { // if we get to here with a RuntimeException, we have a system exception. // EJB 2.1 section 18.3.1 says we need to discard our instance. pool.discard(ctx); } else { // if we get to here with an Exception, we have an application exception. // EJB 2.1 section 18.3.1 says we can keep the instance. We need to return // our instance to the instance pool so we dont get a memory leak. pool.free(ctx); } throw exception; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected void createService() throws Exception { this.beans = new HashMap(1000); String ejbName = con.getBeanMetaData ().getEjbName (); idField = con.getBeanClass ().getField ("id"); log.debug("Using id field: " + idField); // Lookup the isModified method if it exists try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) { isModified = null; // Has to have "boolean" as return type! log.warn("Found isModified method, but return type is not boolean; ignoring"); } else { log.debug("Using isModified method: " + isModified); } } catch (NoSuchMethodException ignored) {} }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected void stopService() throws Exception { this.beans.clear(); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object createBeanClassInstance () throws Exception { return con.getBeanClass ().newInstance (); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object createEntity (Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get (ctx.getInstance ()); // Check exist if (this.beans.containsKey (id)) throw new javax.ejb.DuplicateKeyException ("Already exists: "+id); // Store to file storeEntity (id, ctx.getInstance ()); return id; } catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object postCreateEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { return null; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object findEntity (Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if (finderMethod.getName ().equals ("findByPrimaryKey")) { if (!this.beans.containsKey (args[0])) throw new javax.ejb.FinderException (args[0]+" does not exist"); return factory.getEntityEJBObject(args[0]); } return null; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Collection findEntities(final Method finderMethod, final Object[] args, final EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if (finderMethod.getName ().equals ("findAll")) { return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, this.beans.keySet()); } else { // we only support find all return Collections.EMPTY_LIST; } }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public boolean isStoreRequired (EntityEnterpriseContext ctx) throws Exception { if(isModified == null) { return true; } Boolean modified = (Boolean) isModified.invoke (ctx.getInstance (), new Object[0]); return modified.booleanValue (); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public boolean isModified(EntityEnterpriseContext ctx) throws Exception { return isStoreRequired(ctx); }
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke through interceptors return getNext().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/plugins/EntityLockInterceptor.java
public Object invoke(Invocation mi) throws Exception { // The key. Object key = mi.getId(); // The lock. BeanLock lock ; boolean threadIsScheduled = false; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Begin invoke, key="+key); lock = container.getLockManager().getLock(key); try { lock.schedule(mi); try { return getNext().invoke(mi); } finally { // we are done with the method, decrease the count, if it reaches 0 it will wake up // the next thread lock.sync(); lock.endInvocation(mi); lock.releaseSync(); } } finally { // We are done with the lock in general container.getLockManager().removeLockRef(key); if( trace ) log.trace("End invoke, key="+key); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
public void start() throws Exception { super.start(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Apply any custom security checks if( securityProxy != null ) { EJBContext ctx = null; EnterpriseContext ectx = (EnterpriseContext)mi.getEnterpriseContext(); if( ectx != null ) ctx = ectx.getEJBContext(); Object[] args = mi.getArguments(); securityProxy.setEJBContext(ctx); try { securityProxy.invokeHome(mi.getMethod(), args); } catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; } } return getNext().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
public Object invoke(Invocation mi) throws Exception { // Apply any custom security checks if( securityProxy != null ) { EnterpriseContext ectx = (EnterpriseContext)mi.getEnterpriseContext(); Object bean = ectx.getInstance(); EJBContext ctx = ectx.getEJBContext(); Object[] args = mi.getArguments(); securityProxy.setEJBContext(ctx); try { securityProxy.invoke(mi.getMethod(), args, bean); } catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; } } return getNext().invoke(mi); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void startService() throws Exception { // Lets take a reference to our metadata metaData = (MessageDrivenMetaData) container.getBeanMetaData(); // Resolve the message listener resolveMessageListener(); // Resolve the resource adapter resolveResourceAdapter(); // Create the activation config createActivationSpec(); // Set up proxy parameters setupProxyParameters(); // Activate activate(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
protected void stopService() throws Exception { // Deactivate deactivate(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void startDelivery() throws Exception { if (getState() != STARTED) throw new IllegalStateException("The MDB is not started"); if (deliveryActive.getAndSet(true)) return; activate(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void stopDelivery() throws Exception { stopDelivery(false); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void stopDelivery(boolean asynch) throws Exception { if (getState() != STARTED) throw new IllegalStateException("The MDB is not started"); if (deliveryActive.getAndSet(false) == false) return; if (asynch) { new Thread("StopDelivery: " + getServiceName()) { public void run() { deactivate(); } }.start(); } else { deactivate(); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstancePool.java
protected void createService() throws Exception { super.createService(); // for SLSB, we *do* pool this.reclaim = true; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { return new StatelessSessionEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactory.java
public KeyGenerator getKeyGenerator() throws Exception { return new UUIDKeyGenerator(); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public void setDataSource(ObjectName dataSource) throws Exception { if(getState() == STARTED && !dataSource.equals(this.dataSource)) { ds = lookupDataSource(dataSource); } this.dataSource = dataSource; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public void setTableName(String tableName) throws Exception { if(getState() == STARTED && !tableName.equals(this.tableName)) { initSequence(tableName, sequenceColumn, sequenceName, idColumnName); } this.tableName = tableName; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public KeyGenerator getKeyGenerator() throws Exception { return new HiLoKeyGenerator(ds, tableName, sequenceColumn, sequenceName, idColumnName, selectHiSql, blockSize, tm); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public void startService() throws Exception { Context ctx = new InitialContext(); // bind the factory Util.rebind(ctx, getFactoryName(), this); tm = (TransactionManager)ctx.lookup("java:/TransactionManager"); ds = lookupDataSource(dataSource); initSequence(tableName, sequenceColumn, sequenceName, idColumnName); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
public void stopService() throws Exception { if(dropTable) { dropTableIfExists(tableName); } ds = null; tm = null; // unbind the factory Context ctx = new InitialContext(); Util.unbind(ctx, getFactoryName()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private DataSource lookupDataSource(ObjectName dataSource) throws Exception { try { String dsJndi = (String) server.getAttribute(dataSource, "BindName"); return (DataSource)new InitialContext().lookup(dsJndi); } catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invoke(mi); } finally { } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { Method getEJBObject = Handle.class.getMethod("getEJBObject", new Class[0]); //Invocation on the handle, we don't need a bean instance if (getEJBObject.equals(mi.getMethod())) return getNext().invokeHome(mi); EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invokeHome(mi); } finally { } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void create() throws Exception { ejbLoad = EntityBean.class.getMethod("ejbLoad", new Class[0]); ejbStore = EntityBean.class.getMethod("ejbStore", new Class[0]); ejbActivate = EntityBean.class.getMethod("ejbActivate", new Class[0]); ejbPassivate = EntityBean.class.getMethod("ejbPassivate", new Class[0]); ejbRemove = EntityBean.class.getMethod("ejbRemove", new Class[0]); // Create cache of create methods if (con.getHomeClass() != null) { Method[] methods = con.getHomeClass().getMethods(); createMethodCache( methods ); } if (con.getLocalHomeClass() != null) { Method[] methods = con.getLocalHomeClass().getMethods(); createMethodCache( methods ); } try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) isModified = null; // Has to have "boolean" as return type! } catch (NoSuchMethodException ignored) {} }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public Object createBeanClassInstance() throws Exception { return con.getBeanClass().newInstance(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void createEntity( Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { Object id = null; try { // Call ejbCreate<METHOD) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); Method createMethod = (Method)createMethods.get(m); id = createMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } // set the id ctx.setId(id); // Create a new CacheKey Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id ); // Give it to the context ctx.setCacheKey(cacheKey); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void postCreateEntity( Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_POST_CREATE); Method postCreateMethod = (Method)postCreateMethods.get(m); postCreateMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); // call the finder method Object objectId = callFinderMethod(finderMethod, args, ctx); final Object cacheKey = ((EntityCache)con.getInstanceCache()).createCacheKey( objectId ); return factory.getEntityEJBObject(cacheKey); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { // call the finder method Object result; try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); result = callFinderMethod(finderMethod, args, ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } if (result == null) { // for EJB 1.0 compliance // if the bean couldn't find any matching entities // it returns null, so we return an empty collection return new ArrayList(); } if (result instanceof java.util.Enumeration) { // to preserve 1.0 spec compatiblity ArrayList array = new ArrayList(); Enumeration e = (Enumeration) result; while (e.hasMoreElements() == true) { // Wrap a cache key around the given object id/primary key final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(e.nextElement()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o); } return array; } else if (result instanceof java.util.Collection) { ArrayList array = new ArrayList(((Collection) result).size()); Iterator i = ((Collection) result).iterator(); while (i.hasNext()) { // Wrap a cache key around the given object id/primary key final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(i.next()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o); } return array; } else { // so we received something that's not valid // throw an exception reporting it throw new EJBException("result of finder method is not a valid " + "return type: " + result.getClass()); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public boolean isStoreRequired(EntityEnterpriseContext ctx) throws Exception { if(isModified == null) { return true; } Boolean modified = (Boolean) isModified.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); return modified.booleanValue(); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public boolean isModified(EntityEnterpriseContext ctx) throws Exception { return isStoreRequired(ctx); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
private Object callFinderMethod(Method finderMethod, Object[] args, EntityEnterpriseContext ctx) throws Exception { // get the finder method Method callMethod = (Method)finderMethods.get(finderMethod); if (callMethod == null) { throw new EJBException("couldn't find finder method in bean class. " + finderMethod.toString()); } // invoke the finder method Object result = null; try { result = callMethod.invoke(ctx.getInstance(), args); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } } return result; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
protected void createService() throws Exception { // Initialize the dataStore String ejbName = con.getBeanMetaData().getEjbName(); // Get the system data directory File dir = new File(ServerConfigLocator.locate().getServerTempLocation().toURI()); // Setup the reference to the session data store directory dir = new File(dir, storeDirName); // ejbName is not unique across all deployments, so use a unique token dir = new File(dir, ejbName + "-" + new UID().toString()); storeDir = dir; log.debug("Storing sessions for '" + ejbName + "' in: " + storeDir); // if the directory does not exist then try to create it if( !storeDir.exists() ) { if( MkdirsFileAction.mkdirs(storeDir) == false ) { throw new IOException("Failed to create directory: " + storeDir); } } // make sure we have a directory if( !storeDir.isDirectory() ) { throw new IOException("File exists where directory expected: " + storeDir); } // make sure we can read and write to it if( !storeDir.canWrite() || !storeDir.canRead() ) { throw new IOException("Directory must be readable and writable: " + storeDir); } // Purge state session state files, should be none, due to unique directory purgeAllSessionData(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
protected void destroyService() throws Exception { // Purge data and attempt to delete directory purgeAllSessionData(); // Nuke the directory too if purge is enabled if( purgeEnabled && !storeDir.delete() ) { log.warn("Failed to delete session state storage directory: " + storeDir); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public Object createId(StatefulSessionEnterpriseContext ctx) throws Exception { return new UID(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void createdSession(StatefulSessionEnterpriseContext ctx) throws Exception { // nothing }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public Object run() throws Exception { FileInputStream fis = new FileInputStream(file); return fis; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public Object run() throws Exception { FileOutputStream fis = new FileOutputStream(file); return fis; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public void create() throws Exception { super.create(); BeanMetaData bmd = getContainer().getBeanMetaData(); exceptionRollback = bmd.getExceptionRollback(); if (exceptionRollback == false) exceptionRollback = bmd.getApplicationMetaData().getExceptionRollback(); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public Object invokeHome(Invocation invocation) throws Exception { Transaction oldTransaction = invocation.getTransaction(); for (int i = 0; i < MAX_RETRIES; i++) { try { return runWithTransactions(invocation); } catch (Exception ex) { checkRetryable(i, ex, oldTransaction); } } throw new RuntimeException("Unreachable"); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public Object invoke(Invocation invocation) throws Exception { Transaction oldTransaction = invocation.getTransaction(); for (int i = 0; i < MAX_RETRIES; i++) { try { return runWithTransactions(invocation); } catch (Exception ex) { checkRetryable(i, ex, oldTransaction); } } throw new RuntimeException("Unreachable"); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private void checkRetryable(int i, Exception ex, Transaction oldTransaction) throws Exception { // if oldTransaction != null this means tx was propagated over the wire // and we cannot retry it if (i + 1 >= MAX_RETRIES || oldTransaction != null) throw ex; // Keep ADE check for backward compatibility ApplicationDeadlockException deadlock = isADE(ex); if (deadlock != null) { if (!deadlock.retryable()) throw deadlock; log.debug(deadlock.getMessage() + " retrying tx " + (i + 1)); } else if (retryHandlers != null) { boolean retryable = false; for (int j = 0; j < retryHandlers.length; j++) { retryable = retryHandlers[j].retry(ex); if (retryable) break; } if (!retryable) throw ex; log.debug(ex.getMessage() + " retrying tx " + (i + 1)); } else { throw ex; } Thread.sleep(random.nextInt(1 + i), random.nextInt(1000)); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private Object runWithTransactions(Invocation invocation) throws Exception { // Old transaction is the transaction that comes with the MI Transaction oldTransaction = invocation.getTransaction(); // New transaction is the new transaction this might start Transaction newTransaction = null; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Current transaction in MI is " + oldTransaction); InvocationType type = invocation.getType(); byte transType = container.getBeanMetaData().getTransactionMethod(invocation.getMethod(), type); if ( trace ) printMethod(invocation.getMethod(), transType); // Thread arriving must be clean (jboss doesn't set the thread // previously). However optimized calls come with associated // thread for example. We suspend the thread association here, and // resume in the finally block of the following try. Transaction threadTx = tm.suspend(); if( trace ) log.trace("Thread came in with tx " + threadTx); try { switch (transType) { case MetaData.TX_NOT_SUPPORTED: { // Do not set a transaction on the thread even if in MI, just run try { invocation.setTransaction(null); return invokeNext(invocation, false); } finally { invocation.setTransaction(oldTransaction); } } case MetaData.TX_REQUIRED: { int oldTimeout = 0; Transaction theTransaction = oldTransaction; if (oldTransaction == null) { // No tx running // Create tx oldTimeout = startTransaction(invocation); // get the tx newTransaction = tm.getTransaction(); if( trace ) log.trace("Starting new tx " + newTransaction); // Let the method invocation know invocation.setTransaction(newTransaction); theTransaction = newTransaction; } else { // We have a tx propagated // Associate it with the thread tm.resume(oldTransaction); } // Continue invocation try { Object result = invokeNext(invocation, oldTransaction != null); checkTransactionStatus(theTransaction, type); return result; } finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); } } case MetaData.TX_SUPPORTS: { // Associate old transaction with the thread // Some TMs cannot resume a null transaction and will throw // an exception (e.g. Tyrex), so make sure it is not null if (oldTransaction != null) { tm.resume(oldTransaction); } try { Object result = invokeNext(invocation, oldTransaction != null); if (oldTransaction != null) checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } // Even on error we don't do anything with the tx, // we didn't start it } case MetaData.TX_REQUIRES_NEW: { // Always begin a transaction int oldTimeout = startTransaction(invocation); // get it newTransaction = tm.getTransaction(); // Set it on the method invocation invocation.setTransaction(newTransaction); // Continue invocation try { Object result = invokeNext(invocation, false); checkTransactionStatus(newTransaction, type); return result; } finally { // We started the transaction for sure so we commit or roll back endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); } } case MetaData.TX_MANDATORY: { if (oldTransaction == null) { if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new TransactionRequiredLocalException( "Transaction Required"); } else { throw new TransactionRequiredException( "Transaction Required"); } } // Associate it with the thread tm.resume(oldTransaction); try { Object result = invokeNext(invocation, true); checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } } case MetaData.TX_NEVER: { if (oldTransaction != null) { throw new EJBException("Transaction not allowed"); } return invokeNext(invocation, false); } default: log.error("Unknown TX attribute "+transType+" for method"+invocation.getMethod()); } } finally { // IN case we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } return null; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private int startTransaction(final Invocation invocation) throws Exception { // Get the old timeout and set any new timeout int oldTimeout = -1; if (tm instanceof TransactionTimeoutConfiguration) { oldTimeout = ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); int newTimeout = container.getBeanMetaData().getTransactionTimeout(invocation.getMethod()); tm.setTransactionTimeout(newTimeout); } tm.begin(); return oldTimeout; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
public void remove(String id) throws Exception { EntityMetaData metaData = (EntityMetaData) m_container.getBeanMetaData(); String primKeyClass = metaData.getPrimaryKeyClass(); Object key = PropertyEditors.convertValue(id, primKeyClass); remove(key); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
protected EnterpriseContext acquireContext() throws Exception { return m_container.getInstancePool().get(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() throws Exception { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain, final Subject subject) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { // The instance is created by the caller and is a newInstance(); return new StatefulSessionEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
public void start() throws Exception { super.start(); log.debug("Starting InvalidableEntityInstanceCache..."); EntityMetaData emd = ((EntityMetaData) this.getContainer().getBeanMetaData()); boolean participateInDistInvalidations = emd.doDistributedCacheInvalidations(); byte co = emd.getContainerConfiguration().getCommitOption(); if (participateInDistInvalidations && (co == ConfigurationMetaData.A_COMMIT_OPTION || co == ConfigurationMetaData.D_COMMIT_OPTION) ) { // we are interested in receiving cache invalidation callbacks // String groupName = emd.getDistributedCacheInvalidationConfig().getInvalidationGroupName(); String imName = emd.getDistributedCacheInvalidationConfig().getInvalidationManagerName(); this.invalMgr = (InvalidationManagerMBean) Registry.lookup(imName); this.ig = this.invalMgr.getInvalidationGroup(groupName); this.ig.register(this); this.isTraceEnabled = log.isTraceEnabled(); } }
// in src/main/java/org/jboss/ejb/plugins/lock/NoLock.java
public void schedule(Invocation mi) throws Exception { return; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean isTxExpired(Transaction miTx) throws Exception { return TxUtils.isRollback(miTx); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
public void schedule(Invocation mi) throws Exception { boolean threadScheduled = false; while (!threadScheduled) { /* loop on lock wakeup and restart trying to schedule */ threadScheduled = doSchedule(mi); } }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean doSchedule(Invocation mi) throws Exception { boolean wasThreadScheduled = false; Transaction miTx = mi.getTransaction(); boolean trace = log.isTraceEnabled(); this.sync(); try { if (trace) log.trace("Begin schedule, key=" + mi.getId()); if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } //Next test is independent of whether the context is locked or not, it is purely transactional // Is the instance involved with another transaction? if so we implement pessimistic locking long startWait = System.currentTimeMillis(); try { wasThreadScheduled = waitForTx(miTx, trace); if (wasThreadScheduled && lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } } catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; } } finally { if (miTx == null // non-transactional && wasThreadScheduled) { // if this non-transctional thread was // scheduled in txWaitQueue, we need to call nextTransaction // Otherwise, threads in txWaitQueue will never wake up. nextTransaction(); } this.releaseSync(); } //If we reach here we are properly scheduled to go through so return true return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean waitForTx(Transaction miTx, boolean trace) throws Exception { boolean intr = false; try { boolean wasScheduled = false; // Do we have a running transaction with the context? // We loop here until either until success or until transaction timeout // If we get out of the loop successfully, we can successfully // set the transaction on this puppy. TxLock txLock = null; Object deadlocker = miTx; if (deadlocker == null) deadlocker = Thread.currentThread(); while (getTransaction() != null && // And are we trying to enter with another transaction? !getTransaction().equals(miTx)) { // Check for a deadlock on every cycle try { if( deadlockDetection == true ) DeadlockDetector.singleton.deadlockDetection(deadlocker, this); } catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; } wasScheduled = true; if (lockMonitor != null) lockMonitor.contending(); // That's no good, only one transaction per context // Let's put the thread to sleep the transaction demarcation will wake them up if (trace) log.trace("Transactional contention on context" + id); // Only queue the lock on the first iteration if (txLock == null) txLock = getTxLock(miTx); if (trace) log.trace("Begin wait on Tx=" + getTransaction()); // And lock the threads on the lock corresponding to the Tx in MI synchronized (txLock) { releaseSync(); try { txLock.wait(txTimeout); } catch (InterruptedException ignored) { intr = true; } } // end synchronized(txLock) this.sync(); if (trace) log.trace("End wait on TxLock=" + getTransaction()); if (isTxExpired(miTx)) { log.error(Thread.currentThread() + "Saw rolled back tx=" + miTx + " waiting for txLock" // +" On method: " + mi.getMethod().getName() // +" txWaitQueue size: " + txWaitQueue.size() ); if (txLock.isQueued) { // Remove the TxLock from the queue because this thread is exiting. // Don't worry about notifying other threads that share the same transaction. // They will timeout and throw the below RuntimeException txLocks.remove(txLock); txWaitQueue.remove(txLock); } else if (getTransaction() != null && getTransaction().equals(miTx)) { // We're not qu nextTransaction(); } if (miTx != null) { if( deadlockDetection == true ) DeadlockDetector.singleton.removeWaiting(deadlocker); } throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } // end while(tx!=miTx) // If we get here, this means that we have the txlock if (!wasScheduled) { setTransaction(miTx); } return wasScheduled; } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void create() throws Exception { getCache().create(); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void start() throws Exception { getCache().start(); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { throw new Error("Not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context MessageDrivenContainer mdc = (MessageDrivenContainer) container; InstancePool pool = mdc.getInstancePool(); EnterpriseContext ctx = null; try { ctx = pool.get(); } catch (EJBException e) { throw e; } catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Use this context mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); // There is no need for synchronization since the instance is always // fresh also there should never be a tx associated with the instance. try { // Invoke through interceptors Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free((EnterpriseContext) mi.getEnterpriseContext()); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInterceptor.java
public void create() throws Exception { // empty }
// in src/main/java/org/jboss/ejb/plugins/AbstractInterceptor.java
public void start() throws Exception { // empty }
// in src/main/java/org/jboss/ejb/plugins/AbstractInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { // assert mi != null; return getNext().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // assert mi != null; return getNext().invoke(mi); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { return new EntityEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
public void create() throws Exception { try { ConfigurationMetaData configuration = container.getBeanMetaData().getContainerConfiguration(); commitOption = configuration.getCommitOption(); optionDRefreshRate = configuration.getOptionDRefreshRate(); } catch(Exception e) { log.warn(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); Transaction tx = mi.getTransaction(); Object rtn = getNext().invokeHome(mi); // An anonymous context was sent in, so if it has an id it is a real instance now if(ctx.getId() != null) { // it doesn't need to be read, but it might have been changed from the db already. ctx.setValid(true); if(tx != null) { BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey()); try { lock.schedule(mi); register(ctx, tx); // Set tx lock.endInvocation(mi); } finally { container.getLockManager().removeLockRef(lock.getId()); } } } return rtn; }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); // The Tx coming as part of the Method Invocation Transaction tx = mi.getTransaction(); if(log.isTraceEnabled()) log.trace("invoke called for ctx " + ctx + ", tx=" + tx); if(!ctx.isValid()) { container.getPersistenceManager().loadEntity(ctx); ctx.setValid(true); } // mark the context as read only if this is a readonly method and the context // was not already readonly boolean didSetReadOnly = false; if(!ctx.isReadOnly() && (container.isReadOnly() || container.getBeanMetaData().isMethodReadOnly(mi.getMethod()))) { ctx.setReadOnly(true); didSetReadOnly = true; } // So we can go on with the invocation // Invocation with a running Transaction try { if(tx != null && tx.getStatus() != Status.STATUS_NO_TRANSACTION) { // readonly does not synchronize, lock or belong with transaction. boolean isReadOnly = container.isReadOnly(); if(isReadOnly == false) { Method method = mi.getMethod(); if(method != null) isReadOnly = container.getBeanMetaData().isMethodReadOnly(method.getName()); } try { if(isReadOnly == false) { // register the wrapper with the transaction monitor (but only // register once). The transaction demarcation will trigger the // storage operations register(ctx, tx); } //Invoke down the chain Object retVal = getNext().invoke(mi); // Register again as a finder in the middle of a method // will de-register this entity, and then the rest of the method can // change fields which will never be stored if(isReadOnly == false) { // register the wrapper with the transaction monitor (but only // register once). The transaction demarcation will trigger the // storage operations register(ctx, tx); } // return the return value return retVal; } finally { // We were read-only and the context wasn't already synchronized, tidyup the cache if(isReadOnly && ctx.hasTxSynchronization() == false) { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // FIXME: We cannot passivate here, because previous // interceptors work with the context, in particular // the re-entrance interceptor is doing lock counting // Just remove it from the cache if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } } } else { // No tx try { Object result = getNext().invoke(mi); // Store after each invocation -- not on exception though, or removal // And skip reads too ("get" methods) if(ctx.getId() != null && !container.isReadOnly()) { container.invokeEjbStore(ctx); container.storeEntity(ctx); } return result; } catch(Exception e) { // Exception - force reload on next call ctx.setValid(false); throw e; } finally { switch(commitOption) { // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: // Invalidate state (there might be other points of entry) ctx.setValid(false); break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: try { // Do not call release if getId() is null. This means that // the entity has been removed from cache. // release will schedule a passivation and this removed ctx // could be put back into the cache! // This is necessary because we have no lock, we // don't want to return an instance to the pool that is // being used if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); } catch(Exception e) { log.debug("Exception releasing context", e); } break; } } } } finally { // if we marked the context as read only we need to reset it if(didSetReadOnly) { ctx.setReadOnly(false); } } }
// in src/main/java/org/jboss/ejb/plugins/EntityCreationInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke through interceptors Object retVal = getNext().invokeHome(mi); // Is the context now with an identity? // This means that a create method was called, so invoke ejbPostCreate. EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); if(ctx != null && ctx.getId() != null) { // copy from the context into the mi // interceptors down the chain look in the mi for the id not the ctx. mi.setId(ctx.getId()); // invoke down the invoke chain // the final interceptor in EntityContainer will redirect this // call to postCreateEntity, which calls ejbPostCreate getNext().invoke(mi); // now it's ready and can be scheduled for the synchronization if(TxUtils.isActive(mi.getTransaction())) { GlobalTxEntityMap.NONE.scheduleSync(mi.getTransaction(), ctx); } } return retVal; }
// in src/main/java/org/jboss/ejb/plugins/EntityCreationInterceptor.java
public Object invoke(Invocation mi) throws Exception { // nothing to see here... move along return getNext().invoke(mi); }
// in src/main/java/org/jboss/ejb/plugins/CallValidationInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { validateArguments(mi); Object obj = getNext().invokeHome(mi); return validateReturnValue(mi, obj); }
// in src/main/java/org/jboss/ejb/plugins/CallValidationInterceptor.java
public Object invoke(final Invocation mi) throws Exception { validateArguments(mi); Object obj = getNext().invoke(mi); return validateReturnValue(mi, obj); }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
public void start() throws Exception { super.start(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Apply any declarative security checks checkSecurityAssociation(mi); Object returnValue = getNext().invokeHome(mi); return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
public Object invoke(Invocation mi) throws Exception { // Authenticate the subject and apply any declarative security checks checkSecurityAssociation(mi); Object returnValue = getNext().invoke(mi); return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/SecurityRolesInterceptor.java
private void checkSecurityAssociation(Invocation mi) throws Exception { Principal principal = mi.getPrincipal(); boolean trace = log.isTraceEnabled(); if (realmMapping == null) { throw new EJBException("checkSecurityAssociation", new SecurityException("Role mapping manager has not been set")); } // Get the method permissions InvocationType iface = mi.getType(); Set methodRoles = container.getMethodPermissions(mi.getMethod(), iface); if (methodRoles == null) { String method = mi.getMethod().getName(); String msg = "No method permissions assigned to method=" + method + ", interface=" + iface; log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } else if (trace) { log.trace("method=" + mi.getMethod() + ", interface=" + iface + ", requiredRoles=" + methodRoles); } // Check if the caller is allowed to access the method RunAsIdentity callerRunAsIdentity = SecurityAssociation.peekRunAsIdentity(); if (methodRoles.contains(AnybodyPrincipal.ANYBODY_PRINCIPAL) == false) { // The caller is using a the caller identity if (callerRunAsIdentity == null) { // Now actually check if the current caller has one of the required method roles if (realmMapping.doesUserHaveRole(principal, methodRoles) == false) { Set userRoles = realmMapping.getUserRoles(principal); String method = mi.getMethod().getName(); String msg = "Insufficient method permissions, principal=" + principal + ", method=" + method + ", interface=" + iface + ", requiredRoles=" + methodRoles + ", principalRoles=" + userRoles; log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } } // The caller is using a run-as identity else { // Check that the run-as role is in the set of method roles if (callerRunAsIdentity.doesUserHaveRole(methodRoles) == false) { String method = mi.getMethod().getName(); String msg = "Insufficient method permissions, runAsPrincipal=" + callerRunAsIdentity.getName() + ", method=" + method + ", interface=" + iface + ", requiredRoles=" + methodRoles + ", runAsRoles=" + callerRunAsIdentity.getRunAsRoles(); log.error(msg); SecurityException e = new SecurityException(msg); throw new EJBException("checkSecurityAssociation", e); } } } }
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
public void start() throws Exception { super.start(); }
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { boolean isInvokeMethod = false; return this.process(mi, isInvokeMethod); }
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean isInvokeMethod = true; return this.process(mi, isInvokeMethod); }
// in src/main/java/org/jboss/ejb/plugins/RunAsSecurityInterceptor.java
public Object process(Invocation mi, boolean isInvokeMethod) throws Exception { String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(securityManager != null) { securityDomain = securityManager.getSecurityDomain(); } if (log.isTraceEnabled()) { log.trace("Bean:"+ container.getServiceName() + " securityDomain="+securityDomain + " isInvokeMethod="+ isInvokeMethod); } //Establish a security context if one is missing for Run-As push if(SecurityActions.getSecurityContext() == null) { SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain); } /* If a run-as role was specified, push it so that any calls made by this bean will have the runAsRole available for declarative security checks. */ SecurityActions.pushRunAsIdentity(runAsIdentity); SecurityActions.pushCallerRunAsIdentity(runAsIdentity); if (log.isTraceEnabled()) { log.trace("Security Context = " + SecurityActions.trace(SecurityActions.getSecurityContext())); } try { if(isInvokeMethod) return getNext().invoke(mi); else return getNext().invokeHome(mi); } finally { SecurityActions.popRunAsIdentity(); SecurityActions.popCallerRunAsIdentity(); } }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void create() throws Exception { m_map = new HashMap(); }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void start() throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
public void create() throws Exception { super.create(); tm = getContainer().getTransactionManager(); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
protected Object invokeNext(Invocation invocation, boolean inheritedTx) throws Exception { InvocationType type = invocation.getType(); try { if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || type == InvocationType.SERVICE_ENDPOINT) { // register the Timer with the transaction if (ejbTimeout.equals(invocation.getMethod())) registerTimer(invocation); return getNext().invoke(invocation); } else { return getNext().invokeHome(invocation); } } catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
protected boolean isTxExpired(Transaction miTx) throws Exception { return TxUtils.isRollback(miTx); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); boolean nonReentrant = !(reentrant || isReentrantMethod(mi)); // Not a reentrant method like getPrimaryKey NonReentrantLock methodLock = ctx.getMethodLock(); Transaction miTx = ctx.getTransaction(); boolean locked = false; try { while (!locked) { if (methodLock.attempt(5000, miTx, nonReentrant)) { locked = true; } else { if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } } } catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } } try { ctx.lock(); return getNext().invoke(mi); } finally { ctx.unlock(); methodLock.release(nonReentrant); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void create() throws Exception { if(con.getHomeClass() != null) { Method[] methods = con.getHomeClass().getMethods(); createMethodCache(methods); } if(con.getLocalHomeClass() != null) { Method[] methods = con.getLocalHomeClass().getMethods(); createMethodCache(methods); } insertAfterEjbPostCreate = con.getBeanMetaData().getContainerConfiguration().isInsertAfterEjbPostCreate(); store.create(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public Object createBeanClassInstance() throws Exception { return store.createBeanClassInstance(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void start() throws Exception { store.start(); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void createEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { // Deligate initialization of bean to persistence store store.initEntity(ctx); // Call ejbCreate on the target bean try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); Method createMethod = (Method) createMethods.get(m); createMethod.invoke(ctx.getInstance(), args); } catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // if insertAfterEjbPostCreate == true, this will INSERT entity // otherwise, primary key is extracted from the context and returned Object id; try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_CREATE); id = store.createEntity(m, args, ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Set the key on the target context ctx.setId(id); // Create a new CacheKey Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id); // Give it to the context ctx.setCacheKey(cacheKey); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void postCreateEntity(Method m, Object[] args, EntityEnterpriseContext ctx) throws Exception { // this call should go first as it sets up relationships // for fk fields mapped to pk fields store.postCreateEntity(m, args, ctx); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_POST_CREATE); Method postCreateMethod = (Method) postCreateMethods.get(m); postCreateMethod.invoke(ctx.getInstance(), args); if(insertAfterEjbPostCreate) { store.createEntity(m, args, ctx); } } catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); return store.findEntity(finderMethod, args, ctx, factory); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { try { // return the finderResults so that the invoker layer can extend this back // giving the client an OO 'cursor' AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); return store.findEntities(finderMethod, args, ctx, factory); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public boolean isStoreRequired(EntityEnterpriseContext ctx) throws Exception { return store.isStoreRequired(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public boolean isModified(EntityEnterpriseContext ctx) throws Exception { return store.isModified(ctx); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
public synchronized EnterpriseContext get() throws Exception { boolean intr = false; try { // Wait while someone else is using it while(inUse && isSynchronized) { try { this.wait(); } catch (InterruptedException e) { intr = true; } } // Create if not already created (or it has been discarded) if (ctx == null) { try { ctx = create(getContainer().createBeanClassInstance()); } catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); } catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); } } else { } // Lock and return instance inUse = true; return ctx; } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
public void add() throws Exception { // Empty }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { // The instance is created by the caller and is a newInstance(); return new StatelessSessionEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
public Object invokeHome(final Invocation mi) throws Exception { InstancePool pool = container.getInstancePool(); StatelessSessionEnterpriseContext ctx = null; try { // Acquire an instance in case the ejbCreate throws a CreateException ctx = (StatelessSessionEnterpriseContext) pool.get(); mi.setEnterpriseContext(ctx); // Dispatch the method to the container return getNext().invokeHome(mi); } finally { mi.setEnterpriseContext(null); // If an instance was created, return it to the pool if( ctx != null ) pool.free(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context InstancePool pool = container.getInstancePool(); StatelessSessionEnterpriseContext ctx = null; try { ctx = (StatelessSessionEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Use this context mi.setEnterpriseContext(ctx); // JAXRPC/JAXWS message context Object msgContext = mi.getValue(InvocationKey.SOAP_MESSAGE_CONTEXT); // Timer invocation if (ejbTimeout.equals(mi.getMethod())) { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); } // Service Endpoint invocation else if (msgContext != null) { if (msgContext instanceof javax.xml.rpc.handler.MessageContext) ctx.setMessageContext((javax.xml.rpc.handler.MessageContext)msgContext); AllowedOperationsAssociation.pushInMethodFlag(IN_SERVICE_ENDPOINT_METHOD); } // Business Method Invocation else { AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); } // There is no need for synchronization since the instance is always fresh also there should // never be a tx associated with the instance. try { Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected void createService() throws Exception { // Initialize the dataStore String ejbName = con.getBeanMetaData().getEjbName(); // Get the system data directory File dir = new File(ServerConfigLocator.locate().getServerDataLocation().toURI()); // // jason: may have to use a generated token from container config // to determine a unique name for this config for the given // entity name. it must persist through restarts though... // // Setup the reference to the entity data store directory dir = new File(dir, storeDirName); dir = new File(dir, ejbName); storeDir = dir; log.debug("Storing entity state for '" + ejbName + "' in: " + storeDir); // if the directory does not exist then try to create it if (!storeDir.exists()) { if (!storeDir.mkdirs()) { throw new IOException("Failed to create directory: " + storeDir); } } // make sure we have a directory if (!storeDir.isDirectory()) { throw new IOException("File exists where directory expected: " + storeDir); } // make sure we can read and write to it if (!storeDir.canWrite() || !storeDir.canRead()) { throw new IOException("Directory must be readable and writable: " + storeDir); } // Get the ID field idField = con.getBeanClass().getField("id"); log.debug("Using id field: " + idField); // Lookup the isModified method if it exists try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) { isModified = null; // Has to have "boolean" as return type! log.warn("Found isModified method, but return type is not boolean; ignoring"); } else { log.debug("Using isModified method: " + isModified); } } catch (NoSuchMethodException ignored) {} }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected void destroyService() throws Exception { storeDir.delete(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object createBeanClassInstance() throws Exception { return con.getBeanClass().newInstance(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object createEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { try { Object id = idField.get(ctx.getInstance()); // Check exist if (getFile(id).exists()) throw new DuplicateKeyException("Already exists: "+id); // Store to file storeEntity(id, ctx.getInstance()); return id; } catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object postCreateEntity(final Method m, final Object[] args, final EntityEnterpriseContext ctx) throws Exception { return null; }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public boolean isStoreRequired(final EntityEnterpriseContext ctx) throws Exception { if (isModified == null) { return true; } Boolean modified = (Boolean) isModified.invoke(ctx.getInstance(), new Object[0]); return modified.booleanValue(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public boolean isModified(EntityEnterpriseContext ctx) throws Exception { return isStoreRequired(ctx); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
protected EnterpriseContext acquireContext() throws Exception { return m_container.getInstancePool().get(); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { long begin = System.currentTimeMillis(); try { return super.invokeHome(mi); } finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } } }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
public Object invoke(Invocation mi) throws Exception { long begin = System.currentTimeMillis(); try { return super.invoke(mi); } finally { if (mi.getMethod() != null && publisher.isAlive()) { addEntry(mi, begin, System.currentTimeMillis()); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public void create() throws Exception { BeanMetaData metaData = container.getBeanMetaData(); localJndiName = metaData.getLocalJndiName(); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public void start() throws Exception { BeanMetaData metaData = container.getBeanMetaData(); EJBProxyFactoryContainer invokerContainer = (EJBProxyFactoryContainer) container; localHomeClass = invokerContainer.getLocalHomeClass(); localClass = invokerContainer.getLocalClass(); if(localHomeClass == null || localClass == null) { log.debug(metaData.getEjbName() + " cannot be Bound, doesn't " + "have local and local home interfaces"); return; } // this is faster than newProxyInstance Class[] intfs = {localClass}; Class proxyClass = Proxy.getProxyClass(ClassLoaderAction.UTIL.get(localClass), intfs); final Class[] constructorParams = {InvocationHandler.class}; proxyClassConstructor = proxyClass.getConstructor(constructorParams); Context iniCtx = new InitialContext(); String beanName = metaData.getEjbName(); // Set the transaction manager and transaction propagation // context factory of the GenericProxy class transactionManager = (TransactionManager) iniCtx.lookup("java:/TransactionManager"); // Create method mappings for container invoker Method[] methods = localClass.getMethods(); beanMethodInvokerMap = new HashMap(); for(int i = 0; i < methods.length; i++) { long hash = MarshalledInvocation.calculateHash(methods[i]); beanMethodInvokerMap.put(new Long(hash), methods[i]); } methods = localHomeClass.getMethods(); homeMethodInvokerMap = new HashMap(); for(int i = 0; i < methods.length; i++) { long hash = MarshalledInvocation.calculateHash(methods[i]); homeMethodInvokerMap.put(new Long(hash), methods[i]); } // bind that referance to my name Util.rebind(iniCtx, localJndiName, getEJBLocalHome()); invokerMap.put(localJndiName, this); log.info("Bound EJB LocalHome '" + beanName + "' to jndi '" + localJndiName + "'"); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/RelationInterceptor.java
public Object invoke(Invocation mi) throws Exception { if(!(mi instanceof CMRInvocation)) { return getNext().invoke(mi); } org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage msg = ((CMRInvocation)mi).getCmrMessage(); // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); JDBCCMRFieldBridge2 cmrField = (JDBCCMRFieldBridge2)mi.getArguments()[0]; if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.ADD_RELATION == msg) { Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Add relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.addRelatedId(ctx, relatedId); } else if(org.jboss.ejb.plugins.cmp.jdbc.bridge.CMRMessage.REMOVE_RELATION == msg) { // call removeRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Remove relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.removeRelatedId(ctx, relatedId); } else { // this should not be possible we are using a type safe enum throw new EJBException("Unknown cmp2.0-relationship-message=" + msg); } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
public void lockForUpdate(Transaction tx, Object pk) throws Exception { final int i = getPartitionIndex(pk); partitions[i].lockForUpdate(tx, pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
public void releaseLock(Transaction tx, Object pk) throws Exception { final int i = getPartitionIndex(pk); partitions[i].releaseLock(tx, pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void stop() throws Exception { if(cacheInvalidator != null) { cacheInvalidator.unregister(); } if(cacheName != null) { serviceController.stop(cacheName); serviceController.destroy(cacheName); serviceController.remove(cacheName); } serviceController = null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Cache.java
public void lockForUpdate(Transaction tx, Object pk) throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Cache.java
public void releaseLock(Transaction tx, Object pk) throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void lockForUpdate(Transaction tx, Object pk) throws Exception { CachedRow row = (CachedRow) rowsById.get(pk); if(row != null) { if(row.locker != null && !tx.equals(row.locker)) { throw new Exception("lock acquisition rejected for " + tx + ", the entry is locked for update by " + row.locker + ", id=" + pk); } row.locker = tx; } // else?! }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void releaseLock(Transaction tx, Object pk) throws Exception { CachedRow row = (CachedRow) rowsById.get(pk); if(row != null) { if(!tx.equals(row.locker)) { throw new Exception("rejected to release lock for " + tx + ", the entry is locked for update by " + row.locker + ", id=" + pk); } row.locker = null; } // else?! }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public void create() throws Exception { HashMap managersMap = (HashMap)getApplicationData(CREATED_MANAGERS); if(managersMap == null) { managersMap = new HashMap(); putApplicationData(CREATED_MANAGERS, managersMap); } managersMap.put(container.getBeanMetaData().getEjbName(), this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public void start() throws Exception { initStoreManager(); HashMap managersMap = (HashMap)getApplicationData(CREATED_MANAGERS); Catalog catalog = getCatalog(); if(catalog.getEntityCount() == managersMap.size() && catalog.getEJBNames().equals(managersMap.keySet())) { // Make a copy of the managers (for safty) List managers = new ArrayList(managersMap.values()); // Start Phase 2: resolve relationships for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager2 manager = (JDBCStoreManager2)managers.get(i); manager.resolveRelationships(); } // Start Phase 3: init cmr loaders for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager2 manager = (JDBCStoreManager2)managers.get(i); manager.startEntity(); } // Start Phase 4: create tables and compile queries for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager2 manager = (JDBCStoreManager2)managers.get(i); manager.startStoreManager(); } // add foreign key constraints for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager2 manager = (JDBCStoreManager2)managers.get(i); manager.startCmd.addForeignKeyConstraints(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Object createBeanClassInstance() throws Exception { return instanceFactory.newInstance(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public boolean isModified(EntityEnterpriseContext instance) throws Exception { return entityBridge.isModified(instance); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
protected void initStoreManager() throws Exception { if(log.isDebugEnabled()) { log.debug("Initializing CMP plugin for " + container.getBeanMetaData().getEjbName()); } metaData = loadJDBCEntityMetaData(); // setup the type factory, which is used to map java types to sql types. typeFactory = new JDBCTypeFactory(metaData.getTypeMapping(), metaData.getJDBCApplication().getValueClasses(), metaData.getJDBCApplication().getUserTypeMappings() ); entityBridge = new JDBCEntityBridge2(this, metaData); entityBridge.init(); Catalog catalog = getCatalog(); catalog.addEntity(entityBridge); stop = new JDBCStopCommand(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
private void resolveRelationships() throws Exception { entityBridge.resolveRelationships(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
protected void startStoreManager() throws Exception { queryFactory = new QueryFactory(entityBridge); queryFactory.init(); instanceFactory = new InstanceFactory(this, entityBridge); startCmd = new JDBCStartCommand(this); startCmd.execute(); final JDBCEntityCommandMetaData entityCommand = getMetaData().getEntityCommand(); if(entityCommand == null || "default".equals(entityCommand.getCommandName())) { createCmd = new ApplicationPkCreateCommand(); } else { final Class cmdClass = entityCommand.getCommandClass(); if(cmdClass == null) { throw new DeploymentException( "entity-command class name is not specified for entity " + entityBridge.getEntityName() ); } try { createCmd = (CreateCommand)cmdClass.newInstance(); } catch(ClassCastException cce) { throw new DeploymentException("Entity command " + cmdClass + " does not implement " + CreateCommand.class); } } createCmd.init(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
public Object newInstance() throws Exception { EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(fieldMap, selectorMap, beanClass); return beanProxyConstructor.newInstance(new Object[]{handler}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/EJBSelectBridge.java
public Object invoke(EntityEnterpriseContext instance, Method method, Object[] args) throws Exception { Transaction tx = (instance != null ? instance.getTransaction() : tm.getTransaction()); if(syncBeforeSelect) { EntityContainer.synchronizeEntitiesWithinTransaction(tx); } return execute(args); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void stop() throws Exception { table.stop(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRelationInterceptor.java
public Object invoke(Invocation mi) throws Exception { if(!(mi instanceof CMRInvocation)) return getNext().invoke(mi); CMRMessage relationshipMessage = ((CMRInvocation)mi).getCmrMessage(); if(relationshipMessage == null) { // Not a relationship message. Invoke down the chain return getNext().invoke(mi); } // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge)mi.getArguments()[0]; if(CMRMessage.GET_RELATED_ID == relationshipMessage) { // call getRelateId if(log.isTraceEnabled()) { log.trace("Getting related id: field=" + cmrField.getFieldName() + " id=" + ctx.getId()); } return cmrField.getRelatedId(ctx); } else if(CMRMessage.ADD_RELATION == relationshipMessage) { // call addRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Add relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.addRelation(ctx, relatedId); return null; } else if(CMRMessage.REMOVE_RELATION == relationshipMessage) { // call removeRelation Object relatedId = mi.getArguments()[1]; if(log.isTraceEnabled()) { log.trace("Remove relation: field=" + cmrField.getFieldName() + " id=" + ctx.getId() + " relatedId=" + relatedId); } cmrField.removeRelation(ctx, relatedId); return null; } else if(CMRMessage.SCHEDULE_FOR_CASCADE_DELETE == relationshipMessage) { JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity(); entity.scheduleForCascadeDelete(ctx); return null; } else if(CMRMessage.SCHEDULE_FOR_BATCH_CASCADE_DELETE == relationshipMessage) { JDBCEntityBridge entity = (JDBCEntityBridge)cmrField.getEntity(); entity.scheduleForBatchCascadeDelete(ctx); return null; } else { // this should not be possible we are using a type safe enum throw new EJBException("Unknown cmp2.0-relationship-message=" + relationshipMessage); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/MetaDataLibrary.java
public void startService() throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL stdJDBCUrl = classLoader.getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if(debug) { log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); } Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); Element typeMaps = MetaData.getOptionalChild(stdJDBCElement, "type-mappings"); if(typeMaps != null) { for(Iterator i = MetaData.getChildrenByTagName(typeMaps, "type-mapping"); i.hasNext();) { Element typeMappingElement = (Element)i.next(); JDBCTypeMappingMetaData typeMapping = new JDBCTypeMappingMetaData(typeMappingElement); typeMappings.put(typeMapping.getName(), typeMapping); log.debug("added type-mapping: " + typeMapping.getName()); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/MetaDataLibrary.java
public void stopService() throws Exception { typeMappings.clear(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/DataSourceMetaData.java
public JDBCTypeMappingMetaData getTypeMappingMetaData() throws Exception { return (JDBCTypeMappingMetaData)server.invoke( metadataLibrary, "findTypeMappingMetaData", new Object[]{typeMapping}, new String[]{String.class.getName()} ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public void compileEJBQL(String ejbql, Class returnType, Class[] parameterTypes, JDBCQueryMetaData metadata) throws Exception { // reset all state variables reset(); // set input arguemts this.returnType = returnType; this.parameterTypes = parameterTypes; this.readAhead = metadata.getReadAhead(); // get the parser EJBQLParser parser = new EJBQLParser(new StringReader("")); try { // parse the ejbql into an abstract sytax tree ASTEJBQL ejbqlNode = parser.parse(catalog, parameterTypes, ejbql); // translate to sql sql = ejbqlNode.jjtAccept(this, new StringBuffer()).toString(); } catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; } catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public void compileJBossQL(String ejbql, Class returnType, Class[] parameterTypes, JDBCQueryMetaData metadata) throws Exception { // reset all state variables reset(); // set input arguemts this.returnType = returnType; this.parameterTypes = parameterTypes; this.readAhead = metadata.getReadAhead(); // get the parser JBossQLParser parser = new JBossQLParser(new StringReader("")); try { // parse the ejbql into an abstract sytax tree ASTEJBQL ejbqlNode = parser.parse(catalog, parameterTypes, ejbql); // translate to sql sql = ejbqlNode.jjtAccept(this, new StringBuffer()).toString(); if(log.isTraceEnabled()) { log.trace("ejbql: " + ejbql); log.trace("sql: " + sql); } } catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; } catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCreateBeanClassInstanceCommand.java
public Object execute() throws Exception { EntityBridgeInvocationHandler handler = new EntityBridgeInvocationHandler(fieldMap, selectorMap, beanClass); return beanProxyConstructor.newInstance(new Object[]{handler}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public void create() throws Exception { // Store a reference to this manager in an application level hashtable. // This way in the start method other managers will be able to know // the other managers. HashMap managersMap = (HashMap)getApplicationData(CREATED_MANAGERS); if(managersMap == null) { managersMap = new HashMap(); putApplicationData(CREATED_MANAGERS, managersMap); } managersMap.put(container.getBeanMetaData().getEjbName(), this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public void start() throws Exception { // // // Start Phase 1: create bridge and commands but // don't access other entities initStoreManager(); // If all managers have been started (this is the last manager), // complete the other two phases of startup. Catalog catalog = getCatalog(); HashMap managersMap = (HashMap)getApplicationData(CREATED_MANAGERS); if(catalog.getEntityCount() == managersMap.size() && catalog.getEJBNames().equals(managersMap.keySet())) { // Make a copy of the managers (for safty) ArrayList managers = new ArrayList(managersMap.values()); // // // Start Phase 2: resolve relationships for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager manager = (JDBCStoreManager)managers.get(i); manager.resolveRelationships(); } // // // Start Phase 3: create tables and compile queries for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager manager = (JDBCStoreManager)managers.get(i); manager.startStoreManager(); } // add foreign key constraints for(int i = 0; i < managers.size(); ++i) { JDBCStoreManager manager = (JDBCStoreManager)managers.get(i); manager.startCommand.addForeignKeyConstraints(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private void initStoreManager() throws Exception { if(log.isDebugEnabled()) log.debug("Initializing CMP plugin for " + container.getBeanMetaData().getEjbName()); // get the transaction manager tm = container.getTransactionManager(); // initializes the generic data containers initApplicationDataMap(); // load the metadata for this entity metaData = loadJDBCEntityMetaData(); // setup the type factory, which is used to map java types to sql types. typeFactory = new JDBCTypeFactory( metaData.getTypeMapping(), metaData.getJDBCApplication().getValueClasses(), metaData.getJDBCApplication().getUserTypeMappings() ); // create the bridge between java land and this engine (sql land) entityBridge = new JDBCEntityBridge(metaData, this); entityBridge.init(); // add the entity bridge to the catalog Catalog catalog = getCatalog(); if(catalog == null) { catalog = new Catalog(); putApplicationData(CATALOG, catalog); } catalog.addEntity(entityBridge); // create the read ahead cache readAheadCache = new ReadAheadCache(this); readAheadCache.create(); // Set up Commands commandFactory = new JDBCCommandFactory(this); // Execute the init command initCommand = commandFactory.createInitCommand(); initCommand.execute(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private void resolveRelationships() throws Exception { entityBridge.resolveRelationships(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
private void startStoreManager() throws Exception { entityBridge.start(); // Store manager life cycle commands startCommand = commandFactory.createStartCommand(); stopCommand = commandFactory.createStopCommand(); destroyCommand = commandFactory.createDestroyCommand(); // Entity commands initEntityCommand = commandFactory.createInitEntityCommand(); createBeanClassInstanceCommand = commandFactory.createCreateBeanClassInstanceCommand(); findEntityCommand = commandFactory.createFindEntityCommand(); findEntitiesCommand = commandFactory.createFindEntitiesCommand(); createEntityCommand = commandFactory.createCreateEntityCommand(); postCreateEntityCommand = commandFactory.createPostCreateEntityCommand(); removeEntityCommand = commandFactory.createRemoveEntityCommand(); loadEntityCommand = commandFactory.createLoadEntityCommand(); isModifiedCommand = commandFactory.createIsModifiedCommand(); storeEntityCommand = commandFactory.createStoreEntityCommand(); activateEntityCommand = commandFactory.createActivateEntityCommand(); passivateEntityCommand = commandFactory.createPassivateEntityCommand(); // Relation commands loadRelationCommand = commandFactory.createLoadRelationCommand(); deleteRelationsCommand = commandFactory.createDeleteRelationsCommand(); insertRelationsCommand = commandFactory.createInsertRelationsCommand(); // Create the query manager queryManager = new JDBCQueryManager(this); // Execute the start command, creates the tables startCommand.execute(); // Start the query manager. At this point is creates all of the // query commands. The must occure in the start phase, as // queries can opperate on other entities in the application, and // all entities are gaurenteed to be createed until the start phase. queryManager.start(); readAheadCache.start(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object createBeanClassInstance() throws Exception { if(createBeanClassInstanceCommand == null) throw new IllegalStateException("createBeanClassInstanceCommand == null"); return createBeanClassInstanceCommand.execute(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public void compileEJBQL(String ejbql, Class returnType, Class[] parameterTypes, JDBCQueryMetaData metadata) throws Exception { // reset all state variables reset(); // set input arguemts this.returnType = returnType; this.parameterTypes = parameterTypes; this.readAhead = metadata.getReadAhead(); this.lazyResultSetLoading = metadata.isLazyResultSetLoading(); // get the parser EJBQLParser parser = new EJBQLParser(new StringReader(SQLUtil.EMPTY_STRING)); try { // parse the ejbql into an abstract sytax tree ASTEJBQL ejbqlNode; ejbqlNode = parser.parse(catalog, parameterTypes, ejbql); // translate to sql sql = ejbqlNode.jjtAccept(this, new StringBuffer()).toString(); } catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; } catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public void compileJBossQL(String ejbql, Class returnType, Class[] parameterTypes, JDBCQueryMetaData metadata) throws Exception { // reset all state variables reset(); // set input arguemts this.returnType = returnType; this.parameterTypes = parameterTypes; this.readAhead = metadata.getReadAhead(); this.lazyResultSetLoading = metadata.isLazyResultSetLoading(); // get the parser JBossQLParser parser = new JBossQLParser(new StringReader(SQLUtil.EMPTY_STRING)); try { // parse the ejbql into an abstract sytax tree ASTEJBQL ejbqlNode; ejbqlNode = parser.parse(catalog, parameterTypes, ejbql); // translate to sql sql = ejbqlNode.jjtAccept(this, new StringBuffer()).toString(); } catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; } catch(Error e) { // lame javacc lexer throws Errors reset(); throw e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
private void setParameters(PreparedStatement ps, RelationData relationData, Iterator pairs) throws Exception { int index = 1; JDBCCMPFieldBridge[] leftFields = (JDBCCMPFieldBridge[])relationData.getLeftCMRField().getTableKeyFields(); JDBCCMPFieldBridge[] rightFields = (JDBCCMPFieldBridge[])relationData.getRightCMRField().getTableKeyFields(); int keyIndex = 0; while(pairs.hasNext()) { RelationPair pair = (RelationPair)pairs.next(); // left keys Object leftId = pair.getLeftId(); for(int i = 0; i < leftFields.length; ++i) { index = leftFields[i].setPrimaryKeyParameters(ps, index, leftId); } // right keys Object rightId = pair.getRightId(); for(int i = 0; i < rightFields.length; ++i) { index = rightFields[i].setPrimaryKeyParameters(ps, index, rightId); } if(maxKeysInDelete > 0) { ++keyIndex; if(keyIndex == maxKeysInDelete) { break; } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
public JDBCCreateBeanClassInstanceCommand createCreateBeanClassInstanceCommand() throws Exception { return new JDBCCreateBeanClassInstanceCommand(manager); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
public void set(Logger log, PreparedStatement ps, int index, Object[] args) throws Exception { Object arg = args[argNum]; JDBCParameterSetter param; if(field != null) { if(!isPrimaryKeyParameter) { if(arg instanceof EJBObject) { arg = ((EJBObject)arg).getPrimaryKey(); } else if(arg instanceof EJBLocalObject) { arg = ((EJBLocalObject)arg).getPrimaryKey(); } else { throw new IllegalArgumentException("Expected an instanc of " + "EJBObject or EJBLocalObject, but got an instance of " + arg.getClass().getName()); } } arg = field.getPrimaryKeyValue(arg); // use mapper final JDBCType jdbcType = field.getJDBCType(); arg = jdbcType.getColumnValue(0, arg); param = jdbcType.getParameterSetter()[0]; } else if(property != null) { arg = property.getColumnValue(arg); param = property.getParameterSetter(); } else { if(type != null) { arg = type.getColumnValue(0, arg); param = type.getParameterSetter()[0]; } else { param = JDBCUtil.getParameterSetter(jdbcType, arg == null ? null : arg.getClass()); } } param.set(ps, index, jdbcType, arg, log); //JDBCUtil.setParameter(log, ps, index, jdbcType, arg); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() throws Exception { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain, final Subject subject) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object invoke(EntityEnterpriseContext ctx, Method method, Object[] args) throws Exception { Transaction tx = (ctx != null ? ctx.getTransaction() : tm.getTransaction()); if(syncBeforeSelect) { EntityContainer.synchronizeEntitiesWithinTransaction(tx); } return execute(args); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplexProperty.java
public Object getColumnValue(Object value) throws Exception { Object[] noArgs = new Object[0]; for(int i = 0; i < getters.length; i++) { if(value == null) { return null; } value = getters[i].invoke(value, noArgs); } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplexProperty.java
public Object setColumnValue( Object value, Object columnValue) throws Exception { // Used for invocation of get and set Object[] noArgs = new Object[0]; Object[] singleArg = new Object[1]; // save the first value to return Object returnValue = value; // get the second to last object in the chain for(int i = 0; i < getters.length - 1; i++) { // get the next object in chain Object next = getters[i].invoke(value, noArgs); // the next object is null creat it if(next == null) { // new type based on getter next = getters[i].getReturnType().newInstance(); // and set it into the current value singleArg[0] = next; setters[i].invoke(value, singleArg); } // update value to the next in chain value = next; } // value is now the object on which we need to set the column value singleArg[0] = columnValue; setters[setters.length - 1].invoke(value, singleArg); // return the first object in call chain return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
public EnterpriseContext get() throws Exception { boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Get instance "+this+"#"+pool.size()+"#"+getContainer().getBeanClass()); if( strictMaxSize != null ) { // Block until an instance is available boolean acquired = strictMaxSize.attempt(strictTimeout); if( trace ) log.trace("Acquired("+acquired+") strictMaxSize semaphore, remaining="+strictMaxSize.permits()); if( acquired == false ) throw new EJBException("Failed to acquire the pool semaphore, strictTimeout="+strictTimeout); } synchronized (pool) { if ( pool.isEmpty() == false ) { return (EnterpriseContext) pool.removeFirst(); } } // Pool is empty, create an instance try { Object instance = container.createBeanClassInstance(); return create(instance); } catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
protected void createService() throws Exception { if( this.isStrict == Boolean.TRUE ) this.strictMaxSize = new FIFOSemaphore(this.maxSize); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
protected void destroyService() throws Exception { freeAll(); this.strictMaxSize = null; }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public void create() throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public void start() throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Get context EntityContainer ec = (EntityContainer) getContainer(); EntityEnterpriseContext ctx = (EntityEnterpriseContext) ec.getInstancePool().get(); // Pass it to the method invocation mi.setEnterpriseContext(ctx); // Give it the transaction ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME); Object result; try { // Invoke through interceptors result = getNext().invokeHome(mi); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // No id, means we can put the context back in the pool if (ctx.getId() == null) { ctx.setTransaction(null); ec.getInstancePool().free(ctx); } // We are done return result; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // The key Object key = mi.getId(); EntityEnterpriseContext ctx = null; EntityContainer ec = (EntityContainer) container; if (mi.getTransaction() != null) { //ctx = ec.getTxEntityMap().getCtx(mi.getTransaction(), key); } if (ctx == null) { InstancePool pool = ec.getInstancePool(); try { ctx = (EntityEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } ctx.setCacheKey(key); ctx.setId(key); EntityPersistenceManager pm = ec.getPersistenceManager(); pm.activateEntity(ctx); } boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Begin invoke, key="+key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); try { Object ret = getNext().invoke(mi); return ret; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
public void create() throws Exception { super.start(); BeanMetaData md = getContainer().getBeanMetaData(); ejbName = md.getEjbName(); // Should we log call details callLogging = md.getContainerConfiguration().getCallLogging(); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
public Object invokeHome(Invocation invocation) throws Exception { String methodName; if (invocation.getMethod() != null) { methodName = invocation.getMethod().getName(); } else { methodName = "<no method>"; } boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Start method=" + methodName); } // Log call details if (callLogging) { StringBuffer str = new StringBuffer("InvokeHome: "); str.append(methodName); str.append("("); Object[] args = invocation.getArguments(); if (args != null) { for (int i = 0; i < args.length; i++) { if (i > 0) { str.append(","); } str.append(args[i]); } } str.append(")"); log.debug(str.toString()); } try { return getNext().invokeHome(invocation); } catch(Throwable e) { throw handleException(e, invocation); } finally { if (trace) { log.trace("End method=" + methodName); } } }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
public Object invoke(Invocation invocation) throws Exception { String methodName; if (invocation.getMethod() != null) { methodName = invocation.getMethod().getName(); } else { methodName = "<no method>"; } boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Start method=" + methodName); } // Log call details if (callLogging) { StringBuffer str = new StringBuffer("Invoke: "); if (invocation.getId() != null) { str.append("["); str.append(invocation.getId().toString()); str.append("] "); } str.append(methodName); str.append("("); Object[] args = invocation.getArguments(); if (args != null) { for (int i = 0; i < args.length; i++) { if (i > 0) { str.append(","); } str.append(args[i]); } } str.append(")"); log.debug(str.toString()); } try { return getNext().invoke(invocation); } catch(Throwable e) { throw handleException(e, invocation); } finally { if (trace) { log.trace("End method=" + methodName); } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
public void create() throws Exception { // Do initialization in superclass. super.create(); // bind java:comp/UserTransaction RefAddr refAddr = new RefAddr("userTransaction") { /** This is never really serialized */ private static final long serialVersionUID = -8228448967597474960L; public Object getContent() { return userTransaction; } }; Reference ref = new Reference("javax.transaction.UserTransaction", refAddr, new UserTxFactory().getClass() .getName(), null); ((Context) new InitialContext().lookup("java:comp/")).bind("UserTransaction", ref); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
protected Object invokeNext(Invocation mi) throws Exception { // Save the transaction that comes with the MI Transaction oldTransaction = mi.getTransaction(); // Get old threadlocal: It may be non-null if one BMT bean does a local // call to another. Object oldUserTx = userTransaction.get(); // Suspend any transaction associated with the thread: It may be // non-null on optimized local calls. Transaction threadTx = tm.suspend(); try { EnterpriseContext ctx = ((EnterpriseContext) mi.getEnterpriseContext()); // Set the threadlocal to the userTransaction of the instance try { AllowedOperationsAssociation.pushInMethodFlag(IN_INTERCEPTOR_METHOD); userTransaction.set(ctx.getEJBContext().getUserTransaction()); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Get the bean instance transaction Transaction beanTx = ctx.getTransaction(); // Resume the bean instance transaction // only if it not null, some TMs can't resume(null), e.g. Tyrex if (beanTx != null) tm.resume(beanTx); // Let the MI know about our new transaction mi.setTransaction(beanTx); try { // Let the superclass call next interceptor and do the exception // handling return super.invokeNext(mi, false); } finally { try { if (stateless) checkStatelessDone(); else checkBadStateful(); } finally { tm.suspend(); } } } finally { // Reset threadlocal to its old value userTransaction.set(oldUserTx); // Restore old MI transaction // OSH: Why ??? mi.setTransaction(oldTransaction); // If we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
public Object getObjectInstance(Object ref, Name name, Context nameCtx, Hashtable environment) throws Exception { // The ref is a list with only one RefAddr ... RefAddr refAddr = ((Reference) ref).get(0); // ... whose content is the threadlocal ThreadLocal threadLocal = (ThreadLocal) refAddr.getContent(); // The threadlocal holds the right UserTransaction return threadLocal.get(); }
// in src/main/java/org/jboss/ejb/plugins/SSLSessionInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { extractSessionPrincipal(mi); Object returnValue = getNext().invokeHome(mi); return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/SSLSessionInterceptor.java
public Object invoke(Invocation mi) throws Exception { extractSessionPrincipal(mi); Object returnValue = getNext().invoke(mi); return returnValue; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstancePool.java
protected void createService() throws Exception { super.createService(); // for MDB, we *do* pool this.reclaim = true; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstancePool.java
protected EnterpriseContext create(Object instance) throws Exception { return new MessageDrivenEnterpriseContext(instance, getContainer()); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenTxInterceptorBMT.java
public Object invoke(Invocation mi) throws Exception { return invokeNext(mi); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { // Invocation on the handle, we don't need a bean instance if (getEJBObject.equals(mi.getMethod())) return getNext().invokeHome(mi); // get a new context from the pool (this is a home method call) InstancePool pool = container.getInstancePool(); EnterpriseContext ctx = pool.get(); // set the context on the Invocation mi.setEnterpriseContext(ctx); // It is a new context for sure so we can lock it ctx.lock(); // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME); try { // Invoke through interceptors return getNext().invokeHome(mi); } finally { synchronized (ctx) { AllowedOperationsAssociation.popInMethodFlag(); // Release the lock ctx.unlock(); // Still free? Not free if create() was called successfully if (ctx.getId() == null) { pool.free(ctx); } } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { InstanceCache cache = container.getInstanceCache(); InstancePool pool = container.getInstancePool(); Object methodID = mi.getId(); EnterpriseContext ctx = null; BeanLock lock = container.getLockManager().getLock(methodID); boolean callerRunAsIdentityPresent = SecurityActions.peekRunAsIdentity() != null; boolean pushSecurityContext = SecurityActions.getSecurityContext() == null; try { /* The security context must be established before the cache lookup because the activation of a session should have the caller's security context as ejbActivate is allowed to call other secured resources. Since the pm makes the ejbActivate call, we need to set the caller's security context. The only reason this shows up for stateful session is that we moved the SecurityInterceptor to after the instance interceptor to allow security exceptions to result in invalidation of the session. This may be too literal an interpretation of the ejb spec requirement that runtime exceptions should invalidate the session. */ if(!callerRunAsIdentityPresent && pushSecurityContext) { AuthenticationManager am = container.getSecurityManager(); String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(am != null) securityDomain = am.getSecurityDomain(); SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain , null); //SecurityActions.pushSubjectContext(mi.getPrincipal(), mi.getCredential(), null); } lock.sync(); try { // Get context try { ctx = cache.get(methodID); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } // Associate it with the method invocation mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // BMT beans will lock and replace tx no matter what, CMT do work on transaction boolean isBMT = ((SessionMetaData)container.getBeanMetaData()).isBeanManagedTx(); if (isBMT == false) { // Do we have a running transaction with the context if (ctx.getTransaction() != null && // And are we trying to enter with another transaction !ctx.getTransaction().equals(mi.getTransaction())) { // Calls must be in the same transaction StringBuffer msg = new StringBuffer("Application Error: " + "tried to enter Stateful bean with different tx context"); msg.append(", contextTx: " + ctx.getTransaction()); msg.append(", methodTx: " + mi.getTransaction()); throw new EJBException(msg.toString()); } //If the instance will participate in a new transaction we register a sync for it if (ctx.getTransaction() == null && mi.getTransaction() != null) { register(ctx, mi.getTransaction(), lock); } } if (!ctx.isLocked()) { //take it! ctx.lock(); } else { if (!isCallAllowed(mi)) { // Concurent calls are not allowed throw new EJBException("Application Error: no concurrent " + "calls on stateful beans"); } else { ctx.lock(); } } } finally { lock.releaseSync(); } // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); boolean validContext = true; try { // Invoke through interceptors Object ret = getNext().invoke(mi); return ret; } catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } } } finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
public void start() throws Exception { super.start(); authenticationObserver = (AuthenticationObserver) Registry.lookup(AuthenticationObserver.KEY); //Take care of hot deployed security domains if (container != null) { securityManager = container.getSecurityManager(); if (securityManager != null) { appSecurityDomain = securityManager.getSecurityDomain(); appSecurityDomain = SecurityUtil.unprefixSecurityDomain(appSecurityDomain); } } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { boolean isInvoke = false; return process(mi, isInvoke); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean isInvoke = true; return process(mi, isInvoke); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private Object process(Invocation mi, boolean isInvoke) throws Exception { if (this.shouldBypassSecurity(mi)) { if (log.isTraceEnabled()) log.trace("Bypass security for invoke or invokeHome"); if (isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } SecurityContext sc = SecurityActions.getSecurityContext(); if (sc == null) throw new IllegalStateException("Security Context is null"); RunAs callerRunAsIdentity = sc.getIncomingRunAs(); if (log.isTraceEnabled()) log.trace("Caller RunAs=" + callerRunAsIdentity + ": useCallerIdentity=" + this.isUseCallerIdentity); // Authenticate the subject and apply any declarative security checks try { checkSecurityContext(mi, callerRunAsIdentity); } catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; } RunAs runAsIdentityToPush = runAsIdentity; /** * Special case: if <use-caller-identity> configured and * the caller is arriving with a run-as, we need to push that run-as */ if (callerRunAsIdentity != null && this.isUseCallerIdentity) runAsIdentityToPush = callerRunAsIdentity; /* If a run-as role was specified, push it so that any calls made by this bean will have the runAsRole available for declarative security checks. */ SecurityActions.pushRunAsIdentity(runAsIdentityToPush); try { if (isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } finally { SecurityActions.popRunAsIdentity(); SecurityActions.popSubjectContext(); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private void checkSecurityContext(Invocation mi, RunAs callerRunAsIdentity) throws Exception { Principal principal = mi.getPrincipal(); Object credential = mi.getCredential(); boolean trace = log.isTraceEnabled(); // If there is not a security manager then there is no authentication required Method m = mi.getMethod(); boolean containerMethod = m == null || m.equals(ejbTimeout); if (containerMethod == true || securityManager == null || container == null) { // Allow for the propagation of caller info to other beans SecurityActions.pushSubjectContext(principal, credential, null); return; } if (realmMapping == null) { throw new SecurityException("Role mapping manager has not been set"); } SecurityContext sc = SecurityActions.getSecurityContext(); EJBAuthenticationHelper helper = SecurityHelperFactory.getEJBAuthenticationHelper(sc); boolean isTrusted = containsTrustableRunAs(sc) || helper.isTrusted(); if (!isTrusted) { // Check the security info from the method invocation Subject subject = new Subject(); if (SecurityActions.isValid(helper, subject, m.getName()) == false) { // Notify authentication observer if (authenticationObserver != null) authenticationObserver.authenticationFailed(); // Else throw a generic SecurityException String msg = "Authentication exception, principal=" + principal; throw new SecurityException(msg); } else { SecurityActions.pushSubjectContext(principal, credential, subject); if (trace) { log.trace("Authenticated principal=" + principal + " in security domain=" + sc.getSecurityDomain()); } } } else { // Duplicate the current subject context on the stack since //SecurityActions.dupSubjectContext(); SecurityActions.pushRunAsIdentity(callerRunAsIdentity); } Method ejbMethod = mi.getMethod(); // Ignore internal container calls if (ejbMethod == null) return; // Get the caller Subject caller = SecurityActions.getContextSubject(); if (caller == null) throw new IllegalStateException("Authenticated User. But caller subject is null"); //Establish the deployment rolename-principalset custom mapping(if available) SecurityRolesAssociation.setSecurityRoles(this.deploymentRoles); boolean isAuthorized = false; Set<Principal> methodRoles = container.getMethodPermissions(ejbMethod, mi.getType()); SecurityContext currentSC = SecurityActions.getSecurityContext(); if (SecurityActions.getSecurityManagement(currentSC) == null) SecurityActions.setSecurityManagement(currentSC, securityManagement); AbstractEJBAuthorizationHelper authorizationHelper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); authorizationHelper.setPolicyRegistration(container.getPolicyRegistration()); isAuthorized = SecurityActions.authorize(authorizationHelper, ejbName, ejbMethod, mi.getPrincipal(), mi.getType().toInterfaceString(), ejbCS, caller, callerRunAsIdentity, container.getJaccContextID(), new SimpleRoleGroup(methodRoles)); if (!isAuthorized) { String msg = "Denied: caller with subject=" + caller + " and security context post-mapping roles=" + SecurityActions.getRolesFromSecurityContext(currentSC) + ": ejbMethod=" + ejbMethod; throw new SecurityException(msg); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private boolean shouldBypassSecurity(Invocation mi) throws Exception { // If there is not a security manager then there is no authentication required Method m = mi.getMethod(); boolean containerMethod = m == null || m.equals(ejbTimeout); if (containerMethod == true || securityManager == null || container == null) { // Allow for the propagation of caller info to other beans SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), "BYPASSED-SECURITY"); if (this.runAsIdentity != null) SecurityActions.pushRunAsIdentity(runAsIdentity); return true; } return false; }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
public void create() throws Exception { }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
protected void setProxyFactory(String invokerBinding, Invocation mi) throws Exception { // if (BeanMetaData.LOCAL_INVOKER_PROXY_BINDING.equals(invokerBinding)) return; if (invokerBinding == null) { log.trace("invokerBInding is null in ProxyFactoryFinder"); return; } /* if (invokerBinding == null) { log.error("***************** invokerBinding is null ********"); log.error("Method name: " + mi.getMethod().getName()); log.error("jmx name: " + container.getJmxName().toString()); new Throwable().printStackTrace(); log.error("*************************"); throw new EJBException("Couldn't insert proxy factory, " + "invokerBinding was null"); } */ Object proxyFactory = container.lookupProxyFactory(invokerBinding); if (proxyFactory == null) { String methodName; if(mi.getMethod() != null) { methodName = mi.getMethod().getName(); } else { methodName ="<no method>"; } log.error("***************** proxyFactory is null ********"); log.error("Method name: " + methodName); log.error("jmx name: " + container.getJmxName().toString()); log.error("invokerBinding: " + invokerBinding); log.error("Stack trace", new Throwable()); log.error("*************************"); throw new EJBException("Couldn't find proxy factory"); } container.setProxyFactory(proxyFactory); }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { String invokerBinding = (String)mi.getAsIsValue(InvocationKey.INVOKER_PROXY_BINDING); setProxyFactory(invokerBinding, mi); String oldInvokerBinding = ENCThreadLocalKey.getKey(); // Only override current ENC binding if we're not local // if ((!BeanMetaData.LOCAL_INVOKER_PROXY_BINDING.equals(invokerBinding)) || oldInvokerBinding == null) if (invokerBinding != null || oldInvokerBinding == null) { ENCThreadLocalKey.setKey(invokerBinding); } Interceptor next = getNext(); Object value = null; try { value = next.invokeHome(mi); } finally { ENCThreadLocalKey.setKey(oldInvokerBinding); // JBAS-4192 clear the container's thread local container.setProxyFactory(null); } return value; }
// in src/main/java/org/jboss/ejb/plugins/ProxyFactoryFinderInterceptor.java
public Object invoke(Invocation mi) throws Exception { String invokerBinding = (String)mi.getAsIsValue(InvocationKey.INVOKER_PROXY_BINDING); setProxyFactory(invokerBinding, mi); String oldInvokerBinding = ENCThreadLocalKey.getKey(); // Only override current ENC binding if we're not local or there has not been a previous call // if ((!BeanMetaData.LOCAL_INVOKER_PROXY_BINDING.equals(invokerBinding)) || oldInvokerBinding == null) if (invokerBinding != null || oldInvokerBinding == null) { ENCThreadLocalKey.setKey(invokerBinding); } Interceptor next = getNext(); Object value = null; try { value = next.invoke(mi); } finally { ENCThreadLocalKey.setKey(oldInvokerBinding); // JBAS-4192 clear the container's thread local container.setProxyFactory(null); } return value; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorBMT.java
public void create() throws Exception { // Do initialization in superclass. super.create(); // Set the atateless attribute stateless = ((SessionMetaData)container.getBeanMetaData()).isStateless(); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorBMT.java
public Object invokeHome(Invocation mi) throws Exception { // stateless: no context, no transaction, no call to the instance if (stateless || mi.getEnterpriseContext() == null) return getNext().invokeHome(mi); else return invokeNext(mi); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorBMT.java
public Object invoke(Invocation mi) throws Exception { return invokeNext(mi); }
// in src/main/java/org/jboss/ejb/plugins/security/SecurityActions.java
static SecurityContext createAndSetSecurityContext(final String domain, final String fqnClassName) throws PrivilegedActionException { return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>() { public SecurityContext run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain, fqnClassName); setSecurityContext(sc); return sc; }} ); }
// in src/main/java/org/jboss/ejb/plugins/security/SecurityActions.java
public SecurityContext run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain, fqnClassName); setSecurityContext(sc); return sc; }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
Override public Object invoke(Invocation mi) throws Exception { boolean isInvoke = true; return this.process(mi, isInvoke); }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
Override public Object invokeHome(Invocation mi) throws Exception { boolean isInvoke = false; return this.process(mi, isInvoke); }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
private Object process(Invocation mi, boolean isInvoke) throws Exception { //No Security in the absence of SecurityDomain if(securityDomain == null) { if(isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } if (log.isTraceEnabled()) { log.trace("process:isInvoke="+isInvoke + " bean="+ container.getServiceName()); } SecurityIdentity si = null; String incomingDomain = null; Method m = mi.getMethod(); boolean isEjbTimeOutMethod = m!= null && m.getName().equals(timedObjectMethod); //For local ejb invocations if(mi.isLocal() && !isEjbTimeOutMethod) { if (log.isTraceEnabled()) { log.trace("True mi.isLocal() && !isEjbTimeOutMethod"); } //Cache the security context SecurityContext sc = SecurityActions.getSecurityContext(); if(sc != null) { si = SecurityActions.getSecurityIdentity(sc); incomingDomain = sc.getSecurityDomain(); } SecurityActions.setSecurityManagement(sc, container.getSecurityManagement()); // set the container's security domain in the security context SecurityActions.setSecurityDomain(sc, this.securityDomain); if (log.isTraceEnabled()) { log.trace("SecurityIdentity="+SecurityActions.trace(si)); } //Set the security context on the invocation mi.setSecurityContext(sc); } else { if (log.isTraceEnabled()) { log.trace("False mi.isLocal() && !isEjbTimeOutMethod"); } establishSecurityContext(mi); } try { //Establish the run-as on the SC as the caller SC SecurityContext currentSC = SecurityActions.getSecurityContext(); SecurityActions.pushCallerRunAsIdentity(currentSC.getOutgoingRunAs()); if (log.isTraceEnabled()) { log.trace("Going to the SecurityInterceptor with SC="+SecurityActions.trace(currentSC)); } if(isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } finally { SecurityActions.popCallerRunAsIdentity(); if(mi.isLocal() && si != null) SecurityActions.setSecurityIdentity(SecurityActions.getSecurityContext(), si); if(mi.isLocal() && incomingDomain != null) SecurityActions.setSecurityDomain(SecurityActions.getSecurityContext(), incomingDomain); if (log.isTraceEnabled()) { log.trace("Exit process():isInvoke="+isInvoke); } } }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
private void establishSecurityContext(Invocation mi) throws Exception { //For Local EJB invocations, the security context needs //to be obtained from the thread local. For remote ejb //invocations, the SC is obtained in the invocation SecurityContext sc = mi.getSecurityContext(); SecurityContext newSC = SecurityActions.createAndSetSecurityContext(securityDomain, container.getSecurityContextClassName()); if(sc != null) { //Get the run-as, principal, cred etc from the invocation and set it on the context SecurityActions.setSecurityIdentity(newSC, SecurityActions.getSecurityIdentity(sc)); } else { //Local EJB Invocation or some one created the Invocation object on the server side mi.setSecurityContext(newSC); } //Set the SecurityManagement on the context SecurityActions.setSecurityManagement(newSC, container.getSecurityManagement()); if (log.isTraceEnabled()) { log.trace("establishSecurityIdentity:SecCtx="+SecurityActions.trace(newSC)); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
public void create() throws Exception { super.create(); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void invokeEjbStore(Thread thread, EntityEnterpriseContext instance) throws Exception { if(instance.getId() != null) { EntityContainer container = (EntityContainer) instance.getContainer(); // set the context class loader before calling the store method SecurityActions.setContextClassLoader(thread, container.getClassLoader()); container.pushENC(); try { // store it container.invokeEjbStore(instance); } finally { container.popENC(); } } }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { // only synchronize if the id is not null. A null id means // that the entity has been removed. if(instance.getId() != null) { EntityContainer container = (EntityContainer) instance.getContainer(); // set the context class loader before calling the store method SecurityActions.setContextClassLoader(thread, container.getClassLoader()); container.pushENC(); try { // store it container.storeEntity(instance); instance.setTxAssociation(SYNCHRONIZED); } finally { container.popENC(); } } }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { EntityContainer container = (EntityContainer)instance.getContainer(); if(container.getPersistenceManager().isStoreRequired(instance)) { throw new EJBException("The instance of " + container.getBeanMetaData().getEjbName() + " with pk=" + instance.getId() + " was not stored to prevent potential inconsistency of data in the database:" + " the instance was evicted from the cache during the transaction" + " and the database was possibly updated by another process."); } }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void invokeEjbStore(Thread thread, EntityEnterpriseContext instance) throws Exception { GlobalTxEntityMap.SYNC_SCHEDULED.invokeEjbStore(thread, instance); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void invokeEjbStore(Thread thread, EntityEnterpriseContext instance) throws Exception { }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object createBeanClassInstance() throws Exception { return persistenceManager.createBeanClassInstance(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void createService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Acquire classes from CL if (metaData.getHome() != null) homeInterface = classLoader.loadClass(metaData.getHome()); if (metaData.getRemote() != null) remoteInterface = classLoader.loadClass(metaData.getRemote()); // Call default init super.createService(); // Make some additional validity checks with regards to the container configuration checkCoherency (); // Map the bean methods setupBeanMapping(); // Map the home methods setupHomeMapping(); // Map the interfaces to Long setupMarshalledInvocationMapping(); // Try to register the instance pool as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instancePool, poolName); } catch(Throwable t) { log.debug("Failed to register cache as mbean", t); } // Initialize pool instancePool.setContainer(this); instancePool.create(); for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); ci.create(); } // Try to register the instance cache as an MBean try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "cache"); ObjectName cacheName = new ObjectName(containerName.getDomain(), props); server.registerMBean(instanceCache, cacheName); } catch(Throwable t) { log.debug("Failed to register cache as mbean", t); } // Init instance cache instanceCache.setContainer(this); instanceCache.create(); // Init persistence persistenceManager.setContainer(this); persistenceManager.create(); // Initialize the interceptor by calling the chain Interceptor in = interceptor; while (in != null) { in.setContainer(this); in.create(); in = in.getNext(); } readOnly = ((EntityMetaData)metaData).isReadOnly(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void startService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Call default start super.startService(); // Start container invokers for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); ci.start(); } // Start instance cache instanceCache.start(); // Start the instance pool instancePool.start(); Interceptor i = interceptor; while(i != null) { i.start(); i = i.getNext(); } // Restore persisted ejb timers restoreTimers(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void stopService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { //Stop items in reverse order from start //This assures that CachedConnectionInterceptor will get removed //from in between this and the pm before the pm is stopped. // Stop all interceptors in the chain Interceptor in = interceptor; while (in != null) { in.stop(); in = in.getNext(); } // Stop the instance pool instancePool.stop(); // Stop persistence persistenceManager.stop(); // Stop instance cache instanceCache.stop(); // Stop container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); ci.stop(); } // Call default stop super.stopService(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void destroyService() throws Exception { // Associate thread with classloader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try { // Destroy container invoker for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); ci.destroy(); } // Destroy instance cache instanceCache.destroy(); instanceCache.setContainer(null); try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "cache"); ObjectName cacheName = new ObjectName(containerName.getDomain(), props); server.unregisterMBean(cacheName); } catch(Throwable ignore) { } // Destroy persistence persistenceManager.destroy(); persistenceManager.setContainer(null); // Destroy the pool instancePool.destroy(); instancePool.setContainer(null); try { ObjectName containerName = super.getJmxName(); Hashtable props = containerName.getKeyPropertyList(); props.put("plugin", "pool"); ObjectName poolName = new ObjectName(containerName.getDomain(), props); server.unregisterMBean(poolName); } catch(Throwable ignore) { } // Destroy all the interceptors in the chain Interceptor in = interceptor; while (in != null) { in.destroy(); in.setContainer(null); in = in.getNext(); } MarshalledInvocation.removeHashes(homeInterface); MarshalledInvocation.removeHashes(remoteInterface); // Call default destroy super.destroyService(); } finally { popENC(); // Reset classloader SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Map to EJBHome.remove(Object) to EJBObject.remove() InvocationType type = mi.getType(); if (type == InvocationType.HOME) mi.setType(InvocationType.REMOTE); else if (type == InvocationType.LOCALHOME) mi.setType(InvocationType.LOCAL); mi.setMethod(EJBOBJECT_REMOVE); // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); mi.setId(ejbObject.getPrimaryKey()); } else mi.setId(arg); mi.setArguments(new Object[0]); return getInterceptor().invoke(mi); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object internalInvoke(Invocation mi) throws Exception { // Invoke through interceptors return getInterceptor().invoke(mi); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBLocalObject createLocalHome(Invocation mi) throws Exception { // The persistence manager takes care of the wiring and creating the EJBLocalObject final EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().createEntity(mi.getMethod(), mi.getArguments(), ctx); // The context implicitely carries the EJBObject createCount++; return localProxyFactory.getEntityEJBLocalObject(ctx.getId(), true); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void postCreateLocalHome(Invocation mi) throws Exception { // The persistence manager takes care of the post create step getPersistenceManager().postCreateEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object findLocal(Invocation mi) throws Exception { Method method = mi.getMethod(); Object[] args = mi.getArguments(); EntityEnterpriseContext instance = (EntityEnterpriseContext)mi.getEnterpriseContext(); boolean syncOnCommitOnly = metaData.getContainerConfiguration().getSyncOnCommitOnly(); Transaction tx = mi.getTransaction(); Class returnType = method.getReturnType(); if (Collection.class.isAssignableFrom(returnType) || returnType == Enumeration.class) { // as per the spec 9.6.4, entities must be synchronized with the datastore when an ejbFind<METHOD> is called. if (!syncOnCommitOnly) { synchronizeEntitiesWithinTransaction(tx); } // Iterator finder Collection c = getPersistenceManager().findEntities(method, args, instance, localProxyFactory); // BMP entity finder methods are allowed to return java.util.Enumeration. if (returnType == Enumeration.class) { return java.util.Collections.enumeration(c); } else { return c; } } else { return findSingleObject(tx, method, args, instance, localProxyFactory); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object find(Invocation mi) throws Exception { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Method method = mi.getMethod(); Object[] args = mi.getArguments(); EntityEnterpriseContext instance = (EntityEnterpriseContext)mi.getEnterpriseContext(); boolean syncOnCommitOnly = metaData.getContainerConfiguration().getSyncOnCommitOnly(); Transaction tx = mi.getTransaction(); Class returnType = method.getReturnType(); if (Collection.class.isAssignableFrom(returnType) || returnType == Enumeration.class) { // as per the spec 9.6.4, entities must be synchronized with the datastore when an ejbFind<METHOD> is called. if (!syncOnCommitOnly) { synchronizeEntitiesWithinTransaction(tx); } // Iterator finder Collection c = getPersistenceManager().findEntities(method, args, instance, ci); // BMP entity finder methods are allowed to return java.util.Enumeration. // We need a serializable Enumeration, so we can't use Collections.enumeration() if (returnType == Enumeration.class) { return new SerializableEnumeration(c); } else { return c; } } else { return findSingleObject(tx, method, args, instance, ci); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void invokeEjbStore(EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() != null) { final EntityPersistenceManager pm = getPersistenceManager(); pm.invokeEjbStore(ctx); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void storeEntity(EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() != null) { final EntityPersistenceManager pm = getPersistenceManager(); if(pm.isStoreRequired(ctx)) { pm.storeEntity(ctx); } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void postCreateHome(Invocation mi) throws Exception { // The persistence manager takes care of the post create step getPersistenceManager().postCreateEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBObject createHome(Invocation mi) throws Exception { // The persistence manager takes care of the wiring and creating the EJBObject getPersistenceManager().createEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); // The context implicitely carries the EJBObject createCount++; return ((EntityEnterpriseContext)mi.getEnterpriseContext()).getEJBObject(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private void setupHomeMappingImpl(Method[] m, String finderName, String append) throws Exception { // Adrian Brock: This should go away when we don't support EJB1x boolean isEJB1x = metaData.getApplicationMetaData().isEJB1x(); for (int i = 0; i < m.length; i++) { String methodName = m[i].getName(); try { try // Try home method { String ejbHomeMethodName = "ejbHome" + methodName.substring(0,1).toUpperCase() + methodName.substring(1); homeMapping.put(m[i], beanClass.getMethod(ejbHomeMethodName, m[i].getParameterTypes())); continue; } catch (NoSuchMethodException ignore) {} // just go on with other types of methods // Implemented by container (in both cases) if (methodName.startsWith("find")) { homeMapping.put(m[i], this.getClass().getMethod(finderName, new Class[] { Invocation.class })); } else if (methodName.equals("create") || (isEJB1x == false && methodName.startsWith("create"))) { homeMapping.put(m[i], this.getClass().getMethod("create"+append, new Class[] { Invocation.class })); beanMapping.put(m[i], this.getClass().getMethod("postCreate"+append, new Class[] { Invocation.class })); } else { homeMapping.put(m[i], this.getClass().getMethod(methodName+append, new Class[] { Invocation.class })); } } catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void setupHomeMapping() throws Exception { try { if (homeInterface != null) { Method[] m = homeInterface.getMethods(); setupHomeMappingImpl( m, "find", "Home" ); } if (localHomeInterface != null) { Method[] m = localHomeInterface.getMethods(); setupHomeMappingImpl( m, "findLocal", "LocalHome" ); } // Special methods // Get the One on Handle (getEJBObject), get the class Class handleClass = Class.forName("javax.ejb.Handle"); // Get the methods (there is only one) Method[] handleMethods = handleClass.getMethods(); //Just to make sure let's iterate for (int j=0; j<handleMethods.length ;j++) { //Get only the one called handle.getEJBObject if (handleMethods[j].getName().equals("getEJBObject")) { //Map it in the home stuff homeMapping.put(handleMethods[j], this.getClass().getMethod("getEJBObject", new Class[] {Invocation.class})); } } } catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private void setupBeanMappingImpl( Method[] m, String intfName ) throws Exception { for (int i = 0; i < m.length; i++) { if (!m[i].getDeclaringClass().getName().equals(intfName)) { // Implemented by bean beanMapping.put(m[i], beanClass.getMethod(m[i].getName(), m[i].getParameterTypes())); } else { // Implemented by container beanMapping.put(m[i], getClass().getMethod(m[i].getName(), new Class[] { Invocation.class })); } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void setupBeanMapping() throws Exception { try { if (remoteInterface != null) { Method[] m = remoteInterface.getMethods(); setupBeanMappingImpl( m, "javax.ejb.EJBObject" ); } if (localInterface != null) { Method[] m = localInterface.getMethods(); setupBeanMappingImpl( m, "javax.ejb.EJBLocalObject" ); } if( TimedObject.class.isAssignableFrom( beanClass ) ) { // Map ejbTimeout beanMapping.put( TimedObject.class.getMethod( "ejbTimeout", new Class[] { Timer.class } ), beanClass.getMethod( "ejbTimeout", new Class[] { Timer.class } ) ); } } catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void setupMarshalledInvocationMapping() throws Exception { // Create method mappings for container invoker if (homeInterface != null) { Method [] m = homeInterface.getMethods(); for (int i = 0 ; i<m.length ; i++) { marshalledInvocationMapping.put( new Long(MarshalledInvocation.calculateHash(m[i])), m[i]); } } if (remoteInterface != null) { Method [] m = remoteInterface.getMethods(); for (int j = 0 ; j<m.length ; j++) { marshalledInvocationMapping.put( new Long(MarshalledInvocation.calculateHash(m[j])), m[j]); } } // Get the getEJBObjectMethod Method getEJBObjectMethod = Class.forName("javax.ejb.Handle").getMethod("getEJBObject", new Class[0]); // Hash it marshalledInvocationMapping.put(new Long(MarshalledInvocation.calculateHash(getEJBObjectMethod)),getEJBObjectMethod); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
protected void checkCoherency () throws Exception { // Check clustering cohrency wrt metadata // if (metaData.isClustered()) { boolean clusteredProxyFactoryFound = false; for (Iterator it = proxyFactories.keySet().iterator(); it.hasNext(); ) { String invokerBinding = (String)it.next(); EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding); if (ci instanceof org.jboss.proxy.ejb.ClusterProxyFactory) clusteredProxyFactoryFound = true; } if (!clusteredProxyFactoryFound) { log.warn("*** EJB '" + this.metaData.getEjbName() + "' deployed as CLUSTERED but not a single clustered-invoker is bound to container ***"); } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private Object findSingleObject(Transaction tx, Method method, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if(method.getName().equals("findByPrimaryKey")) { if(args[0] == null) throw new IllegalArgumentException("findByPrimaryKey called with null argument."); if(metaData.getContainerConfiguration().getCommitOption() != ConfigurationMetaData.B_COMMIT_OPTION) { Object key = instance.getCacheKey(); if(key == null) { key = ((EntityCache)instanceCache).createCacheKey(args[0]); } if(instanceCache.isActive(key)) { return factory.getEntityEJBObject(key); } } } else if(!metaData.getContainerConfiguration().getSyncOnCommitOnly()) { EntityContainer.synchronizeEntitiesWithinTransaction(tx); } return getPersistenceManager().findEntity(method, args, instance, factory); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke and handle exceptions Method miMethod = mi.getMethod(); Method m = (Method) homeMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } if (m.getDeclaringClass().equals(EntityContainer.class)) { try { return mi.performCall(EntityContainer.this, m, new Object[] { mi }); } catch (Exception e) { rethrow(e); } } else // Home method { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); try { AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_EJB_HOME); return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } finally{ AllowedOperationsAssociation.popInMethodFlag(); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) beanMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(EntityContainer.class)) { // Invoke container try { return mi.performCall(EntityContainer.this, m, new Object[]{ mi }); } catch (Exception e) { rethrow(e); } } else { // Invoke bean instance try { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); Object instance = ctx.getInstance(); return mi.performCall(instance, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/Shutdown.java
public static void main(final String[] args) throws Exception { if (args.length == 0) { displayUsage(); System.exit(0); } String sopts = "-:hD:s:n:a:u:p:S::v::o:r:"; LongOpt[] lopts = { new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'), new LongOpt("server", LongOpt.REQUIRED_ARGUMENT, null, 's'), new LongOpt("adapter", LongOpt.REQUIRED_ARGUMENT, null, 'a'), new LongOpt("serverName", LongOpt.REQUIRED_ARGUMENT, null, 'n'), new LongOpt("shutdown", LongOpt.NO_ARGUMENT, null, 'S'), new LongOpt("user", LongOpt.REQUIRED_ARGUMENT, null, 'u'), new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'), new LongOpt("password", LongOpt.REQUIRED_ARGUMENT, null, 'p'), new LongOpt("host", LongOpt.REQUIRED_ARGUMENT, null, 'o'), new LongOpt("port", LongOpt.REQUIRED_ARGUMENT, null, 'r'), }; Getopt getopt = new Getopt(PROGRAM_NAME, args, sopts, lopts); int code; String arg; String serverURL = null; String username = null; String password = null; ObjectName serverJMXName = new ObjectName("jboss.system:type=Server"); String hostname=null; String port=null; boolean verbose = false; while ((code = getopt.getopt()) != -1) { switch (code) { case ':': case '?': // for now both of these should exit with error status System.exit(1); break; case 1: // this will catch non-option arguments // (which we don't currently care about) System.err.println(PROGRAM_NAME + ": unused non-option argument: " + getopt.getOptarg()); break; case 'h': displayUsage(); System.exit(0); break; case 'D': { // set a system property arg = getopt.getOptarg(); String name, value; int i = arg.indexOf("="); if (i == -1) { name = arg; value = "true"; } else { name = arg.substring(0, i); value = arg.substring(i + 1, arg.length()); } System.setProperty(name, value); break; } case 's': serverURL = getopt.getOptarg(); break; case 'n': serverJMXName = new ObjectName(getopt.getOptarg()); break; case 'S': // nothing... break; case 'a': String adapterName = getopt.getOptarg(); System.out.println("adapter name is ignored " + adapterName); break; case 'u': username = getopt.getOptarg(); break; case 'p': password = getopt.getOptarg(); break; // host name case 'o': hostname = getopt.getOptarg(); break; // host port case 'r': port = getopt.getOptarg(); break; // be noisy case 'v': verbose = true; break; } } // If there was a username specified, but no password prompt for it if( username != null && password == null ) { System.out.print("Enter password for "+username+": "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); password = br.readLine(); } if( serverURL == null) { serverURL = DEFAULT_BASEURL + (hostname != null ? hostname : DEFAULT_HOSTNAME) + ":" + (port != null ? port : DEFAULT_PORT) + DEFAULT_RMIOBJECTNAME; } if( verbose ) { System.out.println("JMX server url=" + serverURL); } HashMap env = new HashMap(); if (username != null && password != null) { if (verbose ) { System.out.println("will connect with username=" + username); } String[] creds = new String[2]; creds[0] = username; creds[1] = password; env.put(JMXConnector.CREDENTIALS, creds); } JMXServiceURL url = new JMXServiceURL(serverURL); JMXConnector jmxc = JMXConnectorFactory.connect(url, env); MBeanServerConnection adaptor = jmxc.getMBeanServerConnection(); ServerProxyHandler handler = new ServerProxyHandler(adaptor, serverJMXName); Class<?>[] ifaces = {JBossASServer.class}; ClassLoader tcl = Thread.currentThread().getContextClassLoader(); JBossASServer server = (JBossASServer) Proxy.newProxyInstance(tcl, ifaces, handler); server.shutdown(); System.out.println("Shutdown message has been posted to the server."); System.out.println("Server shutdown may take a while - check logfiles for completion"); jmxc.close(); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationsTxGrouper.java
public static void registerInvalidationSynchronization(Transaction tx, InvalidationGroup group, Serializable key) throws Exception { InvalidatorSynchronization synch = (InvalidatorSynchronization) synchLocal.get(tx); if(synch == null) { synch = new InvalidatorSynchronization(tx); synchLocal.set(tx, synch); // If there is no tx don't try to use it if( tx != null ) tx.registerSynchronization(synch); } synch.addInvalidation(group, key); // If there is no tx call afterCompletion if( tx == null ) synch.afterCompletion(javax.transaction.Status.STATUS_NO_TRANSACTION); }
// in src/main/java/org/jboss/cache/invalidation/triggers/EntityBeanCacheBatchInvalidatorInterceptor.java
public void start() throws Exception { org.jboss.metadata.EntityMetaData emd = ((org.jboss.metadata.EntityMetaData)this.getContainer ().getBeanMetaData ()); doCacheInvalidations = emd.doDistributedCacheInvalidations (); if (doCacheInvalidations) { // we are interested in receiving cache invalidation callbacks // String groupName = emd.getDistributedCacheInvalidationConfig ().getInvalidationGroupName (); String imName = emd.getDistributedCacheInvalidationConfig ().getInvalidationManagerName (); this.invalMgr = (org.jboss.cache.invalidation.InvalidationManagerMBean)org.jboss.system.Registry.lookup (imName); this.ig = this.invalMgr.getInvalidationGroup (groupName); } }
// in src/main/java/org/jboss/cache/invalidation/triggers/EntityBeanCacheBatchInvalidatorInterceptor.java
protected boolean changed (org.jboss.invocation.Invocation mi, org.jboss.ejb.EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() == null) return true; if(!container.isReadOnly()) { java.lang.reflect.Method method = mi.getMethod(); if(method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { return invalidateRelated ? container.getPersistenceManager().isModified(ctx) : container.getPersistenceManager().isStoreRequired(ctx); } } return false; }
// in src/main/java/org/jboss/cache/invalidation/triggers/EntityBeanCacheBatchInvalidatorInterceptor.java
public Object invoke(org.jboss.invocation.Invocation mi) throws Exception { if (doCacheInvalidations) { // We are going to work with the context a lot org.jboss.ejb.EntityEnterpriseContext ctx = (org.jboss.ejb.EntityEnterpriseContext)mi.getEnterpriseContext(); Object id = ctx.getId(); // The Tx coming as part of the Method Invocation javax.transaction.Transaction tx = mi.getTransaction(); // Invocation with a running Transaction if (tx != null && tx.getStatus() != javax.transaction.Status.STATUS_NO_TRANSACTION) { //Invoke down the chain Object retVal = getNext().invoke(mi); if (changed(mi, ctx)) { org.jboss.cache.invalidation.InvalidationsTxGrouper.registerInvalidationSynchronization (tx, this.ig, (java.io.Serializable)id); } // return the return value return retVal; } // else { // No tx Object result = getNext().invoke(mi); if (changed(mi, ctx)) { org.jboss.cache.invalidation.InvalidationsTxGrouper.registerInvalidationSynchronization (tx, this.ig, (java.io.Serializable)id); } return result; } } else { return getNext().invoke(mi); } }
// in src/main/java/org/jboss/cache/invalidation/triggers/EntityBeanCacheBatchInvalidatorInterceptor.java
public void importXml(Element element) throws Exception { String str = MetaData.getElementAttribute(element, "invalidate-related"); invalidateRelated = (str == null ? true : Boolean.valueOf(str).booleanValue()); if(log.isTraceEnabled()) { log.trace("invalidate-related: " + invalidateRelated); } }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
protected void startService () throws Exception { log.info("Starting JMS cache invalidation bridge"); // Deal with the InvalidationManager first.. // this.invalMgr = (org.jboss.cache.invalidation.InvalidationManagerMBean) org.jboss.system.Registry.lookup (this.invalidationManagerName); this.invalidationSubscription = invalMgr.registerBridgeListener (this); // deal with JMS next // InitialContext iniCtx = getInitialContext (); Object tmp = iniCtx.lookup(this.connectionFactoryName); TopicConnectionFactory tcf = (TopicConnectionFactory) tmp; conn = tcf.createTopicConnection(); topic = (Topic) iniCtx.lookup(this.topicName); session = conn.createTopicSession(this.transacted, this.acknowledgeMode); conn.start(); // Are we publisher, subscriber, or both? // if (this.propagationMode == JMSCacheInvalidationBridgeMBean.IN_OUT_BRIDGE_PROPAGATION || this.propagationMode == JMSCacheInvalidationBridgeMBean.IN_ONLY_BRIDGE_PROPAGATION) { this.subscriber = session.createSubscriber(topic); this.subscriber.setMessageListener(this); } if (this.propagationMode == JMSCacheInvalidationBridgeMBean.IN_OUT_BRIDGE_PROPAGATION || this.propagationMode == JMSCacheInvalidationBridgeMBean.OUT_ONLY_BRIDGE_PROPAGATION) { this.pub = session.createPublisher(topic); this.publishingAuthorized = true; } }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public void startService () throws Exception { // bind us in system registry // log.debug ("Starting Invalidation Manager " + this.getServiceName ().toString ()); org.jboss.system.Registry.bind (this.getServiceName ().toString (), this); this.hashcode = this.getServiceName ().hashCode (); }
// in src/main/java/org/jboss/monitor/BeanCacheMonitor.java
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { m_mbeanServer = server; return name; }
// in src/main/java/org/jboss/monitor/BeanCacheMonitor.java
public void preDeregister() throws Exception {}
// in src/main/java/org/jboss/monitor/EntityLockMonitor.java
protected void startService() throws Exception { bind(); log.info("EntityLockMonitor started"); }
// in src/main/java/org/jboss/web/WebServer.java
public void start() throws Exception { if (executor == null) throw new IllegalArgumentException("Required property 'executor' not specified"); try { server = new ServerSocket(port, backlog, bindAddress); log.debug("Started server: " + server); listen(); } catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); } catch (IOException e) { throw e; } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public synchronized WebApplication start(DeploymentUnit unit, JBossWebMetaData metaData) throws Exception { Thread thread = Thread.currentThread(); ClassLoader appClassLoader = thread.getContextClassLoader(); WebApplication webApp = null; try { // Create a classloader for the war to ensure a unique ENC ClassLoader warLoader = unit.getClassLoader(); thread.setContextClassLoader(warLoader); String webContext = metaData.getContextRoot(); // Get the war URL URL warUrl = unit.getAttachment("org.jboss.web.expandedWarURL", URL.class); if (warUrl == null && unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vdu = VFSDeploymentUnit.class.cast(unit); warUrl = VFSUtils.getPhysicalURL(vdu.getRoot()); } // Dynamic WebMetaData deployments might not provide an URL // We use the DEploymentUnit name as identifier instead. // The JAXWS Endpoint API for example does this. String warURLString = (warUrl != null ? warUrl.toExternalForm() : unit.getName()); // Strip any jar: url syntax. This should be be handled by the vfs if (warURLString.startsWith("jar:")) warURLString = warURLString.substring(4, warURLString.length() - 2); log.debug("webContext: " + webContext); log.debug("warURL: " + warURLString); // Register the permissions with the JACC layer String contextID = metaData.getJaccContextID(); if (contextID == null) contextID = unit.getSimpleName(); metaData.setJaccContextID(contextID); webApp = new WebApplication(metaData); webApp.setClassLoader(warLoader); webApp.setDeploymentUnit(unit); performDeploy(webApp, warURLString); } finally { thread.setContextClassLoader(appClassLoader); } return webApp; }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public synchronized void stop(DeploymentUnit di, WebApplication webApp) throws Exception { URL warURL = webApp.getURL(); String warUrl = warURL.toString(); performUndeploy(webApp, warUrl); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void processEnc(ClassLoader loader, WebApplication webApp) throws Exception { if (loader == null) throw new IllegalArgumentException("Classloader passed to process ENC refs is null"); log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin"); InitialContext iniCtx = new InitialContext(); Context envCtx = null; Thread currentThread = Thread.currentThread(); ClassLoader currentLoader = currentThread.getContextClassLoader(); JBossWebMetaData metaData = webApp.getMetaData(); try { // Create a java:comp/env environment unique for the web application log.debug("Creating ENC using ClassLoader: " + loader); ClassLoader parent = loader.getParent(); while (parent != null) { log.debug(".." + parent); parent = parent.getParent(); } // TODO: The enc should be an input? currentThread.setContextClassLoader(loader); // webApp.setENCLoader(loader); envCtx = (Context)iniCtx.lookup("java:comp"); // TODO: inject the ORB try { ObjectName ORB_NAME = new ObjectName("jboss:service=CorbaORB"); org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB)server.getAttribute(ORB_NAME, "ORB"); // Bind the orb if (orb != null) { NonSerializableFactory.rebind(envCtx, "ORB", orb); log.debug("Bound java:comp/ORB"); } } catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); } // TODO: injection, Add a link to the global transaction manager envCtx.bind("UserTransaction", new LinkRef("UserTransaction")); log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction"); envCtx = envCtx.createSubcontext("env"); processEncReferences(webApp, envCtx); } finally { currentThread.setContextClassLoader(currentLoader); } String securityDomain = metaData.getSecurityDomain(); log.debug("linkSecurityDomain"); linkSecurityDomain(securityDomain, envCtx); log.debug("AbstractWebContainer.parseWebAppDescriptors, End"); }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingDeployer.java
Override protected JSFDeployment parse(DeploymentUnit unit, String name, JSFDeployment output) throws Exception { if (unit instanceof VFSDeploymentUnit == false) { return null; } if (ignoreName(unit, name)) { return null; } VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; List<VirtualFile> facesConfigXmlFiles = vfsDeploymentUnit.getMetaDataFiles(new FacesConfigXmlFileNameMatchFilter(), MetaDataTypeFilter.ALL); if (facesConfigXmlFiles == null || facesConfigXmlFiles.isEmpty()) { return null; } JSFDeployment jsfDeployment = vfsDeploymentUnit.getAttachment(JSFDeployment.class); for (VirtualFile facesConfigXmlFile : facesConfigXmlFiles) { if (this.ignoreFile(vfsDeploymentUnit, facesConfigXmlFile)) { continue; } jsfDeployment = this.parse(vfsDeploymentUnit, facesConfigXmlFile, jsfDeployment); } return jsfDeployment; }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingDeployer.java
Override protected JSFDeployment parse(VFSDeploymentUnit unit, VirtualFile file, JSFDeployment jsfDeployment) throws Exception { URL facesConfigURL = file.toURL(); if (jsfDeployment == null) { // create the jsf deployment. Note that we don't have to attach it to the deployment unit, since that part // will be done by the AbstractVFSParsingDeployer which will attach the return value of this method to the unit. jsfDeployment = new JSFDeployment(); } // parse the xml file and update the jsf deployment FacesConfigParsingUtil.parse(unit, facesConfigURL, jsfDeployment); // return the updated jsf deployment return jsfDeployment; }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public void start() throws Exception { startModule(); }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public void stop() throws Exception { stopModule(); }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public synchronized void startModule() throws Exception { if (this.unit == null || this.container == null || this.deployment == null) throw new IllegalStateException("WebModules cannot be restarted, and must be redeployed"); // Get the war URL JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); WebApplication webApp = deployment.start(unit, metaData); String warURL = unit.getName(); container.addDeployedApp(warURL, webApp); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
public void start() throws Exception { // TODO: remove dependency on jmx this.server = MBeanServerLocator.locateJBoss(); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
public void stop() throws Exception { }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
protected void deployWebModule(DeploymentUnit unit, JBossWebMetaData metaData, AbstractWarDeployment deployment) throws Exception { log.debug("deployWebModule: " + unit.getName()); try { ServiceMetaData webModule = new ServiceMetaData(); String name = getObjectName(metaData); ObjectName objectName = new ObjectName(name); webModule.setObjectName(objectName); webModule.setCode(WebModule.class.getName()); // WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment) ServiceConstructorMetaData constructor = new ServiceConstructorMetaData(); constructor.setSignature(new String[] { DeploymentUnit.class.getName(), AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName() }); constructor.setParameters(new Object[] { unit, this, deployment }); webModule.setConstructor(constructor); List<ServiceAttributeMetaData> attrs = new ArrayList<ServiceAttributeMetaData>(); ServiceAttributeMetaData attr = new ServiceAttributeMetaData(); attr.setName("SecurityManagement"); ServiceInjectionValueMetaData injectionValue = new ServiceInjectionValueMetaData(deployment.getSecurityManagementName()); attr.setValue(injectionValue); attrs.add(attr); ServiceAttributeMetaData attrPR = new ServiceAttributeMetaData(); attrPR.setName("PolicyRegistration"); ServiceInjectionValueMetaData injectionValuePR = new ServiceInjectionValueMetaData(deployment.getPolicyRegistrationName()); attrPR.setValue(injectionValuePR); attrs.add(attrPR); ServiceAttributeMetaData attrKernel = new ServiceAttributeMetaData(); attrKernel.setName("Kernel"); ServiceInjectionValueMetaData injectionValueKernel = new ServiceInjectionValueMetaData(KernelConstants.KERNEL_NAME); attrKernel.setValue(injectionValueKernel); attrs.add(attrKernel); webModule.setAttributes(attrs); // Dependencies...Still have old jmx names here Collection<String> depends = metaData.getDepends(); List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>(); if (depends != null && depends.isEmpty() == false) { if (log.isTraceEnabled()) log.trace(name + " has dependencies: " + depends); for (String iDependOn : depends) { ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData(); sdmd.setIDependOn(iDependOn); dependencies.add(sdmd); } } // SwitchBoard Barrier switchBoard = unit.getAttachment(Barrier.class); if (switchBoard != null) { // Setup switchboard dependency on the deployment ServiceDependencyMetaData switchBoardDependency = new AnyStateServiceDependencyMetaData(switchBoard.getId(), ControllerState.START, ControllerState.INSTALLED); dependencies.add(switchBoardDependency); log.debug("Added switchboard dependency: " + switchBoard.getId() + " for web module: " + name); } // Injection Manager InjectionManager injectionManager = unit.getAttachment(InjectionManager.class); if (injectionManager != null) { // set the InjectionManager on the deployment deployment.setInjectionManager(injectionManager); // Setup the Injector Environment webEnvironment = metaData.getJndiEnvironmentRefsGroup(); if (webEnvironment != null) { // convert JBMETA metadata to jboss-injection specific metadata JndiEnvironmentRefsGroup jndiEnvironment = new JndiEnvironmentImpl(webEnvironment, unit.getClassLoader()); // For optimization, we'll create an Injector only if there's atleast one InjectionTarget if (this.hasInjectionTargets(jndiEnvironment)) { // create the injector EEInjector eeInjector = new EEInjector(jndiEnvironment); // add the injector the injection manager injectionManager.addInjector(eeInjector); // Deploy the Injector as a MC bean (so that the fully populated naming context (obtained via the SwitchBoard // Barrier) gets injected. String injectorMCBeanName = this.getInjectorMCBeanName(unit); BeanMetaData injectorBMD = this.createInjectorBMD(injectorMCBeanName, eeInjector, switchBoard); unit.addAttachment(BeanMetaData.class + ":" + injectorMCBeanName, injectorBMD); // Add the Injector dependency on the deployment (so that the DU doesn't // get started till the Injector is available) ServiceDependencyMetaData injectorDepdendency = new ServiceDependencyMetaData(); injectorDepdendency.setIDependOn(injectorMCBeanName); dependencies.add(injectorDepdendency); log.debug("Added Injector dependency: " + injectorMCBeanName + " for web module: " + name); } } } // TODO: We haven't yet integrated PC and EJB reference providers in SwitchBoard. // The following sections will be removed after the RPs are made available // JBAS-6795 Add dependency on PersistenceContext references PersistenceContextReferencesMetaData pcRefs = metaData.getPersistenceContextRefs(); if (pcRefs != null) { for (PersistenceContextReferenceMetaData pcRef : metaData.getPersistenceContextRefs()) { // TODO: this is a duplication of the logic in PersistenceContextHandler String persistenceUnitName = pcRef.getPersistenceUnitName(); String beanName = persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(unit, persistenceUnitName); ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData(); sdmd.setIDependOn(beanName); dependencies.add(sdmd); } } webModule.setDependencies(dependencies); // Here's where a bit of magic happens. By attaching the ServiceMetaData // to the deployment, we now make the deployment "relevant" to // deployers that use ServiceMetaData as an input (e.g. the // org.jboss.system.deployers.ServiceDeployer). Those deployers // can now take over deploying the web module. unit.addAttachment("WarServiceMetaData", webModule, ServiceMetaData.class); } catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e); } }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
protected void processMetaData(VFSDeploymentUnit unit, List<VirtualFile> classpath) throws Exception { ResourcesIndex ri = unit.getAttachment(ResourcesIndex.class); if (ri == null) { return; } AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>(); Web30MetaDataCreator creator = new Web30MetaDataCreator(finder); // Merge processed annotations from all scopes Set<Class<? extends Annotation>> annotations = new HashSet<Class<? extends Annotation>>(); AnnotationContext annotationContext = creator.getAnnotationContext(); if (annotationContext.getTypeAnnotations() != null) annotations.addAll(annotationContext.getTypeAnnotations()); if (annotationContext.getMethodAnnotations() != null) annotations.addAll(annotationContext.getMethodAnnotations()); if (annotationContext.getFieldAnnotations() != null) annotations.addAll(annotationContext.getFieldAnnotations()); boolean metaData = false; for (VirtualFile path : classpath) { Set<Class<?>> annotatedClasses = new HashSet<Class<?>>(); for (Class<? extends Annotation> annotation : annotations) { annotatedClasses.addAll(ri.getAnnotatedClasses(path, annotation)); } WebMetaData annotationMetaData = creator.create(annotatedClasses); if (annotationMetaData != null) { unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME + ":" + path.getName(), annotationMetaData, WebMetaData.class); metaData = true; } } if (metaData) unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, Boolean.TRUE); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
private void processConfigFilesContextParamValue(final VFSDeploymentUnit vfsDeploymentUnit, final JSFDeployment jsfDeployment, final String configFilesContextParamValue) throws Exception { if (configFilesContextParamValue == null) { return; } // trim the context param value String trimmedConfigParamValues = configFilesContextParamValue.trim(); // split the paths which are separated by "," delimiter String[] paths = trimmedConfigParamValues.split(","); for (String path : paths) { // trim each path path = path.trim(); if (path.isEmpty()) { continue; } // skip this path, since .war/WEB-INF/faces-config.xml is by default parsed // (by a separate deployer) if (WEB_INF_FACES_CONFIG_XML.equals(path)) { continue; } // get hold of the file relative to the deployment unit root VirtualFile facesConfigXml = vfsDeploymentUnit.getRoot().getChild(path); // for a file which wasn't found, just log a WARN and move on to the next if (facesConfigXml == null) { logger.warn("Faces config xml not found at relative path: " + path + " in unit " + vfsDeploymentUnit.getRoot()); continue; } logger.debug("Found faces config xml with relative path: " + path + " in unit " + vfsDeploymentUnit.getRoot()); // parse the faces config file FacesConfigParsingUtil.parse(vfsDeploymentUnit, facesConfigXml.toURL(), jsfDeployment); } }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
public static void parse(final DeploymentUnit unit, final URL facesConfigXmlURL, final JSFDeployment jsfDeployment) throws Exception { logger.debug("Checking for the presence of JSF managed-bean(s) in JSF config file: " + facesConfigXmlURL + " in deployment unit: " + unit); // get the parser factory SAXParserFactory parserFactory = getParserFactory(); // create a parser SAXParser saxParser = parserFactory.newSAXParser(); InputStream inputStream = null; try { // get the input stream and the input source for the faces config file inputStream = getInputStream(facesConfigXmlURL); InputSource inputSource = new InputSource(getInputStream(facesConfigXmlURL)); inputSource.setSystemId(facesConfigXmlURL.toExternalForm()); // parse it! saxParser.parse(inputSource, new DefaultHandler() { /** * Flag to keep track of managed-bean-class element being processed */ private boolean managedBeanClassElementProcessingInProgress; /** * Uses the {@link JBossEntityResolver} to resolve the entity. If it cannot be resolved by the {@link JBossEntityResolver} * then this method lets the {@link DefaultHandler} to resolve it. * * @param publicId * @param systemId * @return * @throws IOException * @throws SAXException */ @Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { // try resolving it with the JBossEntityResolver InputSource source = jBossJSFEntityResolver.resolveEntity(publicId, systemId); if (source != null) { return source; } // we couldn't resolve, so let the default handler try to resolve it return super.resolveEntity(publicId, systemId); } @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // we are only interested in managed-bean-class element. if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = true; } // let the super do its job super.startElement(uri, localName, qName, attributes); } @Override public void endElement(String uri, String localName, String qName) throws SAXException { // reset the flag when the managed-bean-class element ends if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = false; } // let super do its job super.endElement(uri, localName, qName); } @Override public void characters(char[] ch, int start, int length) throws SAXException { // if we are currently processing the managed-bean-class element, then fetch the managed bean // class name text if (this.managedBeanClassElementProcessingInProgress) { // get the managed bean class name String managedBeanClassName = new String(ch, start, length); if (!managedBeanClassName.trim().isEmpty()) { logger.debug("Found JSF managed bean class: " + managedBeanClassName + " in unit " + unit); // add it to the jsf deployment jsfDeployment.addManagedBean(managedBeanClassName); } } // let super do its job now super.characters(ch, start, length); } }); } finally { if (inputStream != null) { inputStream.close(); } } return; }
// in src/main/java/org/jboss/web/deployers/SpecCompliantWarAnnotationDeployer.java
Override protected void processMetaData(VFSDeploymentUnit unit, List<VirtualFile> classpath) throws Exception { ResourcesIndex resourceIndex = unit.getAttachment(ResourcesIndex.class); if (resourceIndex == null) { return; } AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>(); Web30MetaDataCreator creator = new Web30MetaDataCreator(finder); // Merge processed annotations from all scopes Set<Class<? extends Annotation>> annotations = new HashSet<Class<? extends Annotation>>(); AnnotationContext annotationContext = creator.getAnnotationContext(); if (annotationContext.getTypeAnnotations() != null) annotations.addAll(annotationContext.getTypeAnnotations()); if (annotationContext.getMethodAnnotations() != null) annotations.addAll(annotationContext.getMethodAnnotations()); if (annotationContext.getFieldAnnotations() != null) annotations.addAll(annotationContext.getFieldAnnotations()); Collection<Class<?>> specEligibleResourceInjectionClasses = this.getResourceInjectionEligibleWebAppClasses(resourceIndex, classpath); boolean metaData = false; final JSFDeployment jsfDeployment = unit.getAttachment(JSFDeployment.class); final ManagedBeanDeploymentMetaData managedBeanDeployment = unit.getAttachment(ManagedBeanDeploymentMetaData.class); for (VirtualFile path : classpath) { Collection<Class<?>> eligibleAnnotatedClasses = new HashSet<Class<?>>(); for (Class<? extends Annotation> annotation : annotations) { Collection<Class<?>> annotatedClasses = resourceIndex.getAnnotatedClasses(path, annotation); // include the jsf and Java EE6 managed beans as eligible for resource injection specEligibleResourceInjectionClasses.addAll(this.getManagedBeansRelatedClasses(jsfDeployment, managedBeanDeployment, annotatedClasses)); // filter out any extra non-spec classes which shouldn't be picked up for resource injection processing eligibleAnnotatedClasses.addAll(this.retainResourceInjectionEligibleWebAppClasses(specEligibleResourceInjectionClasses, annotatedClasses)); } WebMetaData annotationMetaData = creator.create(eligibleAnnotatedClasses); if (annotationMetaData != null) { unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME + ":" + path.getName(), annotationMetaData, WebMetaData.class); metaData = true; } } if (metaData) { unit.addAttachment(WEB_ANNOTATED_ATTACHMENT_NAME, Boolean.TRUE); } }
// in src/main/java/org/jboss/web/WebService.java
protected void createService() throws Exception { // Load the file mime.types into the mapping list Properties mimeTypes = new Properties(); try { mimeTypes.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("org/jboss/web/mime.types")); Enumeration keys = mimeTypes.keys(); while (keys.hasMoreElements()) { String extension = (String) keys.nextElement(); String type = mimeTypes.getProperty(extension); server.addMimeType(extension, type); } } catch (Exception e) { log.error("Failed to load org/jboss/web/mime.types; ignoring", e); } // if no override has been specified, default to the jboss bind address if (getBindAddress() == null) setBindAddress(System.getProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS)); // if no host specified, default to the java.rmi.server.hostname property value if (getHost() == null) setHost(System.getProperty("java.rmi.server.hostname")); // Set the rmi codebase if it is not already set String codebase = getCodebase(); if (codebase == null) { // JBAS-8540 codebase = "http://" + ServerConfigUtil.fixHostnameForURL(getHost()) + ":" + getPort() + "/"; System.setProperty("java.rmi.server.codebase", codebase); } log.info("Using RMI server codebase: " + codebase); }
// in src/main/java/org/jboss/web/WebService.java
protected void startService() throws Exception { // Start the WebServer running server.start(); // JBAS-8540 log.debug("Started WebServer with address: " + ServerConfigUtil.fixHostnameForURL(getBindAddress()) + ":" + getPort()); }
// in src/main/java/org/jboss/web/WebService.java
protected void stopService() throws Exception { server.stop(); // JBAS-8540 log.debug("Stopped WebServer with address: " + ServerConfigUtil.fixHostnameForURL(getBindAddress()) + ":" + getPort()); }
// in src/main/java/org/jboss/web/WebClassLoaderFactory.java
public static WebClassLoader createWebClassLoader(Class<?> webClassLoaderClass, ObjectName containerName, RealClassLoader parent) throws Exception { Constructor constructor = webClassLoaderClass.getConstructor(new Class[]{ObjectName.class, RealClassLoader.class}); return (WebClassLoader) constructor.newInstance(new Object[]{containerName, parent}); }
// in src/main/java/org/jboss/web/RMICodebaseConfigurer.java
Override protected void startService() throws Exception { // Set the rmi codebase if it is not already set String codebase = System.getProperty("java.rmi.server.codebase"); if (codebase == null) { if (host != null) { codebase = "http://" + getHostPortion() + getPortPortion() + "/"; System.setProperty("java.rmi.server.codebase", codebase); } else { getLog().warn("Property codebaseHost has not been set; cannot set java.rmi.server.codebase"); } } }
// in src/main/java/org/jboss/proxy/compiler/Runtime.java
void makeProxyType(ProxyCompiler compiler) throws Exception { this.compiler = compiler; // temporary, for use during loading byte code[] = compiler.getCode(); compiler.proxyType = super.defineClass(compiler.getProxyClassName(), code, 0, code.length); super.resolveClass(compiler.proxyType); // set the Foo$Impl.info pointer to myself Field field = compiler.proxyType.getField(RUNTIME_FN); field.set(null, this); compiler = null; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
public static ProxyTarget newTarget(ClassLoader parent, InvocationHandler invocationHandler, Class targetTypes[]) throws Exception { return Impl.getImpl(targetTypes).newTarget(invocationHandler, parent); }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
ProxyTarget newTarget(InvocationHandler invocationHandler, ClassLoader parent) throws Exception { if (proxyConstructor == null) { // make the proxy constructor ProxyCompiler pc = new ProxyCompiler(parent, superclass, targetTypes, methods); Class type[] = { InvocationHandler.class }; proxyConstructor = pc.getProxyType().getConstructor(type); } Object args[] = { invocationHandler }; return (ProxyTarget)proxyConstructor.newInstance(args); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
protected EJBObject getEjbObjectViaInvoker() throws Exception { if (log.isTraceEnabled()) { log.trace("Using legacy invoker method for getEJBObject() invocation."); } SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); Invocation invocation = new Invocation( null, GET_EJB_OBJECT, new Object[]{id}, //No transaction set up in here? it will get picked up in the proxy null, // fix for bug 474134 from Luke Taylor sa.getPrincipal(), sa.getCredential()); invocation.setObjectName(new Integer(objectName)); invocation.setValue(InvocationKey.INVOKER_PROXY_BINDING, invokerProxyBinding, PayloadKey.AS_IS); // It is a home invocation invocation.setType(InvocationType.HOME); // Create an invocation context for the invocation InvocationContext ctx = new InvocationContext(); invocation.setInvocationContext(ctx); // Get the invoker to the target server (cluster or node) // Ship it if (isLocal()) return (EJBObject) InvokerInterceptor.getLocal().invoke(invocation); else return (EJBObject) invoker.invoke(invocation); }
// in src/main/java/org/jboss/proxy/ejb/SecurityActions.java
static SecurityContext createSecurityContext(final Principal p, final Object cred, final String sdomain) throws Exception { return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>() { public SecurityContext run() throws Exception { return SecurityContextFactory.createSecurityContext(p,cred, null, sdomain); } }); }
// in src/main/java/org/jboss/proxy/ejb/SecurityActions.java
public SecurityContext run() throws Exception { return SecurityContextFactory.createSecurityContext(p,cred, null, sdomain); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public void create() throws Exception { jmxName = container.getJmxName(); jmxNameHash = jmxName.hashCode(); jmxNameHashInteger = new Integer(jmxNameHash); // Create metadata BeanMetaData bmd = container.getBeanMetaData(); boolean isSession = !(bmd instanceof EntityMetaData); boolean isStatelessSession = false; if(isSession) { SessionMetaData smd = (SessionMetaData) bmd; if(bmd.getRemote() == null) { isServiceEndpointOnly = true; // nothing more to do return; } isStatelessSession = smd.isStateless(); } Class pkClass = null; if(!isSession) { EntityMetaData metaData = (EntityMetaData) bmd; String pkClassName = metaData.getPrimaryKeyClass(); try { if(pkClassName != null) { pkClass = container.getClassLoader().loadClass(pkClassName); } else { pkClass = container.getClassLoader() .loadClass(metaData.getEjbClass()) .getField(metaData.getPrimKeyField()) .getClass(); } } catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); } catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); } } ejbMetaData = new EJBMetaDataImpl( ((EJBProxyFactoryContainer) container).getRemoteClass(), ((EJBProxyFactoryContainer) container).getHomeClass(), pkClass, //null if not entity isSession, //Session isStatelessSession, //Stateless new HomeHandleImpl(jndiBinding) ); log.debug("Proxy Factory for " + jndiBinding + " initialized"); initInterceptorClasses(); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public void start() throws Exception { if(!isServiceEndpointOnly) { setupInvokers(); bindProxy(); } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void setupInvokers() throws Exception { ObjectName oname = new ObjectName(invokerMetaData.getInvokerMBean()); Invoker invoker = (Invoker) Registry.lookup(oname); if(invoker == null) { throw new RuntimeException("invoker is null: " + oname); } homeInvoker = beanInvoker = invoker; }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void initInterceptorClasses() throws Exception { HashMap interceptors = new HashMap(); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); Element clientInterceptors = MetaData.getOptionalChild( proxyConfig, "client-interceptors", null ); if(clientInterceptors != null) { String value = MetaData.getElementAttribute(clientInterceptors, "exposeContainer"); this.includeIClientIface = Boolean.valueOf(value).booleanValue(); NodeList children = clientInterceptors.getChildNodes(); for(int i = 0; i < children.getLength(); i++) { Node currentChild = children.item(i); if(currentChild.getNodeType() == Node.ELEMENT_NODE) { Element interceptor = (Element) children.item(i); interceptors.put(interceptor.getTagName(), interceptor); } } } else { log.debug("client interceptors element is null"); } Element homeInterceptorConf = (Element) interceptors.get(HOME_INTERCEPTOR); loadInterceptorClasses(homeInterceptorClasses, homeInterceptorConf); if(homeInterceptorClasses.size() == 0) { throw new DeploymentException("There are no home interface interceptors configured"); } Element beanInterceptorConf = (Element) interceptors.get(BEAN_INTERCEPTOR); loadInterceptorClasses(beanInterceptorClasses, beanInterceptorConf); if(beanInterceptorClasses.size() == 0) { throw new DeploymentException("There are no bean interface interceptors configured"); } Element listEntityInterceptorConf = (Element) interceptors.get(LIST_ENTITY_INTERCEPTOR); loadInterceptorClasses(listEntityInterceptorClasses, listEntityInterceptorConf); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void loadInterceptorClasses(ArrayList classes, Element interceptors) throws Exception { Iterator interceptorElements = MetaData.getChildrenByTagName(interceptors, "interceptor"); ClassLoader loader = container.getClassLoader(); while(interceptorElements != null && interceptorElements.hasNext()) { Element ielement = (Element) interceptorElements.next(); String className = null; className = MetaData.getElementContent(ielement); // load the invoker interceptor that corresponds to the beans call semantic String byValueAttr = MetaData.getElementAttribute(ielement, "call-by-value"); if(byValueAttr != null) { if (container.isCallByValue() == new Boolean(byValueAttr).booleanValue()) { Class clazz = loader.loadClass(className); classes.add(clazz); } } else { Class clazz = loader.loadClass(className); classes.add(clazz); } } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void loadInterceptorChain(ArrayList chain, ClientContainer client) throws Exception { Interceptor last = null; for(int i = 0; i < chain.size(); i++) { Class clazz = (Class) chain.get(i); Interceptor interceptor = (Interceptor) clazz.newInstance(); if(last == null) { last = interceptor; client.setNext(interceptor); } else { last.setNext(interceptor); last = interceptor; } } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void bindProxy() throws Exception { try { // Create a stack from the description (in the future) for now we hardcode it InvocationContext context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); // The behavior for home proxying should be isolated in an interceptor FIXME context.setInvoker(homeInvoker); context.setValue(InvocationKey.EJB_METADATA, ejbMetaData); context.setInvokerProxyBinding(invokerMetaData.getName()); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } ClientContainer client = null; EJBProxyFactoryContainer pfc = (EJBProxyFactoryContainer) container; Class[] ifaces = {pfc.getHomeClass(), Class.forName("javax.ejb.Handle")}; if( includeIClientIface ) { ifaces = new Class[] {IClientContainer.class, pfc.getHomeClass(), Class.forName("javax.ejb.Handle")}; client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } loadInterceptorChain(homeInterceptorClasses, client); // Create the EJBHome this.home = (EJBHome) Proxy.newProxyInstance( // Class loader pointing to the right classes from deployment pfc.getHomeClass().getClassLoader(), // The classes we want to implement home and handle ifaces, // The home proxy as invocation handler client); // Create stateless session object // Same instance is used for all objects if(ejbMetaData.isStatelessSession() == true) { // Create a stack from the description (in the future) for now we hardcode it context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); // The behavior for home proxying should be isolated in an interceptor FIXME context.setInvoker(beanInvoker); context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } Class[] ssifaces = {pfc.getRemoteClass()}; if( includeIClientIface ) { ssifaces = new Class[] {IClientContainer.class, pfc.getRemoteClass()}; client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } loadInterceptorChain(beanInterceptorClasses, client); this.statelessObject = (EJBObject)Proxy.newProxyInstance( // Correct CL pfc.getRemoteClass().getClassLoader(), // Interfaces ssifaces, // SLSB proxy as invocation handler client ); } else { // this is faster than newProxyInstance Class[] intfs = {pfc.getRemoteClass()}; if( this.includeIClientIface ) { intfs = new Class[]{IClientContainer.class, pfc.getRemoteClass()}; } Class proxyClass = Proxy.getProxyClass(pfc.getRemoteClass().getClassLoader(), intfs); final Class[] constructorParams = {InvocationHandler.class}; proxyClassConstructor = proxyClass.getConstructor(constructorParams); } // Bind the home in the JNDI naming space rebindHomeProxy(); } catch(Exception e) { throw new ServerException("Could not bind home", e); } }
// in src/main/java/org/jboss/proxy/ejb/SecurityContextInterceptor.java
private SecurityContext createSecurityContext(Invocation invocation) throws Exception { //There may be principal set on the invocation Principal p = invocation.getPrincipal(); Object cred = invocation.getCredential(); //Create a new SecurityContext String domain = (String) invocation.getInvocationContext().getValue(InvocationKey.SECURITY_DOMAIN); if(domain == null) domain = "CLIENT_PROXY"; return SecurityActions.createSecurityContext(p,cred, domain); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
protected void loadInterceptorChain(ArrayList chain, ClientContainer client) throws Exception { Interceptor last = null; for (int i = 0; i < chain.size(); i++) { Class clazz = (Class)chain.get(i); Interceptor interceptor = (Interceptor) clazz.newInstance(); if (last == null) { last = interceptor; client.setNext(interceptor); } else { last.setNext(interceptor); last = interceptor; } } }
// in src/etc/class.java
public void startService() throws Exception { // Use the newline for the opening bracket so we can match top and bottom bracket visually Class cls = Class.forName(dataSourceClass); vendorSource = (XADataSource)cls.newInstance(); // JUMP A LINE BETWEEN LOGICALLY DISCTINT **STEPS** AND ADD A LINE OF COMMENT TO IT cls = vendorSource.getClass(); if(properties != null && properties.length() > 0) { try { } catch (IOException ioe) { } for (Iterator i = props.entrySet().iterator(); i.hasNext();) { // Get the name and value for the attributes Map.Entry entry = (Map.Entry) i.next(); String attributeName = (String) entry.getKey(); String attributeValue = (String) entry.getValue(); // Print the debug message log.debug("Setting attribute '" + attributeName + "' to '" + attributeValue + "'"); // get the attribute Method setAttribute = cls.getMethod("set" + attributeName, new Class[] { String.class }); // And set the value setAttribute.invoke(vendorSource, new Object[] { attributeValue }); } } // Test database vendorSource.getXAConnection().close(); // Bind in JNDI bind(new InitialContext(), "java:/"+getPoolName(), new Reference(vendorSource.getClass().getName(), getClass().getName(), null)); }
375
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { log.warn("Failed to install SecurityAssociationAuthenticator", e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { log.warn("Failed to read "+SSL_FACTORY_BUILDER, e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (Exception e) { log.warn("Could not instantiate SSLSocketFactoryFactory", e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { log.warn("Failed to install SecurityAssociationAuthenticator", e); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { throw new InvocationTargetException(e); }
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { e.printStackTrace(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { e.printStackTrace(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { e.printStackTrace(); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception ignored) { return null; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (Exception e) { log.error(e); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch (Exception e) { }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Exception e) { log.fatal("Could not initialize UnifiedInvokerProxy.", e); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { log.error("Error adding unified invoker as handler upon connector being set.", e); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { Throwable th = JMXExceptionDecoder.decode(e); if(log.isTraceEnabled()) { log.trace("Failed to invoke on mbean: " + mbean, th); } if(th instanceof Exception) { e = (Exception) th; } throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Exception e) { log.debug(iface+"No addNotificationListener(ObjectName, RMINotificationListener)"); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Exception e) { log.debug(iface+"No removeNotificationListener(ObjectName, RMINotificationListener)"); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Throwable t) { log.debug("Failed to notify client, unregistering listener", t); try { removeNotificationListener(targetName, client); } catch(Exception e) { log.debug("Failed to unregister listener", e); } }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Exception e) { log.debug("Failed to unregister listener", e); }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception inner) { throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(Exception e) { // Can't happen }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(Exception e) { String msg = "Failed to authorize principal=" + caller + ",MBean=" + objname + ", Operation=" + opname; SecurityException ex = new SecurityException(msg); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthenticationInterceptor.java
catch (Exception e) { }
// in src/main/java/org/jboss/jmx/connector/invoker/ExternalizableRolesAuthorization.java
catch (Exception e) { log.error("Error reading roles from jmxinvoker-roles.properties:",e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception e) { // ignore }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception e) { error = e; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception e) { close(); throw e; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception ignored) { log.trace("Ignored error during close", ignored); }
// in src/main/java/org/jboss/deployment/EARStructure.java
catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/JBossEjbParsingDeployer.java
catch (Exception ex) { DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex); }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(Exception ignored) { if(log.isTraceEnabled()) log.trace("Failed to load class: "+className, ignored); }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(Exception e) { }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(Exception e) { }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e); }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
catch (Exception e) { return false; }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { log.error("Cannot commit Parent Policy Configuration:",e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(Exception e) { NamingException ne = new NamingException("Failed to update jndiName"); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Exception e) { log.error("getDeployedApplications failed", e); appendErrorTag(buffer, "Failed to getDeployedApplications " + e.toString()); closeJndiTag(buffer); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Exception e) { // this is not expected - report it log.error("JNDIView.getHAJndiAttributes() failed", e); return null; }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception e) { handleOutputFileCreationException(file.toURI(), e); }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception ignored) { ; }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception ignored) {}
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
catch (Exception e) { log.warn("Failed to delete JNP URL file " + outputFile + " due to " + e); }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(Exception e) { NamingException ex = new NamingException("Failed to retrieve Naming interface for provider " + provider); ex.setRootCause(e); throw ex; }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch (Exception e) { if(e.getCause() instanceof IOException) { //no auth.conf or whatever so we make our own dummy conf = new DummyConfiguration(); } }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
catch(Exception e) { NamingException ne = new NamingException("Failed to obtain value from binding: "+name); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception ex) { throw new RuntimeException("UT factory lookup failed", ex); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception ex) { // ignore }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (Exception ex) { log.error("rollback failed", ex); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch (Exception e) { log.warn("Failed to unbind "+JNDI_NAME, e); }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (Exception e) { log.warn("Got Exception when looking for DeploymentUnit: " + e); return null; }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (Exception e) { log.warn("Got Exception when looking for DeploymentUnit: " + e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { throw new EJBException("Failed to create timer", e); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { log.error("Retry timeout failed for timer: " + txtimer, e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { log.error("Cannot create timer table", e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { log.error("Cannot deserialize", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { log.error("Cannot deserialize", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
catch (Exception e) { log.error("Cannot register txtimer with Tx: " + this); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
catch (Exception e) { log.error("Error invoking ejbTimeout", e); }
// in src/main/java/org/jboss/ejb/txtimer/FixedDelayRetryPolicy.java
catch (Exception ignore) { ignore.printStackTrace(); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (Exception e) { log.warn("Unable to restore timer record: " + handle); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.error("Cannot obtain the implementation of a RetryPolicy", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a PersistencePolicy, using NoopPersistencePolicy: " + e.toString()); persistencePolicy = new NoopPersistencePolicy(); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Cannot obtain the implementation of a TimerIdGenerator, using BigIntegerTimerIdGenerator: " + e.toString()); timerIdGenerator = new BigIntegerTimerIdGenerator(); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.error("Cannot create TimedObjectInvoker: " + timedObjectInvokerClassName, e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
catch (Exception e) { log.warn("Unable to restore timer record: " + handle, e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception ignore) { }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new RuntimeException("Cannot start EJBTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new IllegalStateException("Cannot create EJBTimerService proxy: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot createTimerService", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot createTimerService", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot getTimerService", e); return null; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot removeTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot removeTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { log.error("Cannot restoreTimer", e); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { destroyService(); throw e; }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.error("unexpected exception stopping Container: " + con.getJmxName(), e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.warn("Could not load the " + className + " interceptor for this container", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { log.warn("The Container Invoker " + invoker + " (in jboss.xml or standardjboss.xml) could not be created because of " + e + " We will ignore this error, but you may miss a transport for this bean."); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { log.warn("Failed to grant access to the Handle.getEJBObject method"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { throw new EJBException("Could not create timer service", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { log.error("Could not remove timer service", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { log.warn("Could not restore ejb timers", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { log.debug("failed to lookup DefaultDS; ignoring", e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { log.warn("Error undeploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception ignored) { // Ignore the lack of an EntityLockMonitor }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
catch (Exception x) { log.error("Failed to setSessionContext", x); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/CacheKey.java
catch (Exception e) { Logger log = Logger.getLogger(getClass()); log.error("failed to initialize, id="+id, e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (Exception e) { log.error("Error getting callerPrincipal for " + con.getBeanClass(),e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (Exception e) { log.error("isCallerInRole("+ roleName+") had exception:",e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { exception = e; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { exceptionThrown = e; throw e; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException (e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch (Exception e) { log.error("Failed to initialze DefaultSecurityProxy", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(Exception e) { log.error("Failed to initialze SecurityProxy", e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Could not load messaging-type class " + messagingType, e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Cannot locate resource adapter deployment " + resourceAdapterName, e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
catch (Exception ignore) { }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossJMSMessageEndpointFactory.java
catch (Exception ignored) { // backwards comaptibility }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactoryService.java
catch( Exception e ) { log.error( "Caught exception during startService()", e ); // Ingore }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactoryService.java
catch( Exception e ) { log.error( "Caught exception during startService()", e ); // Ingore }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/uuid/UUIDKeyGeneratorFactoryService.java
catch( Exception e ) { log.error( "Caught exception during stopService()", e ); // Ingore }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to begin a new transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { log.error("Failed to commit.", e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Exception ex) { log.warn("Unable to importXml for the TxInterceptorCMT", ex); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Exception ex) { checkRetryable(i, ex, oldTransaction); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Exception ex) { checkRetryable(i, ex, oldTransaction); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
catch (Exception ignored) { log.debug(ignored); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
catch (Exception ignored) { log.debug(ignored); }
// in src/main/java/org/jboss/ejb/plugins/InvalidableEntityInstanceCache.java
catch (Exception e) { log.debug(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception ignored) { log.warn("failed to passivate, id="+id, ignored); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.warn(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { vcr = null; log.warn("problem scheduling valid contexts refresher", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.debug("Exception releasing context", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { // Exception - force reload on next call ctx.setValid(false); throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.debug("Exception releasing context", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { log.debug("Exception releasing context", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception ex) { log.warn("Unable to determine transaction context", ex); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { throwRemoteException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (Exception e) { // catch JMSExceptions, tx.SystemExceptions, and NPE's // don't want to bother the container even if the metrics fail. return null; }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (Exception e) { }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { RemoveException re = new RemoveException(e.getMessage()); re.initCause(e); throw re; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ignore) { }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to register table cache for " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { log.error("Failed to stop entity bridge.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeRemoveRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeAddRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(Exception e) { throw new EJBException("Internal error extracting primary key from instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(Exception e) { throw new EJBException("Internal error", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCMappingMetaData.java
catch(Exception e) { log.warn("Unrecognized jdbc-type: " + name + ", using Types.OTHER", e); return Types.OTHER; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find getter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find setter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { throw new EJBException("Failed to obtain current transaction", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new IllegalStateException( "Failed to create an instance of " + valueType + " with the " + fieldValue + " as a ctor argument" ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.error("Could not suspend current transaction before drop table. " + "'" + qualifiedTableName + "' will not be dropped.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.debug("Could not drop table " + qualifiedTableName + ": " + e.getMessage()); success = false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(Exception e) { log.error("Could not reattach original transaction after drop table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("EXCEPTION ALTER :" + e.toString()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(Exception e) { log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(Exception e) { throw new EJBException("Error getting application tx data map.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCPostCreateEntityCommand.java
catch(Exception e) { // no such object }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { throw new EJBException("Error getting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { throw new EJBException("Error creating primary key instance: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error extracting primary key from " + "instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP2xFieldBridge.java
catch(Exception e) { // no such object }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP2xFieldBridge.java
catch(Exception e) { // no such object }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception ignore) { // no such entity. it is ok to ignore }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception ignore) { // no such entity. it is ok to ignore valid = false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in getRelatedId", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in addRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in removeRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(Exception e) { throw new EJBException("Load relation failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { prepare = null; getGeneratedKeys = null; generateKeys = null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { throw processException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Exception ignored) { }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Exception ignored) { log.warn("failed to passivate, id=" + id, ignored); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (Exception e) { //ignore }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (Exception ex) { log.error("Failed to rollback", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (Exception ex) { log.error("Failed to rollback", ex); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to setup InstanceSynchronization", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to invoke afterBegin", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to invoke beforeCompletion", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { log.error("failed to invoke afterCompletion", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/security/PreSecurityInterceptor.java
catch (Exception e) { if (log.isTraceEnabled()) { log.trace("Exception in creating TimedObject method:",e); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
catch (Exception ignored) { }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { rethrow(e); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationsTxGrouper.java
catch(Exception ex) { InvalidationsTxGrouper.log.warn("Failed sending invalidations messages", ex); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn(ex.getMessage()); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn("Failed to stop JMS resources associated with the JMS bridge: ", ex); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (Exception ex) { log.warn("failed to do cluster seppuku event: " , ex); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
catch (Exception e) { log.debug ("Problem while trying to register a new invalidation group in JMX", e); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
catch (Exception e) { log.debug ("Problem while trying to un-register a new invalidation group in JMX", e); }
// in src/main/java/org/jboss/monitor/EntityLockMonitor.java
catch (Exception ignored) {}
// in src/main/java/org/jboss/web/WebServer.java
catch (Exception ignore) {}
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (Exception e) { log.warn("Could not get global URL[] from default loader repository!", e); }
// in src/main/java/org/jboss/web/deployers/WebModule.java
catch (Exception e) { throw new DeploymentException("Error during stop", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { log.debug("Ignoring path element: " + vf, e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw new DeploymentException("Failed to create web module", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { log.debug("Failed to remove expanded war", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception ignore) { }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing fragment for JAR: " + jar, e); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (Exception e) { DeploymentException.rethrowAsDeploymentException("Deployment error scanning HandlesTypes", e); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (Exception e) { if (error) { DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jar, e); } else { log.info("Skipped SCI for JAR: " + jar, e); } }
// in src/main/java/org/jboss/web/WebService.java
catch (Exception e) { log.error("Failed to load org/jboss/web/mime.types; ignoring", e); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (Exception e) { return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (Exception e) { // e.printStackTrace(); return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (Exception e) { // e.printStackTrace(); return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (Exception ignored) { }
// in src/main/java/org/jboss/verifier/Main.java
catch (Exception e) { System.err.println("Problem starting the application:"); System.err.println("Exception: " + e); System.err.println("Message: " + e.getMessage()); e.printStackTrace(); System.exit(-1); }
// in src/main/java/org/jboss/proxy/compiler/Proxy.java
catch (Exception e) { throw new NestedRuntimeException("Failed to create new proxy target", e); }
// in src/main/java/org/jboss/proxy/compiler/ProxyCompiler.java
catch (Exception e) { log.error("Failed to dump class file", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { log.debug("Exception reported, try JNDI method to recover EJB object instead", e); return getEjbObjectViaJndi(); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new ServerException("Could not bind home", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { // ignore. }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
208
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { throw new InvocationTargetException(e); }
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Exception e) { if (e instanceof MBeanException) e = ((MBeanException)e).getTargetException(); if (e instanceof RuntimeMBeanException) e = ((RuntimeMBeanException)e).getTargetException(); if (e instanceof RuntimeOperationsException) e = ((RuntimeOperationsException)e).getTargetException(); // Only log errors if trace is enabled if( log.isTraceEnabled() ) log.trace("operation failed", e); throw e; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getPayloadValue failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
catch (Exception e) { JBossLazyUnmarshallingException ise = new JBossLazyUnmarshallingException("getArguments failed"); ise.initCause(e); throw ise; }
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (Exception e) { e = (Exception) JMXExceptionDecoder.decode(e); if (log.isTraceEnabled()) log.trace("Failed to invoke on mbean: " + mbean, e); throw e; }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
catch(Exception e) { Throwable th = JMXExceptionDecoder.decode(e); if(log.isTraceEnabled()) { log.trace("Failed to invoke on mbean: " + mbean, th); } if(th instanceof Exception) { e = (Exception) th; } throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception e) // ClassNotFoundException, IllegalAccessException, InstantiationException { // policy class not found. Make a second try using // the 'org.jboss.jmx.connector.invoker.serializablepolicy.' package prefix // for the "standard" reponse policies provided with jboss. // If that fails, too, rethrow the original exception. try { policyClass = "org.jboss.jmx.connector.invoker.serializablepolicy." + policyClass; Class clazz = Thread.currentThread().getContextClassLoader().loadClass(policyClass); policy = (SerializablePolicy)clazz.newInstance(); } catch (Exception inner) { throw e; } }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
catch (Exception inner) { throw e; }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(Exception e) { String msg = "Failed to authorize principal=" + caller + ",MBean=" + objname + ", Operation=" + opname; SecurityException ex = new SecurityException(msg); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load standardjboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception ex) { log.error("failed to load jboss.xml. There could be a syntax error.", ex); throw ex; }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (Exception e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (Exception e) { close(); throw e; }
// in src/main/java/org/jboss/deployment/EARStructure.java
catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/WebAppFragmentParsingDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating managed object for " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch(Exception e) { throw new DeploymentException("Exception generated in deploy", e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/EarLibExcludeDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot exclude ear's lib.", e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(Exception e) { NamingException ne = new NamingException("Failed to update jndiName"); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(Exception e) { NamingException ex = new NamingException("Failed to retrieve Naming interface for provider " + provider); ex.setRootCause(e); throw ex; }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
catch(Exception e) { NamingException ne = new NamingException("Failed to obtain value from binding: "+name); ne.setRootCause(e); throw ne; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception ex) { throw new RuntimeException("UT factory lookup failed", ex); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (Exception e) { throw new EJBException("Failed to create timer", e); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new RuntimeException("Cannot start EJBTimerService", e); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new IllegalStateException("Cannot create EJBTimerService proxy: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { destroyService(); throw e; }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Pool (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Exception e) { throw new DeploymentException("Missing or invalid Instance Cache (in jboss.xml or standardjboss.xml)", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Exception e) { throw new EJBException("Could not create timer service", e); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
catch (Exception e) { if (deployed.isEmpty() == false) { for (JBossMessageDrivenBeanMetaData messageDriven : deployed) { try { undeploy(unit, messageDriven); } catch (Exception t) { log.warn("Error undeploying destination: " + messageDriven.getName(), t); } } } throw DeploymentException.rethrowAsDeploymentException("Error deploying destination" + bean.getName(), e); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { exceptionThrown = e; throw e; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException (e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (Exception e) { throw new EJBException ("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to begin a new transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new EJBException("Unable to get an instance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Exception e) { // Exception - force reload on next call ctx.setValid(false); throw e; }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { RemoveException re = new RemoveException(e.getMessage()); re.initCause(e); throw re; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to register table cache for " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Exception e) { throw new DeploymentException("Failed to start table cache.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
catch(Exception e) { throw new EJBException( "Failed to load instance of " + entityBridge.getEntityName() + " with pk=" + ctx.getId(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeRemoveRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(Exception e) { throw new EJBException("Error in invokeAddRelatedId()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
catch(Exception e) { throw new EJBException("Internal error extracting primary key from instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(Exception e) { throw new EJBException("Internal error", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreEntityCommand.java
catch(Exception e) { throw new EJBException("Store failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(Exception e) { throw new DeploymentException("Failed to obtain type-mapping metadata from the metadata library MBean: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find getter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCValuePropertyMetaData.java
catch(Exception e) { throw new DeploymentException("Unable to find setter for property " + propertyName + " on dependent value class " + classType.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { throw new EJBException("Failed to obtain current transaction", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet.", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Failed to read ResultSet", e); throw new EJBException("Failed to read ResultSet: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed instantiate state factory: " + implClassName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new IllegalStateException( "Failed to create an instance of " + valueType + " with the " + fieldValue + " as a ctor argument" ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Could not instantiate mapper: " + userTypeMapping.getMapper(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new DeploymentException("Failed to instantiate " + className, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + " alter table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.error("Could not alter table " + tableName + ": " + e.getMessage()); throw new DeploymentException("Error while alter table " + tableName + " " + sql, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "alter table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating table.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create table " + tableName); throw new DeploymentException("Error while creating table " + tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "creating index.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.debug("Could not create index " + indexName + "on table" + tableName); throw new DeploymentException("Error while creating table", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "sending sql command.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Issuing sql " + currentCmd + " failed: " + e.toString()); throw new DeploymentException("Error while issuing sql in post-table-create", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create index"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
catch(Exception e) { throw new EJBException("Error getting application tx data map.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertRelationsCommand.java
catch(Exception e) { throw new EJBException("Could insert relations into " + cmrField.getQualifiedTableName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(Exception e) { // if there is a problem reset the state before exiting reset(); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDeleteRelationsCommand.java
catch(Exception e) { throw new EJBException("Could not delete relations from " + cmrField.getQualifiedTableName(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
catch (Exception e) { throw new EJBException("Load failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCommandFactory.java
catch(Exception e) { throw new DeploymentException("Couldn't create entity command: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(Exception e) { throw new DeploymentException("Failed to create an instance of " + impl.getName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { throw new EJBException("Error getting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeComplex.java
catch(Exception e) { e.printStackTrace(); throw new EJBException("Error setting column value", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (Exception e) { throw new DeploymentException("Error while droping table "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { throw new EJBException("Error creating primary key instance: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error extracting primary key from " + "instance", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new DeploymentException("findByPrimaryKey(" + relatedEntity.getPrimaryKeyClass().getName() + " pk) was not found in " + homeClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in getRelatedId", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in addRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { throw new EJBException("Error in removeRelation", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting foreign-key field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(Exception e) { throw new DeploymentException("Could not create KeyGenerator instance.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
catch(Exception e) { throw new EJBException("Load relation failed", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { throw processException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(Exception e) { throw new DeploymentException("Error: can't create key generator instance; key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception ex) { // synch adds a reference to the lock, so we must release the ref // because afterCompletion will never get called. getContainer().getLockManager().removeLockRef(lock.getId()); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
catch(Exception causeByException) { // EJB 1.1 section 12.3.2 and EJB 2 section 18.3.3 // exception during store must log exception, mark tx for // rollback and throw a TransactionRolledback[Local]Exception // if using caller's transaction. All of this is handled by // the AbstractTxInterceptor and LogInterceptor. // // All we need to do here is mark the transaction for rollback // and rethrow the causeByException. The caller will handle logging // and wraping with TransactionRolledback[Local]Exception. try { tx.setRollbackOnly(); } catch(Exception e) { log.warn("Exception while trying to rollback tx: " + tx, e); } // Rethrow cause by exception if(causeByException instanceof EJBException) { throw (EJBException) causeByException; } throw new EJBException("Exception in store of entity:" + ((instance == null || instance.getId() == null) ? "<null>" : instance.getId().toString()), causeByException); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (Exception e) { // ditch the half built mappings homeMapping.clear(); beanMapping.clear(); throw e; }
// in src/main/java/org/jboss/web/deployers/WebModule.java
catch (Exception e) { throw new DeploymentException("Error during stop", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw new DeploymentException("Failed to create web module", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Error creating web module " + unit.getName(), e); }
// in src/main/java/org/jboss/web/deployers/WarAnnotationMetaDataDeployer.java
catch (Exception e) { throw DeploymentException.rethrowAsDeploymentException("Cannot process metadata", e); }
// in src/main/java/org/jboss/web/deployers/WebContextParamFacesConfigParsingDeployer.java
catch (Exception e) { throw new DeploymentException(e); }
// in src/main/java/org/jboss/web/deployers/SharedTldMetaDataDeployer.java
catch (Exception e) { throw new DeploymentException("Error processing TLDs for JAR: " + tldJar, e); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (Exception e) { // Remove the invalid context if (context != null) structureContext.removeChild(context); throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/proxy/compiler/Proxy.java
catch (Exception e) { throw new NestedRuntimeException("Failed to create new proxy target", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new ServerException("Could not bind home", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
17
unknown (Lib) ExceptionInInitializerError 14 14
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch(Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
catch (Exception e) { e.printStackTrace(); throw new ExceptionInInitializerError(e); }
0 0 0 0
unknown (Lib) FinderException 20
            
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public Object findEntity (Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if (finderMethod.getName ().equals ("findByPrimaryKey")) { if (!this.beans.containsKey (args[0])) throw new javax.ejb.FinderException (args[0]+" does not exist"); return factory.getEntityEJBObject(args[0]); } return null; }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object findEntity(final Method finderMethod, final Object[] args, final EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { if (finderMethod.getName().equals("findByPrimaryKey")) { if (!getFile(args[0]).exists()) throw new FinderException(args[0]+" does not exist"); return factory.getEntityEJBObject(args[0]); } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
public QueryCommand getQueryCommand(Method queryMethod) throws FinderException { QueryCommand queryCommand = (QueryCommand)queriesByMethod.get(queryMethod); if(queryCommand == null) { throw new FinderException("Unknown query method: " + queryMethod); } return queryCommand; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
static Object fetchOne(JDBCEntityBridge2 entity, String sql, QueryParameter[] params, ResultReader resultReader, Object[] args, GenericEntityObjectFactory factory, Logger log) throws FinderException { Object pk; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; } } try { if(log.isDebugEnabled()) { log.debug("executing: " + sql); } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entity.getDataSource().getConnection(); } ps = con.prepareStatement(sql); if(params != null) { for(int i = 0; i < params.length; i++) { params[i].set(log, ps, i + 1, args); } } rs = ps.executeQuery(); if(rs.next()) { pk = resultReader.readRow(rs, factory); if(rs.next()) { List list = new ArrayList(); list.add(pk); list.add(resultReader.readRow(rs, factory)); while(rs.next()) { list.add(resultReader.readRow(rs, factory)); } throw new FinderException("More than one instance matches the single-object finder criteria: " + list); } } else { throw new ObjectNotFoundException(); } } catch(FinderException e) { throw e; } catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Collection readResultSet(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, GenericEntityObjectFactory factory) throws FinderException { Collection result; try { if((limit == 0 || count-- > 0) && rs.next()) { result = collectionFactory.newCollection(); Object instance = resultReader.readRow(rs, factory); result.add(instance); while((limit == 0 || count-- > 0) && rs.next()) { instance = resultReader.readRow(rs, factory); result.add(instance); } } else { result = Collections.EMPTY_SET; } } catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
public Collection fetchCollection(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { if(log.isTraceEnabled()) { log.trace("executing dynamic-ql: " + args[0]); } JDBCStoreManager2 manager = (JDBCStoreManager2)entity.getManager(); QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog()); try { compiler.compileJBossQL((String)args[0], metadata.getMethod().getReturnType(), getParamTypes(args), metadata ); } catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); } String sql = compiler.getSQL(); int offsetParam = compiler.getOffsetParam(); int offsetValue = compiler.getOffsetValue(); int limitParam = compiler.getLimitParam(); int limitValue = compiler.getLimitValue(); AbstractQueryCommand.ResultReader resultReader; if(!compiler.isSelectEntity()) { if(compiler.isSelectField()) { resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2)compiler.getSelectField()); } else { resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction()); } } else { resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2)compiler.getSelectEntity(), compiler.isSelectDistinct()); } return AbstractQueryCommand.fetchCollection( entity, sql, toArray(compiler.getInputParameters()), AbstractQueryCommand.toInt(args, offsetParam, offsetValue), AbstractQueryCommand.toInt(args, limitParam, limitValue), new AbstractQueryCommand.EagerCollectionStrategy(collectionFactory, resultReader, log), schema, factory, (Object[])args[1], log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { if(log.isTraceEnabled()) { log.trace("executing dynamic-ql: " + args[0]); } JDBCStoreManager2 manager = (JDBCStoreManager2)entity.getManager(); QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog()); try { compiler.compileJBossQL((String)args[0], metadata.getMethod().getReturnType(), getParamTypes(args), metadata ); } catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); } String sql = compiler.getSQL(); AbstractQueryCommand.ResultReader resultReader; if(!compiler.isSelectEntity()) { if(compiler.isSelectField()) { resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2)compiler.getSelectField()); } else { resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction()); } } else { resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2)compiler.getSelectEntity(), compiler.isSelectDistinct()); } return AbstractQueryCommand.fetchOne(entity, sql, toArray(compiler.getInputParameters()), resultReader, (Object[])args[1], factory, log ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
private static Class[] getParamTypes(Object[] args) throws FinderException { Class[] parameterTypes; // get the parameters Object[] parameters = (Object[])args[1]; if(parameters == null) { parameterTypes = new Class[0]; } else { // get the parameter types parameterTypes = new Class[parameters.length]; for(int i = 0; i < parameters.length; i++) { if(parameters[i] == null) { throw new FinderException("Parameter[" + i + "] is null"); } parameterTypes[i] = parameters[i].getClass(); } } return parameterTypes; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/EJBSelectBridge.java
public Object execute(Object[] args) throws FinderException { JDBCStoreManager2 manager = command.getStoreManager(); GenericEntityObjectFactory factory = (metadata.isResultTypeMappingLocal() ? (GenericEntityObjectFactory)manager.getContainer().getLocalProxyFactory() : manager.getContainer().getProxyFactory()); Object result; switch(returnType) { case SINGLE: result = command.fetchOne(schema, factory, args); if(result == null && getMethod().getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + getMethod().getReturnType().getName() ); } break; case COLLECTION: result = command.fetchCollection(schema, factory, args); break; default: throw new IllegalStateException("Unexpected return type: " + returnType); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Collection createCollection(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, JDBCEntityBridge selectEntity, JDBCCMPFieldBridge selectField, SelectFunction selectFunction, JDBCStoreManager selectManager, List onFindCMRList, boolean[] eagerLoadMask, GenericEntityObjectFactory factory) throws FinderException { try { List results = new ArrayList(); if(selectEntity != null) { ReadAheadCache selectReadAheadCache = selectManager.getReadAheadCache(); List ids = new ArrayList(); boolean loadOnFindCmr = !onFindCMRList.isEmpty(); Object[] ref = new Object[1]; Object prevPk = null; while((limit == 0 || count-- > 0) && rs.next()) { int index = 1; // get the pk index = selectEntity.loadPrimaryKeyResults(rs, index, ref); Object pk = ref[0]; boolean addPk = (loadOnFindCmr ? !pk.equals(prevPk) : true); if(addPk) { ids.add(pk); results.add(factory.getEntityEJBObject(pk)); prevPk = pk; } // read the preload fields if(eagerLoadMask != null) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < eagerLoadMask.length; i++) { if(eagerLoadMask[i]) { JDBCFieldBridge field = tableFields[i]; ref[0] = null; // read the value and store it in the readahead cache index = field.loadArgumentResults(rs, index, ref); if(addPk) { selectReadAheadCache.addPreloadData(pk, field, ref[0]); } } } if(!onFindCMRList.isEmpty()) { index = loadOnFindCMRFields(pk, onFindCMRList, rs, index, log); } } } // add the results list to the cache selectReadAheadCache.addFinderResults(ids, queryMetaData.getReadAhead()); } else if(selectField != null) { // load the field Object[] valueRef = new Object[1]; while((limit == 0 || count-- > 0) && rs.next()) { valueRef[0] = null; selectField.loadArgumentResults(rs, 1, valueRef); results.add(valueRef[0]); } } else { while(rs.next()) { results.add(selectFunction.readResult(rs)); } } if(log.isDebugEnabled() && limit != 0 && count == 0) { log.debug("Query result was limited to " + limit + " row(s)"); } return results; } catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntityCommand.java
public Object execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(finderMethod); Collection result = query.execute(finderMethod, args, ctx, factory); if(result.isEmpty()) { throw new ObjectNotFoundException(NO_SUCH_ENTITY); } else if(result.size() == 1) { return result.iterator().next(); } else { throw new FinderException("More than one entity matches the finder criteria: " + result); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { String dynamicQL = (String)args[0]; if(getLog().isDebugEnabled()) { getLog().debug("DYNAMIC-QL: " + dynamicQL); } QLCompiler compiler = null; try { compiler = JDBCQueryManager.getInstance(metadata.getQLCompilerClass(), catalog); } catch(DeploymentException e) { throw new FinderException(e.getMessage()); } // get the parameters Object[] parameters = (Object[])args[1]; // parameter types Class[] parameterTypes; if(parameters == null) { parameterTypes = new Class[0]; } else { // get the parameter types parameterTypes = new Class[parameters.length]; for(int i = 0; i < parameters.length; i++) { if(parameters[i] == null) { throw new FinderException("Parameter[" + i + "] is null"); } parameterTypes[i] = parameters[i].getClass(); } } // compile the dynamic-ql try { compiler.compileJBossQL( dynamicQL, finderMethod.getReturnType(), parameterTypes, metadata); } catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); } int offset = toInt(parameters, compiler.getOffsetParam(), compiler.getOffsetValue()); int limit = toInt(parameters, compiler.getLimitParam(), compiler.getLimitValue()); JDBCEntityBridge selectEntity = null; JDBCCMPFieldBridge selectField = null; SelectFunction selectFunction = null; if(compiler.isSelectEntity()) { selectEntity = (JDBCEntityBridge) compiler.getSelectEntity(); } else if(compiler.isSelectField()) { selectField = (JDBCCMPFieldBridge) compiler.getSelectField(); } else { selectFunction = compiler.getSelectFunction(); } boolean[] mask; List leftJoinCMRList; JDBCReadAheadMetaData readahead = metadata.getReadAhead(); if(selectEntity != null && readahead.isOnFind()) { mask = selectEntity.getLoadGroupMask(readahead.getEagerLoadGroup()); boolean modifiedMask = false; leftJoinCMRList = compiler.getLeftJoinCMRList(); // exclude non-searchable columns if distinct is used if(compiler.isSelectDistinct()) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < tableFields.length; ++i) { if(mask[i] && !tableFields[i].getJDBCType().isSearchable()) { if(!modifiedMask) { boolean[] original = mask; mask = new boolean[original.length]; System.arraycopy(original, 0, mask, 0, mask.length); modifiedMask = true; } mask[i] = false; } } } } else { mask = null; leftJoinCMRList = Collections.EMPTY_LIST; } // get the parameter order setParameterList(compiler.getInputParameters()); EntityContainer con = ((JDBCStoreManager)compiler.getStoreManager()).getContainer(); factory = metadata.isResultTypeMappingLocal() && con.getLocalHomeClass() != null ? con.getLocalProxyFactory() : con.getProxyFactory(); return execute( compiler.getSQL(), parameters, offset, limit, selectEntity, selectField, selectFunction, (JDBCStoreManager) compiler.getStoreManager(), mask, compiler.getInputParameters(), leftJoinCMRList, metadata, factory, log ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public JDBCQueryCommand getQueryCommand(Method queryMethod) throws FinderException { JDBCQueryCommand queryCommand = (JDBCQueryCommand)knownQueries.get(queryMethod); if(queryCommand == null) { throw new FinderException("Unknown query: " + queryMethod); } return queryCommand; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object execute(Object[] args) throws FinderException { Collection retVal; Method method = getMethod(); try { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(method); EntityContainer selectedContainer = query.getSelectManager().getContainer(); GenericEntityObjectFactory factory; if(queryMetaData.isResultTypeMappingLocal() && selectedContainer.getLocalHomeClass() != null) { factory = selectedContainer.getLocalProxyFactory(); } else { factory = selectedContainer.getProxyFactory(); } retVal = query.execute(method, args, null, factory); } catch(FinderException e) { throw e; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); } if(!Collection.class.isAssignableFrom(getReturnType())) { // single object if(retVal.size() == 0) { throw new ObjectNotFoundException(); } if(retVal.size() > 1) { throw new FinderException(getSelectorName() + " returned " + retVal.size() + " objects"); } Object o = retVal.iterator().next(); if(o == null && method.getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + method.getReturnType().getName() ); } return o; } else { // collection or set if(Set.class.isAssignableFrom(getReturnType())) { return new HashSet(retVal); } else { return retVal; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
public Collection execute(Method unused, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { try { // invoke implementation method on ejb instance Object value = finderMethod.invoke(ctx.getInstance(), args); // if expected return type is Collection, return as is // if expected return type is not Collection, wrap value in Collection if(value instanceof Enumeration) { Enumeration enumeration = (Enumeration)value; List result = new ArrayList(); while(enumeration.hasMoreElements()) { result.add(enumeration.nextElement()); } cacheResults(result); return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, result); } else if(value instanceof Collection) { List result; if (value instanceof List) result = (List)value; else result = new ArrayList((Collection)value); cacheResults(result); return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, result); } else { // Don't bother trying to cache this return Collections.singleton(factory.getEntityEJBObject(value)); } } catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); } catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); } catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } } }
9
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(DeploymentException e) { throw new FinderException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
29
            
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public Object findEntity(final Method finderMethod, final Object[] args, final EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { if (finderMethod.getName().equals("findByPrimaryKey")) { if (!getFile(args[0]).exists()) throw new FinderException(args[0]+" does not exist"); return factory.getEntityEJBObject(args[0]); } return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
public QueryCommand getQueryCommand(Method queryMethod) throws FinderException { QueryCommand queryCommand = (QueryCommand)queriesByMethod.get(queryMethod); if(queryCommand == null) { throw new FinderException("Unknown query method: " + queryMethod); } return queryCommand; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/FindByPrimaryKeyCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { Object pk = args[0]; if(pk == null) { throw new IllegalArgumentException("Null argument for findByPrimaryKey"); } Object instance; boolean cached = entity.getTable().hasRow(pk); if(!cached) { instance = super.executeFetchOne(args, factory); if(instance == null) { throw new ObjectNotFoundException("Instance not find: entity=" + entity.getEntityName() + ", pk=" + pk); } } else { instance = factory.getEntityEJBObject(pk); } return instance; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws FinderException { QueryCommand query = queryFactory.getQueryCommand(finderMethod); return query.fetchOne(schema, factory, args); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws FinderException { QueryCommand query = queryFactory.getQueryCommand(finderMethod); return query.fetchCollection(schema, factory, args); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Collection fetchCollection(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { int offset = toInt(args, offsetParam, offsetValue); int limit = toInt(args, limitParam, limitValue); return fetchCollection(entity, sql, params, offset, limit, collectionStrategy, schema, factory, args, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { schema.flush(); return executeFetchOne(args, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
protected Object executeFetchOne(Object[] args, GenericEntityObjectFactory factory) throws FinderException { return fetchOne(entity, sql, params, resultReader, args, factory, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
static Collection fetchCollection(JDBCEntityBridge2 entity, String sql, QueryParameter[] params, int offset, int limit, CollectionStrategy collectionStrategy, Schema schema, GenericEntityObjectFactory factory, Object[] args, Logger log) throws FinderException { schema.flush(); int count = offset; Collection result; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; } } try { if(log.isDebugEnabled()) { log.debug("executing: " + sql); } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entity.getDataSource().getConnection(); } ps = con.prepareStatement(sql); if(params != null) { for(int i = 0; i < params.length; i++) { params[i].set(log, ps, i + 1, args); } } rs = ps.executeQuery(); // skip 'offset' results while(count > 0 && rs.next()) { count--; } count = limit; } catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Finder failed: " + e.getMessage(), e); FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; } result = collectionStrategy.readResultSet(con, ps, rs, limit, count, factory); return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
static Object fetchOne(JDBCEntityBridge2 entity, String sql, QueryParameter[] params, ResultReader resultReader, Object[] args, GenericEntityObjectFactory factory, Logger log) throws FinderException { Object pk; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; } } try { if(log.isDebugEnabled()) { log.debug("executing: " + sql); } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entity.getDataSource().getConnection(); } ps = con.prepareStatement(sql); if(params != null) { for(int i = 0; i < params.length; i++) { params[i].set(log, ps, i + 1, args); } } rs = ps.executeQuery(); if(rs.next()) { pk = resultReader.readRow(rs, factory); if(rs.next()) { List list = new ArrayList(); list.add(pk); list.add(resultReader.readRow(rs, factory)); while(rs.next()) { list.add(resultReader.readRow(rs, factory)); } throw new FinderException("More than one instance matches the single-object finder criteria: " + list); } } else { throw new ObjectNotFoundException(); } } catch(FinderException e) { throw e; } catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Collection readResultSet(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, GenericEntityObjectFactory factory) throws FinderException { Collection result; try { if((limit == 0 || count-- > 0) && rs.next()) { result = collectionFactory.newCollection(); Object instance = resultReader.readRow(rs, factory); result.add(instance); while((limit == 0 || count-- > 0) && rs.next()) { instance = resultReader.readRow(rs, factory); result.add(instance); } } else { result = Collections.EMPTY_SET; } } catch(Exception e) { log.error("Finder failed: " + e.getMessage(), e); throw new FinderException(e.getMessage()); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
public Collection fetchCollection(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { if(log.isTraceEnabled()) { log.trace("executing dynamic-ql: " + args[0]); } JDBCStoreManager2 manager = (JDBCStoreManager2)entity.getManager(); QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog()); try { compiler.compileJBossQL((String)args[0], metadata.getMethod().getReturnType(), getParamTypes(args), metadata ); } catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); } String sql = compiler.getSQL(); int offsetParam = compiler.getOffsetParam(); int offsetValue = compiler.getOffsetValue(); int limitParam = compiler.getLimitParam(); int limitValue = compiler.getLimitValue(); AbstractQueryCommand.ResultReader resultReader; if(!compiler.isSelectEntity()) { if(compiler.isSelectField()) { resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2)compiler.getSelectField()); } else { resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction()); } } else { resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2)compiler.getSelectEntity(), compiler.isSelectDistinct()); } return AbstractQueryCommand.fetchCollection( entity, sql, toArray(compiler.getInputParameters()), AbstractQueryCommand.toInt(args, offsetParam, offsetValue), AbstractQueryCommand.toInt(args, limitParam, limitValue), new AbstractQueryCommand.EagerCollectionStrategy(collectionFactory, resultReader, log), schema, factory, (Object[])args[1], log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { if(log.isTraceEnabled()) { log.trace("executing dynamic-ql: " + args[0]); } JDBCStoreManager2 manager = (JDBCStoreManager2)entity.getManager(); QLCompiler compiler = new EJBQLToSQL92Compiler(manager.getCatalog()); try { compiler.compileJBossQL((String)args[0], metadata.getMethod().getReturnType(), getParamTypes(args), metadata ); } catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); } String sql = compiler.getSQL(); AbstractQueryCommand.ResultReader resultReader; if(!compiler.isSelectEntity()) { if(compiler.isSelectField()) { resultReader = new AbstractQueryCommand.FieldReader((JDBCCMPFieldBridge2)compiler.getSelectField()); } else { resultReader = new AbstractQueryCommand.FunctionReader(compiler.getSelectFunction()); } } else { resultReader = new AbstractQueryCommand.EntityReader((JDBCEntityBridge2)compiler.getSelectEntity(), compiler.isSelectDistinct()); } return AbstractQueryCommand.fetchOne(entity, sql, toArray(compiler.getInputParameters()), resultReader, (Object[])args[1], factory, log ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
private static Class[] getParamTypes(Object[] args) throws FinderException { Class[] parameterTypes; // get the parameters Object[] parameters = (Object[])args[1]; if(parameters == null) { parameterTypes = new Class[0]; } else { // get the parameter types parameterTypes = new Class[parameters.length]; for(int i = 0; i < parameters.length; i++) { if(parameters[i] == null) { throw new FinderException("Parameter[" + i + "] is null"); } parameterTypes[i] = parameters[i].getClass(); } } return parameterTypes; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/EJBSelectBridge.java
public Object execute(Object[] args) throws FinderException { JDBCStoreManager2 manager = command.getStoreManager(); GenericEntityObjectFactory factory = (metadata.isResultTypeMappingLocal() ? (GenericEntityObjectFactory)manager.getContainer().getLocalProxyFactory() : manager.getContainer().getProxyFactory()); Object result; switch(returnType) { case SINGLE: result = command.fetchOne(schema, factory, args); if(result == null && getMethod().getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + getMethod().getReturnType().getName() ); } break; case COLLECTION: result = command.fetchCollection(schema, factory, args); break; default: throw new IllegalStateException("Unexpected return type: " + returnType); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
public Object invoke(Object proxy, Method method, Object[] args) throws FinderException { // todo find a better workaround // CMP/CMR field bridges are mapped to its abstract method names because of the bug // in reflection introduced in Sun's 1.4 JVM, i.e. when an abstract class C1 extends a super class C2 // and implements interface I and C2 and I both declare method with the same signature M, // C1.getMethods() will contain M twice. // ejbSelect methods are mapped to Method objects instead. Because ejbSelect methods having the same name // might have different signatures. Hopefully, the probability of an ejbSelect method to appear in an interface // is lower. String methodName = method.getName(); BridgeInvoker invoker = (BridgeInvoker) fieldMap.get(methodName); if(invoker == null) { //invoker = (BridgeInvoker) selectorMap.get(methodName); invoker = (BridgeInvoker) selectorMap.get(method); if(invoker == null) { throw new EJBException("Method is not a known CMP field " + "accessor, CMR field accessor, or ejbSelect method: " + "methodName=" + methodName); } } try { return invoker.invoke(ctx, method, args); } catch(RuntimeException e) { throw e; } catch(FinderException e) { throw e; } catch(Exception e) { throw new EJBException("Internal error", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { int offset = toInt(args, offsetParam, offsetValue); int limit = toInt(args, limitParam, limitValue); return execute(sql, args, offset, limit, selectEntity, selectField, selectFunction, selectManager, eagerLoadMask, parameters, onFindCMRList, queryMetaData, factory, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected Collection execute(String sql, Object[] args, int offset, int limit, JDBCEntityBridge selectEntity, JDBCCMPFieldBridge selectField, SelectFunction selectFunction, JDBCStoreManager selectManager, boolean[] eagerLoadMask, List parameters, List onFindCMRList, JDBCQueryMetaData queryMetaData, GenericEntityObjectFactory factory, Logger log) throws FinderException { int count = offset; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; final JDBCEntityBridge entityBridge = (JDBCEntityBridge)selectManager.getEntityBridge(); boolean throwRuntimeExceptions = entityBridge.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entityBridge.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; } } try { // create the statement if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); if(limit != 0 || offset != 0) { log.debug("Query offset=" + offset + ", limit=" + limit); } } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entityBridge.getDataSource().getConnection(); } ps = con.prepareStatement(sql); // Set the fetch size of the statement if(entityBridge.getFetchSize() > 0) { ps.setFetchSize(entityBridge.getFetchSize()); } // set the parameters for(int i = 0; i < parameters.size(); i++) { QueryParameter parameter = (QueryParameter) parameters.get(i); parameter.set(log, ps, i + 1, args); } // execute statement rs = ps.executeQuery(); // skip 'offset' results while(count > 0 && rs.next()) { count--; } count = limit; } catch(Exception e) { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); log.error("Find failed", e); FinderException fe = new FinderException("Find failed: " + e); fe.initCause(e); throw fe; } return collectionFactory.createCollection(con, ps, rs, limit, count, selectEntity, selectField, selectFunction, selectManager, onFindCMRList, eagerLoadMask, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Collection createCollection(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, JDBCEntityBridge selectEntity, JDBCCMPFieldBridge selectField, SelectFunction selectFunction, JDBCStoreManager selectManager, List onFindCMRList, boolean[] eagerLoadMask, GenericEntityObjectFactory factory) throws FinderException { try { List results = new ArrayList(); if(selectEntity != null) { ReadAheadCache selectReadAheadCache = selectManager.getReadAheadCache(); List ids = new ArrayList(); boolean loadOnFindCmr = !onFindCMRList.isEmpty(); Object[] ref = new Object[1]; Object prevPk = null; while((limit == 0 || count-- > 0) && rs.next()) { int index = 1; // get the pk index = selectEntity.loadPrimaryKeyResults(rs, index, ref); Object pk = ref[0]; boolean addPk = (loadOnFindCmr ? !pk.equals(prevPk) : true); if(addPk) { ids.add(pk); results.add(factory.getEntityEJBObject(pk)); prevPk = pk; } // read the preload fields if(eagerLoadMask != null) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < eagerLoadMask.length; i++) { if(eagerLoadMask[i]) { JDBCFieldBridge field = tableFields[i]; ref[0] = null; // read the value and store it in the readahead cache index = field.loadArgumentResults(rs, index, ref); if(addPk) { selectReadAheadCache.addPreloadData(pk, field, ref[0]); } } } if(!onFindCMRList.isEmpty()) { index = loadOnFindCMRFields(pk, onFindCMRList, rs, index, log); } } } // add the results list to the cache selectReadAheadCache.addFinderResults(ids, queryMetaData.getReadAhead()); } else if(selectField != null) { // load the field Object[] valueRef = new Object[1]; while((limit == 0 || count-- > 0) && rs.next()) { valueRef[0] = null; selectField.loadArgumentResults(rs, 1, valueRef); results.add(valueRef[0]); } } else { while(rs.next()) { results.add(selectFunction.readResult(rs)); } } if(log.isDebugEnabled() && limit != 0 && count == 0) { log.debug("Query result was limited to " + limit + " row(s)"); } return results; } catch(Exception e) { log.error("Find failed", e); throw new FinderException("Find failed: " + e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Collection createCollection(Connection con, PreparedStatement ps, ResultSet rs, int limit, int count, JDBCEntityBridge selectEntity, JDBCCMPFieldBridge selectField, SelectFunction selectFunction, JDBCStoreManager selectManager, List onFindCMRList, boolean[] eagerLoadMask, GenericEntityObjectFactory factory) throws FinderException { return new LazyCollection(con, ps, rs, limit, count, selectEntity, selectField, selectFunction, selectManager, eagerLoadMask, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntityCommand.java
public Object execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(finderMethod); Collection result = query.execute(finderMethod, args, ctx, factory); if(result.isEmpty()) { throw new ObjectNotFoundException(NO_SUCH_ENTITY); } else if(result.size() == 1) { return result.iterator().next(); } else { throw new FinderException("More than one entity matches the finder criteria: " + result); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntitiesCommand.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(finderMethod); return query.execute(finderMethod, args, ctx, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { return findEntityCommand.execute(finderMethod, args, ctx, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Collection findEntities(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { return findEntitiesCommand.execute(finderMethod, args, ctx, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { String dynamicQL = (String)args[0]; if(getLog().isDebugEnabled()) { getLog().debug("DYNAMIC-QL: " + dynamicQL); } QLCompiler compiler = null; try { compiler = JDBCQueryManager.getInstance(metadata.getQLCompilerClass(), catalog); } catch(DeploymentException e) { throw new FinderException(e.getMessage()); } // get the parameters Object[] parameters = (Object[])args[1]; // parameter types Class[] parameterTypes; if(parameters == null) { parameterTypes = new Class[0]; } else { // get the parameter types parameterTypes = new Class[parameters.length]; for(int i = 0; i < parameters.length; i++) { if(parameters[i] == null) { throw new FinderException("Parameter[" + i + "] is null"); } parameterTypes[i] = parameters[i].getClass(); } } // compile the dynamic-ql try { compiler.compileJBossQL( dynamicQL, finderMethod.getReturnType(), parameterTypes, metadata); } catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); } int offset = toInt(parameters, compiler.getOffsetParam(), compiler.getOffsetValue()); int limit = toInt(parameters, compiler.getLimitParam(), compiler.getLimitValue()); JDBCEntityBridge selectEntity = null; JDBCCMPFieldBridge selectField = null; SelectFunction selectFunction = null; if(compiler.isSelectEntity()) { selectEntity = (JDBCEntityBridge) compiler.getSelectEntity(); } else if(compiler.isSelectField()) { selectField = (JDBCCMPFieldBridge) compiler.getSelectField(); } else { selectFunction = compiler.getSelectFunction(); } boolean[] mask; List leftJoinCMRList; JDBCReadAheadMetaData readahead = metadata.getReadAhead(); if(selectEntity != null && readahead.isOnFind()) { mask = selectEntity.getLoadGroupMask(readahead.getEagerLoadGroup()); boolean modifiedMask = false; leftJoinCMRList = compiler.getLeftJoinCMRList(); // exclude non-searchable columns if distinct is used if(compiler.isSelectDistinct()) { JDBCFieldBridge[] tableFields = selectEntity.getTableFields(); for(int i = 0; i < tableFields.length; ++i) { if(mask[i] && !tableFields[i].getJDBCType().isSearchable()) { if(!modifiedMask) { boolean[] original = mask; mask = new boolean[original.length]; System.arraycopy(original, 0, mask, 0, mask.length); modifiedMask = true; } mask[i] = false; } } } } else { mask = null; leftJoinCMRList = Collections.EMPTY_LIST; } // get the parameter order setParameterList(compiler.getInputParameters()); EntityContainer con = ((JDBCStoreManager)compiler.getStoreManager()).getContainer(); factory = metadata.isResultTypeMappingLocal() && con.getLocalHomeClass() != null ? con.getLocalProxyFactory() : con.getProxyFactory(); return execute( compiler.getSQL(), parameters, offset, limit, selectEntity, selectField, selectFunction, (JDBCStoreManager) compiler.getStoreManager(), mask, compiler.getInputParameters(), leftJoinCMRList, metadata, factory, log ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
public JDBCQueryCommand getQueryCommand(Method queryMethod) throws FinderException { JDBCQueryCommand queryCommand = (JDBCQueryCommand)knownQueries.get(queryMethod); if(queryCommand == null) { throw new FinderException("Unknown query: " + queryMethod); } return queryCommand; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindByPrimaryKeyQuery.java
public Collection execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { // Check in readahead cache. if(manager.getReadAheadCache().getPreloadDataMap(args[0], false) != null) { // copy pk [JBAS-1361] Object pk = null; JDBCFieldBridge[] pkFields = manager.getEntityBridge().getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCAbstractCMPFieldBridge pkField = ((JDBCAbstractCMPFieldBridge)pkFields[i]); Object fieldValue = pkField.getPrimaryKeyValue(args[0]); pk = pkField.setPrimaryKeyValue(pk, fieldValue); } final Object ejbObject = factory.getEntityEJBObject(pk); return Collections.singletonList(ejbObject); } return super.execute(finderMethod, args, ctx, factory); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object execute(Object[] args) throws FinderException { Collection retVal; Method method = getMethod(); try { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(method); EntityContainer selectedContainer = query.getSelectManager().getContainer(); GenericEntityObjectFactory factory; if(queryMetaData.isResultTypeMappingLocal() && selectedContainer.getLocalHomeClass() != null) { factory = selectedContainer.getLocalProxyFactory(); } else { factory = selectedContainer.getProxyFactory(); } retVal = query.execute(method, args, null, factory); } catch(FinderException e) { throw e; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); } if(!Collection.class.isAssignableFrom(getReturnType())) { // single object if(retVal.size() == 0) { throw new ObjectNotFoundException(); } if(retVal.size() > 1) { throw new FinderException(getSelectorName() + " returned " + retVal.size() + " objects"); } Object o = retVal.iterator().next(); if(o == null && method.getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + method.getReturnType().getName() ); } return o; } else { // collection or set if(Set.class.isAssignableFrom(getReturnType())) { return new HashSet(retVal); } else { return retVal; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
public Collection execute(Method unused, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { try { // invoke implementation method on ejb instance Object value = finderMethod.invoke(ctx.getInstance(), args); // if expected return type is Collection, return as is // if expected return type is not Collection, wrap value in Collection if(value instanceof Enumeration) { Enumeration enumeration = (Enumeration)value; List result = new ArrayList(); while(enumeration.hasMoreElements()) { result.add(enumeration.nextElement()); } cacheResults(result); return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, result); } else if(value instanceof Collection) { List result; if (value instanceof List) result = (List)value; else result = new ArrayList((Collection)value); cacheResults(result); return GenericEntityObjectFactory.UTIL.getEntityCollection(factory, result); } else { // Don't bother trying to cache this return Collections.singleton(factory.getEntityEJBObject(value)); } } catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); } catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); } catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } } }
4
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
catch(FinderException e) { throw new DeploymentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(FinderException e) { throw e; }
4
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/InstanceFactory.java
catch(FinderException e) { throw new DeploymentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(FinderException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
catch(FinderException e) { throw e; }
0
unknown (Lib) HeuristicMixedException 0 0 4
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx commit: " + tx); int status = tm.getStatus(); tm.commit(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
2
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicMixedException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (HeuristicMixedException e) { throwJBossException(e, invocation.getType()); }
1
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicMixedException e) { throw e; }
0
unknown (Lib) HeuristicRollbackException 0 0 4
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx commit: " + tx); int status = tm.getStatus(); tm.commit(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
2
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicRollbackException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (HeuristicRollbackException e) { throwJBossException(e, invocation.getType()); }
1
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (HeuristicRollbackException e) { throw e; }
0
checked (Lib) IOException 14
            
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public Object addDecoration(Object dataObject) throws IOException { if(dataObject instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) dataObject; if(remoteInv.getParameter() instanceof Invocation) { Invocation inv = (Invocation) remoteInv.getParameter(); MarshalledInvocation marshInv = new MarshalledInvocation(inv); if(inv != null) { // now that have invocation object related to ejb invocations, // need to get the possible known payload objects and make sure // they get serialized. try { marshInv.setTransactionPropagationContext(getTransactionPropagationContext()); } catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); } // reset the invocation parameter within remote invocation remoteInv.setParameter(marshInv); } else { //Should never get here, but will check anyways log.error("Attempting to marshall Invocation but is null. Can not proceed."); throw new IOException("Can not process data object due to the InvocationRequest's parameter being null."); } } } return dataObject; }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
public void write(Object dataObject, OutputStream output, int version) throws IOException { if(dataObject instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) dataObject; if(remoteInv.getParameter() instanceof Invocation) { Invocation inv = (Invocation) remoteInv.getParameter(); MarshalledInvocation marshInv = new MarshalledInvocation(inv); if(inv != null) { // now that have invocation object related to ejb invocations, // need to get the possible known payload objects and make sure // they get serialized. try { marshInv.setTransactionPropagationContext(getTransactionPropagationContext()); } catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); } // reset the invocation parameter within remote invocation remoteInv.setParameter(marshInv); } else { //Should never get here, but will check anyways log.error("Attempting to marshall Invocation but is null. Can not proceed."); throw new IOException("Can not process data object due to the InvocationRequest's parameter being null."); } } super.write(dataObject, output, version); } else // assume this is going to be the response { super.write(dataObject, output); } }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void loadProperties(String contextPropsURL) throws IOException { InputStream is = null; contextProps = new Properties(); // See if this is a URL we can load try { URL url = new URL(contextPropsURL); is = url.openStream(); contextProps.load(is); return; } catch (IOException e) { // Failed, try to locate a classpath resource below is = null; } is = Thread.currentThread().getContextClassLoader().getResourceAsStream(contextPropsURL); if( is == null ) { throw new IOException("Failed to locate context props as URL or resource:"+contextPropsURL); } contextProps.load(is); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Object resolveObject(Object obj) throws IOException { Object resolved = obj; // section 6.4.1 of the ejb1.1 specification states what must be taken care of // ejb reference (remote interface) : resolve handle to EJB if (obj instanceof Handle) resolved = ((Handle)obj).getEJBObject(); // ejb reference (home interface) : resolve handle to EJB Home else if (obj instanceof HomeHandle) resolved = ((HomeHandle)obj).getEJBHome(); // naming context: the jnp implementation of contexts is serializable, do nothing else if( obj instanceof HandleWrapper ) { HandleWrapper wrapper = (HandleWrapper) obj; try { resolved = wrapper.get(); } catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); } } else if (obj instanceof StatefulSessionBeanField) { byte type = ((StatefulSessionBeanField)obj).type; // session context: recreate it if (type == StatefulSessionBeanField.SESSION_CONTEXT) resolved = ctx.getSessionContext(); // user transaction: restore it else if (type == StatefulSessionBeanField.USER_TRANSACTION) resolved = ctx.getSessionContext().getUserTransaction(); } return resolved; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
protected void createService() throws Exception { // Initialize the dataStore String ejbName = con.getBeanMetaData().getEjbName(); // Get the system data directory File dir = new File(ServerConfigLocator.locate().getServerTempLocation().toURI()); // Setup the reference to the session data store directory dir = new File(dir, storeDirName); // ejbName is not unique across all deployments, so use a unique token dir = new File(dir, ejbName + "-" + new UID().toString()); storeDir = dir; log.debug("Storing sessions for '" + ejbName + "' in: " + storeDir); // if the directory does not exist then try to create it if( !storeDir.exists() ) { if( MkdirsFileAction.mkdirs(storeDir) == false ) { throw new IOException("Failed to create directory: " + storeDir); } } // make sure we have a directory if( !storeDir.isDirectory() ) { throw new IOException("File exists where directory expected: " + storeDir); } // make sure we can read and write to it if( !storeDir.canWrite() || !storeDir.canRead() ) { throw new IOException("Directory must be readable and writable: " + storeDir); } // Purge state session state files, should be none, due to unique directory purgeAllSessionData(); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected void createService() throws Exception { // Initialize the dataStore String ejbName = con.getBeanMetaData().getEjbName(); // Get the system data directory File dir = new File(ServerConfigLocator.locate().getServerDataLocation().toURI()); // // jason: may have to use a generated token from container config // to determine a unique name for this config for the given // entity name. it must persist through restarts though... // // Setup the reference to the entity data store directory dir = new File(dir, storeDirName); dir = new File(dir, ejbName); storeDir = dir; log.debug("Storing entity state for '" + ejbName + "' in: " + storeDir); // if the directory does not exist then try to create it if (!storeDir.exists()) { if (!storeDir.mkdirs()) { throw new IOException("Failed to create directory: " + storeDir); } } // make sure we have a directory if (!storeDir.isDirectory()) { throw new IOException("File exists where directory expected: " + storeDir); } // make sure we can read and write to it if (!storeDir.canWrite() || !storeDir.canRead()) { throw new IOException("Directory must be readable and writable: " + storeDir); } // Get the ID field idField = con.getBeanClass().getField("id"); log.debug("Using id field: " + idField); // Lookup the isModified method if it exists try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) { isModified = null; // Has to have "boolean" as return type! log.warn("Found isModified method, but return type is not boolean; ignoring"); } else { log.debug("Using isModified method: " + isModified); } } catch (NoSuchMethodException ignored) {} }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
protected void reconnect(Object object) throws IOException { if (object instanceof ObjectImpl) { try { // Check we are still connected ObjectImpl objectImpl = (ObjectImpl) object; objectImpl._get_delegate(); } catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } } } else throw new IOException("Not an ObjectImpl " + object.getClass().getName()); }
4
            
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); }
103
            
// in src/main/java/org/jboss/invocation/DataContainerMarshallingInvokerInterceptor.java
protected IMarshalledValue createMarshalledValueForCallByValue(Object value) throws IOException { return new LocalMarshalledValue(value,new SafeCloningRepository(safeToReuse)); }
// in src/main/java/org/jboss/invocation/MarshalledValueOutputStream.java
protected void annotateClass(Class cl) throws IOException { super.annotateClass(cl); }
// in src/main/java/org/jboss/invocation/MarshalledValueOutputStream.java
protected void annotateProxyClass(Class cl) throws IOException { super.annotateProxyClass(cl); }
// in src/main/java/org/jboss/invocation/MarshalledValueOutputStream.java
protected Object replaceObject(Object obj) throws IOException { if( (obj instanceof Remote) && !(obj instanceof RemoteStub) ) { Remote remote = (Remote) obj; try { obj = RemoteObject.toStub(remote); } catch(IOException ignore) { // Let the Serialization layer try with the orignal obj } } return obj; }
// in src/main/java/org/jboss/invocation/ByValueInvokerInterceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { // We have no state }
// in src/main/java/org/jboss/invocation/ByValueInvokerInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { // We have no state }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeObject(externalURLValue); }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { externalURLValue = (String) in.readObject(); externalURL = Util.resolveURL(externalURLValue); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected IMarshalledValue createMarshalledValueForCallByValue(Object value) throws IOException { return SerializationStreamFactory.getManagerInstance().createdMarshalledValue(value); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
private MarshalledInvocation createInvocationCopy(Invocation invocation, IMarshalledValue value) throws IOException, ClassNotFoundException { MarshalledInvocation invocationCopy = new MarshalledInvocation(invocation); invocationCopy.setMethod(null); invocationCopy.setMethodHash(MarshalledInvocation.calculateHash(invocation.getMethod())); invocationCopy.setMarshalledArguments(value); invocationCopy.setArguments(null); InvocationContext copyContext = null; if (invocation.getInvocationContext()!=null) { copyContext = (InvocationContext)createMarshalledValueForCallByValue(invocation.getInvocationContext()).get(); } invocationCopy.setInvocationContext(copyContext); Map payLoad = invocation.getPayload(); Map payloadCopy = new HashMap(); if (payLoad!=null && payLoad.size()!=0) { Iterator keys = payLoad.keySet().iterator(); while (keys.hasNext()) { Object currentKey = keys.next(); Object valueSource = payLoad.get(currentKey); payloadCopy.put(currentKey,this.createMarshalledValueForCallByValue(valueSource)); } } invocationCopy.payload = payloadCopy; return invocationCopy; }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeObject(invokerID); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { invokerID = (GUID)in.readObject(); }
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { String className = v.getName(); Class resolvedClass = null; // Check the class cache first if it exists if( classCache != null ) { synchronized( classCache ) { resolvedClass = (Class) classCache.get(className); } } if( resolvedClass == null ) { ClassLoader loader = SecurityActions.getContextClassLoader(); try { resolvedClass = loader.loadClass(className); } catch(ClassNotFoundException e) { /* Use the super.resolveClass() call which will resolve array classes and primitives. We do not use this by default as this can result in caching of stale values across redeployments. */ resolvedClass = super.resolveClass(v); } if( classCache != null ) { synchronized( classCache ) { classCache.put(className, resolvedClass); } } } return resolvedClass; }
// in src/main/java/org/jboss/invocation/MarshalledValueInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("["); for(int i = 0; i < interfaces.length; i ++) { if( i > 0 ) tmp.append(','); tmp.append(interfaces[i]); } tmp.append(']'); log.trace("resolveProxyClass called, ifaces="+tmp.toString()); } // Load the interfaces from the cache or thread context class loader ClassLoader loader = null; Class[] ifaceClasses = new Class[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { Class iface = null; String className = interfaces[i]; // Check the proxy cache if it exists if( classCache != null ) { synchronized( classCache ) { iface = (Class) classCache.get(className); } } // Load the interface class using the thread context ClassLoader if( iface == null ) { if( loader == null ) loader = Thread.currentThread().getContextClassLoader(); iface = loader.loadClass(className); if( classCache != null ) { synchronized( classCache ) { classCache.put(className, iface); } } } ifaceClasses[i] = iface; } return Proxy.getProxyClass(loader, ifaceClasses); }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public Object get() throws IOException, ClassNotFoundException { if (serializedForm == null) return null; ByteArrayInputStream bais = new ByteArrayInputStream(serializedForm); MarshalledValueInputStream mvis = new MarshalledValueInputStream(bais); Object retValue = mvis.readObject(); mvis.close(); return retValue; }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int length = in.readInt(); serializedForm = null; if( length > 0 ) { serializedForm = new byte[length]; in.readFully(serializedForm); } hashCode = in.readInt(); }
// in src/main/java/org/jboss/invocation/MarshalledValue.java
public void writeExternal(ObjectOutput out) throws IOException { int length = serializedForm != null ? serializedForm.length : 0; out.writeInt(length); if( length > 0 ) { out.write(serializedForm); } out.writeInt(hashCode); }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
public void writeExternal(java.io.ObjectOutput out) throws IOException { // TODO invocationType should be removed from as is payload // for now, it is in there for binary compatibility getAsIsPayload().put(InvocationKey.TYPE, invocationType); // FIXME marcf: the "specific" treatment of Transactions should be abstracted. // Write the TPC, not the local transaction out.writeObject(tpc); long methodHash = this.methodHash; if(methodHash == 0) { methodHash = calculateHash(this.method); } out.writeLong(methodHash); out.writeObject(this.objectName); String serializationType = null; if (invocationContext!=null) { serializationType = (String)invocationContext.getValue("SERIALIZATION_TYPE"); } if(this.args == null && this.marshalledArgs != null) { out.writeObject(this.marshalledArgs); } else { out.writeObject(createMarshalledValue(serializationType,this.args)); } // Write out payload hashmap // Don't use hashmap serialization to avoid not-needed data being // marshalled // The map contains only serialized representations of every other object // Everything else is possibly tied to classloaders that exist inside the // server but not in the generic JMX land. they will travel in the payload // as MarshalledValue objects, see the Invocation getter logic // if (payload == null) out.writeInt(0); else { out.writeInt(payload.size()); Iterator keys = payload.keySet().iterator(); while (keys.hasNext()) { Object currentKey = keys.next(); // This code could be if (object.getClass().getName().startsWith("java")) then don't serialize. // Bench the above for speed. out.writeObject(currentKey); Object value = payload.get(currentKey); // no reason to marshall an already marshalled value if(!(value instanceof MarshalledValue)) { value = createMarshalledValue(serializationType,value); } out.writeObject(value); } } // This map is "safe" as is //out.writeObject(as_is_payload); if (as_is_payload == null) out.writeInt(0); else { out.writeInt(as_is_payload.size()); Iterator keys = as_is_payload.keySet().iterator(); while (keys.hasNext()) { Object currentKey = keys.next(); out.writeObject(currentKey); out.writeObject(as_is_payload.get(currentKey)); } } }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
private Object createMarshalledValue(String serializationType, Object valueToBeMarshalled) throws IOException { if (serializationType!=null) { return (IMarshalledValue)SerializationStreamFactory.getManagerInstance(serializationType).createdMarshalledValue(valueToBeMarshalled); } else { return new MarshalledValue(valueToBeMarshalled); } }
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
public void readExternal(java.io.ObjectInput in) throws IOException, ClassNotFoundException { tpc = in.readObject(); this.methodHash = in.readLong(); this.objectName = in.readObject(); marshalledArgs = in.readObject(); int payloadSize = in.readInt(); if (payloadSize > 0) { payload = new HashMap(); for (int i = 0; i < payloadSize; i++) { Object key = in.readObject(); Object value = in.readObject(); payload.put(key, value); } } int as_is_payloadSize = in.readInt(); if (as_is_payloadSize > 0) { as_is_payload = new HashMap(); for (int i = 0; i < as_is_payloadSize; i++) { Object key = in.readObject(); Object value = in.readObject(); as_is_payload.put(key, value); } } // TODO invocationType should be removed from as is payload // for now, it is in there for binary compatibility invocationType = (InvocationType)getAsIsValue(InvocationKey.TYPE); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata); return removeDecoration(ret); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); return removeDecoration(ret); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationUnMarshaller.java
public Object removeDecoration(Object obj) throws IOException { if(obj instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) obj; Object param = remoteInv.getParameter(); if(param instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) param; Object txCxt = mi.getTransactionPropagationContext(); if(txCxt != null) { TransactionPropagationContextImporter tpcImporter = TransactionPropagationContextUtil.getTPCImporter(); mi.setTransaction(tpcImporter.importTransactionPropagationContext(txCxt)); } } } return obj; }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationUnMarshaller.java
public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); if(ret instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) ret; Object param = remoteInv.getParameter(); if(param instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) param; Object txCxt = mi.getTransactionPropagationContext(); if(txCxt != null) { TransactionPropagationContextImporter tpcImporter = TransactionPropagationContextUtil.getTPCImporter(); mi.setTransaction(tpcImporter.importTransactionPropagationContext(txCxt)); } } } return ret; }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public void write(Object dataObject, OutputStream output) throws IOException { super.write(addDecoration(dataObject), output); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public void write(Object dataObject, OutputStream output, int version) throws IOException { super.write(addDecoration(dataObject), output, version); }
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public Object addDecoration(Object dataObject) throws IOException { if(dataObject instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) dataObject; if(remoteInv.getParameter() instanceof Invocation) { Invocation inv = (Invocation) remoteInv.getParameter(); MarshalledInvocation marshInv = new MarshalledInvocation(inv); if(inv != null) { // now that have invocation object related to ejb invocations, // need to get the possible known payload objects and make sure // they get serialized. try { marshInv.setTransactionPropagationContext(getTransactionPropagationContext()); } catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); } // reset the invocation parameter within remote invocation remoteInv.setParameter(marshInv); } else { //Should never get here, but will check anyways log.error("Attempting to marshall Invocation but is null. Can not proceed."); throw new IOException("Can not process data object due to the InvocationRequest's parameter being null."); } } } return dataObject; }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
public void write(Object dataObject, OutputStream output, int version) throws IOException { if(dataObject instanceof InvocationRequest) { InvocationRequest remoteInv = (InvocationRequest) dataObject; if(remoteInv.getParameter() instanceof Invocation) { Invocation inv = (Invocation) remoteInv.getParameter(); MarshalledInvocation marshInv = new MarshalledInvocation(inv); if(inv != null) { // now that have invocation object related to ejb invocations, // need to get the possible known payload objects and make sure // they get serialized. try { marshInv.setTransactionPropagationContext(getTransactionPropagationContext()); } catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); } // reset the invocation parameter within remote invocation remoteInv.setParameter(marshInv); } else { //Should never get here, but will check anyways log.error("Attempting to marshall Invocation but is null. Can not proceed."); throw new IOException("Can not process data object due to the InvocationRequest's parameter being null."); } } super.write(dataObject, output, version); } else // assume this is going to be the response { super.write(dataObject, output); } }
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
public IMarshalledValue createdMarshalledValue(Object source) throws IOException { if (source instanceof IMarshalledValue) { return (IMarshalledValue) source; } else { return new MarshalledValueEX(source); } }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeInt(CURRENT_VERSION); out.writeUTF(locator.getOriginalURI()); out.writeBoolean(strictRMIException); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { int version = in.readInt(); // Read in and map the version of the serialized data seen switch(version) { case VERSION_5_0: locator = new InvokerLocator(in.readUTF()); strictRMIException = in.readBoolean(); init(locator); break; default: throw new StreamCorruptedException("Unknown version seen: " + version); } }
// in src/main/java/org/jboss/deployment/EARStructure.java
private void scanEar(VirtualFile root, JBossAppMetaData appMetaData) throws IOException { List<VirtualFile> archives = root.getChildren(); if (archives != null) { String earPath = root.getPathName(); ModulesMetaData modules = appMetaData.getModules(); if (modules == null) { modules = new ModulesMetaData(); appMetaData.setModules(modules); } for (VirtualFile vfArchive : archives) { String filename = earRelativePath(earPath, vfArchive.getPathName()); // Check if the module already exists, i.e. it is declared in jboss-app.xml ModuleMetaData moduleMetaData = appMetaData.getModule(filename); int type = typeFromSuffix(filename, vfArchive); if (type >= 0 && moduleMetaData == null) { moduleMetaData = new ModuleMetaData(); AbstractModule module = null; switch(type) { case J2eeModuleMetaData.EJB: module = new EjbModuleMetaData(); break; case J2eeModuleMetaData.CLIENT: module = new JavaModuleMetaData(); break; case J2eeModuleMetaData.CONNECTOR: module = new ConnectorModuleMetaData(); break; case J2eeModuleMetaData.SERVICE: case J2eeModuleMetaData.HAR: module = new ServiceModuleMetaData(); break; case J2eeModuleMetaData.WEB: module = new WebModuleMetaData(); break; } module.setFileName(filename); moduleMetaData.setValue(module); modules.add(moduleMetaData); } } } }
// in src/main/java/org/jboss/deployment/EARStructure.java
private int typeFromSuffix(String path, VirtualFile archive) throws IOException { int type = -1; if( path.endsWith(".war") ) type = J2eeModuleMetaData.WEB; else if( path.endsWith(".rar") ) type = J2eeModuleMetaData.CONNECTOR; else if( path.endsWith(".har") ) type = J2eeModuleMetaData.HAR; else if( path.endsWith(".sar") ) type = J2eeModuleMetaData.SERVICE; else if( path.endsWith(".jar") ) { // Look for a META-INF/application-client.xml VirtualFile mfFile = getMetaDataFile(archive, "META-INF/MANIFEST.MF"); VirtualFile clientXml = getMetaDataFile(archive, "META-INF/application-client.xml"); VirtualFile ejbXml = getMetaDataFile(archive, "META-INF/ejb-jar.xml"); VirtualFile jbossXml = getMetaDataFile(archive, "META-INF/jboss.xml"); if( clientXml != null ) { type = J2eeModuleMetaData.CLIENT; } else if( mfFile != null ) { Manifest mf = VFSUtils.readManifest(mfFile); Attributes attrs = mf.getMainAttributes(); if( attrs.containsKey(Attributes.Name.MAIN_CLASS) ) { type = J2eeModuleMetaData.CLIENT; } else { // TODO: scan for annotations. Assume EJB for now type = J2eeModuleMetaData.EJB; } } else if( ejbXml != null || jbossXml != null ) { type = J2eeModuleMetaData.EJB; } else { // TODO: scan for annotations. Assume EJB for now type = J2eeModuleMetaData.EJB; } } return type; }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
private void scanEar(VFSDeploymentUnit unit, VirtualFile root, JBossAppMetaData j2eeMetaData) throws IOException { List<VirtualFile> archives = root.getChildren(); if (archives != null) { String earPath = root.getPathName(); ModulesMetaData modules = j2eeMetaData.getModules(); if (modules == null) { modules = new ModulesMetaData(); j2eeMetaData.setModules(modules); } for (VirtualFile vfArchive : archives) { String filename = earRelativePath(earPath, vfArchive.getPathName()); // Check if the module already exists, i.e. it is declared in jboss-app.xml ModuleMetaData moduleMetaData = j2eeMetaData.getModule(filename); int type = typeFromSuffix(unit, filename, vfArchive); if (type >= 0 && moduleMetaData == null) { moduleMetaData = new ModuleMetaData(); AbstractModule module = null; switch(type) { case J2eeModuleMetaData.EJB: module = new EjbModuleMetaData(); break; case J2eeModuleMetaData.CLIENT: module = new JavaModuleMetaData(); break; case J2eeModuleMetaData.CONNECTOR: module = new ConnectorModuleMetaData(); break; case J2eeModuleMetaData.SERVICE: case J2eeModuleMetaData.HAR: module = new ServiceModuleMetaData(); break; case J2eeModuleMetaData.WEB: module = new WebModuleMetaData(); break; } module.setFileName(filename); moduleMetaData.setValue(module); modules.add(moduleMetaData); } } } }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
private int typeFromSuffix(VFSDeploymentUnit unit, String path, VirtualFile archive) throws IOException { int type = -1; if( path.endsWith(".war") ) type = J2eeModuleMetaData.WEB; else if( path.endsWith(".rar") ) type = J2eeModuleMetaData.CONNECTOR; else if( path.endsWith(".har") ) type = J2eeModuleMetaData.HAR; else if( path.endsWith(".sar") ) type = J2eeModuleMetaData.SERVICE; else if( path.endsWith(".jar") ) { // Look for a META-INF/application-client.xml VirtualFile mfFile = unit.getMetaDataFile("MANIFEST.MF"); VirtualFile clientXml = unit.getMetaDataFile("application-client.xml"); VirtualFile ejbXml = unit.getMetaDataFile("ejb-jar.xml"); VirtualFile jbossXml = unit.getMetaDataFile("jboss.xml"); if( clientXml != null ) { type = J2eeModuleMetaData.CLIENT; } else if( mfFile != null ) { Manifest mf = VFSUtils.readManifest(mfFile); Attributes attrs = mf.getMainAttributes(); if( attrs.containsKey(Attributes.Name.MAIN_CLASS) ) { type = J2eeModuleMetaData.CLIENT; } else { // TODO: scan for annotations. Assume EJB for now type = J2eeModuleMetaData.EJB; } } else if( ejbXml != null || jbossXml != null ) { type = J2eeModuleMetaData.EJB; } else { // TODO: scan for annotations. Assume EJB for now type = J2eeModuleMetaData.EJB; } } return type; }
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
protected String getClassName(VirtualFile classFile) throws IOException { String pathName = classFile.getPathName(); String name = pathName.substring(rootLength, pathName.length()-6); name = name.replace('/', '.'); return name; }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
protected Collection<Class<?>> getClasses(VFSDeploymentUnit unit, String mainClassName, VirtualFile classpath) throws IOException { AnnotatedClassFilter classVisitor = new AnnotatedClassFilter(unit, unit.getClassLoader(), classpath, mainClassName); classpath.visit(classVisitor); Map<VirtualFile, Class<?>> classes = classVisitor.getAnnotatedClasses(); if (classes != null && classes.size() > 0) { if(log.isTraceEnabled()) log.trace("Annotated classes: " + classes); } else { classes = new HashMap<VirtualFile, Class<?>>(); } return classes.values(); }
// in src/main/java/org/jboss/deployment/AnnotationMetaDataDeployer.java
protected String getMainClassName(VFSDeploymentUnit unit) throws IOException { VirtualFile file = unit.getMetaDataFile("MANIFEST.MF"); if (log.isTraceEnabled()) log.trace("parsing " + file); if(file == null) { return null; } Manifest mf = VFSUtils.readManifest(file); Attributes attrs = mf.getMainAttributes(); return attrs.getValue(Attributes.Name.MAIN_CLASS); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void setPropertiesURL(String contextPropsURL) throws IOException { contextInfo.loadProperties(contextPropsURL); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void setProperties(final Properties props) throws IOException { contextInfo.setProperties(props); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public Properties getProperties() throws IOException { return contextInfo.getProperties(); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void loadProperties(String contextPropsURL) throws IOException { InputStream is = null; contextProps = new Properties(); // See if this is a URL we can load try { URL url = new URL(contextPropsURL); is = url.openStream(); contextProps.load(is); return; } catch (IOException e) { // Failed, try to locate a classpath resource below is = null; } is = Thread.currentThread().getContextClassLoader().getResourceAsStream(contextPropsURL); if( is == null ) { throw new IOException("Failed to locate context props as URL or resource:"+contextPropsURL); } contextProps.load(is); }
// in src/main/java/org/jboss/naming/NamingProviderURLWriter.java
protected void establishBootStrapURL() throws IOException { if (getBootstrapURL() == null && getBootstrapAddress() != null) { InetAddress addr = InetAddress.getByName(getBootstrapAddress()); if (addr.isAnyLocalAddress()) { addr = findLoopbackAddress(); if (addr == null) { addr = InetAddress.getLocalHost(); } } // Build the bootstrap URL StringBuilder sb = new StringBuilder("jnp://"); if (addr instanceof Inet6Address) { sb.append('['); sb.append(addr.getHostAddress()); sb.append(']'); } else { sb.append(addr.getHostAddress()); } sb.append(':'); sb.append(getBootstrapPort()); setBootstrapURL(sb.toString()); } }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
private Naming getNamingServer(URL providerURL) throws ClassNotFoundException, IOException, InvocationTargetException, IllegalAccessException { // Initialize the proxy Util class to integrate JAAS authentication Util.init(); if( log.isTraceEnabled() ) log.trace("Retrieving content from : "+providerURL); HttpURLConnection conn = (HttpURLConnection) providerURL.openConnection(); Util.configureHttpsHostVerifier(conn); Util.configureSSLSocketFactory(conn); int length = conn.getContentLength(); String type = conn.getContentType(); if( log.isTraceEnabled() ) log.trace("ContentLength: "+length+"\nContentType: "+type); InputStream is = conn.getInputStream(); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); ois.close(); Object obj = mv.get(); if( (obj instanceof Naming) == false ) { String msg = "Invalid reply content seen: "+obj.getClass(); Throwable t = null; if( obj instanceof Throwable ) { t = (Throwable) obj; if( t instanceof InvocationException ) t = ((InvocationException)t).getTargetException(); } if( t != null ) log.warn(msg, t); else log.warn(msg); IOException e = new IOException(msg); throw e; } Naming namingServer = (Naming) obj; return namingServer; }
// in src/main/java/org/jboss/naming/NamingService.java
public void setNamingProxy(Object proxy) throws IOException { namingMain.setNamingProxy(proxy); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException { // No state }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { // No state }
// in src/main/java/org/jboss/ejb/CacheKey.java
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(id); out.writeObject(mo); out.writeInt(hashCode); }
// in src/main/java/org/jboss/ejb/CacheKey.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { id = in.readObject(); mo = (MarshalledObject) in.readObject(); hashCode = in.readInt(); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected Object replaceObject (Object obj) throws IOException { if (obj instanceof javax.ejb.EJBObject) return ((javax.ejb.EJBObject)obj).getHandle (); return obj; }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
protected Object resolveObject (Object obj) throws IOException { if (obj instanceof javax.ejb.Handle) return ((javax.ejb.Handle)obj).getEJBObject (); return obj; }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectOutputStream.java
protected Object replaceObject(Object obj) throws IOException { Object replacement = obj; // section 6.4.1 of the ejb1.1 specification states what must be taken care of // ejb reference (remote interface) : store handle if (obj instanceof EJBObject) replacement = ((EJBObject)obj).getHandle(); // ejb reference (home interface) : store handle else if (obj instanceof EJBHome) replacement = ((EJBHome)obj).getHomeHandle(); // session context : store a typed dummy object else if (obj instanceof SessionContext) replacement = new StatefulSessionBeanField(StatefulSessionBeanField.SESSION_CONTEXT); // naming context : the jnp implementation is serializable, do nothing // user transaction : store a typed dummy object else if (obj instanceof UserTransaction) replacement = new StatefulSessionBeanField(StatefulSessionBeanField.USER_TRANSACTION); else if( obj instanceof Handle ) replacement = new HandleWrapper((Handle)obj); else if( (obj instanceof Remote) && !(obj instanceof RemoteStub) ) { Remote remote = (Remote) obj; try { replacement = RemoteObject.toStub(remote); } catch(IOException ignore) { // Let the Serialization layer try with original object } } return replacement; }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Object resolveObject(Object obj) throws IOException { Object resolved = obj; // section 6.4.1 of the ejb1.1 specification states what must be taken care of // ejb reference (remote interface) : resolve handle to EJB if (obj instanceof Handle) resolved = ((Handle)obj).getEJBObject(); // ejb reference (home interface) : resolve handle to EJB Home else if (obj instanceof HomeHandle) resolved = ((HomeHandle)obj).getEJBHome(); // naming context: the jnp implementation of contexts is serializable, do nothing else if( obj instanceof HandleWrapper ) { HandleWrapper wrapper = (HandleWrapper) obj; try { resolved = wrapper.get(); } catch(ClassNotFoundException e) { throw new IOException("Failed to find class: "+e.getMessage()); } } else if (obj instanceof StatefulSessionBeanField) { byte type = ((StatefulSessionBeanField)obj).type; // session context: recreate it if (type == StatefulSessionBeanField.SESSION_CONTEXT) resolved = ctx.getSessionContext(); // user transaction: restore it else if (type == StatefulSessionBeanField.USER_TRANSACTION) resolved = ctx.getSessionContext().getUserTransaction(); } return resolved; }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { try { // use the application classloader to resolve the class return appCl.loadClass(v.getName()); } catch (ClassNotFoundException e) { // we should probably never get here return super.resolveClass(v); } }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { Class clazz = null; Class[] ifaceClasses = new Class[interfaces.length]; for(int i = 0; i < interfaces.length; i ++) ifaceClasses[i] = Class.forName(interfaces[i], false, appCl); try { clazz = Proxy.getProxyClass(appCl, ifaceClasses); } catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); } return clazz; }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected Object replaceObject(final Object obj) throws IOException { if (obj instanceof EJBObject) return ((EJBObject)obj).getHandle(); return obj; }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
protected Object resolveObject(final Object obj) throws IOException { if (obj instanceof Handle) return ((Handle)obj).getEJBObject(); return obj; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); factory = (BaseLocalProxyFactory) BaseLocalProxyFactory.invokerMap.get(jndiName); }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); }
// in src/main/java/org/jboss/ejb/ListCacheKey.java
public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); out.writeLong(listId); out.writeInt(index); }
// in src/main/java/org/jboss/ejb/ListCacheKey.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); listId = in.readLong(); index = in.readInt(); }
// in src/main/java/org/jboss/web/WebServer.java
protected String getPath(BufferedReader in) throws IOException { String line = in.readLine(); log.trace("raw request=" + line); // Find the request path by parsing the 'REQUEST_TYPE filePath HTTP_VERSION' string int start = line.indexOf(' ') + 1; int end = line.indexOf(' ', start + 1); // The file minus the leading '/' String filePath = line.substring(start + 1, end); return filePath; }
// in src/main/java/org/jboss/web/WebServer.java
protected byte[] getBytes(URL url) throws IOException { InputStream in = new BufferedInputStream(url.openStream()); log.debug("Retrieving " + url); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] tmp = new byte[1024]; int bytes; while ((bytes = in.read(tmp)) != -1) { out.write(tmp, 0, bytes); } in.close(); return out.toByteArray(); }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
public static void parse(final DeploymentUnit unit, final URL facesConfigXmlURL, final JSFDeployment jsfDeployment) throws Exception { logger.debug("Checking for the presence of JSF managed-bean(s) in JSF config file: " + facesConfigXmlURL + " in deployment unit: " + unit); // get the parser factory SAXParserFactory parserFactory = getParserFactory(); // create a parser SAXParser saxParser = parserFactory.newSAXParser(); InputStream inputStream = null; try { // get the input stream and the input source for the faces config file inputStream = getInputStream(facesConfigXmlURL); InputSource inputSource = new InputSource(getInputStream(facesConfigXmlURL)); inputSource.setSystemId(facesConfigXmlURL.toExternalForm()); // parse it! saxParser.parse(inputSource, new DefaultHandler() { /** * Flag to keep track of managed-bean-class element being processed */ private boolean managedBeanClassElementProcessingInProgress; /** * Uses the {@link JBossEntityResolver} to resolve the entity. If it cannot be resolved by the {@link JBossEntityResolver} * then this method lets the {@link DefaultHandler} to resolve it. * * @param publicId * @param systemId * @return * @throws IOException * @throws SAXException */ @Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { // try resolving it with the JBossEntityResolver InputSource source = jBossJSFEntityResolver.resolveEntity(publicId, systemId); if (source != null) { return source; } // we couldn't resolve, so let the default handler try to resolve it return super.resolveEntity(publicId, systemId); } @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // we are only interested in managed-bean-class element. if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = true; } // let the super do its job super.startElement(uri, localName, qName, attributes); } @Override public void endElement(String uri, String localName, String qName) throws SAXException { // reset the flag when the managed-bean-class element ends if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = false; } // let super do its job super.endElement(uri, localName, qName); } @Override public void characters(char[] ch, int start, int length) throws SAXException { // if we are currently processing the managed-bean-class element, then fetch the managed bean // class name text if (this.managedBeanClassElementProcessingInProgress) { // get the managed bean class name String managedBeanClassName = new String(ch, start, length); if (!managedBeanClassName.trim().isEmpty()) { logger.debug("Found JSF managed bean class: " + managedBeanClassName + " in unit " + unit); // add it to the jsf deployment jsfDeployment.addManagedBean(managedBeanClassName); } } // let super do its job now super.characters(ch, start, length); } }); } finally { if (inputStream != null) { inputStream.close(); } } return; }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { // try resolving it with the JBossEntityResolver InputSource source = jBossJSFEntityResolver.resolveEntity(publicId, systemId); if (source != null) { return source; } // we couldn't resolve, so let the default handler try to resolve it return super.resolveEntity(publicId, systemId); }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
private static InputStream getInputStream(URL url) throws IOException { URLConnection conn = url.openConnection(); conn.setUseCaches(false); return new BufferedInputStream(conn.getInputStream()); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
Override protected void performMount(VirtualFile file) throws IOException { Automounter.mount(file, MountOption.EXPANDED, MountOption.COPY); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
protected void addPathsRecursively(StructureContext context, ContextInfo info, VirtualFile parent, String path) throws IOException { List<VirtualFile> children = parent.getChildren(); for (VirtualFile child : children) { if (!isLeaf(child)) { String newPath = path + "/" + child.getName(); addMetaDataPath(context, info, newPath, MetaDataType.ALTERNATIVE); addPathsRecursively(context, info, child, newPath); } } }
// in src/main/java/org/jboss/proxy/Interceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeObject(nextInterceptor); }
// in src/main/java/org/jboss/proxy/Interceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { nextInterceptor = (Interceptor)in.readObject(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public byte[] internalGetCode() throws IOException { // first, flush out all references to the cpool getIndex(this); getIndex(superClass); for (int i = 0; i < interfaces.length; i++) { getIndex(interfaces[i]); } int nfields = 0; int nmethods = 0; for (int i = 0; i < members.size(); i++) { AMember m = (AMember) members.elementAt(i); if (m.code != null) { byte[] codeAttr = getMethodCode(m, m.code); if (codeAttr != null) { addAttribute(m, "Code", codeAttr); } } for (int j = 0; j < m.attr.size(); j++) { Attr a = (Attr) m.attr.elementAt(j); getUtfIndex(a.name); } if (m.name.length() == 0) { continue; } getUtfIndex(m.name); getUtfIndex(m.sig); if (isMethodSig(m.sig)) { nmethods += 1; } else { nfields += 1; } } // next, deal with internal references in the cpool for (int i = 0; i < cv.size(); i++) { Object x = cv.elementAt(i); if (x == null) { continue; } else if (x instanceof String) { String s = (String)x; short si = getUtfIndex(s); short data[] = { CONSTANT_STRING, si }; x = data; } else if (x instanceof Class) { Class c = (Class)x; short ci = getUtfIndex(c.getName().replace('.', '/')); short data[] = { CONSTANT_CLASS, ci }; x = data; } else if (x instanceof Field) { Field m = (Field)x; short ci = getIndex(m.getDeclaringClass()); short nt = getNTIndex(m.getName(), getSig(m.getType())); short data[] = { CONSTANT_FIELD, ci, nt }; x = data; } else if (x instanceof Constructor) { Constructor m = (Constructor)x; short ci = getIndex(m.getDeclaringClass()); short nt = getNTIndex("<init>", getSig(Void.TYPE, m.getParameterTypes())); short data[] = { CONSTANT_METHOD, ci, nt }; x = data; } else if (x instanceof Method) { Method m = (Method)x; Class c = m.getDeclaringClass(); short kind = c.isInterface() ? CONSTANT_INTERFACEMETHOD : CONSTANT_METHOD; short ci = getIndex(c); short nt = getNTIndex(m.getName(), getSig(m.getReturnType(), m.getParameterTypes())); short data[] = { kind, ci, nt }; x = data; } else if (x instanceof ProxyAssembler) { ProxyAssembler asm = (ProxyAssembler)x; short ci = getUtfIndex(asm.className.replace('.', '/')); short data[] = { CONSTANT_CLASS, ci }; x = data; } else if (x instanceof AMember) { AMember m = (AMember) x; short kind = !isMethodSig(m.sig) ? CONSTANT_FIELD : m.asm.isInterface() ? CONSTANT_INTERFACEMETHOD : CONSTANT_METHOD; short ci = getIndex(m.asm); short nt = getNTIndex(m.name, m.sig); short data[] = { kind, ci, nt }; x = data; } else if (x instanceof NameAndType) { NameAndType nt = (NameAndType) x; short data[] = { CONSTANT_NAMEANDTYPE, nt.name, nt.sig }; x = data; } cv.setElementAt(x, i); // update } ByteArrayOutputStream bytes = new ByteArrayOutputStream(400); DataOutputStream ds = new DataOutputStream(bytes); ds.writeInt(JAVA_MAGIC); ds.writeShort(JAVA_MINOR_VERSION); ds.writeShort(JAVA_VERSION); int cvsize = cv.size(); ds.writeShort(cvsize); for (int i = 0; i < cv.size(); i++) { Object x = cv.elementAt(i); if (x == null) { continue; } else if (x instanceof short[]) { short data[] = (short[])x; ds.writeByte(data[0]); for (int j = 1; j < data.length; j++) { ds.writeShort(data[j]); } } else if (x instanceof byte[]) { ds.write((byte[])x); } else if (x instanceof Integer) { ds.writeByte(CONSTANT_INTEGER); ds.writeInt(((Integer)x).intValue()); // (do other primitive literal types?) } else { throw new RuntimeException("unexpected"); } } ds.writeShort(modifiers); ds.writeShort(getIndex(this)); ds.writeShort(getIndex(superClass)); ds.writeShort(interfaces.length); for (int i = 0; i < interfaces.length; i++) { ds.writeShort(getIndex(interfaces[i])); } for (int pass = 0; pass <= 1; pass++) { boolean methods = (pass > 0); ds.writeShort(methods ? nmethods : nfields); for (int i = 0; i < members.size(); i++) { AMember m = (AMember) members.elementAt(i); if (m.name.length() == 0 || isMethodSig(m.sig) != methods) { continue; } ds.writeShort(m.mods); ds.writeShort(getUtfIndex(m.name)); ds.writeShort(getUtfIndex(m.sig)); writeAttrs(ds, m.attr); } } AMember m0 = (AMember) members.elementAt(0); writeAttrs(ds, (Vector) m0.attr); // sanity check if (cvsize != cv.size()) { throw new RuntimeException("cvsize"); } return bytes.toByteArray(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
private byte[] getMethodCode(AMember m, ByteArrayOutputStream code) throws IOException { if (code.size() == 0) { if ((current.mods & (Modifier.NATIVE | Modifier.ABSTRACT)) == 0) { current.mods |= Modifier.ABSTRACT; modifiers |= Modifier.ABSTRACT; } return null; } ByteArrayOutputStream bytes = new ByteArrayOutputStream(code.size()+30); DataOutputStream ds = new DataOutputStream(bytes); int slop = 10; // ?? int max_stack = current.locmax + slop; int max_locals = current.spmax + slop; ds.writeShort(max_stack); ds.writeShort(max_locals); ds.writeInt(code.size()); code.writeTo(ds); ds.writeShort(0); // exception_table.length Vector attrs = new Vector(); for (int i = m.attr.size(); --i >= 0; ) { Attr ma = (Attr) m.attr.elementAt(i); if (ma.name.startsWith("Code.")) { m.attr.removeElementAt(i); ma.name = ma.name.substring("Code.".length()); attrs.addElement(ma); getUtfIndex(ma.name); } } writeAttrs(ds, attrs); return bytes.toByteArray(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
private void writeAttrs(DataOutputStream ds, Vector attrs) throws IOException { ds.writeShort(attrs.size()); for (int i = 0; i < attrs.size(); i++) { Attr a = (Attr) attrs.elementAt(i); ds.writeShort(getUtfIndex(a.name)); if (a.data instanceof byte[]) { byte[] xa = (byte[])a.data; ds.writeInt(xa.length); ds.write(xa); } else { throw new RuntimeException("unexpected"); } } }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
private void writeObject(ObjectOutputStream oos) throws IOException { ObjectOutputStream.PutField putField = oos.putFields(); putField.put("jndiName", jndiName); putField.put("jndiEnv", jndiEnv); oos.writeFields(); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
private void writeObject(ObjectOutputStream oos) throws IOException { ObjectOutputStream.PutField putField = oos.putFields(); putField.put("jndiName", jndiName); putField.put("jndiEnv", jndiEnv); oos.writeFields(); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ObjectInputStream.GetField getField = ois.readFields(); id = getField.get("id", null); jndiName = (String) getField.get("jndiName", null); jndiEnv = (Hashtable) getField.get("jndiEnv", null); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
private void writeObject(ObjectOutputStream oos) throws IOException { ObjectOutputStream.PutField putField = oos.putFields(); putField.put("id", id); putField.put("jndiName", jndiName); putField.put("jndiEnv", jndiEnv); oos.writeFields(); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public void writeEJBObject(EJBObject ejbObject, ObjectOutputStream oostream) throws IOException { oostream.writeObject(ejbObject); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public EJBObject readEJBObject(ObjectInputStream oistream) throws IOException, ClassNotFoundException { Object ejbObject = oistream.readObject(); reconnect(ejbObject); return (EJBObject) PortableRemoteObject.narrow(ejbObject, EJBObject.class); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public void writeEJBHome(EJBHome ejbHome, ObjectOutputStream oostream) throws IOException { oostream.writeObject(ejbHome); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public EJBHome readEJBHome(ObjectInputStream oistream) throws IOException, ClassNotFoundException { Object ejbHome = oistream.readObject(); reconnect(ejbHome); return (EJBHome) PortableRemoteObject.narrow(ejbHome, EJBHome.class); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
protected void reconnect(Object object) throws IOException { if (object instanceof ObjectImpl) { try { // Check we are still connected ObjectImpl objectImpl = (ObjectImpl) object; objectImpl._get_delegate(); } catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } } } else throw new IOException("Not an ObjectImpl " + object.getClass().getName()); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { super.writeExternal(out); // Write out a version identifier for future extensibility out.writeInt(EXTERNAL_VERSION); // There is no additional data currently }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); // Read the version identifier int version = in.readInt(); if( version == EXTERNAL_VERSION ) { // This version has no additional data } // Set the logging trace level trace = log.isTraceEnabled(); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
public void writeExternal(final ObjectOutput out) throws IOException { super.writeExternal(out); out.writeObject(list); }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); list = (List) in.readObject(); }
// in src/main/java/org/jboss/proxy/ejb/ReadAheadResult.java
public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(mainResult); out.writeObject(getAheadResult()); }
// in src/main/java/org/jboss/proxy/ejb/ReadAheadResult.java
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { mainResult = in.readObject(); aheadArray = (Object[]) in.readObject(); }
// in src/main/java/org/jboss/proxy/ClientContainer.java
public void writeExternal(final ObjectOutput out) throws IOException { out.writeObject(next); out.writeObject(context); }
// in src/main/java/org/jboss/proxy/ClientContainer.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { next = (Interceptor) in.readObject(); context = (InvocationContext) in.readObject(); }
29
            
// in src/main/java/org/jboss/invocation/MarshalledValueOutputStream.java
catch(IOException ignore) { // Let the Serialization layer try with the orignal obj }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (IOException e) { throw new ServerException("IOE", e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); }
// in src/main/java/org/jboss/deployment/EARStructure.java
catch (IOException e) { // TODO - should we throw this fwd? log.warn("Exception while searching for lib dir: " + e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch (IOException e) { // Failed, try to locate a classpath resource below is = null; }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(IOException e) { CommunicationException ce = new CommunicationException("Operation failed"); ce.setRootCause(e); throw ce; }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (IOException e) { log.error("Cannot serialize: " + obj, e); }
// in src/main/java/org/jboss/ejb/plugins/SessionObjectOutputStream.java
catch(IOException ignore) { // Let the Serialization layer try with original object }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { throw e; }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { // If the server is not null meaning we were not stopped report the err if (server != null) log.error("Failed to accept connection", e); return; }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException ie) { return; }
// in src/main/java/org/jboss/web/WebServer.java
catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException ex) { // Ignore }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException ex) { log.error("error writting response", ex); }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
catch (IOException e) { log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e); }
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (IOException e) { ; }
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException cantHappen) { cantHappen.printStackTrace(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/etc/class.java
catch (IOException ioe) { }
15
            
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (IOException e) { throw new ServerException("IOE", e); }
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (IOException e) { throw new DeploymentException("Failed to obtain xml doc from URL", e); }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(IOException e) { CommunicationException ce = new CommunicationException("Operation failed"); ce.setRootCause(e); throw ce; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(IOException e) { // will never happen because io is in memory, but required by the interface throw new DeploymentException("Error parsing function-sql: " + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/web/WebServer.java
catch (IOException e) { throw e; }
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
2
unknown (Lib) IllegalAccessException 0 0 5
            
// in src/main/java/org/jboss/invocation/Invocation.java
public Object performCall(Object instance, Method m, Object[] arguments) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Exception { return m.invoke(instance,arguments); }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
private Naming getNamingServer(URL providerURL) throws ClassNotFoundException, IOException, InvocationTargetException, IllegalAccessException { // Initialize the proxy Util class to integrate JAAS authentication Util.init(); if( log.isTraceEnabled() ) log.trace("Retrieving content from : "+providerURL); HttpURLConnection conn = (HttpURLConnection) providerURL.openConnection(); Util.configureHttpsHostVerifier(conn); Util.configureSSLSocketFactory(conn); int length = conn.getContentLength(); String type = conn.getContentType(); if( log.isTraceEnabled() ) log.trace("ContentLength: "+length+"\nContentType: "+type); InputStream is = conn.getInputStream(); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); ois.close(); Object obj = mv.get(); if( (obj instanceof Naming) == false ) { String msg = "Invalid reply content seen: "+obj.getClass(); Throwable t = null; if( obj instanceof Throwable ) { t = (Throwable) obj; if( t instanceof InvocationException ) t = ((InvocationException)t).getTargetException(); } if( t != null ) log.warn(msg, t); else log.warn(msg); IOException e = new IOException(msg); throw e; } Naming namingServer = (Naming) obj; return namingServer; }
// in src/main/java/org/jboss/naming/NamingService.java
public void setClientSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setClientSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void setServerSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setServerSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void setJNPServerSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setJNPServerSocketFactory(factoryClassName); }
23
            
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (IllegalAccessException e) { log.error(e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IllegalAccessException e) { // Should never happen log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IllegalAccessException e) { // Whatever, I guess non-binary will not work for this field. }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (IllegalAccessException e) { // If CMP primary key class MUST have a public // constructor with no parameters. 10.8.2.a /// if (cmp) { fireSpecViolationEvent(entity, new Section("10.8.2.a")); status = false; } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (IllegalAccessException e) { // If CMP primary key class MUST have a public // constructor with no parameters. 10.8.2.a /// if (cmp) { fireSpecViolationEvent(entity, new Section("10.8.2.a")); status = false; } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (IllegalAccessException e) { // [FIXME] The two error messages below are incorrect. // The RMI-IDL language mapping does not require // the value types to have a no args constructor. // [JPL] // //fireSpecViolationEvent(entity, new Section("9.2.9.a")); //status = false; }
17
            
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (IllegalAccessException e) { ctx.setId(null); throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (IllegalAccessException e) { throw new javax.ejb.CreateException ("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (IllegalAccessException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (IllegalAccessException e) { throw new CreateException("Could not create entity: "+e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalAccessException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Unable to access finder implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
0
runtime (Lib) IllegalArgumentException 142
            
// in src/main/java/org/jboss/invocation/Invocation.java
public void setValue(Object key, Object value, PayloadKey type) { if(type == PayloadKey.TRANSIENT) { getTransientPayload().put(key,value); } else if(type == PayloadKey.AS_IS) { getAsIsPayload().put(key,value); } else if(type == PayloadKey.PAYLOAD) { getPayload().put(key,value); } else { throw new IllegalArgumentException("Unknown PayloadKey: " + type); } }
// in src/main/java/org/jboss/client/AppClientMain.java
public static void main(String[] args) throws Exception { log.debug("System Properties"); Properties sysprops = System.getProperties(); for (Object key : sysprops.keySet()) log.debug(" " + key + "=" + sysprops.getProperty((String) key)); // read the client class from args String clientClass = null; String clientName = null; ArrayList<String> newArgs = new ArrayList<String>(); String[] launchers = DEFAULT_LAUNCHERS; for (int i = 0; i < args.length; i++) { String arg = args[i]; log.debug("arg=" + arg); if( arg.equals(JBOSS_CLIENT_PARAM) ) { clientClass = args[i+1]; i ++; } else if( arg.equals(J2EE_CLIENT_PARAM) ) { /* Set the j2ee.client system property so the AppContextFactory sees what name the client app JNDI enc is bound under */ clientName = args[i+1]; System.setProperty(javaURLContextFactory.J2EE_CLIENT_NAME_PROP, clientName); log.info(javaURLContextFactory.J2EE_CLIENT_NAME_PROP + "=" + clientName); i ++; } else if( arg.equals(LAUNCHERS_PARAM) ) { launchers = args[i+1].split(","); log.info(LAUNCHERS_PARAM + "=" + args[i+1]); i ++; } else { newArgs.add(args[i]); } } ClassLoader loader = Thread.currentThread().getContextClassLoader(); if( loader == null ) loader = AppClientMain.class.getClassLoader(); // Look for a manifest Main-Class if (clientClass == null) { clientClass = getMainClassName(loader); throw new IllegalArgumentException("Neither a Main-Class was found in the manifest, " +"nor was a " + JBOSS_CLIENT_PARAM + " specified"); } // If J2EE_CLIENT_NAME_PROP was not specified, look in the jar descriptors if (clientName == null) { clientName = getClientName(loader); } String[] mainArgs = new String [newArgs.size()]; newArgs.toArray(mainArgs); // Try each launcher in the order specified for(String launcherName : launchers) { try { Class<AppClientLauncher> launcherClass = (Class<AppClientLauncher>) loader.loadClass(launcherName); AppClientLauncher launcher = launcherClass.newInstance(); launcher.launch(clientClass, clientName, mainArgs); break; } catch(Throwable t) { log.warn("Failed to launch using: "+launcherName, t); } } }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static Connection createConnection(final Object factory, final String username, final String password) throws JMSException { if (factory == null) throw new IllegalArgumentException("factory is null"); log.debug("using connection factory: " + factory); log.debug("using username/password: " + String.valueOf(username) + "/-- not shown --"); Connection connection; if (factory instanceof XAConnectionFactory) { XAConnectionFactory qFactory = (XAConnectionFactory) factory; if (username != null) connection = qFactory.createXAConnection(username, password); else connection = qFactory.createXAConnection(); log.debug("created XAConnection: " + connection); } else if (factory instanceof ConnectionFactory) { ConnectionFactory qFactory = (ConnectionFactory) factory; if (username != null) connection = qFactory.createConnection(username, password); else connection = qFactory.createConnection(); log.debug("created Connection: " + connection); } else { throw new IllegalArgumentException("factory is invalid"); } return connection; }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static QueueConnection createQueueConnection(final Object factory, final String username, final String password) throws JMSException { if (factory == null) throw new IllegalArgumentException("factory is null"); log.debug("using connection factory: " + factory); log.debug("using username/password: " + String.valueOf(username) + "/-- not shown --"); QueueConnection connection; if (factory instanceof XAQueueConnectionFactory) { XAQueueConnectionFactory qFactory = (XAQueueConnectionFactory) factory; if (username != null) connection = qFactory.createXAQueueConnection(username, password); else connection = qFactory.createXAQueueConnection(); log.debug("created XAQueueConnection: " + connection); } else if (factory instanceof QueueConnectionFactory) { QueueConnectionFactory qFactory = (QueueConnectionFactory) factory; if (username != null) connection = qFactory.createQueueConnection(username, password); else connection = qFactory.createQueueConnection(); log.debug("created QueueConnection: " + connection); } else throw new IllegalArgumentException("factory is invalid"); return connection; }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static TopicConnection createTopicConnection(final Object factory, final String username, final String password) throws JMSException { if (factory == null) throw new IllegalArgumentException("factory is null"); log.debug("using connection factory: " + factory); log.debug("using username/password: " + String.valueOf(username) + "/-- not shown --"); TopicConnection connection; if (factory instanceof XATopicConnectionFactory) { XATopicConnectionFactory tFactory = (XATopicConnectionFactory) factory; if (username != null) connection = tFactory.createXATopicConnection(username, password); else connection = tFactory.createXATopicConnection(); log.debug("created XATopicConnection: " + connection); } else if (factory instanceof TopicConnectionFactory) { TopicConnectionFactory tFactory = (TopicConnectionFactory) factory; if (username != null) connection = tFactory.createTopicConnection(username, password); else connection = tFactory.createTopicConnection(); log.debug("created TopicConnection: " + connection); } else throw new IllegalArgumentException("factory is invalid"); return connection; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected XAConnectionFactory getConnectionFactory() throws Exception { // Get the JMS Provider Adapter if (providerName == null) throw new IllegalArgumentException("Null provider name"); String providerAdapterJNDI = providerName; if (providerAdapterJNDI.startsWith("java:") == false) providerAdapterJNDI = "java:" + providerAdapterJNDI; Context ctx = new InitialContext(); JMSProviderAdapter adapter = (JMSProviderAdapter) Util.lookup(providerAdapterJNDI, JMSProviderAdapter.class); // Determine the XAConnectionFactory name String connectionFactoryRef = adapter.getFactoryRef(); if (connectionFactoryRef == null) throw new IllegalStateException("Provider '" + providerName + "' has no FactoryRef"); // Lookup the connection factory ctx = adapter.getInitialContext(); try { return (XAConnectionFactory) Util.lookup(ctx, connectionFactoryRef, XAConnectionFactory.class); } finally { ctx.close(); } }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(DeploymentUnit unit, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (unit == null) throw new IllegalArgumentException("Null unit"); ClassLoadingMetaData clmd = unit.getAttachment(ClassLoadingMetaData.class); if (clmd != null) return clmd; clmd = create(unit.getName(), loaderMetaData, parentDelegation); if (clmd != null) unit.addAttachment(ClassLoadingMetaData.class, clmd); return clmd; }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
public static ClassLoadingMetaData create(String deploymentName, LoaderRepositoryMetaData loaderMetaData, boolean parentDelegation) throws DeploymentException { if (deploymentName == null) throw new IllegalArgumentException("Null deployment name"); if (loaderMetaData == null) throw new IllegalArgumentException("Null loader repository metadata"); LoaderRepositoryConfig repositoryConfig = new LoaderRepositoryConfig(); repositoryConfig.repositoryClassName = loaderMetaData.getLoaderRepositoryClass(); if (repositoryConfig.repositoryClassName == null || repositoryConfig.repositoryClassName.length() == 0) repositoryConfig.repositoryClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_CLASS; // Get the object name of the repository String name = loaderMetaData.getName(); if (name != null) { try { repositoryConfig.repositoryName = new ObjectName(name.trim()); } catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); } } StringBuilder configData = new StringBuilder(); Set<LoaderRepositoryConfigMetaData> children = loaderMetaData.getLoaderRepositoryConfig(); if (children != null) { for (LoaderRepositoryConfigMetaData child : children) { // This looks stupid? Why inside a loop? String parserClassName = child.getConfigParserClass(); if (parserClassName == null || parserClassName.length() == 0) repositoryConfig.configParserClassName = ServerConstants.DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS; else repositoryConfig.configParserClassName = parserClassName; // Append all config String childConfig = child.getConfig(); if (childConfig != null) configData.append(childConfig); } } repositoryConfig.repositoryConfig = configData.toString().trim(); return LoaderRepositoryConfigHelper.create(name, repositoryConfig, parentDelegation); }
// in src/main/java/org/jboss/deployment/EARStructure.java
public void setEarLibFilter(VirtualFileFilter earLibFilter) { if (earLibFilter == null) throw new IllegalArgumentException("Null filter"); this.earLibFilter = earLibFilter; }
// in src/main/java/org/jboss/deployment/ListDeploymentUnitFilter.java
public void start() { if (filters == null || filters.isEmpty()) throw new IllegalArgumentException("Null or empty filters list."); }
// in src/main/java/org/jboss/deployment/TldParsingDeployer.java
protected TldMetaData parse(VirtualFile file) throws Exception { if (file == null) throw new IllegalArgumentException("Null file"); // Implicit TLDs are reserved as the "implicit.tld" name if (file.getName().equals("implicit.tld")) { return new TldMetaData(); } else { return super.parse(file); } }
// in src/main/java/org/jboss/deployment/JSFDeployment.java
public void addManagedBean(String managedBeanClass) { if (managedBeanClass == null || managedBeanClass.trim().isEmpty()) { throw new IllegalArgumentException("Managed bean class cannot be null or empty string"); } this.managedBeans.add(managedBeanClass); }
// in src/main/java/org/jboss/deployment/security/JaccPolicyUtil.java
public static void createPermissions(PolicyConfiguration policyConfiguration, Object metadata) throws PolicyContextException { if(metadata == null) throw new IllegalArgumentException("Meta Data is null"); if(policyConfiguration == null) throw new IllegalArgumentException("Policy Configuration is null"); if(metadata instanceof JBossWebMetaData) { JBossWebMetaData wmd = (JBossWebMetaData)metadata; WebPermissionMapping.createPermissions(wmd, policyConfiguration); } else if(metadata instanceof JBossEnterpriseBeanMetaData) { JBossEnterpriseBeanMetaData bmd = (JBossEnterpriseBeanMetaData)metadata; EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } else if(metadata instanceof JBossMetaData) { JBossMetaData jmd = (JBossMetaData)metadata; JBossEnterpriseBeansMetaData beans = jmd.getEnterpriseBeans(); for(JBossEnterpriseBeanMetaData bmd : beans) { EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } } else throw new IllegalStateException("Unknown metadata"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (duration < 0) throw new IllegalArgumentException("duration is negative"); return createTimer(new Date(System.currentTimeMillis() + duration), 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialDuration < 0) throw new IllegalArgumentException("initial duration is negative"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); return createTimer(new Date(System.currentTimeMillis() + initialDuration), intervalDuration, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (expiration == null) throw new IllegalArgumentException("expiration is null"); return createTimer(expiration, 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSource, String tableName) throws SQLException { if (tableName == null) throw new IllegalArgumentException("Timers tableName is null"); if (tableName.length() == 0) throw new IllegalArgumentException("Timers tableName is empty"); this.tableName = tableName; init(server, dataSource); }
// in src/main/java/org/jboss/ejb/txtimer/TimedObjectId.java
public static TimedObjectId parse(String externalForm) { if (externalForm.startsWith("[") == false || externalForm.endsWith("]") == false) throw new IllegalArgumentException("Square brackets expected arround: " + externalForm); // take first and last char off String inStr = externalForm.substring(1, externalForm.length() - 1); if (inStr.startsWith("target=") == false) throw new IllegalArgumentException("Cannot parse: " + externalForm); String jmxStr = inStr.substring(7); String pkStr = null; int pkIndex = jmxStr.indexOf(",pk="); if (pkIndex > 0) { pkStr = jmxStr.substring(pkIndex + 4); jmxStr = jmxStr.substring(0, pkIndex); } ObjectName contatinerId = ObjectNameFactory.create(jmxStr); return new TimedObjectId(contatinerId, pkStr); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public void setInstancePool(InstancePool ip) { if (ip == null) throw new IllegalArgumentException("Null pool"); this.instancePool = ip; }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
public void addCreateDestination(CreateDestination factory) { if (factory == null) throw new IllegalArgumentException("Null factory"); factories.add(factory); addOutput(factory.getOutput()); }
// in src/main/java/org/jboss/ejb/deployers/CreateDestinationDeployer.java
public void removeCreateDestination(CreateDestination factory) { if (factory == null) throw new IllegalArgumentException("Null factory"); factories.add(factory); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public BeanLock getLock(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to get lock ref with a null object"); HashMap mapInUse = getHashMap(id); synchronized (mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock!=null) { lock.addRef(); return lock; } } try { BeanLock lock2 = (BeanLock)createLock(id); synchronized(mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); // in case of bad luck, this might happen if (lock != null) { lock.addRef(); return lock; } mapInUse.put(id, lock2); lock2.addRef(); return lock2; } } catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); } }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public void removeLockRef(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to remove lock ref with a null object"); HashMap mapInUse = getHashMap(id); synchronized(mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock != null) { try { lock.removeRef(); if( trace ) log.trace("Remove ref lock:"+lock); } finally { // schrouf: ALLWAYS ensure proper map lock removal even in case // of exception within lock.removeRef ! There seems to be a bug // in the ref counting of QueuedPessimisticEJBLock under certain // conditions ( lock.ref < 0 should never happen !!! ) if (lock.getRefs() <= 0) { Object mapLock = mapInUse.remove(lock.getId()); if( trace ) log.trace("Lock no longer referenced, lock: "+lock); } } } } }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public boolean canPassivate(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to passivate with a null object"); HashMap mapInUse = getHashMap(id); synchronized (mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock == null) throw new IllegalStateException("Attempt to passivate without a lock"); return (lock.getRefs() <= 1); } }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
protected void ageOut(LRUCacheEntry entry) { if( m_cache == null ) return; if (entry == null) { throw new IllegalArgumentException ("Cannot remove a null cache entry"); } if( log.isTraceEnabled() ) { m_buffer.setLength(0); m_buffer.append("Aging out from cache bean "); m_buffer.append(m_cache.getContainer().getBeanMetaData().getEjbName()); m_buffer.append("with id = "); m_buffer.append(entry.m_key); m_buffer.append("; cache size = "); m_buffer.append(getList().m_count); log.trace(m_buffer.toString()); } // This will schedule the passivation m_cache.release((EnterpriseContext)entry.m_object); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if (id == null) throw new IllegalArgumentException("Can't get an object with a null key"); EnterpriseContext ctx; synchronized (getCacheLock()) { CachePolicy cache = getCache(); ctx = (EnterpriseContext)cache.get(id); if (ctx == null) { try { ctx = acquireContext(); setKey(id, ctx); if (doActivate(ctx) == false) // This is a recursive activation return ctx; logActivation(id); // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here cache.insert(id, ctx); } catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void insert(EnterpriseContext ctx) { if (ctx == null) throw new IllegalArgumentException("Can't insert a null object in the cache"); Object key = getKey(ctx); synchronized (getCacheLock()) { // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here getCache().insert(key, ctx); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void release(EnterpriseContext ctx) { if (ctx == null) throw new IllegalArgumentException("Can't release a null object"); // Here I remove the bean; call to remove(id) is wrong // cause will remove also the cache lock that is needed // by the passivation, that eventually will remove it. /* the removal should only be done if the instance is not in use. this is taken care of in tryToPassivate Object id = getKey(ctx); synchronized (getCacheLock()) { if (getCache().peek(id) != null) getCache().remove(id); } */ tryToPassivate(ctx, true); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public void remove(Object id) { if (id == null) throw new IllegalArgumentException("Can't remove an object using a null key"); synchronized (getCacheLock()) { if (getCache().peek(id) != null) { getCache().remove(id); } }
// in src/main/java/org/jboss/ejb/plugins/CallValidationInterceptor.java
protected void validateArguments(Invocation mi) { if (mi.getType() == InvocationType.REMOTE) { Object[] params = mi.getArguments(); for (int i = 0; i < params.length; i++) { Object obj = params[i]; if (obj instanceof TimerHandle) throw new IllegalArgumentException("Cannot pass TimerHandle through remote interface"); } } }
// in src/main/java/org/jboss/ejb/plugins/CallValidationInterceptor.java
protected Object validateReturnValue(Invocation mi, Object retValue) { if (mi.getType() == InvocationType.REMOTE) { if (retValue instanceof TimerHandle) throw new IllegalArgumentException("Cannot return TimerHandle from remote interface"); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public Object get(Object key) { if (key == null) { throw new IllegalArgumentException("Requesting an object using a null key"); } EnterpriseContext ctx = null; synchronized (m_map) { ctx = (EnterpriseContext) m_map.get(key); } return ctx; }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void insert(Object key, Object ctx) { if (ctx == null) { throw new IllegalArgumentException("Cannot insert a null object in the cache"); } if (key == null) { throw new IllegalArgumentException("Cannot insert an object in the cache with null key"); } synchronized (m_map) { Object obj = m_map.get(key); if (obj == null) { m_map.put(key, ctx); } else { throw new IllegalStateException("Attempt to put in the cache an object that is already there"); } } }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void remove(Object key) { if (key == null) { throw new IllegalArgumentException("Removing an object using a null key"); } synchronized (m_map) { Object value = m_map.get(key); if (value != null) { m_map.remove(key); } else { throw new IllegalArgumentException("Cannot remove an object that isn't in the cache"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/IdentifierManager.java
public void declareCollectionMember( String identifier, String path) { List fieldList = (List)fieldLists.get(path); Object field = fieldList.get(fieldList.size()-1); if(!(field instanceof CMRFieldBridge)) { throw new IllegalArgumentException("Path is collection valued: "+path); } CMRFieldBridge cmrField = (CMRFieldBridge)field; if(cmrField.isSingleValued()) { throw new IllegalArgumentException("Path is collection valued: "+path); } identifiers.put(identifier, cmrField.getRelatedEntity()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/IdentifierManager.java
public void registerPath( String path, List pathList, List fieldList) { if(pathList.size() != fieldList.size()) { throw new IllegalArgumentException("Path list and field list must " + "have the same size: pathList.size=" + pathList.size() + " fieldList.size=" + fieldList.size()); } pathLists.put(path, pathList); fieldLists.put(path, fieldList); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PersistentContext.java
public void setPk(Object pk) throws DuplicateKeyException { if(pk == null) { throw new IllegalArgumentException("Primary key is null!"); } row.insert(pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/FindByPrimaryKeyCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { Object pk = args[0]; if(pk == null) { throw new IllegalArgumentException("Null argument for findByPrimaryKey"); } Object instance; boolean cached = entity.getTable().hasRow(pk); if(!cached) { instance = super.executeFetchOne(args, factory); if(instance == null) { throw new ObjectNotFoundException("Instance not find: entity=" + entity.getEntityName() + ", pk=" + pk); } } else { instance = factory.getEntityEJBObject(pk); } return instance; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
protected void setParameters(List p) { if(p.size() > 0) { params = new QueryParameter[p.size()]; for(int i = 0; i < p.size(); i++) { Object pi = p.get(i); if(!(pi instanceof QueryParameter)) { throw new IllegalArgumentException("Element " + i + " of list is not an instance of QueryParameter, but " + p.get(i).getClass().getName()); } params[i] = (QueryParameter) pi; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private Object getPrimaryKey(Object o) { if(o == null) { throw new IllegalArgumentException("This implementation does not support null members."); } if(!relatedEntity.getLocalInterface().isInstance(o)) { throw new IllegalArgumentException("Argument must be of type " + entity.getLocalInterface().getName()); } EJBLocalObject local = (EJBLocalObject)o; try { return local.getPrimaryKey(); } catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(value == null) { throw new IllegalArgumentException("Can't set collection-valued CMR field to null: " + entity.getEntityName() + "." + getFieldName() ); } destroyExistingRelationships(ctx); Collection newValue = (Collection)value; if(!newValue.isEmpty()) { Set copy = new HashSet(newValue); for(Iterator iter = copy.iterator(); iter.hasNext();) { Object relatedId = getPrimaryKey(iter.next()); addRelatedId(ctx, relatedId); relatedCMRField.invokeAddRelatedId(relatedId, ctx.getId()); loader.addRelatedId(ctx, relatedId); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
public JDBCRelationshipRoleMetaData getOtherRelationshipRole(JDBCRelationshipRoleMetaData role) { if (left == role) { return right; } else if (right == role) { return left; } else { throw new IllegalArgumentException("Specified role is not the left " + "or right role. role=" + role); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
protected void setParameterList(List p) { for(int i = 0; i < p.size(); i++) { if(!(p.get(i) instanceof QueryParameter)) { throw new IllegalArgumentException("Element " + i + " of list " + "is not an instance of QueryParameter, but " + p.get(i).getClass().getName()); } } parameters = new ArrayList(p); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
private void existsClause(ASTPath path, StringBuffer buf, boolean not) { if(!path.isCMRField()) { throw new IllegalArgumentException("path must be a cmr field"); } JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) path.getCMRField(); String pathStr = path.getPath(path.size() - 2); String parentAlias = aliasManager.getAlias(pathStr); // if exists is not supported we use a left join and is null if(!subquerySupported) { // add the path to the list of paths to left join addLeftJoinPath(pathStr, path); forceDistinct = true; addJoinPath(path); if(cmrField.getRelationMetaData().isForeignKeyMappingStyle()) { JDBCEntityBridge childEntity = (JDBCEntityBridge) cmrField.getRelatedEntity(); String childAlias = aliasManager.getAlias(path.getPath()); SQLUtil.getIsNullClause(!not, childEntity.getPrimaryKeyFields(), childAlias, buf); } else { String relationTableAlias = aliasManager.getRelationTableAlias(path.getPath()); SQLUtil.getIsNullClause(!not, cmrField.getTableKeyFields(), relationTableAlias, buf); } return; } if(not) { buf.append(SQLUtil.NOT); } buf.append(SQLUtil.EXISTS).append('('); if(cmrField.getRelationMetaData().isForeignKeyMappingStyle()) { JDBCEntityBridge childEntity = (JDBCEntityBridge) cmrField.getRelatedEntity(); String childAlias = aliasManager.getAlias(path.getPath()); buf.append(SQLUtil.SELECT); SQLUtil.getColumnNamesClause(childEntity.getPrimaryKeyFields(), childAlias, buf) .append(SQLUtil.FROM) .append(childEntity.getQualifiedTableName()).append(' ').append(childAlias) .append(SQLUtil.WHERE); SQLUtil.getJoinClause(cmrField, parentAlias, childAlias, buf); } else { String relationTableAlias = aliasManager.getRelationTableAlias(path.getPath()); buf.append(SQLUtil.SELECT); SQLUtil.getColumnNamesClause(cmrField.getTableKeyFields(), relationTableAlias, buf) .append(SQLUtil.FROM) .append(cmrField.getQualifiedTableName()) .append(' ') .append(relationTableAlias) .append(SQLUtil.WHERE); SQLUtil.getRelationTableJoinClause(cmrField, parentAlias, relationTableAlias, buf); } buf.append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
public void set(Logger log, PreparedStatement ps, int index, Object[] args) throws Exception { Object arg = args[argNum]; JDBCParameterSetter param; if(field != null) { if(!isPrimaryKeyParameter) { if(arg instanceof EJBObject) { arg = ((EJBObject)arg).getPrimaryKey(); } else if(arg instanceof EJBLocalObject) { arg = ((EJBLocalObject)arg).getPrimaryKey(); } else { throw new IllegalArgumentException("Expected an instanc of " + "EJBObject or EJBLocalObject, but got an instance of " + arg.getClass().getName()); } } arg = field.getPrimaryKeyValue(arg); // use mapper final JDBCType jdbcType = field.getJDBCType(); arg = jdbcType.getColumnValue(0, arg); param = jdbcType.getParameterSetter()[0]; } else if(property != null) { arg = property.getColumnValue(arg); param = property.getParameterSetter(); } else { if(type != null) { arg = type.getColumnValue(0, arg); param = type.getParameterSetter()[0]; } else { param = JDBCUtil.getParameterSetter(jdbcType, arg == null ? null : arg.getClass()); } } param.set(ps, index, jdbcType, arg, log); //JDBCUtil.setParameter(log, ps, index, jdbcType, arg); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
private static JDBCFieldBridge getCMPField( JDBCEntityPersistenceStore manager, Class intf, String fieldName) { Catalog catalog = manager.getCatalog(); JDBCAbstractEntityBridge entityBridge = (JDBCAbstractEntityBridge)catalog.getEntityByInterface(intf); if(entityBridge == null) { throw new IllegalArgumentException("Entity not found in application " + "catalog with interface=" + intf.getName()); } JDBCFieldBridge cmpField = (JDBCFieldBridge)entityBridge.getFieldByName(fieldName); if(cmpField == null) { throw new IllegalArgumentException("cmpField not found:" + " cmpFieldName=" + fieldName + " entityName=" + entityBridge.getEntityName()); } return cmpField; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
public static StringBuffer getJoinClause(JDBCFieldBridge[] pkFields, String parent, JDBCFieldBridge[] fkFields, String child, StringBuffer buf) { if(pkFields.length != fkFields.length) { throw new IllegalArgumentException( "Error createing theta join clause:" + " pkField.size()=" + pkFields.length + " fkField.size()=" + fkFields.length); } boolean and = false; for(int i = 0; i < pkFields.length; ++i) { // these types should not be null JDBCType pkType = getJDBCType(pkFields[i]); JDBCType fkType = getJDBCType(fkFields[i]); if(and) buf.append(AND); else and = true; getJoinClause(pkType, parent, fkType, child, buf); } return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
private static StringBuffer getJoinClause(JDBCType pkType, String parent, JDBCType fkType, String child, StringBuffer buf) { if(parent.length() > 0) { parent += '.'; } if(child.length() > 0) { child += '.'; } String[] pkColumnNames = pkType.getColumnNames(); String[] fkColumnNames = fkType.getColumnNames(); if(pkColumnNames.length != fkColumnNames.length) { throw new IllegalArgumentException("PK and FK have different number of columns"); } buf.append(parent).append(pkColumnNames[0]).append('=').append(child).append(fkColumnNames[0]); int i = 1; while(i < pkColumnNames.length) { buf.append(AND) .append(parent) .append(pkColumnNames[i]) .append('=') .append(child) .append(fkColumnNames[i++]); } return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMR field cannot be set " + "in ejbCreate; this should be done in the ejbPostCreate " + "method instead [EJB 2.0 Spec. 10.5.2]."); } if(isCollectionValued() && value == null) { throw new IllegalArgumentException("null cannot be assigned to a " + "collection-valued cmr-field [EJB 2.0 Spec. 10.3.8]."); } /* if(allFKFieldsMappedToPKFields) { throw new IllegalStateException( "Can't modify relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]."); } */ setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private Object getRelatedPrimaryKey(Object localObject) { Object relatedId; if(relatedEntity.getLocalInterface().isAssignableFrom(localObject.getClass())) { EJBLocalObject local = (EJBLocalObject) localObject; try { relatedId = local.getPrimaryKey(); } catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); } /* if(relatedManager.wasCascadeDeleted(relatedId)) { throw new IllegalArgumentException("The instance was cascade-deleted: pk=" + relatedId); } */ } else { throw new IllegalArgumentException("The values of this field must be of type " + relatedEntity.getLocalInterface().getName()); } return relatedId; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean add(Object o) { if(o == null) { throw new IllegalArgumentException("Null cannot be added to a CMR " + "relationship collection"); } checkForPKChange(); List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } if(!relatedLocalInterface.isInstance(o)) { String msg = "Object must be an instance of " + relatedLocalInterface.getName() + ", but is an isntance of ["; Class[] classes = o.getClass().getInterfaces(); for(int i = 0; i < classes.length; i++) { if(i > 0) msg += ", "; msg += classes[i].getName(); } msg += "]"; throw new IllegalArgumentException(msg); } Object id = getPrimaryKey((EJBLocalObject) o); if(idList.contains(id)) { return false; } cmrField.createRelationLinks(ctx, id); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean remove(Object o) { List idList = getIdList(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); if(!relatedLocalInterface.isInstance(o)) { throw new IllegalArgumentException("Object must be an instance of " + relatedLocalInterface.getName()); } Object id = getPrimaryKey((EJBLocalObject) o); if(!idList.contains(id)) { return false; } cmrField.destroyRelationLinks(ctx, id); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean contains(Object o) { List idList = getIdList(); if(!relatedLocalInterface.isInstance(o)) { throw new IllegalArgumentException("Object must be an instance of " + relatedLocalInterface.getName()); } Object id = getPrimaryKey((EJBLocalObject) o); return idList.contains(id); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
private Object getPrimaryKey(EJBLocalObject o) { try { return o.getPrimaryKey(); } catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if(id == null) throw new IllegalArgumentException("Can't get an object with a null key"); Map cache = getLocalCache(); EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id); if(instance == null) { try { // acquire instance = (EntityEnterpriseContext) container.getInstancePool().get(); // set key instance.setId(id); instance.setCacheKey(id); // activate container.getPersistenceManager().activateEntity(instance); // insert cache.put(id, instance); } catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); } } return instance; }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public void insert(EnterpriseContext instance) { if(instance == null) throw new IllegalArgumentException("Can't insert a null object in the cache"); EntityEnterpriseContext entity = (EntityEnterpriseContext) instance; getLocalCache().put(entity.getCacheKey(), instance); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public void release(EnterpriseContext instance) { if(instance == null) throw new IllegalArgumentException("Can't release a null object"); tryToPassivate(instance); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void setInstancePool(InstancePool ip) { if (ip == null) throw new IllegalArgumentException("Null pool"); this.instancePool = ip; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void setInstanceCache(InstanceCache ic) { if (ic == null) throw new IllegalArgumentException("Null cache"); this.instanceCache = ic; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void setPersistenceManager(EntityPersistenceManager pm) { if (pm == null) throw new IllegalArgumentException("Null persistence manager"); persistenceManager = pm; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private Object findSingleObject(Transaction tx, Method method, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if(method.getName().equals("findByPrimaryKey")) { if(args[0] == null) throw new IllegalArgumentException("findByPrimaryKey called with null argument."); if(metaData.getContainerConfiguration().getCommitOption() != ConfigurationMetaData.B_COMMIT_OPTION) { Object key = instance.getCacheKey(); if(key == null) { key = ((EntityCache)instanceCache).createCacheKey(args[0]); } if(instanceCache.isActive(key)) { return factory.getEntityEJBObject(key); } } } else if(!metaData.getContainerConfiguration().getSyncOnCommitOnly()) { EntityContainer.synchronizeEntitiesWithinTransaction(tx); } return getPersistenceManager().findEntity(method, args, instance, factory); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public Object getAttribute (String attribute) throws javax.management.AttributeNotFoundException, javax.management.MBeanException, javax.management.ReflectionException { if (attribute == null || attribute.equals ("")) throw new IllegalArgumentException ("null or empty attribute name"); if (attribute.equals ("AsynchronousInvalidation")) return new Boolean(this.asynchronous); else throw new javax.management.AttributeNotFoundException(attribute + " is not a known attribute"); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public java.lang.Object invoke (java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature) throws javax.management.MBeanException, javax.management.ReflectionException { if ("invalidate".equals (actionName)) { if (params.length == 1) { if (params[0] instanceof Serializable[]) this.invalidate ((Serializable[])params[0]); else if (params[0] instanceof Serializable) this.invalidate ((Serializable)params[0]); else throw new IllegalArgumentException ("First argument must be Serializable (or array of)"); } else if (params.length == 2) { if (params[0] instanceof Serializable[]) this.invalidate ((Serializable[])params[0], ((Boolean)params[1]).booleanValue ()); else if (params[0] instanceof Serializable) this.invalidate ((Serializable)params[0], ((Boolean)params[1]).booleanValue ()); else throw new IllegalArgumentException ("First argument must be Serializable (or array of)"); } else { throw new IllegalArgumentException ("Unknown operation with these parameters: " + actionName); } } else if("invalidateAll".equals(actionName)) { if(params == null || params.length == 0) { this.invalidateAll(); } else if (params.length == 1) { this.invalidateAll (((Boolean)params[1]).booleanValue ()); } else { throw new IllegalArgumentException ("invalidateAll can take zero or one parameter but got " + params.length); } } else { throw new IllegalArgumentException ("Unknown operation: " + actionName); } return null; }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public void setAttribute (javax.management.Attribute attribute) throws javax.management.AttributeNotFoundException, javax.management.InvalidAttributeValueException, javax.management.MBeanException, javax.management.ReflectionException { String attrName = attribute.getName(); if (attrName == null || attrName.equals ("")) throw new IllegalArgumentException ("null or empty attribute name"); if (attrName.equals ("AsynchronousInvalidation")) { Object value = attribute.getValue (); if (value instanceof Boolean) this.asynchronous = ((Boolean)value).booleanValue (); else throw new javax.management.InvalidAttributeValueException("Attribute is of boolean type"); } else throw new javax.management.AttributeNotFoundException(attrName + " is not a known attribute"); }
// in src/main/java/org/jboss/web/WebPermissionMapping.java
public static void createPermissions(JBossWebMetaData metaData, PolicyConfiguration pc) throws PolicyContextException { HashMap<String, PatternInfo> patternMap = qualifyURLPatterns(metaData); log.debug("Qualified url patterns: "+patternMap); List<SecurityConstraintMetaData> constraints = metaData.getSecurityConstraints(); if(constraints != null) { for(SecurityConstraintMetaData sc : constraints) { WebResourceCollectionsMetaData resources = sc.getResourceCollections(); TransportGuaranteeType transport = sc.getTransportGuarantee(); if( sc.isExcluded() || sc.isUnchecked() ) { // Process the permissions for the excluded/unchecked resources if(resources != null) for(WebResourceCollectionMetaData wrc : resources) { List<String> httpMethods = wrc.getHttpMethods(); List<String> urlPatterns = wrc.getUrlPatterns(); int length = urlPatterns != null ? urlPatterns.size() : 0; for(int n = 0; n < length; n ++) { String url = urlPatterns.get(n); PatternInfo info = (PatternInfo) patternMap.get(url); // Add the excluded methods if( sc.isExcluded() ) { info.addExcludedMethods(httpMethods); } } } } else { // Process the permission for the resources x roles if(resources != null) for(WebResourceCollectionMetaData wrc : resources) { List<String> httpMethods = wrc.getHttpMethods(); List<String> urlPatterns = wrc.getUrlPatterns(); int length = urlPatterns != null ? urlPatterns.size() : 0; for(int n = 0; n < length; n ++) { String url = urlPatterns.get(n); // Get the qualified url pattern PatternInfo info = (PatternInfo) patternMap.get(url); HashSet<String> mappedRoles = new HashSet<String>(); if(sc.getRoleNames() != null) for(String role : sc.getRoleNames()) { if( role.equals("*") ) { //JBAS-1824: Allow "*" to provide configurable authorization bypass if(metaData.isJaccAllStoreRole()) mappedRoles.add("*"); else { // The wildcard ref maps to all declared security-role names for(SecurityRoleMetaData srmd : metaData.getSecurityRoles()) { role = srmd.getRoleName(); mappedRoles.add(role); } } } else { mappedRoles.add(role); } } info.addRoles(mappedRoles, httpMethods); // Add the transport to methods info.addTransport(transport.name(), httpMethods); //SECURITY-63: Missing auth-constraint needs unchecked policy if(sc.getAuthConstraint() == null) info.isMissingAuthConstraint = true; } } } } } // Create the permissions for(PatternInfo info : patternMap.values()) { String qurl = info.getQualifiedPattern(); if( info.isOverriden == true ) { log.debug("Dropping overriden pattern: "+info); continue; } // Create the excluded permissions String[] httpMethods = info.getExcludedMethods(); if( httpMethods != null ) { // There were excluded security-constraints WebResourcePermission wrp = new WebResourcePermission(qurl, httpMethods); WebUserDataPermission wudp = new WebUserDataPermission(qurl, httpMethods, null); pc.addToExcludedPolicy(wrp); pc.addToExcludedPolicy(wudp); //!(excluded methods) [JACC 1.1] String excludedString = "!" + getCommaSeparatedString(httpMethods); WebResourcePermission wrp1 = new WebResourcePermission(info.pattern, excludedString); WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern,excludedString); pc.addToUncheckedPolicy(wrp1); pc.addToUncheckedPolicy(wudp1); } // Create the role permissions Iterator<Map.Entry<String, Set<String>>> roles = info.getRoleMethods(); while( roles.hasNext() ) { Map.Entry<String, Set<String>> roleMethods = roles.next(); String role = (String) roleMethods.getKey(); WebResourcePermission wrp; if("*".equals(role)) { //JBAS-1824: <role-name>*</role-name> wrp = new WebResourcePermission(qurl, (String)null); } else { Set<String> methods = roleMethods.getValue(); httpMethods = new String[methods.size()]; methods.toArray(httpMethods); wrp = new WebResourcePermission(qurl, httpMethods); } pc.addToRole(role, wrp); //JACC 1.1: create !(httpmethods) in unchecked perms if(httpMethods != null) { final String pattern = info.pattern; final String methodsAsString = "!" + getCommaSeparatedString(httpMethods); WebResourcePermission wrpUnchecked = null; try { wrpUnchecked = new WebResourcePermission(pattern, methodsAsString); } catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); } pc.addToUncheckedPolicy(wrpUnchecked); } } // Create the unchecked permissions String[] missingHttpMethods = info.getMissingMethods(); if( missingHttpMethods.length > 0 ) { // Create the unchecked permissions WebResourcePermissions WebResourcePermission wrp = new WebResourcePermission(qurl, missingHttpMethods); pc.addToUncheckedPolicy(wrp); } else pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null)); //SECURITY-63: Missing auth-constraint needs unchecked policy if(info.isMissingAuthConstraint) { pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null)); } // Create the unchecked permissions WebUserDataPermissions Iterator<Map.Entry<String, Set<String>>> transportContraints = info.getTransportMethods(); while( transportContraints.hasNext() ) { Map.Entry<String, Set<String>> transportMethods = transportContraints.next(); String transport = transportMethods.getKey(); Set<String> methods = transportMethods.getValue(); httpMethods = new String[methods.size()]; methods.toArray(httpMethods); WebUserDataPermission wudp = new WebUserDataPermission(qurl, httpMethods, transport); pc.addToUncheckedPolicy(wudp); //If the transport is "NONE", then add an exlusive WebUserDataPermission //with the url pattern and null if("NONE".equals(transport)) { WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern, null); pc.addToUncheckedPolicy(wudp1); } else { //JACC 1.1: Transport is CONFIDENTIAL/INTEGRAL, add a !(http methods) if(httpMethods != null) { WebUserDataPermission wudpNonNull = new WebUserDataPermission(info.pattern, "!" + getCommaSeparatedString(httpMethods)); pc.addToUncheckedPolicy(wudpNonNull); } } } } /* Create WebRoleRefPermissions for all servlet/security-role-refs along with all the cross product of servlets and security-role elements that are not referenced via a security-role-ref as described in JACC section 3.1.3.2 */ JBossServletsMetaData servlets = metaData.getServlets(); for(JBossServletMetaData servlet : servlets) { String servletName = servlet.getServletName(); SecurityRoleRefsMetaData roleRefs = servlet.getSecurityRoleRefs(); //Perform the unreferenced roles processing for every servlet name Set<String> unreferencedRoles = metaData.getSecurityRoleNames(); if(roleRefs != null) for(SecurityRoleRefMetaData roleRef : roleRefs) { String roleName = roleRef.getRoleLink(); WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, roleRef.getName()); pc.addToRole(roleName, wrrp); /* A bit of a hack due to how tomcat calls out to its Realm.hasRole() with a role name that has been mapped to the role-link value. We may need to handle this with a custom request wrapper. */ wrrp = new WebRoleRefPermission(servletName, roleName); pc.addToRole(roleRef.getName(), wrrp); // Remove the role from the unreferencedRoles unreferencedRoles.remove(roleName); } //Spec 3.1.3.2: For each servlet element in the deployment descriptor //a WebRoleRefPermission must be added to each security-role of the //application whose name does not appear as the rolename //in a security-role-ref within the servlet element. if(unreferencedRoles != null) for(String unrefRole : unreferencedRoles) { WebRoleRefPermission unrefP = new WebRoleRefPermission(servletName,unrefRole); pc.addToRole(unrefRole, unrefP); } } Set<String> unreferencedRoles = metaData.getSecurityRoleNames(); //JACC 1.1:Spec 3.1.3.2: For each security-role defined in the deployment descriptor, an //additional WebRoleRefPermission must be added to the corresponding role by //calling the addToRole method on the PolicyConfiguration object. The //name of all such permissions must be the empty string, and the actions of each //such permission must be the role-name of the corresponding role. if(unreferencedRoles != null) for(String unreferencedRole : unreferencedRoles) { WebRoleRefPermission wrrep = new WebRoleRefPermission("", unreferencedRole); pc.addToRole(unreferencedRole, wrrep); } // Now build the cross product of the unreferencedRoles and servlets Set<String> servletNames = servlets.keySet(); if(servletNames != null) for(String servletName : servletNames) { if(unreferencedRoles != null) for(String role : unreferencedRoles) { WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, role); pc.addToRole(role, wrrp); } } /** * The programmatic security checks are made from jsps. * JBAS-3054:Use of isCallerInRole from jsp does not work for JACC */ if(unreferencedRoles != null) for(String role : unreferencedRoles) { WebRoleRefPermission wrrp = new WebRoleRefPermission("", role); pc.addToRole(role, wrrp); } }
// in src/main/java/org/jboss/web/WebApplication.java
public void setURL(URL url) { if (url == null) throw new IllegalArgumentException("Null URL"); this.url = url; }
// in src/main/java/org/jboss/web/WebServer.java
public void start() throws Exception { if (executor == null) throw new IllegalArgumentException("Required property 'executor' not specified"); try { server = new ServerSocket(port, backlog, bindAddress); log.debug("Started server: " + server); listen(); } catch(java.net.BindException be) { throw new Exception("Port "+port+" already in use.",be); } catch (IOException e) { throw e; } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void processEnc(ClassLoader loader, WebApplication webApp) throws Exception { if (loader == null) throw new IllegalArgumentException("Classloader passed to process ENC refs is null"); log.debug("AbstractWebContainer.parseWebAppDescriptors, Begin"); InitialContext iniCtx = new InitialContext(); Context envCtx = null; Thread currentThread = Thread.currentThread(); ClassLoader currentLoader = currentThread.getContextClassLoader(); JBossWebMetaData metaData = webApp.getMetaData(); try { // Create a java:comp/env environment unique for the web application log.debug("Creating ENC using ClassLoader: " + loader); ClassLoader parent = loader.getParent(); while (parent != null) { log.debug(".." + parent); parent = parent.getParent(); } // TODO: The enc should be an input? currentThread.setContextClassLoader(loader); // webApp.setENCLoader(loader); envCtx = (Context)iniCtx.lookup("java:comp"); // TODO: inject the ORB try { ObjectName ORB_NAME = new ObjectName("jboss:service=CorbaORB"); org.omg.CORBA.ORB orb = (org.omg.CORBA.ORB)server.getAttribute(ORB_NAME, "ORB"); // Bind the orb if (orb != null) { NonSerializableFactory.rebind(envCtx, "ORB", orb); log.debug("Bound java:comp/ORB"); } } catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); } // TODO: injection, Add a link to the global transaction manager envCtx.bind("UserTransaction", new LinkRef("UserTransaction")); log.debug("Linked java:comp/UserTransaction to JNDI name: UserTransaction"); envCtx = envCtx.createSubcontext("env"); processEncReferences(webApp, envCtx); } finally { currentThread.setContextClassLoader(currentLoader); } String securityDomain = metaData.getSecurityDomain(); log.debug("linkSecurityDomain"); linkSecurityDomain(securityDomain, envCtx); log.debug("AbstractWebContainer.parseWebAppDescriptors, End"); }
// in src/main/java/org/jboss/web/deployers/WARStructure.java
public void setWebInfLibFilter(VirtualFileFilter webInfLibFilter) { if (webInfLibFilter == null) throw new IllegalArgumentException("Null filter"); this.webInfLibFilter = webInfLibFilter; }
// in src/main/java/org/jboss/verifier/BeanVerifier.java
protected void setVerifier( String version ) { if( VERSION_1_1.equals(version) ) { verifier = new EJBVerifier11(this); } else if( VERSION_2_0.equals(version) ) { verifier = new EJBVerifier20(this); } else if (VERSION_2_1.equals(version)) { verifier=new EJBVerifier21(this); } else { throw new IllegalArgumentException( UNRECOGNIZED_VERSION + ": " + version); } }
// in src/main/java/org/jboss/verifier/event/VerificationEvent.java
public void setState(String state) { if( WARNING.equalsIgnoreCase(state) ) { isWarning = true; isOk = false; } else if( OK.equalsIgnoreCase(state) ) { isOk = true; isWarning = false; } else { throw new IllegalArgumentException( STATE_NOT_RECOGNIZED + ": " + state); } }
// in src/main/java/org/jboss/verifier/Main.java
public static void main(String[] args) { try { if( args.length < 1 ) { throw new IllegalArgumentException( "Usage: beanverifier mybeans.jar"); } URL url = new File(args[0]).toURL(); URLClassLoader cl = new URLClassLoader( new URL[] {url}, Thread.currentThread().getContextClassLoader()); XmlFileLoader xfl = new XmlFileLoader(); BeanVerifier verifier = new BeanVerifier(); xfl.setClassLoader(cl); verifier.addVerificationListener(new Listener()); verifier.verify(url, xfl.load(null)); } catch (Exception e) { System.err.println("Problem starting the application:"); System.err.println("Exception: " + e); System.err.println("Message: " + e.getMessage()); e.printStackTrace(); System.exit(-1); } System.exit(returnCode); }
// in src/main/java/org/jboss/proxy/compiler/Utility.java
public static String getObjectEquivalentClassName(BasicType t) { switch (t.getType()) { case Constants.T_INT: return "java.lang.Integer"; case Constants.T_SHORT: return "java.lang.Short"; case Constants.T_BOOLEAN: return "java.lang.Boolean"; case Constants.T_CHAR: return "java.lang.Character"; case Constants.T_BYTE: return "java.lang.Byte"; case Constants.T_FLOAT: return "java.lang.Float"; case Constants.T_DOUBLE: return "java.lang.Double"; case Constants.T_LONG: return "java.lang.Long"; default: throw new IllegalArgumentException("Unexpected Type: " + t); } }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
Method[] checkTargetType(Class targetType) { if (targetType.isArray()) { throw new IllegalArgumentException ("cannot subclass an array type: " + targetType.getName()); } if (targetType.isPrimitive()) { throw new IllegalArgumentException ("cannot subclass a primitive type: " + targetType); } int tmod = targetType.getModifiers(); if (Modifier.isFinal(tmod)) { throw new IllegalArgumentException ("cannot subclass a final type: " + targetType); } if (!Modifier.isPublic(tmod)) { throw new IllegalArgumentException ("cannot subclass a non-public type: " + targetType); } // Make sure the subclass will not need a "super" statement. if (!targetType.isInterface()) { if (!targetType.isAssignableFrom(superclass)) { if (superclass.isAssignableFrom(targetType)) { superclass = targetType; } else { throw new IllegalArgumentException ("inconsistent superclass: " + targetType); } } } // Decide what overrideable methods this type supports. Method methodList[] = targetType.getMethods(); int nm = 0; for (int i = 0; i < methodList.length; i++) { Method m = methodList[i]; if (eligibleForInvocationHandler(m)) { methodList[nm++] = m; // (reuse the method array) } } while (nm < methodList.length) { methodList[nm++] = null; // (pad the reused method array) } return methodList; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
void checkSuperclass() { Constructor constructors[] = superclass.getConstructors(); for (int i = 0; i < constructors.length; i++) { Constructor c = constructors[i]; int mod = c.getModifiers(); if (Modifier.isPublic(mod) && c.getParameterTypes().length == 0) { return; // OK } } throw new IllegalArgumentException ("cannot subclass without nullary constructor: " +superclass.getName()); }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
Object invoke(Object target, Member method, Object values[]) throws Throwable { // Note: // // We will not invoke the method unless we are expecting it. // Thus, we cannot blindly call Method.invoke, but must first // check our list of allowed methods. try { Method methods[] = this.methods; // cache // use fast pointer equality (it usually succeeds) for (int i = methods.length; --i >= 0; ) { if (methods[i] == method) { return methods[i].invoke(target, values); } } // special case: allow a null method to select the unique one if (method == null) { if (methods.length == 1) { return methods[0].invoke(target, values); } throw new IllegalArgumentException("non-unique method"); } // try the slower form of equality for (int i = methods.length; --i >= 0; ) { if (methods[i].equals(method)) { return methods[i].invoke(target, values); } } } catch (InvocationTargetException e) { throw e.getTargetException(); } throw new IllegalArgumentException("method unexpected "+method); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public short getMemberIndex(Object cls, String name, Class ptypes[]) { if (cls instanceof Class) { Class c = (Class) cls; Member m; try { if (ptypes == null) { m = c.getField(name); } else if (name.equals("<init>")) { m = c.getConstructor(ptypes); } else { m = c.getMethod(name, ptypes); } } catch (NoSuchMethodException ee) { throw new IllegalArgumentException(ee+" in "+c); } catch (NoSuchFieldException ee) { throw new IllegalArgumentException(ee+" in "+c); } return getIndex(m); } else if (cls instanceof ProxyAssembler) { ProxyAssembler asm = (ProxyAssembler) cls; String sig = getSig(null, ptypes); AMember m = asm.findMember(sig, name); if (m == null) { throw new IllegalArgumentException(sig + " " + name); } return getIndex(m); } else { throw new IllegalArgumentException("not a type: "+cls); } }
9
            
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
catch (ParseException e) { throw new IllegalArgumentException("Cannot parse date/time in: " + externalForm); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
catch(NumberFormatException e) { throw new IllegalArgumentException("The parameter must begin with a number"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/web/WebPermissionMapping.java
catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); }
// in src/main/java/org/jboss/verifier/Section.java
catch ( ParseException e ) { throw new IllegalArgumentException( CONSTRUCTION_ERROR ); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchMethodException ee) { throw new IllegalArgumentException(ee+" in "+c); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchFieldException ee) { throw new IllegalArgumentException(ee+" in "+c); }
57
            
// in src/main/java/org/jboss/invocation/Invocation.java
public Object performCall(Object instance, Method m, Object[] arguments) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Exception { return m.invoke(instance,arguments); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (duration < 0) throw new IllegalArgumentException("duration is negative"); return createTimer(new Date(System.currentTimeMillis() + duration), 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialDuration < 0) throw new IllegalArgumentException("initial duration is negative"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); return createTimer(new Date(System.currentTimeMillis() + initialDuration), intervalDuration, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (expiration == null) throw new IllegalArgumentException("expiration is null"); return createTimer(expiration, 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object setPrimaryKeyValue(Object primaryKey, Object value) throws IllegalArgumentException { try { if(pkField != null) { // if we are trying to set a null value into a null pk, we are already done. if(value == null && primaryKey == null) { return null; } // if we don't have a pk object yet create one if(primaryKey == null) { primaryKey = pkClass.newInstance(); } // Set this field's value into the primary key object. pkField.set(primaryKey, value); return primaryKey; } else { // This field is the primary key, so no extraction is necessary. return value; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object loadArgumentResults(ResultSet rs, int parameterIndex) throws IllegalArgumentException { try { // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); if(javaTypes.length > 1) { throw new IllegalStateException("Complex types are not supported yet."); } JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); Object columnValue = null; for(int i = 0; i < javaTypes.length; i++) { columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); columnValue = jdbcType.setColumnValue(i, null, columnValue); } // retrun the updated parameterIndex return columnValue; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object getPrimaryKeyValue(Object primaryKey) throws IllegalArgumentException { try { if(pkField != null) { if(primaryKey == null) { return null; } return pkField.get(primaryKey); } else { return primaryKey; } } catch(Exception e) { throw new EJBException("Internal error getting primary key field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public Object getPrimaryKeyValue(Object primaryKey) throws IllegalArgumentException { try { if(primaryKeyField != null) { if(primaryKey == null) { return null; } // Extract this field's value from the primary key. return primaryKeyField.get(primaryKey); } else { // This field is the primary key, so no extraction is necessary. return primaryKey; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error getting primary key " + "field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public Object setPrimaryKeyValue(Object primaryKey, Object value) throws IllegalArgumentException { try { if(primaryKeyField != null) { // if we are tring to set a null value // into a null pk, we are already done. if(value == null && primaryKey == null) { return null; } // if we don't have a pk object yet create one if(primaryKey == null) { primaryKey = primaryKeyClass.newInstance(); } // Set this field's value into the primary key object. primaryKeyField.set(primaryKey, value); return primaryKey; } else { // This field is the primary key, so no extraction is necessary. return value; } } catch(Exception e) { // Non recoverable internal exception throw new EJBException("Internal error setting instance field " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int setPrimaryKeyParameters(PreparedStatement ps, int parameterIndex, Object primaryKey) throws IllegalArgumentException { Object primaryKeyValue = getPrimaryKeyValue(primaryKey); return setArgumentParameters(ps, parameterIndex, primaryKeyValue); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int loadPrimaryKeyResults(ResultSet rs, int parameterIndex, Object[] pkRef) throws IllegalArgumentException { // value of this field, will be filled in below Object[] argumentRef = new Object[1]; parameterIndex = loadArgumentResults(rs, parameterIndex, argumentRef, true); // set the value of this field into the pk pkRef[0] = argumentRef[0] == null ? null : setPrimaryKeyValue(pkRef[0], argumentRef[0]); // retrun the updated parameterIndex return parameterIndex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef) throws IllegalArgumentException { return loadArgumentResults(rs, parameterIndex, argumentRef, false); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
private int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef, boolean nullColumnNullifiesResult) throws IllegalArgumentException { try { // value of this field, will be filled in below // set the value of this field into the pk argumentRef[0] = null; // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); for(int i = 0; i < javaTypes.length; i++) { Object columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); if(nullColumnNullifiesResult && columnValue == null) { argumentRef[0] = null; parameterIndex += javaTypes.length - i - 1; break; } argumentRef[0] = jdbcType.setColumnValue(i, argumentRef[0], columnValue); } // retrun the updated parameterIndex return parameterIndex; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/as/naming/javaee/NamingJavaEEApplicationInformer.java
public String getApplicationName(DeploymentUnit deploymentUnit) throws IllegalArgumentException { if(!isJavaEEApplication(deploymentUnit)) return null; // JBAS-8528 String explicitAppName = this.getExplicitApplicationName(deploymentUnit); if (explicitAppName != null) { return explicitAppName; } String name = deploymentUnit.getSimpleName(); // prevent StringIndexOutOfBoundsException and only cut when there is a typical extension return stripSuffix(name); }
4
            
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch (IllegalArgumentException e) { log.debug("Could not create the finder " + name + ", because no matching CMP field was found."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/web/WebPermissionMapping.java
catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); }
3
            
// in src/main/java/org/jboss/ejb/plugins/SessionObjectInputStream.java
catch(IllegalArgumentException e) { throw new ClassNotFoundException("Failed to resolve proxy class", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(IllegalArgumentException e) { log.error("Error invoking custom finder " + finderMethod.getName(), e); throw new FinderException("Illegal arguments for finder " + "implementation: " + finderMethod.getName()); }
// in src/main/java/org/jboss/web/WebPermissionMapping.java
catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); }
1
runtime (Lib) IllegalStateException 231
            
// in src/main/java/org/jboss/invocation/MarshalledInvocation.java
public Method getMethod() { if (this.method != null) return this.method; // Try the hash, the methodMap should be set this.method = (Method) methodMap.get(new Long(methodHash)); // Keep it in the payload if (this.method == null) { throw new IllegalStateException("Failed to find method for hash:" + methodHash + " available=" + methodMap); } return this.method; }
// in src/main/java/org/jboss/jmx/connector/invoker/MBeanProxyRemote.java
protected void startService() throws Exception { if (MBeanProxyExt.remote != null) throw new IllegalStateException("Remote MBeanServerConnection is already set " + MBeanProxyExt.remote); Object o = server.getAttribute(mbeanServerConnection, "Proxy"); if (o instanceof MBeanServerConnection == false) throw new DeploymentException(mbeanServerConnection + " does not define an MBeanServerConnection"); MBeanProxyExt.remote = (MBeanServerConnection) o; }
// in src/main/java/org/jboss/jms/jndi/AbstractJMSProviderAdapter.java
public String getFactoryRef() { if (factoryRef == null) throw new IllegalStateException("Combined ConnectionFactory 'FactoryRef' not configured."); return factoryRef; }
// in src/main/java/org/jboss/jms/jndi/AbstractJMSProviderAdapter.java
public String getQueueFactoryRef() { if (queueFactoryRef == null) throw new IllegalStateException("Queue ConnectionFactory 'QueueFactoryRef' not configured."); return queueFactoryRef; }
// in src/main/java/org/jboss/jms/jndi/AbstractJMSProviderAdapter.java
public String getTopicFactoryRef() { if (topicFactoryRef == null) throw new IllegalStateException("Topic ConnectionFactory 'TopicFactoryRef' not configured."); return topicFactoryRef; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected XAConnectionFactory getConnectionFactory() throws Exception { // Get the JMS Provider Adapter if (providerName == null) throw new IllegalArgumentException("Null provider name"); String providerAdapterJNDI = providerName; if (providerAdapterJNDI.startsWith("java:") == false) providerAdapterJNDI = "java:" + providerAdapterJNDI; Context ctx = new InitialContext(); JMSProviderAdapter adapter = (JMSProviderAdapter) Util.lookup(providerAdapterJNDI, JMSProviderAdapter.class); // Determine the XAConnectionFactory name String connectionFactoryRef = adapter.getFactoryRef(); if (connectionFactoryRef == null) throw new IllegalStateException("Provider '" + providerName + "' has no FactoryRef"); // Lookup the connection factory ctx = adapter.getInitialContext(); try { return (XAConnectionFactory) Util.lookup(ctx, connectionFactoryRef, XAConnectionFactory.class); } finally { ctx.close(); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected void resolve(DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, JBossEnterpriseBeansMetaData beans, DeploymentEndpointResolver resolver, List<String> unresolvedPaths) throws Exception { if(beans == null || beans.size() == 0) return; String vfsPath = unit.getRelativePath(); for(JBossEnterpriseBeanMetaData bean : beans) { // Find the container dependency metadata String ejbCompID = "ejb/" + vfsPath + "#" + bean.getEjbName(); ContainerDependencyMetaData cdmd = endpointMap.get(ejbCompID); if(cdmd == null) throw new IllegalStateException("Failed to find ContainerDependencyMetaData for: "+ejbCompID); Environment env = bean.getJndiEnvironmentRefsGroup(); resolve(cdmd, unit, endpointMap, env, resolver, unresolvedPaths); } }
// in src/main/java/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
protected ContainerDependencyMetaData resolveEjbInterface(String iface, DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, DeploymentEndpointResolver resolver) throws Exception { ClassLoader loader = unit.getClassLoader(); Class<?> ifaceClass = loader.loadClass(iface); String vfsContext = unit.getRelativePath(); EndpointInfo info = resolver.getEndpointInfo(ifaceClass, EndpointType.EJB, vfsContext); if(info == null) throw new IllegalStateException("Failed to find ContainerDependencyMetaData for interface: "+ iface); ContainerDependencyMetaData cdmd = endpointMap.get(info.getComponentKey()); return cdmd; }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { PolicyConfiguration pc = unit.getAttachment(PolicyConfiguration.class); if (pc == null) return; DeploymentUnit parent = unit.getParent(); if (parent == null) throw new IllegalStateException("Unit has not parent: " + unit); PolicyConfiguration parentPc = parent.getAttachment(PolicyConfiguration.class); try { if (parentPc != null && pc != parentPc) { parentPc.linkConfiguration(pc); } pc.commit(); } catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); } }
// in src/main/java/org/jboss/deployment/AppParsingDeployer.java
protected EarMetaData parse(VFSDeploymentUnit unit, VirtualFile file, EarMetaData root) throws Exception { EarMetaData ear = super.parse(unit,file, root); List<DeploymentUnit> children = unit.getChildren(); ModulesMetaData modules = ear.getModules(); if(children != null && modules != null) { for(DeploymentUnit child : children) { String moduleName = child.getSimpleName(); ModuleMetaData module = modules.get(moduleName); if(module != null && module.getAlternativeDD() != null) { VirtualFile altDDFile = unit.getRoot().getChild(module.getAlternativeDD()); if(altDDFile == null) throw new IllegalStateException("Failed to locate alternative DD '" + module.getAlternativeDD() + "' in " + unit.getRoot().getPathName()); String attachmentName; if(module.getType() == ModuleMetaData.ModuleType.Ejb) attachmentName = EjbJarMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Web) attachmentName = WebMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Client) attachmentName = ApplicationClientMetaData.class.getName(); else if(module.getType() == ModuleMetaData.ModuleType.Connector) attachmentName = "org.jboss.resource.metadata.ConnectorMetaData"; else throw new IllegalStateException("Expected module types in an EAR are ejb, web, java and connector but got " + module.getType() + " for " + child.getName() + " in " + unit.getName()); child.addAttachment(attachmentName + ".altDD", altDDFile); if(log.isTraceEnabled()) log.trace("attached alt-dd " + altDDFile + " for module " + child.getSimpleName()); } } } return ear; }
// in src/main/java/org/jboss/deployment/security/JaccPolicyUtil.java
public static void createPermissions(PolicyConfiguration policyConfiguration, Object metadata) throws PolicyContextException { if(metadata == null) throw new IllegalArgumentException("Meta Data is null"); if(policyConfiguration == null) throw new IllegalArgumentException("Policy Configuration is null"); if(metadata instanceof JBossWebMetaData) { JBossWebMetaData wmd = (JBossWebMetaData)metadata; WebPermissionMapping.createPermissions(wmd, policyConfiguration); } else if(metadata instanceof JBossEnterpriseBeanMetaData) { JBossEnterpriseBeanMetaData bmd = (JBossEnterpriseBeanMetaData)metadata; EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } else if(metadata instanceof JBossMetaData) { JBossMetaData jmd = (JBossMetaData)metadata; JBossEnterpriseBeansMetaData beans = jmd.getEnterpriseBeans(); for(JBossEnterpriseBeanMetaData bmd : beans) { EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } } else throw new IllegalStateException("Unknown metadata"); }
// in src/main/java/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java
public EndpointInfo getEndpointInfo(String ref, String type, String vfsContext) { String prefix = type; // Parse the ref to obtain the path and endpoint name String unitPath = vfsContext; String endpointName = ref; if (ref.indexOf('#') != -1) { // <ejb-link> is of the form relative-path/file.jar#Bean String path = ref.substring(0, ref.indexOf('#')); // resolve any ../* prefix if(path.startsWith("../")) { String[] deploymentPaths = unitPath.split("/"); int count = 0; while(path.startsWith("../")) { path = path.substring(3); count ++; } // build the relative path from the root String rootPath = ""; for(int n = 0; n < (deploymentPaths.length - count); n ++) rootPath += deploymentPaths + "/"; unitPath = rootPath + path; } else { unitPath = path; } // // Get the endpoint name endpointName = ref.substring(ref.indexOf('#') + 1); } EndpointInfo info = null; String key = prefix + "/" + unitPath +"#" + endpointName; ContainerDependencyMetaData cdmd = endpointMap.get(key); if(cdmd != null) { info = new EndpointInfo(unitPath, endpointName, type); return info; } // It could not be found in the unit itself, let's search globally if(ref.indexOf('#') == -1) { // See MappedReferenceMetaDataResolverDeployer.mapEjbs if(type.equals(EndpointType.EJB)) { key = "ejb/" + ref; } else if(type.equals(EndpointType.MessageDestination)) { key = "message-destination/" + ref; } String ejbCompID = endpointAlternateMap.get(key); if(ejbCompID != null) { cdmd = endpointMap.get(ejbCompID); if(cdmd == null) throw new IllegalStateException("endpoint mapping is corrupt, can't find '" + ejbCompID + "' in " + endpointMap); info = new EndpointInfo(cdmd.getDeploymentPath(), cdmd.getComponentName(), type); return info; } } else { log.debug("Failed to find mapping for ref: "+ref+" path: "+vfsContext); if(log.isTraceEnabled()) log.trace("Available keys: "+endpointMap.keySet()); } return info; }
// in src/main/java/org/jboss/naming/NamingAlias.java
protected void startService() throws Exception { if( fromName == null ) throw new IllegalStateException("fromName is null"); if( toName == null ) throw new IllegalStateException("toName is null"); createLinkRef(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void setRollbackOnly(Object tpc) throws RemoteException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); tx.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSourceName) throws SQLException { this.server = server; this.dataSourceName = dataSourceName; // Get the DataSource from JNDI try { String dsJndiTx = (String)server.getAttribute(dataSourceName, "BindName"); ds = (DataSource)new InitialContext().lookup(dsJndiTx); } catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); } // Get the DataSource meta data String dsName = dataSourceName.getKeyProperty("name"); metaDataName = ObjectNameFactory.create("jboss.jdbc:datasource=" + dsName + ",service=metadata"); if (this.server.isRegistered(metaDataName) == false) throw new IllegalStateException("Cannot find datasource meta data: " + metaDataName); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void createTableIfNotExists() throws SQLException { Connection con = null; Statement st = null; try { JDBCTypeMappingMetaData typeMapping = (JDBCTypeMappingMetaData)server.getAttribute(metaDataName, "TypeMappingMetaData"); if (typeMapping == null) throw new IllegalStateException("Cannot obtain type mapping from: " + metaDataName); JDBCMappingMetaData objectMetaData = typeMapping.getTypeMappingMetaData(Object.class); binarySqlType = objectMetaData.getJdbcType(); if (!SQLUtil.tableExists(getTableName(), ds)) { con = ds.getConnection(); String dateType = typeMapping.getTypeMappingMetaData(Timestamp.class).getSqlType(); String longType = typeMapping.getTypeMappingMetaData(Long.class).getSqlType(); String objectType = objectMetaData.getSqlType(); // The create table DDL StringBuffer createTableDDL = new StringBuffer("create table " + getTableName() + " (" + " " + getColumnTimerID() + " varchar(80) not null," + " " + getColumnTargetID() + " varchar(250) not null," + " " + getColumnInitialDate() + " " + dateType + " not null," + " " + getColumnTimerInterval() + " " + longType + "," + " " + getColumnInstancePK() + " " + objectType + "," + " " + getColumnInfo() + " " + objectType + ", "); // Add the primary key constraint using the pk-constraint-template JDBCFunctionMappingMetaData pkConstraint = typeMapping.getPkConstraintTemplate(); String name = SQLUtil.unquote(getTableName(), ds) + "_PK"; name = SQLUtil.fixConstraintName(name, ds); String[] templateParams = new String[] { name, getColumnTimerID() + ", " + getColumnTargetID() }; pkConstraint.getFunctionSql(templateParams, createTableDDL); // Complete the statement createTableDDL.append(" )"); log.debug("Executing DDL: " + createTableDDL); st = con.createStatement(); st.executeUpdate(createTableDDL.toString()); } } catch (SQLException e) { throw e; } catch (Exception e) { log.error("Cannot create timer table", e); } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); return sc.getOutgoingRunAs(); //return SecurityAssociation.peekRunAsIdentity(); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public Object run() { //return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public Object run() { //SecurityAssociation.pushRunAsIdentity(id); SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setOutgoingRunAs(id); return null; }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public RunAs peek() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); return sc.getOutgoingRunAs(); //return SecurityAssociation.peekRunAsIdentity(); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public void push(RunAs id) { //SecurityAssociation.pushRunAsIdentity(id); SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setOutgoingRunAs(id); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
public RunAs pop() { //return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBHome getEJBHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return (EJBHome) ci.getEJBHome(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public boolean isIdentical(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.isIdentical(this, mi); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBMetaData getEJBMetaDataHome() throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.getEJBMetaData(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public HomeHandle getHomeHandleHome() throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } EJBHome home = (EJBHome) ci.getEJBHome(); return home.getHomeHandle(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBLocalObject createLocalHome() throws CreateException { if (localProxyFactory == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; return localProxyFactory.getStatelessSessionEJBLocalObject(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBObject createHome() throws RemoteException, CreateException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; Object obj = ci.getStatelessSessionEJBObject(); return (EJBObject) obj; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public EJBObject getEJBObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBObject", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); if (((StatelessSessionContainer)con).getProxyFactory()==null) throw new IllegalStateException( "No remote interface defined." ); if (ejbObject == null) { EJBProxyFactory proxyFactory = con.getProxyFactory(); if(proxyFactory == null) { String defaultInvokerName = con.getBeanMetaData(). getContainerConfiguration().getDefaultInvokerName(); proxyFactory = con.lookupProxyFactory(defaultInvokerName); } ejbObject = (EJBObject) proxyFactory.getStatelessSessionEJBObject(); } return ejbObject; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public EJBLocalObject getEJBLocalObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBLocalObject", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); if (con.getLocalHomeClass()==null) throw new IllegalStateException( "No local interface for bean." ); if (ejbLocalObject == null) { ejbLocalObject = ((StatelessSessionContainer)con).getLocalProxyFactory().getStatelessSessionEJBLocalObject(); } return ejbLocalObject; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { // All we need is an EJBObject for this Id, the first argument is the Id EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Object id = mi.getArguments()[0]; if (id == null) throw new IllegalStateException("Cannot get a session interface with a null id"); // Does the session still exist? InstanceCache cache = getInstanceCache(); BeanLock lock = getLockManager().getLock(id); lock.sync(); try { if (cache.get(id) == null) throw new RemoteException("Session no longer exists: " + id); } finally { lock.releaseSync(); getLockManager().removeLockRef(id); } // Ok lets create the proxy return (EJBObject) ci.getStatefulSessionEJBObject(id); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public EJBHome getEJBHome() { throw new IllegalStateException("getEJBHome should not be access from a message driven bean"); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public EJBLocalHome getEJBLocalHome() { throw new IllegalStateException("getEJBHome should not be access from a message driven bean"); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public boolean isCallerInRole(String id) { throw new IllegalStateException("isCallerInRole should not be access from a message driven bean"); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public UserTransaction getUserTransaction() { if (isContainerManagedTx()) throw new IllegalStateException("getUserTransaction should not be access for container managed Tx"); AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); return super.getUserTransaction(); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public boolean getRollbackOnly() { if (isUserManagedTx()) throw new IllegalStateException("getRollbackOnly should not be access for user managed Tx"); AllowedOperationsAssociation.assertAllowedIn("getRollbackOnly", IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); // // jason: I think this is lame... but the spec says this is how it is. // I think it would be better to silently ignore... or not so silently // but still continue. // if (!isTxRequired()) { throw new IllegalStateException ("getRollbackOnly must only be called in the context of a transaction (EJB 2.0 - 15.5.1)"); } return super.getRollbackOnly(); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public void setRollbackOnly() { if (isUserManagedTx()) throw new IllegalStateException("setRollbackOnly should not be access for user managed Tx"); AllowedOperationsAssociation.assertAllowedIn("getRollbackOnly", IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); if (!isTxRequired()) { throw new IllegalStateException ("setRollbackOnly must only be called in the context of a transaction (EJB 2.0 - 15.5.1)"); } super.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/Container.java
public ObjectName getJmxName() { if (jmxName == null) { BeanMetaData beanMetaData = getBeanMetaData(); if (beanMetaData == null) { throw new IllegalStateException("Container metaData is null"); } String jndiName = beanMetaData.getContainerObjectNameJndiName(); if (jndiName == null) { throw new IllegalStateException("Container jndiName is null"); } // The name must be escaped since the jndiName may be arbitrary String name = BASE_EJB_CONTAINER_NAME + ",jndiName=" + jndiName; try { jmxName = ObjectNameConverter.convert(name); } catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); } } return jmxName; }
// in src/main/java/org/jboss/ejb/Container.java
public TimerService getTimerService(Object pKey) throws IllegalStateException { if (this instanceof StatefulSessionContainer) throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService"); // Validate that the bean implements the TimedObject interface if (TimedObject.class.isAssignableFrom(beanClass) == false) { // jbcts-381 return EJBTimerServiceImpl.FOR_NON_TIMED_OBJECT; } TimerService timerService = null; try { timerService = this.timerService.createTimerService(getJmxName(), pKey, this); } catch (Exception e) { throw new EJBException("Could not create timer service", e); } return timerService; }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public EJBObject getEJBObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBObject", IN_EJB_POST_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_EJB_LOAD | IN_EJB_STORE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); if(((EntityContainer)con).getRemoteClass() == null) { throw new IllegalStateException( "No remote interface defined." ); } if (ejbObject == null) { // Create a new CacheKey Object cacheKey = ((EntityCache)((EntityContainer)con).getInstanceCache()).createCacheKey(id); EJBProxyFactory proxyFactory = con.getProxyFactory(); if(proxyFactory == null) { String defaultInvokerName = con.getBeanMetaData(). getContainerConfiguration().getDefaultInvokerName(); proxyFactory = con.lookupProxyFactory(defaultInvokerName); } ejbObject = (EJBObject)proxyFactory.getEntityEJBObject(cacheKey); } return ejbObject; }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public EJBLocalObject getEJBLocalObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBLocalObject", IN_EJB_POST_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_EJB_LOAD | IN_EJB_STORE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); if (con.getLocalHomeClass()==null) throw new IllegalStateException( "No local interface for bean." ); if (ejbLocalObject == null) { Object cacheKey = ((EntityCache)((EntityContainer)con).getInstanceCache()).createCacheKey(id); ejbLocalObject = ((EntityContainer)con).getLocalProxyFactory().getEntityEJBLocalObject(cacheKey); } return ejbLocalObject; }
// in src/main/java/org/jboss/ejb/deployers/CreateDestination.java
public void create() { if (matcher == null) throw new IllegalStateException("No matcher has been set"); if (factory == null) throw new IllegalStateException("No factory has been set"); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public boolean canPassivate(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to passivate with a null object"); HashMap mapInUse = getHashMap(id); synchronized (mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock == null) throw new IllegalStateException("Attempt to passivate without a lock"); return (lock.getRefs() <= 1); } }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public EJBObject getEJBObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBObject", IN_EJB_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_BUSINESS_METHOD | IN_AFTER_BEGIN | IN_BEFORE_COMPLETION | IN_AFTER_COMPLETION); if (((StatefulSessionContainer)con).getRemoteClass()==null) throw new IllegalStateException( "No remote interface defined." ); if (ejbObject == null) { EJBProxyFactory proxyFactory = con.getProxyFactory(); if(proxyFactory == null) { String defaultInvokerName = con.getBeanMetaData(). getContainerConfiguration().getDefaultInvokerName(); proxyFactory = con.lookupProxyFactory(defaultInvokerName); } ejbObject = (EJBObject) proxyFactory.getStatefulSessionEJBObject(id); } return ejbObject; }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public EJBLocalObject getEJBLocalObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBLocalObject", IN_EJB_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_BUSINESS_METHOD | IN_AFTER_BEGIN | IN_BEFORE_COMPLETION | IN_AFTER_COMPLETION); if (con.getLocalHomeClass()==null) throw new IllegalStateException( "No local interface for bean." ); if (ejbLocalObject == null) { ejbLocalObject = ((StatefulSessionContainer)con).getLocalProxyFactory().getStatefulSessionEJBLocalObject(id); } return ejbLocalObject; }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { throw new IllegalStateException("getTimerService should not be access from a stateful session bean"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
Principal getCallerPrincipalInternal() { if( beanPrincipal == null ) { RealmMapping rm = con.getRealmMapping(); SecurityContext sc = SecurityActions.getSecurityContext(); Principal caller = null; try { caller = SecurityHelperFactory.getEJBAuthorizationHelper(sc).getCallerPrincipal(); } catch (Exception e) { log.error("Error getting callerPrincipal for " + con.getBeanClass(),e); } /* Apply any domain caller mapping. This should really only be done for non-run-as callers. */ if (rm != null) caller = rm.getPrincipal(caller); if( caller == null ) { /* Try the incoming request principal. This is needed if a client clears the current caller association and and an interceptor calls getCallerPrincipal as the call stack unwinds. */ if( principal != null ) { if( rm != null ) caller = rm.getPrincipal(principal); else caller = principal; } // Check for an unauthenticated principal value else { ApplicationMetaData appMetaData = con.getBeanMetaData().getApplicationMetaData(); String name = appMetaData.getUnauthenticatedPrincipal(); if (name != null) caller = new SimplePrincipal(name); } } if( caller == null ) { throw new IllegalStateException("No valid security context for the caller identity"); } /* Save caller as the beanPrincipal for reuse if getCallerPrincipal is called as the stack unwinds. An example of where this would occur is the cmp2 audit layer. */ beanPrincipal = caller; } return beanPrincipal; }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public EJBHome getEJBHome() { EJBProxyFactory proxyFactory = con.getProxyFactory(); if (proxyFactory == null) throw new IllegalStateException("No remote home defined."); return (EJBHome) proxyFactory.getEJBHome(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public EJBLocalHome getEJBLocalHome() { if (con.getLocalHomeClass() == null) throw new IllegalStateException("No local home defined."); if (con instanceof EntityContainer) return ((EntityContainer) con).getLocalProxyFactory().getEJBLocalHome(); else if (con instanceof StatelessSessionContainer) return ((StatelessSessionContainer) con).getLocalProxyFactory().getEJBLocalHome(); else if (con instanceof StatefulSessionContainer) return ((StatefulSessionContainer) con).getLocalProxyFactory().getEJBLocalHome(); // Should never get here throw new EJBException("No EJBLocalHome available (BUG!)"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public boolean getRollbackOnly() { // EJB1.1 11.6.1: Must throw IllegalStateException if BMT if (con.getBeanMetaData().isBeanManagedTx()) throw new IllegalStateException("getRollbackOnly() not allowed for BMT beans."); try { TransactionManager tm = con.getTransactionManager(); // The getRollbackOnly and setRollBackOnly method of the SessionContext interface should be used // only in the session bean methods that execute in the context of a transaction. if (tm.getTransaction() == null) throw new IllegalStateException("getRollbackOnly() not allowed without a transaction."); // JBAS-3847, consider an asynchronous rollback due to timeout int status = tm.getStatus(); return TxUtils.isRollback(status); } catch (SystemException e) { log.warn("failed to get tx manager status; ignoring", e); return true; } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void setRollbackOnly() { // EJB1.1 11.6.1: Must throw IllegalStateException if BMT if (con.getBeanMetaData().isBeanManagedTx()) throw new IllegalStateException("setRollbackOnly() not allowed for BMT beans."); try { TransactionManager tm = con.getTransactionManager(); // The getRollbackOnly and setRollBackOnly method of the SessionContext interface should be used // only in the session bean methods that execute in the context of a transaction. if (tm.getTransaction() == null) throw new IllegalStateException("setRollbackOnly() not allowed without a transaction."); tm.setRollbackOnly(); } catch (SystemException e) { log.warn("failed to set rollback only; ignoring", e); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public UserTransaction getUserTransaction() { if (userTransaction == null) { if (isContainerManagedTx()) { throw new IllegalStateException ("CMT beans are not allowed to get a UserTransaction"); } userTransaction = new UserTransactionImpl(); } return userTransaction; }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void startDelivery() throws Exception { if (getState() != STARTED) throw new IllegalStateException("The MDB is not started"); if (deliveryActive.getAndSet(true)) return; activate(); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public void stopDelivery(boolean asynch) throws Exception { if (getState() != STARTED) throw new IllegalStateException("The MDB is not started"); if (deliveryActive.getAndSet(false) == false) return; if (asynch) { new Thread("StopDelivery: " + getServiceName()) { public void run() { deactivate(); } }.start(); } else { deactivate(); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
public Object invoke(Invocation mi) throws Throwable { // Are we still useable? if (released.get()) throw new IllegalStateException("This message endpoint + " + getProxyString(mi) + " has been released"); // Concurrent invocation? synchronized (this) { Thread currentThread = Thread.currentThread(); if (inUseThread != null && inUseThread.equals(currentThread) == false) throw new IllegalStateException("This message endpoint + " + getProxyString(mi) + " is already in use by another thread " + inUseThread); inUseThread = currentThread; } String method = mi.getMethod().getName(); if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " in use by " + method + " " + inUseThread); // Which operation? if (method.equals("release")) { release(mi); return null; } else if (method.equals("beforeDelivery")) { before(mi); return null; } else if (method.equals("afterDelivery")) { after(mi); return null; } else return delivery(mi); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void before(Invocation mi) throws Throwable { // Called out of sequence if (getBeforeDeliveryInvoke()) throw new IllegalStateException("Missing afterDelivery from the previous beforeDelivery for message endpoint " + getProxyString(mi)); // Set the classloader MessageDrivenContainer container = getContainer(mi); synchronized (this) { oldClassLoader = GetTCLAction.getContextClassLoader(inUseThread); SetTCLAction.setContextClassLoader(inUseThread, container.getClassLoader()); } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " set context classloader to " + container.getClassLoader()); // start any transaction try { startTransaction("beforeDelivery", mi, container); setBeforeDeliveryInvoke(true); } catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void after(Invocation mi) throws Throwable { // Called out of sequence if(!getBeforeDeliveryInvoke()) { throw new IllegalStateException("afterDelivery without a previous beforeDelivery for message endpoint " + getProxyString(mi)); } // Finish this delivery committing if we can try { finish("afterDelivery", mi, true); } catch (Throwable t) { throw new ResourceException(t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected Object delivery(Invocation mi) throws Throwable { // Have we already delivered a message? if (delivered.get()) throw new IllegalStateException("Multiple message delivery between before and after delivery is not allowed for message endpoint " + getProxyString(mi)); if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivering"); // Mark delivery if beforeDelivery was invoked if (getOldClassLoader() != null) delivered.set(true); MessageDrivenContainer container = getContainer(mi); boolean commit = true; try { // Check for starting a transaction if (getOldClassLoader() == null) startTransaction("delivery", mi, container); return getNext().invoke(mi); } catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; } finally { // No before/after delivery, end any transaction and release the lock if (getOldClassLoader() == null) { try { // Finish any transaction we started endTransaction(mi, commit); } finally { releaseThreadLock(mi); } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected JBossMessageEndpointFactory getMessageEndpointFactory(Invocation mi) { if (endpointFactory == null) endpointFactory = (JBossMessageEndpointFactory) mi.getInvocationContext().getValue(MESSAGE_ENDPOINT_FACTORY); if (endpointFactory == null) throw new IllegalStateException("No message endpoint factory in " + mi.getInvocationContext().context); return endpointFactory; }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected MessageDrivenContainer getContainer(Invocation mi) { JBossMessageEndpointFactory messageEndpointFactory = getMessageEndpointFactory(mi); MessageDrivenContainer container = messageEndpointFactory.getContainer(); if (container == null) throw new IllegalStateException("No container associated with message endpoint factory: " + messageEndpointFactory.getServiceName()); return container; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private Object readResolve() throws ObjectStreamException { server = MBeanServerLocator.locateJBoss(); tm = TransactionManagerLocator.getInstance().locate(); try { ds = lookupDataSource(dataSource); } catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); } return this; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
public synchronized Object generateKey() { if(lo < hi) { ++lo; } else { Transaction curTx = null; try { curTx = tm.suspend(); } catch(SystemException e) { throw new IllegalStateException("Failed to suspend current transaction."); } try { tm.begin(); } catch(Exception e) { throw new IllegalStateException("Failed to begin a new transaction."); } try { doGenerate(); tm.commit(); } catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); } catch(Exception e) { log.error("Failed to commit.", e); } finally { if(curTx != null) { try { tm.resume(curTx); } catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); } } } } return new Long(lo); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private long selectHi() throws SQLException { Connection con = null; PreparedStatement selectHiSt = null; ResultSet rs = null; if(log.isTraceEnabled()) { log.trace("Executing SQL: " + selectHiSql); } try { con = ds.getConnection(); selectHiSt = con.prepareStatement(selectHiSql); rs = selectHiSt.executeQuery(); if(!rs.next()) { throw new IllegalStateException("The sequence has not been initialized in the service start phase!"); } return rs.getLong(1); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(selectHiSt); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invoke(mi); } finally { } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionSecurityInterceptor.java
public Object invokeHome(Invocation mi) throws Exception { Method getEJBObject = Handle.class.getMethod("getEJBObject", new Class[0]); //Invocation on the handle, we don't need a bean instance if (getEJBObject.equals(mi.getMethod())) return getNext().invokeHome(mi); EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invokeHome(mi); } finally { } }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private void endTransaction(final Invocation invocation, final Transaction tx, final Transaction oldTx, final int oldTimeout) throws TransactionRolledbackException, SystemException { // Assert the correct transaction association Transaction current = tm.getTransaction(); if ((tx == null && current != null) || tx.equals(current) == false) throw new IllegalStateException("Wrong transaction association: expected " + tx + " was " + current); try { // Marked rollback if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) { tx.rollback(); } else { // Commit tx // This will happen if // a) everything goes well // b) app. exception was thrown tx.commit(); } } catch (RollbackException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicMixedException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicRollbackException e) { throwJBossException(e, invocation.getType()); } catch (SystemException e) { throwJBossException(e, invocation.getType()); } catch (IllegalStateException e) { throwJBossException(e, invocation.getType()); } finally { // reassociate the oldTransaction with the Invocation (even null) invocation.setTransaction(oldTx); // Always drop thread association even if committing or // rolling back the newTransaction because not all TMs // will drop thread associations when commit() or rollback() // are called through tx itself (see JTA spec that seems to // indicate that thread assoc is required to be dropped only // when commit() and rollback() are called through TransactionManager // interface) //tx has committed, so we can't throw txRolledbackException. tm.suspend(); // Reset the transaction timeout (unless we didn't set it) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { //return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { //SecurityAssociation.pushRunAsIdentity((RunAsIdentity)id); SecurityContext sa = SecurityContextAssociation.getSecurityContext(); if(sa == null) throw new IllegalStateException("Security Context is null to push runas"); sa.setOutgoingRunAs(id); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public void push(RunAs id) { //SecurityAssociation.pushRunAsIdentity(id); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null to push runas"); sc.setOutgoingRunAs(id); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public RunAs pop() { //Pop the RAI // return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = null; ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.getUtil().createSubjectInfo(p, cred, s); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); Principal p = sc.getUtil().getUserPrincipal(); Object cred = sc.getUtil().getCredential(); sc.getUtil().createSubjectInfo(p,cred,null); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(ra); return null; }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(null); return null; }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void releaseReadLock(Transaction transaction) { if(trace) trace(transaction, "READ (UL)"); if(!readers.remove(transaction)) throw new IllegalStateException("ReadWriteEJBLock: Read lock released when it wasn't taken"); notifyWaiters(); }
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
private void releaseWriteLock(Transaction transaction) { if(trace) trace(transaction, "WRITE (UL)"); if (synched == null) throw new IllegalStateException("ReadWriteEJBLock: Do not call nextTransaction while not synched!"); if(writer != null && !writer.equals(transaction)) throw new IllegalStateException("ReadWriteEJBLock: can't unlock a write lock with a different transaction"); writer = null; notifyWaiters(); }
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
public void release(boolean nonReentrant) { synchronized(lock) { held--; if(held < 0) { throw new IllegalStateException("Released lock too many times"); } else if(held == 0) { lockHolder = null; holdingTx = null; lock.notify(); } if(nonReentrant) { inNonReentrant = false; } } }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected void nextTransaction() { if (synched == null) { throw new IllegalStateException("do not call nextTransaction while not synched!"); } setTransaction(null); // is there a waiting list? if (!txWaitQueue.isEmpty()) { TxLock thelock = (TxLock) txWaitQueue.removeFirst(); txLocks.remove(thelock); thelock.isQueued = false; // The new transaction is the next one, important to set it up to avoid race with // new incoming calls setTransaction(thelock.waitingTx); // log.debug(Thread.currentThread()+" handing off to "+lock.threadName); if( deadlockDetection == true ) DeadlockDetector.singleton.removeWaiting(thelock.deadlocker); synchronized (thelock) { // notify All threads waiting on this transaction. // They will enter the methodLock wait loop. thelock.notifyAll(); } } else { // log.debug(Thread.currentThread()+" handing off to empty queue"); } }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
public void removeRef() { refs--; if (refs == 0 && txWaitQueue.size() > 0) { log.error("removing bean lock and it has tx's in QUEUE! " + toString()); throw new IllegalStateException("removing bean lock and it has tx's in QUEUE!"); } else if (refs == 0 && getTransaction() != null) { log.error("removing bean lock and it has tx set! " + toString()); throw new IllegalStateException("removing bean lock and it has tx set!"); } else if (refs < 0) { log.error("negative lock reference count should never happen !"); throw new IllegalStateException("negative lock reference count !"); } }
// in src/main/java/org/jboss/ejb/plugins/NoPassivationCachePolicy.java
public void insert(Object key, Object ctx) { if (ctx == null) { throw new IllegalArgumentException("Cannot insert a null object in the cache"); } if (key == null) { throw new IllegalArgumentException("Cannot insert an object in the cache with null key"); } synchronized (m_map) { Object obj = m_map.get(key); if (obj == null) { m_map.put(key, ctx); } else { throw new IllegalStateException("Attempt to put in the cache an object that is already there"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
private void delete(View view) throws SQLException { if(view.deleted == null) { if(log.isTraceEnabled()) { log.trace("no rows to delete"); } return; } Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + deleteSql); } con = ds.getConnection(); ps = con.prepareStatement(deleteSql); int batchCount = 0; while(view.deleted != null) { RelationKeys keys = view.deleted; int paramInd = 1; JDBCCMPFieldBridge2[] keyFields = (JDBCCMPFieldBridge2[])leftField.getTableKeyFields(); for(int pkInd = 0; pkInd < keyFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = keyFields[pkInd]; Object fieldValue = pkField.getPrimaryKeyValue(keys.leftKey); paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } keyFields = (JDBCCMPFieldBridge2[])rightField.getTableKeyFields(); for(int pkInd = 0; pkInd < keyFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = keyFields[pkInd]; Object fieldValue = pkField.getPrimaryKeyValue(keys.rightKey); paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } ps.addBatch(); ++batchCount; keys.dereference(); } ps.executeBatch(); if(view.deleted != null) { throw new IllegalStateException("There are still rows to delete!"); } if(log.isTraceEnabled()) { log.trace("deleted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
private Views getViews() { Transaction tx = txLocal.getTransaction(); GlobalTxSynchronization globalSync; try { globalSync = txLocal.getGlobalSynchronization(tx); } catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); } catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); } if(globalSync == null) throw new IllegalStateException("Global transaction synchronization is not available for transaction " + tx); Views views = (Views) globalSync.getTxLocal(viewsTxLocalKey); if(views == null) { views = new Views(tx); globalSync.putTxLocal(viewsTxLocalKey, views); globalSync.addSynchronization(new SchemaSynchronization(views)); } return views; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void delete(View view) throws SQLException { JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + deleteSql); } con = dataSource.getConnection(); ps = con.prepareStatement(deleteSql); int batchCount = 0; while(view.deleted != null) { Row row = view.deleted; int paramInd = 1; for(int pkInd = 0; pkInd < pkFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = pkFields[pkInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } deleteStrategy.executeUpdate(ps); ++batchCount; row.flushStatus(); } deleteStrategy.executeBatch(ps); if(view.deleted != null) { throw new IllegalStateException("There are still rows to delete!"); } if(log.isTraceEnabled()) { log.trace("deleted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public Row getRowByPk(Object pk, boolean required) { /* Row cursor = clean; while(cursor != null) { if(pk.equals(cursor.pk)) { return cursor; } cursor = cursor.next; } cursor = dirty; while(cursor != null) { if(pk.equals(cursor.pk)) { return cursor; } cursor = cursor.next; } cursor = created; while(cursor != null) { if(pk.equals(cursor.pk)) { return cursor; } cursor = cursor.next; } */ Row row = (Row) rowByPk.get(pk); if(row == null) { Object[] fields; Object[] relations = null; try { cache.lock(pk); fields = cache.getFields(pk); if(fields != null && relationsTotal > 0) { relations = cache.getRelations(pk); if(relations == null) { relations = new Object[relationsTotal]; } } } finally { cache.unlock(pk); } if(fields != null) { row = createCleanRow(pk, fields, relations); } } if(row == null && required) { throw new IllegalStateException("row not found: pk=" + pk); } return row; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void committed() { if(cacheUpdates != null) { Row cursor = cacheUpdates; while(cursor != null) { //if(cursor.lockedForUpdate) //{ cache.lock(cursor.pk); try { switch(cursor.state) { case CLEAN: cache.put(tx, cursor.pk, cursor.fields, cursor.relations); break; case DELETED: try { cache.remove(tx, cursor.pk); } catch(Cache.RemoveException e) { log.trace(e.getMessage()); } break; default: throw new IllegalStateException("Unexpected row state: table=" + entity.getQualifiedTableName() + ", pk=" + cursor.pk + ", state=" + cursor.state); } } finally { cache.unlock(cursor.pk); } //cursor.lockedForUpdate = false; //} cursor = cursor.nextCacheUpdate; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void delete() { if(state == CLEAN || state == DIRTY || state == DIRTY_RELATIONS) { updateState(DELETED); } else if(state == CREATED) { dereference(); state = DELETED; view.rowByPk.remove(pk); } else if(state == DELETED) { throw new IllegalStateException("The row is already deleted: pk=" + pk); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void updateState(byte state) { dereference(); if(state == CLEAN) { if(view.clean != null) { next = view.clean; view.clean.prev = this; } view.clean = this; } else if(state == DIRTY) { if(view.dirty != null) { next = view.dirty; view.dirty.prev = this; } view.dirty = this; } else if(state == CREATED) { if(view.created != null) { next = view.created; view.created.prev = this; } view.created = this; } else if(state == DELETED) { if(view.deleted != null) { next = view.deleted; view.deleted.prev = this; } view.deleted = this; } else if(state == DIRTY_RELATIONS) { if(view.dirtyRelations != null) { next = view.dirtyRelations; view.dirtyRelations.prev = this; } view.dirtyRelations = this; } else { throw new IllegalStateException("Can't update to state: " + state); } this.state = state; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
public void isInvalid(Serializable key) { Transaction tx = null; try { tx = tm.getTransaction(); } catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); } if(log.isTraceEnabled()) { log.trace("invalidating key=" + key); } cache.lock(key); try { cache.remove(tx, key); } catch(Cache.RemoveException e) { if(log.isTraceEnabled()) { log.trace(e.getMessage()); } } finally { cache.unlock(key); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
public void areInvalid(Serializable[] keys) { Transaction tx = null; try { tx = tm.getTransaction(); } catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); } boolean trace = log.isTraceEnabled(); for(int i = 0; i < keys.length; ++i) { if(trace) { log.trace("invalidating key[" + i + "]=" + keys[i]); } cache.lock(keys[i]); try { cache.remove(tx, keys[i]); } catch(Cache.RemoveException e) { if(trace) { log.trace(e.getMessage()); } } finally { cache.unlock(keys[i]); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public synchronized void unlock() { if(!locked) { throw new IllegalStateException("The instance is not locked!"); } locked = false; notify(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public void setValueInternal(EntityEnterpriseContext ctx, Object value, boolean makeDirty) { PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); // todo this is weird if(cmpFieldIAmMappedTo != null && cmpFieldIAmMappedTo.isPrimaryKeyMember) { Object curValue = pctx.getFieldValue(rowIndex); if(value != null && !value.equals(curValue)) { throw new IllegalStateException( "Attempt to modify a primary key field through a foreign key field mapped to it: " + entity.getEntityName() + "." + cmpFieldIAmMappedTo.getFieldName() + " -> " + entity.getQualifiedTableName() + "." + cmpFieldIAmMappedTo.getColumnName() + ", current value=" + curValue + ", new value=" + value ); } makeDirty = false; } else { pctx.setFieldValue(rowIndex, value); } if(makeDirty) { pctx.setDirty(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object loadArgumentResults(ResultSet rs, int parameterIndex) throws IllegalArgumentException { try { // update the value from the result set Class[] javaTypes = jdbcType.getJavaTypes(); if(javaTypes.length > 1) { throw new IllegalStateException("Complex types are not supported yet."); } JDBCResultSetReader[] rsReaders = jdbcType.getResultSetReaders(); Object columnValue = null; for(int i = 0; i < javaTypes.length; i++) { columnValue = rsReaders[i].get(rs, parameterIndex++, javaTypes[i], log); columnValue = jdbcType.setColumnValue(i, null, columnValue); } // retrun the updated parameterIndex return columnValue; } catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void addLoadedPk(Object pk) { if(loaded) { throw new IllegalStateException(entity.getEntityName() + "." + getFieldName() + " single-valued CMR field is already loaded. Check the database for consistancy. " + " current value=" + value + ", loaded value=" + pk ); } changeValue(pk); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void addLoadedPk(Object pk) { if(loaded) { throw new IllegalStateException(entity.getEntityName() + "." + getFieldName() + " collection-valued CMR field is already loaded. Check the database for consistancy. " + " current value=" + value + ", loaded value=" + pk ); } if(pk != null) { value.add(pk); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void remove() { try { idIter.remove(); } catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); } removeById(curId); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean hasNext() { try { return idIter.hasNext(); } catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public Object next() { try { curId = idIter.next(); } catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); } return relatedContainer.getLocalProxyFactory().getEntityEJBLocalObject(curId); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/EJBSelectBridge.java
public Object execute(Object[] args) throws FinderException { JDBCStoreManager2 manager = command.getStoreManager(); GenericEntityObjectFactory factory = (metadata.isResultTypeMappingLocal() ? (GenericEntityObjectFactory)manager.getContainer().getLocalProxyFactory() : manager.getContainer().getProxyFactory()); Object result; switch(returnType) { case SINGLE: result = command.fetchOne(schema, factory, args); if(result == null && getMethod().getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + getMethod().getReturnType().getName() ); } break; case COLLECTION: result = command.fetchCollection(schema, factory, args); break; default: throw new IllegalStateException("Unexpected return type: " + returnType); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public FieldBridge getFieldByName(String fieldName) { FieldBridge field; for(int i = 0; i < pkFields.length; ++i) { field = pkFields[i]; if(field.getFieldName().equals(fieldName)) { return field; } } for(int i = 0; i < cmpFields.length; ++i) { field = cmpFields[i]; if(field.getFieldName().equals(fieldName)) { return field; } } for(int i = 0; i < cmrFields.length; ++i) { field = cmrFields[i]; if(field.getFieldName().equals(fieldName)) { return field; } } throw new IllegalStateException("Field " + fieldName + " not found in entity " + getEntityName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
public JDBCFunctionMappingMetaData getFunctionMapping(String name) { JDBCFunctionMappingMetaData funcMapping = (JDBCFunctionMappingMetaData)functionMappings.get(name.toLowerCase()); if(funcMapping == null) throw new IllegalStateException("Function " + name + " is not defined for " + this.name); return funcMapping; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
public JDBCApplicationMetaData load() throws DeploymentException { JDBCApplicationMetaData jamd = new JDBCApplicationMetaData( container.getBeanMetaData().getApplicationMetaData(), container.getClassLoader() ); // Load standardjbosscmp-jdbc.xml from the default classLoader // we always load defaults first URL stdJDBCUrl = container.getClassLoader().getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if (debug) log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); // first create the metadata jamd = new JDBCApplicationMetaData(stdJDBCElement, jamd); // Load jbosscmp-jdbc.xml if provided URL jdbcUrl = null; VirtualFile dd = container.getDeploymentUnit().getMetaDataFile("jbosscmp-jdbc.xml"); if(dd != null) { try { jdbcUrl = dd.toURL(); } catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); } } if(jdbcUrl != null) { if (debug) log.debug(jdbcUrl.toString() + " found. Overriding defaults"); Element jdbcElement = XmlFileLoader.getDocument(jdbcUrl, true).getDocumentElement(); jamd = new JDBCApplicationMetaData(jdbcElement, jamd); } return jamd; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public boolean add(Object o) { if(firstIterator == null) { return results.add(o); } throw new IllegalStateException("Can't modify collection while the first iterator is not exhausted."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public boolean remove(Object o) { if(firstIterator == null) { return results.remove(o); } throw new IllegalStateException("Can't modify collection while the first iterator is not exhausted."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
private static Object cloneValue(Object fieldValue, Class argType) { if(fieldValue == null) { return null; } Class valueType = fieldValue.getClass(); Constructor ctor; try { ctor = valueType.getConstructor(new Class[]{argType}); } catch(NoSuchMethodException e) { throw new IllegalStateException( "Failed to find a ctor in " + valueType + " that takes an instance of " + argType + " as an argument." ); } try { return ctor.newInstance(new Object[]{fieldValue}); } catch(Exception e) { throw new IllegalStateException( "Failed to create an instance of " + valueType + " with the " + fieldValue + " as a ctor argument" ); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
public JDBCType getJDBCType(Class javaType) { if(complexTypes.containsKey(javaType)) { return (JDBCTypeComplex)complexTypes.get(javaType); } else { JDBCTypeSimple type = (JDBCTypeSimple)mappedSimpleTypes.get(javaType); if(type == null) { JDBCUserTypeMappingMetaData userTypeMapping = (JDBCUserTypeMappingMetaData)userTypeMappings.get(javaType.getName()); Mapper mapper = null; if(userTypeMapping != null) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { javaType = cl.loadClass(userTypeMapping.getMappedType()); } catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); } try { mapper = (Mapper)newInstance(userTypeMapping.getMapper()); } catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); } } JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType); String sqlType = typeMappingMD.getSqlType(); int jdbcType = typeMappingMD.getJdbcType(); boolean notNull = javaType.isPrimitive(); boolean autoIncrement = false; JDBCParameterSetter paramSetter; if(typeMappingMD.getParamSetter() != null) { try { paramSetter = (JDBCParameterSetter)newInstance(typeMappingMD.getParamSetter()); } catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); } } else { paramSetter = JDBCUtil.getParameterSetter(jdbcType, javaType); } JDBCResultSetReader resultReader; if(typeMappingMD.getResultReader() != null) { try { resultReader = (JDBCResultSetReader)newInstance(typeMappingMD.getResultReader()); } catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); } } else { resultReader = JDBCUtil.getResultSetReader(jdbcType, javaType); } type = new JDBCTypeSimple( null, javaType, jdbcType, sqlType, notNull, autoIncrement, mapper, paramSetter, resultReader ); } return type; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTEJBQL node, Object data) { Node selectNode = node.jjtGetChild(0); Node fromNode = node.jjtGetChild(1); // compile selectNode StringBuffer selectClause = new StringBuffer(50); selectNode.jjtAccept(this, selectClause); StringBuffer whereClause = null; StringBuffer orderByClause = null; for(int i = 2; i < node.jjtGetNumChildren(); ++i) { Node childNode = node.jjtGetChild(i); if(childNode instanceof ASTWhere) { whereClause = new StringBuffer(20); childNode.jjtAccept(this, whereClause); } else if(childNode instanceof ASTOrderBy) { orderByClause = new StringBuffer(); childNode.jjtAccept(this, orderByClause); } else if(childNode instanceof ASTLimitOffset) { childNode.jjtAccept(this, null); } } // compile fromNode StringBuffer fromClause = new StringBuffer(30); fromNode.jjtAccept(this, fromClause); // left-join for(Iterator iter = identifierToTable.entrySet().iterator(); iter.hasNext();) { final Map.Entry entry = (Map.Entry) iter.next(); final String identifier = (String) entry.getKey(); final String table = (String) entry.getValue(); final String alias = aliasManager.getAlias(identifier); fromClause.append(table).append(' ').append(alias); join(alias, fromClause); if(iter.hasNext()) { fromClause.append(SQLUtil.COMMA); } } selectDistinct = ((ASTSelect) selectNode).distinct || returnType == Set.class || forceDistinct; // assemble sql StringBuffer sql = (StringBuffer) data; if(selectManager.getMetaData().hasRowLocking() && !(selectObject instanceof SelectFunction)) { JDBCFunctionMappingMetaData rowLockingTemplate = typeMapping.getRowLockingTemplate(); if(rowLockingTemplate == null) { throw new IllegalStateException("Row locking template is not defined for given mapping: " + typeMapping.getName()); } boolean distinct = selectDistinct; Object args[] = new Object[]{ distinct ? SQLUtil.DISTINCT + selectClause : selectClause.toString(), fromClause, whereClause == null || whereClause.length() == 0 ? null : whereClause, orderByClause == null || orderByClause.length() == 0 ? null : orderByClause }; rowLockingTemplate.getFunctionSql(args, sql); } else { sql.append(SQLUtil.SELECT); if(selectDistinct) { sql.append(SQLUtil.DISTINCT); } sql.append(selectClause) .append(SQLUtil.FROM) .append(fromClause); if(whereClause != null && whereClause.length() > 0) { sql.append(SQLUtil.WHERE).append(whereClause); } if(orderByClause != null && orderByClause.length() > 0) { sql.append(SQLUtil.ORDERBY).append(orderByClause); } } if(countCompositePk) { sql.insert(0, "SELECT COUNT(*) FROM (").append(") t_count"); } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTLimitOffset node, Object data) { int child = 0; if(node.hasOffset) { Node offsetNode = node.jjtGetChild(child++); if(offsetNode instanceof ASTParameter) { ASTParameter param = (ASTParameter) offsetNode; Class parameterType = getParameterType(param.number); if(int.class != parameterType && Integer.class != parameterType) { throw new IllegalStateException("OFFSET parameter must be an int"); } offsetParam = param.number; } else { ASTExactNumericLiteral param = (ASTExactNumericLiteral) offsetNode; offsetValue = (int) param.value; } } if(node.hasLimit) { Node limitNode = node.jjtGetChild(child); if(limitNode instanceof ASTParameter) { ASTParameter param = (ASTParameter) limitNode; Class parameterType = getParameterType(param.number); if(int.class != parameterType && Integer.class != parameterType) { throw new IllegalStateException("LIMIT parameter must be an int"); } limitParam = param.number; } else { ASTExactNumericLiteral param = (ASTExactNumericLiteral) limitNode; limitValue = (int) param.value; } } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTSelect select, Object data) { StringBuffer sql = (StringBuffer) data; final Node child0 = select.jjtGetChild(0); final ASTPath path; if(child0 instanceof ASTPath) { path = (ASTPath) child0; if(path.isCMPField()) { // set the select object JDBCFieldBridge selectField = (JDBCFieldBridge) path.getCMPField(); selectManager = selectField.getManager(); selectObject = selectField; setTypeFactory(selectManager.getJDBCTypeFactory()); // todo inner or left? //addLeftJoinPath(path); addInnerJoinPath(path); String alias = aliasManager.getAlias(path.getPath(path.size() - 2)); SQLUtil.getColumnNamesClause(selectField, alias, sql); } else { JDBCAbstractEntityBridge selectEntity = (JDBCAbstractEntityBridge) path.getEntity(); selectManager = selectEntity.getManager(); selectObject = selectEntity; setTypeFactory(selectEntity.getManager().getJDBCTypeFactory()); final String alias = aliasManager.getAlias(path.getPath()); if(select.distinct) { SQLUtil.getSearchableColumnNamesClause(selectEntity.getTableFields(), alias, sql); } else { SQLUtil.getColumnNamesClause(selectEntity.getTableFields(), alias, sql); } /* if(readAhead.isOnFind()) { String eagerLoadGroupName = readAhead.getEagerLoadGroup(); boolean[] loadGroupMask = selectEntity.getLoadGroupMask(eagerLoadGroupName); SQLUtil.appendColumnNamesClause( selectEntity.getTableFields(), loadGroupMask, alias, sql ); } */ addLeftJoinPath(path); } } else { // the function should take a path expresion as a parameter path = getPathFromChildren(child0); if(path == null) { throw new IllegalStateException("The function in SELECT clause does not contain a path expression."); } if(path.isCMPField()) { JDBCFieldBridge selectField = (JDBCFieldBridge) path.getCMPField(); selectManager = selectField.getManager(); setTypeFactory(selectManager.getJDBCTypeFactory()); if(selectField.getJDBCType().hasMapper()) this.functionJDBCType = selectField.getJDBCType(); } else if(path.isCMRField()) { JDBCFieldBridge cmrField = (JDBCFieldBridge) path.getCMRField(); selectManager = cmrField.getManager(); setTypeFactory(selectManager.getJDBCTypeFactory()); addLeftJoinPath(path); } else { final JDBCAbstractEntityBridge entity = (JDBCAbstractEntityBridge) path.getEntity(); selectManager = entity.getManager(); setTypeFactory(selectManager.getJDBCTypeFactory()); addLeftJoinPath(path); } selectObject = child0; child0.jjtAccept(this, data); } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTNullComparison node, Object data) { StringBuffer sql = (StringBuffer) data; final Node child0 = node.jjtGetChild(0); if(child0 instanceof ASTPath) { ASTPath path = (ASTPath) child0; addLeftJoinPath(path); JDBCFieldBridge field = (JDBCFieldBridge) path.getField(); if(field instanceof JDBCAbstractCMRFieldBridge) { JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge)field; final String alias; final JDBCFieldBridge[] keyFields; if(cmrField.hasForeignKey()) { alias = aliasManager.getAlias(path.getPath(path.size() - 2)); keyFields = cmrField.getForeignKeyFields(); } else { alias = aliasManager.getAlias(path.getPath()); if(cmrField.getMetaData().getRelationMetaData().isTableMappingStyle()) { keyFields = cmrField.getRelatedCMRField().getEntity().getPrimaryKeyFields(); } else { keyFields = cmrField.getRelatedCMRField().getForeignKeyFields(); } } SQLUtil.getIsNullClause(node.not, keyFields, alias, sql); } else { String alias = aliasManager.getAlias(path.getPath(path.size() - 2)); SQLUtil.getIsNullClause(node.not, field, alias, sql); } } else if(child0 instanceof ASTParameter) { ASTParameter param = (ASTParameter) child0; Class type = getParameterType(param.number); QueryParameter queryParam = new QueryParameter(param.number - 1, typeFactory.getJDBCType(type)); inputParameters.add(queryParam); sql.append("? IS "); if(node.not) { sql.append(SQLUtil.NOT); } sql.append(SQLUtil.NULL); } else { throw new IllegalStateException("Unexpected node in IS NULL clause: " + node); } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTIsEmpty node, Object data) { ASTPath path = (ASTPath) node.jjtGetChild(0); if(!path.isCMRField()) { throw new IllegalStateException("IS EMPTY can be applied only to collection valued CMR field."); } addLeftJoinPath(path); StringBuffer sql = (StringBuffer) data; JDBCAbstractCMRFieldBridge cmrField = (JDBCAbstractCMRFieldBridge) path.getCMRField(); JDBCAbstractEntityBridge relatedEntity = (JDBCAbstractEntityBridge) cmrField.getRelatedEntity(); String alias = aliasManager.getAlias(path.getPath()); SQLUtil.getIsNullClause(node.not, relatedEntity.getPrimaryKeyFields(), alias, sql); return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTMemberOf node, Object data) { Node member = node.jjtGetChild(0); ASTPath colPath = (ASTPath) node.jjtGetChild(1); JDBCAbstractEntityBridge colEntity = (JDBCAbstractEntityBridge) colPath.getEntity(); StringBuffer sql = (StringBuffer) data; if(node.not) { sql.append(SQLUtil.NOT); } sql.append(SQLUtil.EXISTS).append('(').append(SQLUtil.SELECT); if(member instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) member; verifyParameterEntityType(toParam.number, colEntity); inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, colEntity)); String parentAlias = aliasManager.getAlias(colPath.getPath(0)); String localParentAlias = aliasManager.getAlias(colPath.getPath(0) + "_local"); JDBCAbstractEntityBridge parentEntity = (JDBCAbstractEntityBridge) colPath.getEntity(0); SQLUtil.getColumnNamesClause(parentEntity.getPrimaryKeyFields(), localParentAlias, sql); sql.append(SQLUtil.FROM) .append(parentEntity.getQualifiedTableName()).append(' ').append(localParentAlias); innerJoinPath(colPath, sql); sql.append(SQLUtil.WHERE); JDBCAbstractEntityBridge col0 = (JDBCAbstractEntityBridge)colPath.getEntity(0); SQLUtil.getSelfCompareWhereClause(col0.getPrimaryKeyFields(), parentAlias, localParentAlias, sql); sql.append(SQLUtil.AND); String localColAlias = aliasManager.getAlias(colPath.getPath() + "_local"); SQLUtil.getWhereClause(colEntity.getPrimaryKeyFields(), localColAlias, sql); } else { ASTPath memberPath = (ASTPath) member; JDBCAbstractEntityBridge memberEntity = (JDBCAbstractEntityBridge) memberPath.getEntity(); if(!memberEntity.equals(colEntity)) { throw new IllegalStateException("Member must be if the same type as the collection, got: member=" + memberEntity.getEntityName() + ", collection=" + colEntity.getEntityName()); } String memberAlias = aliasManager.getAlias(memberPath.getPath()); if(memberPath.size() > 1) { String parentAlias = aliasManager.getAlias(memberPath.getPath(0) + "_local"); JDBCAbstractEntityBridge parentEntity = (JDBCAbstractEntityBridge) memberPath.getEntity(0); SQLUtil.getColumnNamesClause(parentEntity.getPrimaryKeyFields(), parentAlias, sql); sql.append(SQLUtil.FROM) .append(parentEntity.getQualifiedTableName()).append(' ').append(parentAlias); innerJoinPath(memberPath, sql); innerJoinPath(colPath, sql); } else if(colPath.size() > 1) { String parentAlias = aliasManager.getAlias(colPath.getPath(0) + "_local"); JDBCAbstractEntityBridge parentEntity = (JDBCAbstractEntityBridge) colPath.getEntity(0); SQLUtil.getColumnNamesClause(parentEntity.getPrimaryKeyFields(), parentAlias, sql); sql.append(SQLUtil.FROM) .append(parentEntity.getQualifiedTableName()).append(' ').append(parentAlias); innerJoinPath(colPath, sql); } else { throw new IllegalStateException( "There should be collection valued path expression, not identification variable."); } sql.append(SQLUtil.WHERE); JDBCAbstractEntityBridge member0 = (JDBCAbstractEntityBridge)memberPath.getEntity(0); String colAliasLocal = aliasManager.getAlias(colPath.getPath() + "_local"); if(memberPath.size() > 1) { String memberAliasLocal = aliasManager.getAlias(memberPath.getPath() + "_local"); SQLUtil.getSelfCompareWhereClause(colEntity.getPrimaryKeyFields(), memberAliasLocal, colAliasLocal, sql); sql.append(SQLUtil.AND); String member0Alias = aliasManager.getAlias(memberPath.getPath(0)); String member0AliasLocal = aliasManager.getAlias(memberPath.getPath(0) + "_local"); SQLUtil.getSelfCompareWhereClause(member0.getPrimaryKeyFields(), member0Alias, member0AliasLocal, sql); } else { SQLUtil.getSelfCompareWhereClause(member0.getPrimaryKeyFields(), memberAlias, colAliasLocal, sql); sql.append(SQLUtil.AND); String col0Alias = aliasManager.getAlias(colPath.getPath(0)); String col0AliasLocal = aliasManager.getAlias(colPath.getPath(0) + "_local"); SQLUtil.getSelfCompareWhereClause(colEntity.getPrimaryKeyFields(), col0Alias, col0AliasLocal, sql); } } sql.append(')'); return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTValueClassComparison node, Object data) { StringBuffer buf = (StringBuffer) data; boolean not = (node.opp.equals(SQLUtil.NOT_EQUAL)); String comparison = node.opp; buf.append('('); if(not) { buf.append(SQLUtil.NOT).append('('); comparison = "="; } // setup the from path ASTPath fromPath = (ASTPath) node.jjtGetChild(0); addInnerJoinPath(fromPath); String fromAlias = aliasManager.getAlias(fromPath.getPath(fromPath.size() - 2)); CMPFieldBridge fromCMPField = (CMPFieldBridge) fromPath.getCMPField(); Node toNode = node.jjtGetChild(1); if(toNode instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) toNode; // can only compare like kind entities Class parameterType = getParameterType(toParam.number); if(!(fromCMPField.getFieldType().equals(parameterType))) { throw new IllegalStateException("Only like types can be " + "compared: from CMP field=" + fromCMPField.getFieldType() + " to parameter=" + parameterType); } inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromCMPField)); SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, comparison, buf); } else { ASTPath toPath = (ASTPath) toNode; addInnerJoinPath(toPath); String toAlias = aliasManager.getAlias(toPath.getPath(toPath.size() - 2)); JDBCCMPFieldBridge toCMPField = (JDBCCMPFieldBridge) toPath.getCMPField(); // can only compare like kind entities if(!(fromCMPField.getFieldType().equals(toCMPField.getFieldType()))) { throw new IllegalStateException("Only like types can be " + "compared: from CMP field=" + fromCMPField.getFieldType() + " to CMP field=" + toCMPField.getFieldType()); } SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, comparison, buf); } return (not ? buf.append(')') : buf).append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTPath node, Object data) { StringBuffer buf = (StringBuffer) data; if(!node.isCMPField()) { throw new IllegalStateException("Can only visit cmp valued path node. " + "Should have been handled at a higher level."); } JDBCFieldBridge cmpField = (JDBCFieldBridge) node.getCMPField(); // make sure this is mapped to a single column switch(node.type) { case EJBQLTypes.ENTITY_TYPE: case EJBQLTypes.VALUE_CLASS_TYPE: if(cmpField.getJDBCType().hasMapper() || cmpField.getJDBCType().getParameterSetter() != null) { break; } case EJBQLTypes.UNKNOWN_TYPE: throw new IllegalStateException("Can not visit multi-column path " + "node. Should have been handled at a higher level."); } addLeftJoinPath(node); String alias = aliasManager.getAlias(node.getPath(node.size() - 2)); SQLUtil.getColumnNamesClause(cmpField, alias, buf); return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTAbstractSchema node, Object data) { throw new IllegalStateException("Can not visit abstract schema node. " + " Should have been handled at a higher level."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTParameter node, Object data) { StringBuffer buf = (StringBuffer) data; Class type = getParameterType(node.number); // make sure this is mapped to a single column int ejbqlType = EJBQLTypes.getEJBQLType(type); if(ejbqlType == EJBQLTypes.ENTITY_TYPE || ejbqlType == EJBQLTypes.VALUE_CLASS_TYPE || ejbqlType == EJBQLTypes.UNKNOWN_TYPE) { throw new IllegalStateException("Can not visit multi-column " + "parameter node. Should have been handled at a higher level."); } QueryParameter param = new QueryParameter(node.number - 1, typeFactory.getJDBCType(type)); inputParameters.add(param); buf.append('?'); return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
private void compareEntity(boolean not, Node fromNode, Node toNode, StringBuffer buf) { buf.append('('); if(not) { buf.append(SQLUtil.NOT).append('('); } ASTPath fromPath = (ASTPath) fromNode; addLeftJoinPath(fromPath); String fromAlias = aliasManager.getAlias(fromPath.getPath()); JDBCAbstractEntityBridge fromEntity = (JDBCAbstractEntityBridge) fromPath.getEntity(); if(toNode instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) toNode; // can only compare like kind entities verifyParameterEntityType(toParam.number, fromEntity); inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromEntity)); SQLUtil.getWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, buf); } else { ASTPath toPath = (ASTPath) toNode; addLeftJoinPath(toPath); String toAlias = aliasManager.getAlias(toPath.getPath()); JDBCAbstractEntityBridge toEntity = (JDBCAbstractEntityBridge) toPath.getEntity(); // can only compare like kind entities if(!fromEntity.equals(toEntity)) { throw new IllegalStateException("Only like types can be " + "compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toEntity.getEntityName()); } SQLUtil.getSelfCompareWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, toAlias, buf); } if(not) { buf.append(')'); } buf.append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
private void verifyParameterEntityType(int number, JDBCAbstractEntityBridge entity) { Class parameterType = getParameterType(number); Class remoteClass = entity.getRemoteInterface(); Class localClass = entity.getLocalInterface(); if((localClass == null || !localClass.isAssignableFrom(parameterType)) && (remoteClass == null || !remoteClass.isAssignableFrom(parameterType))) { throw new IllegalStateException("Only like types can be compared: from entity=" + entity.getEntityName() + " to parameter type=" + parameterType); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
public void execute(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { if(entity.isRemoved(ctx)) { throw new IllegalStateException("Instance was already removed: id=" + ctx.getId()); } entity.setIsBeingRemoved(ctx); // remove entity from all relations Object[] oldRelationsRef = new Object[1]; boolean needsSync = entity.removeFromRelations(ctx, oldRelationsRef); // update the related entities (stores the removal from relationships) // if one of the store fails an EJBException will be thrown if(!syncOnCommitOnly && needsSync) { EntityContainer.synchronizeEntitiesWithinTransaction(ctx.getTransaction()); } if(!batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.trace("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } // cascate-delete to old relations, if relation uses cascade. if(oldRelationsRef[0] != null) { Map oldRelations = (Map)oldRelationsRef[0]; entity.cascadeDelete(ctx, oldRelations); } if(batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.debug("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } entity.setRemoved(ctx); manager.getReadAheadCache().removeCachedData(ctx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private String getEntityCreateTableSQL(DataSource dataSource) throws DeploymentException { StringBuffer sql = new StringBuffer(); sql.append(SQLUtil.CREATE_TABLE).append(entity.getQualifiedTableName()).append(" ("); // add fields boolean comma = false; JDBCFieldBridge[] fields = entity.getTableFields(); for(int i = 0; i < fields.length; ++i) { JDBCFieldBridge field = fields[i]; JDBCType type = field.getJDBCType(); if(comma) { sql.append(SQLUtil.COMMA); } else { comma = true; } addField(type, sql); } // add a pk constraint if(entityMetaData.hasPrimaryKeyConstraint()) { JDBCFunctionMappingMetaData pkConstraint = manager.getMetaData().getTypeMapping().getPkConstraintTemplate(); if(pkConstraint == null) { throw new IllegalStateException("Primary key constraint is " + "not allowed for this type of data source"); } String defTableName = entity.getManager().getMetaData().getDefaultTableName(); String name = "pk_" + SQLUtil.unquote(defTableName, dataSource); name = SQLUtil.fixConstraintName(name, dataSource); String[] args = new String[]{ name, SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), new StringBuffer(100)).toString() }; sql.append(SQLUtil.COMMA); pkConstraint.getFunctionSql(args, sql); } return sql.append(')').toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addField(JDBCType type, StringBuffer sqlBuffer) throws DeploymentException { // apply auto-increment template if(type.getAutoIncrement()[0]) { String columnClause = SQLUtil.getCreateTableColumnsClause(type); JDBCFunctionMappingMetaData autoIncrement = manager.getMetaData().getTypeMapping().getAutoIncrementTemplate(); if(autoIncrement == null) { throw new IllegalStateException("auto-increment template not found"); } String[] args = new String[]{columnClause}; autoIncrement.getFunctionSql(args, sqlBuffer); } else { sqlBuffer.append(SQLUtil.getCreateTableColumnsClause(type)); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private String getRelationCreateTableSQL(JDBCAbstractCMRFieldBridge cmrField, DataSource dataSource) throws DeploymentException { JDBCFieldBridge[] leftKeys = cmrField.getTableKeyFields(); JDBCFieldBridge[] rightKeys = cmrField.getRelatedCMRField().getTableKeyFields(); JDBCFieldBridge[] fieldsArr = new JDBCFieldBridge[leftKeys.length + rightKeys.length]; System.arraycopy(leftKeys, 0, fieldsArr, 0, leftKeys.length); System.arraycopy(rightKeys, 0, fieldsArr, leftKeys.length, rightKeys.length); StringBuffer sql = new StringBuffer(); sql.append(SQLUtil.CREATE_TABLE).append(cmrField.getQualifiedTableName()) .append(" (") // add field declaration .append(SQLUtil.getCreateTableColumnsClause(fieldsArr)); // add a pk constraint final JDBCRelationMetaData relationMetaData = cmrField.getMetaData().getRelationMetaData(); if(relationMetaData.hasPrimaryKeyConstraint()) { JDBCFunctionMappingMetaData pkConstraint = manager.getMetaData().getTypeMapping().getPkConstraintTemplate(); if(pkConstraint == null) { throw new IllegalStateException("Primary key constraint is not allowed for this type of data store"); } String name = "pk_" + relationMetaData.getDefaultTableName(); name = SQLUtil.fixConstraintName(name, dataSource); String[] args = new String[]{ name, SQLUtil.getColumnNamesClause(fieldsArr, new StringBuffer(100).toString(), new StringBuffer()).toString() }; sql.append(SQLUtil.COMMA); pkConstraint.getFunctionSql(args, sql); } sql.append(')'); return sql.toString(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStartCommand.java
private void addForeignKeyConstraint(DataSource dataSource, String tableName, String cmrFieldName, JDBCFieldBridge[] fields, String referencesTableName, JDBCFieldBridge[] referencesFields) throws DeploymentException { // can only alter tables we created Set createdTables = (Set) manager.getApplicationData(CREATED_TABLES_KEY); if(!createdTables.contains(tableName)) { return; } JDBCFunctionMappingMetaData fkConstraint = manager.getMetaData().getTypeMapping().getFkConstraintTemplate(); if(fkConstraint == null) { throw new IllegalStateException("Foreign key constraint is not allowed for this type of datastore"); } String a = SQLUtil.getColumnNamesClause(fields, new StringBuffer(50)).toString(); String b = SQLUtil.getColumnNamesClause(referencesFields, new StringBuffer(50)).toString(); String[] args = new String[]{ tableName, SQLUtil.fixConstraintName("fk_" + tableName + "_" + cmrFieldName, dataSource), a, referencesTableName, b}; String sql = fkConstraint.getFunctionSql(args, new StringBuffer(100)).toString(); // since we use the pools, we have to do this within a transaction // suspend the current transaction TransactionManager tm = manager.getContainer().getTransactionManager(); Transaction oldTransaction; try { oldTransaction = tm.suspend(); } catch(Exception e) { throw new DeploymentException(COULDNT_SUSPEND + "alter table create foreign key.", e); } try { Connection con = null; Statement statement = null; try { if(log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } con = dataSource.getConnection(); statement = con.createStatement(); statement.executeUpdate(sql); } finally { // make sure to close the connection and statement before // comitting the transaction or XA will break JDBCUtil.safeClose(statement); JDBCUtil.safeClose(con); } } catch(Exception e) { log.warn("Could not add foreign key constraint: table=" + tableName); throw new DeploymentException("Error while adding foreign key constraint", e); } finally { try { // resume the old transaction if(oldTransaction != null) { tm.resume(oldTransaction); } } catch(Exception e) { throw new DeploymentException(COULDNT_REATTACH + "create table"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
private static Object coerceToJavaType( Object value, Class destination) throws SQLException { try { // // null // if(value == null) { return null; } // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // // Primitive wrapper classes // // We have a primitive wrapper and we want a real primitive // just return the wrapper and the vm will convert it at the proxy if(destination.isPrimitive()) { if(value == null) throw new IllegalStateException("Loaded NULL value for a field of a primitive type."); if((destination.equals(Byte.TYPE) && value instanceof Byte) || (destination.equals(Short.TYPE) && value instanceof Short) || (destination.equals(Character.TYPE) && value instanceof Character) || (destination.equals(Boolean.TYPE) && value instanceof Boolean) || (destination.equals(Integer.TYPE) && value instanceof Integer) || (destination.equals(Long.TYPE) && value instanceof Long) || (destination.equals(Float.TYPE) && value instanceof Float) || (destination.equals(Double.TYPE) && value instanceof Double) ) { return value; } } // // java.util.Date // // make new copy as sub types have problems in comparions if(destination == java.util.Date.class && value instanceof java.util.Date) { // handle timestamp special becauses it hoses the milisecond values if(value instanceof java.sql.Timestamp) { java.sql.Timestamp ts = (java.sql.Timestamp)value; // Timestamp returns whole seconds from getTime and partial // seconds are retrieved from getNanos() // Adrian Brock: Not in 1.4 it doesn't long temp = ts.getTime(); if(temp % 1000 == 0) temp += ts.getNanos() / 1000000; return new java.util.Date(temp); } else { return new java.util.Date(((java.util.Date)value).getTime()); } } // // java.sql.Time // // make a new copy object; you never know what a driver will return if(destination == java.sql.Time.class && value instanceof java.sql.Time) { return new java.sql.Time(((java.sql.Time)value).getTime()); } // // java.sql.Date // // make a new copy object; you never know what a driver will return if(destination == java.sql.Date.class && value instanceof java.sql.Date) { return new java.sql.Date(((java.sql.Date)value).getTime()); } // // java.sql.Timestamp // // make a new copy object; you never know what a driver will return if(destination == java.sql.Timestamp.class && value instanceof java.sql.Timestamp) { // make a new Timestamp object; you never know // what a driver will return java.sql.Timestamp orignal = (java.sql.Timestamp)value; java.sql.Timestamp copy = new java.sql.Timestamp(orignal.getTime()); copy.setNanos(orignal.getNanos()); return copy; } // // java.lang.String --> java.lang.Character or char // // just grab first character if(value instanceof String && (destination == Character.class || destination == Character.TYPE)) { return new Character(((String)value).charAt(0)); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do throw new SQLException("Got a " + value.getClass().getName() + "[cl=" + System.identityHashCode(value.getClass().getClassLoader()) + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + System.identityHashCode(destination) + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public Object createBeanClassInstance() throws Exception { if(createBeanClassInstanceCommand == null) throw new IllegalStateException("createBeanClassInstanceCommand == null"); return createBeanClassInstanceCommand.execute(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
protected SQLException processException(Throwable t) { if (t instanceof InvocationTargetException) { t = ((InvocationTargetException) t).getTargetException(); } if (t instanceof SQLException) { return (SQLException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Error) { throw (Error) t; } log.error(t); throw new IllegalStateException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
public Transaction getTransaction() { try { return transactionManager.getTransaction(); } catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
public boolean load(EntityEnterpriseContext ctx) { if(log.isTraceEnabled()) { log.trace("load data:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId()); } // get the preload data map Map preloadDataMap = getPreloadDataMap(ctx.getId(), false); if(preloadDataMap == null || preloadDataMap.isEmpty()) { // no preloaded data for this entity if(log.isTraceEnabled()) { log.trace("No preload data found:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId()); } return false; } boolean cleanReadAhead = manager.getMetaData().isCleanReadAheadOnLoad(); boolean loaded = false; JDBCCMRFieldBridge onlyOneSingleValuedCMR = null; // iterate over the keys in the preloaded map Iterator iter = preloadDataMap.entrySet().iterator(); while(iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); Object field = entry.getKey(); // get the value that was preloaded for this field Object value = entry.getValue(); // if we didn't get a value something is seriously hosed if(value == null) { throw new IllegalStateException("Preloaded value not found"); } if(cleanReadAhead) { // remove this value from the preload cache as it is about to be loaded iter.remove(); } // check for null value standin if(value == NULL_VALUE) { value = null; } if(field instanceof JDBCCMPFieldBridge) { JDBCCMPFieldBridge cmpField = (JDBCCMPFieldBridge) field; if(!cmpField.isLoaded(ctx)) { if(log.isTraceEnabled()) { log.trace("Preloading data:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId() + " cmpField=" + cmpField.getFieldName()); } // set the value cmpField.setInstanceValue(ctx, value); // mark this field clean as it's value was just loaded cmpField.setClean(ctx); loaded = true; } else { if(log.isTraceEnabled()) { log.trace("CMPField already loaded:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId() + " cmpField=" + cmpField.getFieldName()); } } } else if(field instanceof JDBCCMRFieldBridge) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) field; if(!cmrField.isLoaded(ctx)) { if(log.isTraceEnabled()) { log.trace("Preloading data:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId() + " cmrField=" + cmrField.getFieldName()); } // set the value cmrField.load(ctx, (List) value); // add the loaded list to the related entity's readahead cache JDBCStoreManager relatedManager = (JDBCStoreManager) cmrField.getRelatedCMRField().getManager(); ReadAheadCache relatedReadAheadCache = relatedManager.getReadAheadCache(); relatedReadAheadCache.addFinderResults( (List) value, cmrField.getReadAhead()); if(!loaded) { // this is a hack to fix on-load read-ahead for 1:m relationships if(cmrField.isSingleValued() && onlyOneSingleValuedCMR == null) { onlyOneSingleValuedCMR = cmrField; } else { loaded = true; } } } else { if(log.isTraceEnabled()) { log.trace("CMRField already loaded:" + " entity=" + manager.getEntityBridge().getEntityName() + " pk=" + ctx.getId() + " cmrField=" + cmrField.getFieldName()); } } } } if(cleanReadAhead) { // remove all preload data map as all of the data has been loaded manager.removeEntityTxData(new PreloadKey(ctx.getId())); } return loaded; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
public Transaction getTransaction() { try { return transactionManager.getTransaction(); } catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
private void verifyParameterEntityType(int number, JDBCEntityBridge entity) { Class parameterType = getParameterType(number); Class remoteClass = entity.getMetaData().getRemoteClass(); Class localClass = entity.getMetaData().getLocalClass(); if(( localClass == null || !localClass.isAssignableFrom(parameterType) ) && ( remoteClass == null || !remoteClass.isAssignableFrom(parameterType) )) { throw new IllegalStateException("Only like types can be " + "compared: from entity=" + entity.getEntityName() + " to parameter type=" + parameterType); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
private void compareEntity(boolean not, Node fromNode, Node toNode, StringBuffer buf) { buf.append('('); if(not) { buf.append(SQLUtil.NOT).append('('); } String fromAlias; JDBCEntityBridge fromEntity; ASTPath fromPath = (ASTPath) fromNode; addJoinPath(fromPath); fromAlias = aliasManager.getAlias(fromPath.getPath()); fromEntity = (JDBCEntityBridge) fromPath.getEntity(); if(toNode instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) toNode; // can only compare like kind entities verifyParameterEntityType(toParam.number, fromEntity); inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromEntity)); SQLUtil.getWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, buf); } else { String toAlias; JDBCEntityBridge toEntity; ASTPath toPath = (ASTPath) toNode; addJoinPath(toPath); toAlias = aliasManager.getAlias(toPath.getPath()); toEntity = (JDBCEntityBridge) toPath.getEntity(); // can only compare like kind entities if(!fromEntity.equals(toEntity)) { throw new IllegalStateException("Only like types can be " + "compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toEntity.getEntityName()); } SQLUtil.getSelfCompareWhereClause(fromEntity.getPrimaryKeyFields(), fromAlias, toAlias, buf); } if(not) { buf.append(')'); } buf.append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTSelect node, Object data) { StringBuffer buf = (StringBuffer) data; Node child0 = node.jjtGetChild(0); ASTPath path; if(child0 instanceof ASTPath) { path = (ASTPath) child0; if(path.isCMPField()) { // set the select object JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge) path.getCMPField(); selectManager = (JDBCStoreManager) selectField.getManager(); selectObject = selectField; setTypeFactory(selectManager.getJDBCTypeFactory()); addJoinPath(path); selectAlias = aliasManager.getAlias(path.getPath(path.size() - 2)); SQLUtil.getColumnNamesClause(selectField, selectAlias, buf); } else { // set the select object JDBCEntityBridge selectEntity = (JDBCEntityBridge) path.getEntity(); selectManager = (JDBCStoreManager) selectEntity.getManager(); selectObject = selectEntity; setTypeFactory(selectManager.getJDBCTypeFactory()); selectEntity(path, node.distinct, buf); } } else { // the function should take a path expresion as a parameter path = getPathFromChildren(child0); if(path == null) { throw new IllegalStateException("The function in SELECT clause does not contain a path expression."); } if(path.isCMPField()) { JDBCCMPFieldBridge selectField = (JDBCCMPFieldBridge) path.getCMPField(); selectManager = (JDBCStoreManager) selectField.getManager(); if(selectField.getJDBCType().hasMapper()) this.functionJDBCType = selectField.getJDBCType(); } else if(path.isCMRField()) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) path.getCMRField(); selectManager = (JDBCStoreManager) cmrField.getEntity().getManager(); addJoinPath(path); } else { final JDBCEntityBridge entity = (JDBCEntityBridge) path.getEntity(); selectManager = (JDBCStoreManager) entity.getManager(); addJoinPath(path); } setTypeFactory(selectManager.getJDBCTypeFactory()); selectObject = child0; child0.jjtAccept(this, buf); } return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTNullComparison node, Object data) { StringBuffer buf = (StringBuffer) data; final Node child0 = node.jjtGetChild(0); if(child0 instanceof ASTPath) { ASTPath path = (ASTPath) child0; if(path.isCMRField()) { JDBCCMRFieldBridge cmrField = (JDBCCMRFieldBridge) path.getCMRField(); if(cmrField.getRelationMetaData().isTableMappingStyle()) { existsClause(path, buf, !node.not); return buf; } } String alias = aliasManager.getAlias(path.getPath(path.size() - 2)); JDBCFieldBridge field = (JDBCFieldBridge) path.getField(); // if jdbc type is null then it should be a cmr field in // a one-to-one mapping that isn't a foreign key. // handle it the way the IS EMPTY on the one side of one-to-many // relationship is handled if(field.getJDBCType() == null) { existsClause(path, buf, !node.not); return buf; } // check the path for cmr fields and add them to join paths if(path.fieldList.size() > 2) { for(int i = 0; i < path.fieldList.size(); ++i) { Object pathEl = path.fieldList.get(i); if(pathEl instanceof JDBCCMRFieldBridge) { addJoinPath(path); break; } } } buf = SQLUtil.getIsNullClause(node.not, field, alias, buf); } else if(child0 instanceof ASTParameter) { ASTParameter param = (ASTParameter) child0; Class type = getParameterType(param.number); QueryParameter queryParam = new QueryParameter(param.number - 1, typeFactory.getJDBCType(type)); inputParameters.add(queryParam); buf.append("? IS "); if(node.not) { buf.append(SQLUtil.NOT); } buf.append(SQLUtil.NULL); } else { throw new IllegalStateException("Unexpected node in IS NULL clause: " + node); } return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTMemberOf node, Object data) { StringBuffer buf = (StringBuffer) data; // setup compare to vars first, so we can compre types in from vars ASTPath toPath = (ASTPath) node.jjtGetChild(1); JDBCCMRFieldBridge toCMRField = (JDBCCMRFieldBridge) toPath.getCMRField(); JDBCEntityBridge toChildEntity = (JDBCEntityBridge) toPath.getEntity(); String pathStr = toPath.getPath(toPath.size() - 2); String toParentAlias = aliasManager.getAlias(pathStr); String toChildAlias = aliasManager.getAlias(toPath.getPath()); String relationTableAlias = null; if(toCMRField.getRelationMetaData().isTableMappingStyle()) { relationTableAlias = aliasManager.getRelationTableAlias(toPath.getPath()); } // setup from variables String fromAlias = null; int fromParamNumber = -1; if(node.jjtGetChild(0) instanceof ASTParameter) { ASTParameter fromParam = (ASTParameter) node.jjtGetChild(0); // can only compare like kind entities verifyParameterEntityType(fromParam.number, toChildEntity); fromParamNumber = fromParam.number; } else { ASTPath fromPath = (ASTPath) node.jjtGetChild(0); addJoinPath(fromPath); JDBCEntityBridge fromEntity = (JDBCEntityBridge) fromPath.getEntity(); fromAlias = aliasManager.getAlias(fromPath.getPath()); // can only compare like kind entities if(!fromEntity.equals(toChildEntity)) { throw new IllegalStateException("Only like types can be " + "compared: from entity=" + fromEntity.getEntityName() + " to entity=" + toChildEntity.getEntityName()); } } // add the path to the list of paths to left join addLeftJoinPath(pathStr, toPath); // first part makes toChild not in toParent.child if(!subquerySupported) { addJoinPath(toPath); // subquery not supported; use a left join and is not null if(node.not) { buf.append(SQLUtil.NOT); } buf.append('('); if(relationTableAlias == null) { SQLUtil.getIsNullClause(true, toChildEntity.getPrimaryKeyFields(), toChildAlias, buf); } else { SQLUtil.getIsNullClause(true, toCMRField.getTableKeyFields(), relationTableAlias, buf); } } else { // subquery supported; use exists subquery if(node.not) { buf.append(SQLUtil.NOT); } buf.append(SQLUtil.EXISTS).append('('); if(relationTableAlias == null) { buf.append(SQLUtil.SELECT); SQLUtil.getColumnNamesClause(toChildEntity.getPrimaryKeyFields(), toChildAlias, buf) .append(SQLUtil.FROM) .append(toChildEntity.getQualifiedTableName()) .append(' ') .append(toChildAlias) .append(SQLUtil.WHERE); SQLUtil.getJoinClause(toCMRField, toParentAlias, toChildAlias, buf); } else { buf.append(SQLUtil.SELECT); SQLUtil.getColumnNamesClause(toCMRField.getRelatedCMRField().getTableKeyFields(), relationTableAlias, buf) .append(SQLUtil.FROM) .append(toCMRField.getQualifiedTableName()) .append(' ') .append(relationTableAlias) .append(SQLUtil.WHERE); SQLUtil.getRelationTableJoinClause(toCMRField, toParentAlias, relationTableAlias, buf); } } buf.append(SQLUtil.AND); // second part makes fromNode equal toChild if(fromAlias != null) { // compre pk to pk if(relationTableAlias == null) { SQLUtil.getSelfCompareWhereClause(toChildEntity.getPrimaryKeyFields(), toChildAlias, fromAlias, buf); } else { SQLUtil.getRelationTableJoinClause(toCMRField.getRelatedCMRField(), fromAlias, relationTableAlias, buf); } } else { // add the parameters inputParameters.addAll(QueryParameter.createParameters(fromParamNumber - 1, toChildEntity)); // compare pk to parameter if(relationTableAlias == null) { SQLUtil.getWhereClause(toChildEntity.getPrimaryKeyFields(), toChildAlias, buf); } else { SQLUtil.getWhereClause(toCMRField.getRelatedCMRField().getTableKeyFields(), relationTableAlias, buf); } } buf.append(')'); return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTValueClassComparison node, Object data) { StringBuffer buf = (StringBuffer) data; boolean not = (node.opp.equals(SQLUtil.NOT_EQUAL)); String comparison = node.opp; buf.append('('); if(not) { buf.append(SQLUtil.NOT).append('('); comparison = "="; } // setup the from path ASTPath fromPath = (ASTPath) node.jjtGetChild(0); addJoinPath(fromPath); String fromAlias = aliasManager.getAlias(fromPath.getPath(fromPath.size() - 2)); JDBCCMPFieldBridge fromCMPField = (JDBCCMPFieldBridge) fromPath.getCMPField(); Node toNode = node.jjtGetChild(1); if(toNode instanceof ASTParameter) { ASTParameter toParam = (ASTParameter) toNode; // can only compare like kind entities Class parameterType = getParameterType(toParam.number); if(!(fromCMPField.getFieldType().equals(parameterType))) { throw new IllegalStateException("Only like types can be " + "compared: from CMP field=" + fromCMPField.getFieldType() + " to parameter=" + parameterType); } inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromCMPField)); SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, comparison, buf); } else { ASTPath toPath = (ASTPath) toNode; addJoinPath(toPath); String toAlias = aliasManager.getAlias(toPath.getPath(toPath.size() - 2)); JDBCCMPFieldBridge toCMPField = (JDBCCMPFieldBridge) toPath.getCMPField(); // can only compare like kind entities if(!(fromCMPField.getFieldType().equals(toCMPField.getFieldType()))) { throw new IllegalStateException("Only like types can be " + "compared: from CMP field=" + fromCMPField.getFieldType() + " to CMP field=" + toCMPField.getFieldType()); } SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, comparison, buf); } return (not ? buf.append(')') : buf).append(')'); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTPath node, Object data) { StringBuffer buf = (StringBuffer) data; if(!node.isCMPField()) { throw new IllegalStateException("Can only visit cmp valued path " + "node. Should have been handled at a higher level."); } JDBCCMPFieldBridge cmpField = (JDBCCMPFieldBridge) node.getCMPField(); // make sure this is mapped to a single column switch(node.type) { case EJBQLTypes.ENTITY_TYPE: case EJBQLTypes.VALUE_CLASS_TYPE: if(cmpField.getJDBCType().hasMapper() || cmpField.getJDBCType().getParameterSetter() != null) { break; } case EJBQLTypes.UNKNOWN_TYPE: throw new IllegalStateException("Can not visit multi-column path " + "node. Should have been handled at a higher level."); } addJoinPath(node); String alias = aliasManager.getAlias(node.getPath(node.size() - 2)); SQLUtil.getColumnNamesClause(cmpField, alias, buf); return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTAbstractSchema node, Object data) { throw new IllegalStateException("Can not visit abstract schema node. " + "Should have been handled at a higher level."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTParameter node, Object data) { StringBuffer buf = (StringBuffer) data; Class type = getParameterType(node.number); // make sure this is mapped to a single column int ejbqlType = EJBQLTypes.getEJBQLType(type); if(ejbqlType == EJBQLTypes.ENTITY_TYPE || ejbqlType == EJBQLTypes.VALUE_CLASS_TYPE || ejbqlType == EJBQLTypes.UNKNOWN_TYPE) { throw new IllegalStateException("Can not visit multi-column " + "parameter node. Should have been handled at a higher level."); } QueryParameter param = new QueryParameter(node.number - 1, typeFactory.getJDBCType(type)); inputParameters.add(param); buf.append('?'); return buf; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
private void selectEntity(ASTPath path, boolean distinct, StringBuffer buf) { JDBCEntityBridge selectEntity = (JDBCEntityBridge) path.getEntity(); StringBuffer columnNamesClause = new StringBuffer(200); addJoinPath(path); selectAlias = aliasManager.getAlias(path.getPath()); // get a list of all fields to be loaded // get the identifier for this field SQLUtil.getColumnNamesClause(selectEntity.getPrimaryKeyFields(), selectAlias, columnNamesClause); if(readAhead.isOnFind()) { String eagerLoadGroupName = readAhead.getEagerLoadGroup(); boolean[] loadGroupMask = selectEntity.getLoadGroupMask(eagerLoadGroupName); if(distinct) SQLUtil.appendSearchableColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, selectAlias, columnNamesClause); else SQLUtil.appendColumnNamesClause(selectEntity.getTableFields(), loadGroupMask, selectAlias, columnNamesClause); try { leftJoinCMRList = JDBCAbstractQueryCommand.getLeftJoinCMRNodes( selectEntity, path.getPath(), readAhead.getLeftJoins(), declaredPaths); } catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); } if(!leftJoinCMRList.isEmpty()) { onFindCMRJoin = new StringBuffer(100); JDBCAbstractQueryCommand.leftJoinCMRNodes(selectAlias, leftJoinCMRList, aliasManager, onFindCMRJoin); JDBCAbstractQueryCommand.appendLeftJoinCMRColumnNames(leftJoinCMRList, aliasManager, columnNamesClause); } } buf.append(columnNamesClause); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public boolean[] getLoadGroupMask(String name) { boolean[] mask = (boolean[])loadGroupMasks.get(name); if(mask == null) { throw new IllegalStateException( "Load group '" + name + "' is not defined. Defined load groups: " + loadGroupMasks.keySet() ); } return mask; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
private static EntityState getEntityState(EntityEnterpriseContext ctx) { JDBCContext jdbcCtx = (JDBCContext)ctx.getPersistenceContext(); EntityState entityState = jdbcCtx.getEntityState(); if(entityState == null) throw new IllegalStateException("Entity state is null."); return entityState; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP2xFieldBridge.java
public void setInstanceValue(EntityEnterpriseContext ctx, Object value) { FieldState fieldState = getFieldState(ctx); // update current value if(cmpFieldIAmMappedTo != null && cmpFieldIAmMappedTo.isPrimaryKeyMember()) { // if this field shares the column with the primary key field and new value // changes the primary key then we are in an illegal state. if(value != null) { if(fieldState.isLoaded() && fieldState.isValueChanged(value)) { throw new IllegalStateException( "New value [" + value + "] of a foreign key field " + getFieldName() + " changed the value of a primary key field " + cmpFieldIAmMappedTo.getFieldName() + "[" + fieldState.value + "]" ); } else { fieldState.setValue(value); } } } else { if(cmrChainLink != null && JDBCEntityBridge.isEjbCreateDone(ctx) && fieldState.isLoaded() && fieldState.isValueChanged(value)) { cmrChainLink.execute(ctx, fieldState, value); } fieldState.setValue(value); } // we are loading the field right now so it isLoaded fieldState.setLoaded(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMR field cannot be set " + "in ejbCreate; this should be done in the ejbPostCreate " + "method instead [EJB 2.0 Spec. 10.5.2]."); } if(isCollectionValued() && value == null) { throw new IllegalArgumentException("null cannot be assigned to a " + "collection-valued cmr-field [EJB 2.0 Spec. 10.3.8]."); } /* if(allFKFieldsMappedToPKFields) { throw new IllegalStateException( "Can't modify relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]."); } */ setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void checkSetForeignKey(EntityEnterpriseContext myCtx, Object newValue) throws IllegalStateException { JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCCMP2xFieldBridge pkField = (JDBCCMP2xFieldBridge) pkFields[i]; JDBCCMP2xFieldBridge relatedPkField = (JDBCCMP2xFieldBridge) relatedPKFieldsByMyPKFields.get(pkField); if(relatedPkField != null) { Object comingValue = relatedPkField.getPrimaryKeyValue(newValue); Object currentValue = pkField.getInstanceValue(myCtx); // they shouldn't be null if(!comingValue.equals(currentValue)) { throw new IllegalStateException("Can't create relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]." + " primary key value is " + currentValue + " overriding value is " + comingValue); } } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void addRelation(EntityEnterpriseContext myCtx, Object fk, boolean updateForeignKey) { checkSetForeignKey(myCtx, fk); if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } if(!JDBCEntityBridge.isEjbCreateDone(myCtx)) { throw new IllegalStateException("A CMR field cannot be set or added " + "to a relationship in ejbCreate; this should be done in the " + "ejbPostCreate method instead [EJB 2.0 Spec. 10.5.2]."); } // add to current related set FieldState myState = getFieldState(myCtx); myState.addRelation(fk); // set the foreign key, if we have one. if(hasForeignKey() && updateForeignKey) { setForeignKey(myCtx, fk); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { //return SecurityAssociation.peekRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); return sc.getOutgoingRunAs(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { //return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { //SecurityAssociation.pushRunAsIdentity((RunAsIdentity)id); SecurityContext sa = SecurityContextAssociation.getSecurityContext(); if(sa == null) throw new IllegalStateException("Security Context is null to push runas"); sa.setOutgoingRunAs(id); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public RunAs peek() { //return SecurityAssociation.peekRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); return sc.getOutgoingRunAs(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public void push(RunAs id) { //SecurityAssociation.pushRunAsIdentity(id); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null to push runas"); sc.setOutgoingRunAs(id); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public RunAs pop() { //Pop the RAI // return SecurityAssociation.popRunAsIdentity(); SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); RunAs ra = null; ra = sc.getOutgoingRunAs(); sc.setOutgoingRunAs(null); return ra; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.getUtil().createSubjectInfo(p, cred, s); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { SecurityContext sc = getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); Principal p = sc.getUtil().getUserPrincipal(); Object cred = sc.getUtil().getCredential(); sc.getUtil().createSubjectInfo(p, cred,null); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(ra); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(null); return null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
private List getIdList() { if(setHandle[0] == null) { throw new IllegalStateException("A CMR collection may only be used " + "within the transction in which it was created"); } return setHandle[0]; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public boolean hasNext() { verifyIteratorIsValid(); try { return idIterator.hasNext(); } catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public Object next() { verifyIteratorIsValid(); try { currentId = idIterator.next(); return localFactory.getEntityEJBLocalObject(currentId); } catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
public void remove() { verifyIteratorIsValid(); if(readOnly) { throw new EJBException("This collection is a read-only snapshot"); } if(cmrField.isReadOnly()) { throw new EJBException("Field is read-only: " + cmrField.getFieldName()); } checkForPKChange(); try { idIterator.remove(); cmrField.destroyRelationLinks(ctx, currentId, false); } catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
private void verifyIteratorIsValid() { if(setHandle[0] == null) { throw new IllegalStateException("The iterator of a CMR " + "collection may only be used within the transction in " + "which it was created"); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
public void setValue(EntityEnterpriseContext ctx, Object value) { if(isReadOnly()) { throw new EJBException("Field is read-only: fieldName=" + fieldName); } if(primaryKeyMember && JDBCEntityBridge.isEjbCreateDone(ctx)) { throw new IllegalStateException("A CMP field that is a member " + "of the primary key can only be set in ejbCreate " + "[EJB 2.0 Spec. 10.3.5]."); } if(ctx.isValid()) { if(!isLoaded(ctx)) { // the field must be loaded for dirty cheking to work properly manager.loadField(this, ctx); } lockingStrategy.changed(this, ctx); } setInstanceValue(ctx, value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadRelationCommand.java
private JDBCFunctionMappingMetaData getSelectTemplate(JDBCCMRFieldBridge cmrField) throws DeploymentException { JDBCFunctionMappingMetaData selectTemplate = null; if(cmrField.getRelationMetaData().isTableMappingStyle()) { // relation table if(cmrField.getRelationMetaData().hasRowLocking()) { selectTemplate = cmrField.getRelationMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } else if(cmrField.getRelatedCMRField().hasForeignKey()) { // related has foreign key if(cmrField.getRelatedJDBCEntity().getMetaData().hasRowLocking()) { selectTemplate = cmrField.getRelatedJDBCEntity().getMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } else { // i have foreign key if(entity.getMetaData().hasRowLocking()) { selectTemplate = entity.getMetaData().getTypeMapping().getRowLockingTemplate(); if(selectTemplate == null) { throw new IllegalStateException( "row-locking is not allowed for this type of datastore"); } } } return selectTemplate; }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private Object process(Invocation mi, boolean isInvoke) throws Exception { if (this.shouldBypassSecurity(mi)) { if (log.isTraceEnabled()) log.trace("Bypass security for invoke or invokeHome"); if (isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } SecurityContext sc = SecurityActions.getSecurityContext(); if (sc == null) throw new IllegalStateException("Security Context is null"); RunAs callerRunAsIdentity = sc.getIncomingRunAs(); if (log.isTraceEnabled()) log.trace("Caller RunAs=" + callerRunAsIdentity + ": useCallerIdentity=" + this.isUseCallerIdentity); // Authenticate the subject and apply any declarative security checks try { checkSecurityContext(mi, callerRunAsIdentity); } catch (Exception e) { log.error("Error in Security Interceptor", e); throw e; } RunAs runAsIdentityToPush = runAsIdentity; /** * Special case: if <use-caller-identity> configured and * the caller is arriving with a run-as, we need to push that run-as */ if (callerRunAsIdentity != null && this.isUseCallerIdentity) runAsIdentityToPush = callerRunAsIdentity; /* If a run-as role was specified, push it so that any calls made by this bean will have the runAsRole available for declarative security checks. */ SecurityActions.pushRunAsIdentity(runAsIdentityToPush); try { if (isInvoke) return getNext().invoke(mi); else return getNext().invokeHome(mi); } finally { SecurityActions.popRunAsIdentity(); SecurityActions.popSubjectContext(); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private void checkSecurityContext(Invocation mi, RunAs callerRunAsIdentity) throws Exception { Principal principal = mi.getPrincipal(); Object credential = mi.getCredential(); boolean trace = log.isTraceEnabled(); // If there is not a security manager then there is no authentication required Method m = mi.getMethod(); boolean containerMethod = m == null || m.equals(ejbTimeout); if (containerMethod == true || securityManager == null || container == null) { // Allow for the propagation of caller info to other beans SecurityActions.pushSubjectContext(principal, credential, null); return; } if (realmMapping == null) { throw new SecurityException("Role mapping manager has not been set"); } SecurityContext sc = SecurityActions.getSecurityContext(); EJBAuthenticationHelper helper = SecurityHelperFactory.getEJBAuthenticationHelper(sc); boolean isTrusted = containsTrustableRunAs(sc) || helper.isTrusted(); if (!isTrusted) { // Check the security info from the method invocation Subject subject = new Subject(); if (SecurityActions.isValid(helper, subject, m.getName()) == false) { // Notify authentication observer if (authenticationObserver != null) authenticationObserver.authenticationFailed(); // Else throw a generic SecurityException String msg = "Authentication exception, principal=" + principal; throw new SecurityException(msg); } else { SecurityActions.pushSubjectContext(principal, credential, subject); if (trace) { log.trace("Authenticated principal=" + principal + " in security domain=" + sc.getSecurityDomain()); } } } else { // Duplicate the current subject context on the stack since //SecurityActions.dupSubjectContext(); SecurityActions.pushRunAsIdentity(callerRunAsIdentity); } Method ejbMethod = mi.getMethod(); // Ignore internal container calls if (ejbMethod == null) return; // Get the caller Subject caller = SecurityActions.getContextSubject(); if (caller == null) throw new IllegalStateException("Authenticated User. But caller subject is null"); //Establish the deployment rolename-principalset custom mapping(if available) SecurityRolesAssociation.setSecurityRoles(this.deploymentRoles); boolean isAuthorized = false; Set<Principal> methodRoles = container.getMethodPermissions(ejbMethod, mi.getType()); SecurityContext currentSC = SecurityActions.getSecurityContext(); if (SecurityActions.getSecurityManagement(currentSC) == null) SecurityActions.setSecurityManagement(currentSC, securityManagement); AbstractEJBAuthorizationHelper authorizationHelper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); authorizationHelper.setPolicyRegistration(container.getPolicyRegistration()); isAuthorized = SecurityActions.authorize(authorizationHelper, ejbName, ejbMethod, mi.getPrincipal(), mi.getType().toInterfaceString(), ejbCS, caller, callerRunAsIdentity, container.getJaccContextID(), new SimpleRoleGroup(methodRoles)); if (!isAuthorized) { String msg = "Denied: caller with subject=" + caller + " and security context post-mapping roles=" + SecurityActions.getRolesFromSecurityContext(currentSC) + ": ejbMethod=" + ejbMethod; throw new SecurityException(msg); } }
// in src/main/java/org/jboss/ejb/plugins/security/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(ra); return null; }
// in src/main/java/org/jboss/ejb/plugins/security/SecurityActions.java
public Object run() { SecurityContext sc = SecurityContextAssociation.getSecurityContext(); if(sc == null) throw new IllegalStateException("Security Context is null"); sc.setIncomingRunAs(null); return null; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
public void start() { // This is in here so that EntityMultiInstanceInterceptor can avoid doing a lock.sync(). // if (!container.getLockManager().lockClass.equals(org.jboss.ejb.plugins.lock.NoLock.class) && !container.getLockManager().lockClass.equals(org.jboss.ejb.plugins.lock.JDBCOptimisticLock.class) && !container.getLockManager().lockClass.equals(org.jboss.ejb.plugins.lock.MethodOnlyEJBLock.class) ) { throw new IllegalStateException("the <locking-policy> must be org.jboss.ejb.plugins.lock.NoLock, JDBCOptimisticLock, or MethodOnlyEJBLock for Instance Per Transaction:" + container.getLockManager().lockClass.getName()); } }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceSynchronizationInterceptor.java
public void afterCompletion(int status) { boolean trace = log.isTraceEnabled(); // This is an independent point of entry. We need to make sure the // thread is associated with the right context class loader ClassLoader oldCl = SecurityActions.getContextClassLoader(); SecurityActions.setContextClassLoader(container.getClassLoader()); container.pushENC(); ctx.hasTxSynchronization(false); ctx.setTransaction(null); try { try { // If rolled back -> invalidate instance if (status != Status.STATUS_ROLLEDBACK) { switch (commitOption) { // Keep instance cached after tx commit case ConfigurationMetaData.A_COMMIT_OPTION: throw new IllegalStateException("Commit option A not allowed with this Interceptor"); // Keep instance active, but invalidate state case ConfigurationMetaData.B_COMMIT_OPTION: break; // Invalidate everything AND Passivate instance case ConfigurationMetaData.C_COMMIT_OPTION: break; case ConfigurationMetaData.D_COMMIT_OPTION: throw new IllegalStateException("Commit option D not allowed with this Interceptor"); } } try { if (ctx.getId() != null) container.getPersistenceManager().passivateEntity(ctx); } catch (Exception ignored) { } container.getInstancePool().free(ctx); } finally { if (trace) log.trace("afterCompletion, clear tx for ctx=" + ctx + ", tx=" + tx); } } // synchronized(lock) finally { container.popENC(); SecurityActions.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBHome getEJBHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return (EJBHome) ci.getEJBHome(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public boolean isIdentical(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.isIdentical(this, mi); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object find(Invocation mi) throws Exception { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Method method = mi.getMethod(); Object[] args = mi.getArguments(); EntityEnterpriseContext instance = (EntityEnterpriseContext)mi.getEnterpriseContext(); boolean syncOnCommitOnly = metaData.getContainerConfiguration().getSyncOnCommitOnly(); Transaction tx = mi.getTransaction(); Class returnType = method.getReturnType(); if (Collection.class.isAssignableFrom(returnType) || returnType == Enumeration.class) { // as per the spec 9.6.4, entities must be synchronized with the datastore when an ejbFind<METHOD> is called. if (!syncOnCommitOnly) { synchronizeEntitiesWithinTransaction(tx); } // Iterator finder Collection c = getPersistenceManager().findEntities(method, args, instance, ci); // BMP entity finder methods are allowed to return java.util.Enumeration. // We need a serializable Enumeration, so we can't use Collections.enumeration() if (returnType == Enumeration.class) { return new SerializableEnumeration(c); } else { return c; } } else { return findSingleObject(tx, method, args, instance, ci); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } // All we need is an EJBObject for this Id; return (EJBObject)ci.getEntityEJBObject(((EntityCache) instanceCache).createCacheKey(mi.getId())); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBMetaData getEJBMetaDataHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.getEJBMetaData(); }
// in src/main/java/org/jboss/ejb/AllowedOperationsAssociation.java
public static void assertAllowedIn(String ctxMethod, int flags) { Stack inMethodStack = (Stack)threadLocal.get(); // Strict validation, the caller MUST set the in method flag if (inMethodStack.empty()) { throw new IllegalStateException("Cannot obtain inMethodFlag for: " + ctxMethod); } // The container should push a method flag into the context just before // a call to the instance method if (inMethodStack.empty() == false) { // Check if the given ctxMethod can be called from the ejb instance // this relies on the inMethodFlag being pushed prior to the call to the ejb method Integer inMethodFlag = ((Integer) inMethodStack.peek()); if ((inMethodFlag.intValue() & flags) == 0 && inMethodFlag.intValue() != IN_INTERCEPTOR_METHOD) { String message = ctxMethod + " should not be access from this bean method: " + methodMap.get(inMethodFlag); IllegalStateException ex = new IllegalStateException(message); log.error(message + ", allowed is " + getAllowedMethodList(flags), ex); throw ex; } } }
// in src/main/java/org/jboss/as/naming/javaee/NamingJavaEEComponentInformer.java
public String getComponentName(DeploymentUnit unit) { // FIXME: it's real ugly to analyze the deployment unit at this stage. Better to let the ComponentNamingDeployer be explicitly driven by meta data. JBossEnterpriseBeanMetaData ejb = unit.getAttachment(JBossEnterpriseBeanMetaData.class); JBossServletMetaData servlet = unit.getAttachment(JBossServletMetaData.class); assert ejb != null || servlet != null : "borked deployment unit " + unit; if(ejb != null) return ejb.getEjbName(); if(servlet != null) return servlet.getServletName(); throw new IllegalStateException("Deployment unit " + unit + " has no known component meta data"); }
// in src/main/java/org/jboss/executor/ThreadPoolExecutorFactory.java
private ThreadPoolExecutor createExecutor() { int coreSize = Math.max(calcPoolSize(corePoolSizeBase, corePoolSizePerCpu), 0); if (coreSize == 0) { throw new IllegalStateException("Core size was calculated to 0"); } int maxSize = Math.max(calcPoolSize(maxPoolSizeBase, maxPoolSizePerCpu), 0); if (maxSize == 0) { throw new IllegalStateException("Max size was calculated to 0"); } BlockingQueue<Runnable> queue = workQueue == null ? new LinkedBlockingQueue<Runnable>() : workQueue; ThreadFactory factory = threadFactory == null ? DEFAULT_THREAD_FACTORY : threadFactory; RejectedExecutionHandler handler = rejectedExecutionHandler == null ? DEFAULT_REJECTED_EXECUTION_HANDLER : rejectedExecutionHandler; return new ThreadPoolExecutor(coreSize, maxSize, keepAliveTime, keepAliveTimeUnit, queue, factory, handler); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public String getDefaultSecurityDomain() { if (defaultSecurityDomain == null) throw new IllegalStateException("Default Security Domain is null"); return defaultSecurityDomain; }
// in src/main/java/org/jboss/web/deployers/WebModule.java
public synchronized void startModule() throws Exception { if (this.unit == null || this.container == null || this.deployment == null) throw new IllegalStateException("WebModules cannot be restarted, and must be redeployed"); // Get the war URL JBossWebMetaData metaData = unit.getAttachment(JBossWebMetaData.class); WebApplication webApp = deployment.start(unit, metaData); String warURL = unit.getName(); container.addDeployedApp(warURL, webApp); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
protected boolean isBeforeInternal(Ordering ordering, Set<Ordering> checked) { checked.add(this); if (before.contains(ordering)) { return true; } Iterator<Ordering> beforeIterator = before.iterator(); while (beforeIterator.hasNext()) { Ordering check = beforeIterator.next(); if (checked.contains(check)) { //throw new IllegalStateException(sm.getString("ordering.orderConflict", this.ordering.getJar())); throw new IllegalStateException("Ordering conflict with JAR: " + this.ordering.getJar()); } if (check.isBeforeInternal(ordering, checked)) { return false; } } return false; }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
protected boolean isAfterInternal(Ordering ordering, Set<Ordering> checked) { checked.add(this); if (after.contains(ordering)) { return true; } Iterator<Ordering> afterIterator = after.iterator(); while (afterIterator.hasNext()) { Ordering check = afterIterator.next(); if (checked.contains(check)) { //throw new IllegalStateException(sm.getString("ordering.orderConflict", this.ordering.getJar())); throw new IllegalStateException("Ordering conflict with JAR: " + this.ordering.getJar()); } if (check.isAfterInternal(ordering, checked)) { return false; } } return false; }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
public boolean isLastBeforeOthers() { if (!beforeOthers) { throw new IllegalStateException(); } Iterator<Ordering> beforeIterator = before.iterator(); while (beforeIterator.hasNext()) { Ordering check = beforeIterator.next(); if (!check.beforeOthers) { return true; } else if (check.isLastBeforeOthers()) { return true; } } return false; }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
public boolean isFirstAfterOthers() { if (!afterOthers) { throw new IllegalStateException(); } Iterator<Ordering> afterIterator = after.iterator(); while (afterIterator.hasNext()) { Ordering check = afterIterator.next(); if (!check.afterOthers) { return true; } else if (check.isFirstAfterOthers()) { return true; } } return false; }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
protected static void resolveOrder(List<WebOrdering> webOrderings, List<String> order) { List<Ordering> work = new ArrayList<Ordering>(); // Populate the work Ordering list Iterator<WebOrdering> webOrderingsIterator = webOrderings.iterator(); while (webOrderingsIterator.hasNext()) { WebOrdering webOrdering = webOrderingsIterator.next(); Ordering ordering = new Ordering(); ordering.ordering = webOrdering; ordering.afterOthers = webOrdering.isAfterOthers(); ordering.beforeOthers = webOrdering.isBeforeOthers(); if (ordering.afterOthers && ordering.beforeOthers) { // Cannot be both after and before others //throw new IllegalStateException(sm.getString("ordering.afterAndBeforeOthers", webOrdering.getJar())); throw new IllegalStateException("Ordering includes both before and after others in JAR: " + webOrdering.getJar()); } work.add(ordering); } // Create double linked relationships between the orderings, // and resolve names Iterator<Ordering> workIterator = work.iterator(); while (workIterator.hasNext()) { Ordering ordering = workIterator.next(); WebOrdering webOrdering = ordering.ordering; Iterator<String> after = webOrdering.getAfter().iterator(); while (after.hasNext()) { String name = after.next(); Iterator<Ordering> workIterator2 = work.iterator(); boolean found = false; while (workIterator2.hasNext()) { Ordering ordering2 = workIterator2.next(); if (name.equals(ordering2.ordering.getName())) { if (found) { // Duplicate name //throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar())); throw new IllegalStateException("Duplicate name declared in JAR: " + webOrdering.getJar()); } ordering.addAfter(ordering2); ordering2.addBefore(ordering); found = true; } } } Iterator<String> before = webOrdering.getBefore().iterator(); while (before.hasNext()) { String name = before.next(); Iterator<Ordering> workIterator2 = work.iterator(); boolean found = false; while (workIterator2.hasNext()) { Ordering ordering2 = workIterator2.next(); if (name.equals(ordering2.ordering.getName())) { if (found) { // Duplicate name //throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar())); throw new IllegalStateException("Duplicate name declared in JAR: " + webOrdering.getJar()); } ordering.addBefore(ordering2); ordering2.addAfter(ordering); found = true; } } } } // Validate ordering workIterator = work.iterator(); while (workIterator.hasNext()) { workIterator.next().validate(); } // Create three ordered lists that will then be merged List<Ordering> tempOrder = new ArrayList<Ordering>(); // Create the ordered list of fragments which are before others workIterator = work.iterator(); while (workIterator.hasNext()) { Ordering ordering = workIterator.next(); if (ordering.beforeOthers) { // Insert at the first possible position int insertAfter = -1; boolean last = ordering.isLastBeforeOthers(); int lastBeforeOthers = -1; for (int i = 0; i < tempOrder.size(); i++) { if (ordering.isAfter(tempOrder.get(i))) { insertAfter = i; } if (tempOrder.get(i).beforeOthers) { lastBeforeOthers = i; } } int pos = insertAfter; if (last && lastBeforeOthers > insertAfter) { pos = lastBeforeOthers; } tempOrder.add(pos + 1, ordering); } else if (ordering.afterOthers) { // Insert at the last possible element int insertBefore = tempOrder.size(); boolean first = ordering.isFirstAfterOthers(); int firstAfterOthers = tempOrder.size(); for (int i = tempOrder.size() - 1; i >= 0; i--) { if (ordering.isBefore(tempOrder.get(i))) { insertBefore = i; } if (tempOrder.get(i).afterOthers) { firstAfterOthers = i; } } int pos = insertBefore; if (first && firstAfterOthers < insertBefore) { pos = firstAfterOthers; } tempOrder.add(pos, ordering); } else { // Insert according to other already inserted elements int insertAfter = -1; int insertBefore = tempOrder.size(); for (int i = 0; i < tempOrder.size(); i++) { if (ordering.isAfter(tempOrder.get(i)) || tempOrder.get(i).beforeOthers) { insertAfter = i; } if (ordering.isBefore(tempOrder.get(i)) || tempOrder.get(i).afterOthers) { insertBefore = i; } } if (insertAfter > insertBefore) { // Conflicting order (probably caught earlier) //throw new IllegalStateException(sm.getString("ordering.orderConflict", ordering.ordering.getJar())); throw new IllegalStateException("Fragment ordering conflict with JAR: " + ordering.ordering.getJar()); } // Insert somewhere in the range tempOrder.add(insertAfter + 1, ordering); } } // Create the final ordered list Iterator<Ordering> tempOrderIterator = tempOrder.iterator(); while (tempOrderIterator.hasNext()) { Ordering ordering = tempOrderIterator.next(); order.add(ordering.ordering.getJar()); } }
// in src/main/java/org/jboss/corba/ORBFactory.java
public static void setORB(ORB orb) { if (ORBFactory.orb != null) throw new IllegalStateException("ORB has already been set"); ORBFactory.orb = orb; }
26
            
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new IllegalStateException("Cannot create EJBTimerService proxy: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e) { throw new IllegalStateException("Failed to suspend current transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to begin a new transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(Exception e) { throw new IllegalStateException("Failed to resume transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(ConcurrentModificationException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCXmlFileLoader.java
catch(Exception e) { throw new IllegalStateException("Failed to create URL for " + dd.getPathName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(NoSuchMethodException e) { throw new IllegalStateException( "Failed to find a ctor in " + valueType + " that takes an instance of " + argType + " as an argument." ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(Exception e) { throw new IllegalStateException( "Failed to create an instance of " + valueType + " with the " + fieldValue + " as a ctor argument" ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(ClassNotFoundException e) { throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
catch(DeploymentException e) { throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has " + "been modified"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(ConcurrentModificationException e) { throw new IllegalStateException("Underlying collection has been modified"); }
92
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void rollback() throws SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.rollback(" + tpc + ")"); } try { getSession().rollback(tpc); } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void setRollbackOnly() throws IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.setRollbackOnly(" + tpc + ")"); } try { getSession().setRollbackOnly(tpc); } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void setRollbackOnly(Object tpc) throws RemoteException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); tx.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (duration < 0) throw new IllegalArgumentException("duration is negative"); return createTimer(new Date(System.currentTimeMillis() + duration), 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialDuration < 0) throw new IllegalArgumentException("initial duration is negative"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); return createTimer(new Date(System.currentTimeMillis() + initialDuration), intervalDuration, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (expiration == null) throw new IllegalArgumentException("expiration is null"); return createTimer(expiration, 0, info); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { if (initialExpiration == null) throw new IllegalArgumentException("initial expiration is null"); if (intervalDuration < 0) throw new IllegalArgumentException("interval duration is negative"); try { String timerId = timerIdGenerator.nextTimerId(); TimerImpl timer = new TimerImpl(this, timerId, timedObjectId, timedObjectInvoker, info); persistencePolicy.insertTimer(timerId, timedObjectId, initialExpiration, intervalDuration, info); timer.startTimer(initialExpiration, intervalDuration); return timer; } catch (Exception e) { throw new EJBException("Failed to create timer", e); } }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Collection getTimers() throws IllegalStateException, EJBException { ArrayList activeTimers = new ArrayList(); synchronized (timers) { Iterator it = timers.values().iterator(); while (it.hasNext()) { TimerImpl timer = (TimerImpl)it.next(); if (timer.isActive()) activeTimers.add(timer); } } return activeTimers; }
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
public Timer getTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { EJBTimerService ejbTimerService = EJBTimerServiceLocator.getEjbTimerService(); ObjectName containerId = timedObjectId.getContainerId(); Object instancePk = timedObjectId.getInstancePk(); TimerServiceImpl timerService = (TimerServiceImpl)ejbTimerService.getTimerService(containerId, instancePk); if (timerService == null) throw new NoSuchObjectLocalException("TimerService not available: " + timedObjectId); TimerImpl timer = (TimerImpl)timerService.getTimer(this); if (timer == null || timer.isActive() == false) throw new NoSuchObjectLocalException("Timer not available: " + timedObjectId); return timer; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public void cancel() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.cancel"); registerTimerWithTx(); cancelInTx(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public long getTimeRemaining() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getTimeRemaining"); return nextExpire - System.currentTimeMillis(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Date getNextTimeout() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getNextTimeout"); return new Date(nextExpire); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Serializable getInfo() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getInfo"); return info; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public TimerHandle getHandle() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getHandle"); return new TimerHandleImpl(this); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new IllegalStateException("The object does not implement javax.ejb.TimedObject interface!"); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { return Collections.EMPTY_LIST; }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public void removeTimerService(ObjectName containerId, boolean keepState) throws IllegalStateException { // remove all timers with the given containerId synchronized(timerServiceMap) { Iterator<Map.Entry<TimedObjectId, TimerServiceImpl>> it = timerServiceMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<TimedObjectId, TimerServiceImpl> entry = it.next(); TimedObjectId key = entry.getKey(); TimerServiceImpl timerService = entry.getValue(); if (containerId.equals(key.getContainerId())) { log.debug("removeTimerService: " + timerService); timerService.shutdown(keepState); it.remove(); } } } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public void removeTimerService(ObjectName containerId, Object instancePk, boolean keepState) throws IllegalStateException { // remove a single timer service TimedObjectId timedObjectId = new TimedObjectId(containerId, instancePk); if (timedObjectId.getInstancePk() != null) { TimerServiceImpl timerService = (TimerServiceImpl)getTimerService(containerId, instancePk); if (timerService != null) { log.debug("removeTimerService: " + timerService); timerService.shutdown(false); timerServiceMap.remove(timedObjectId); } } // remove all timers with the given containerId else { synchronized(timerServiceMap) { Iterator<Map.Entry<TimedObjectId, TimerServiceImpl>> it = timerServiceMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<TimedObjectId, TimerServiceImpl> entry = it.next(); TimedObjectId key = (TimedObjectId) entry.getKey(); TimerServiceImpl timerService = (TimerServiceImpl) entry.getValue(); if (containerId.equals(key.getContainerId())) { log.debug("removeTimerService: " + timerService); timerService.shutdown(keepState); it.remove(); } } } } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceImpl.java
public void restoreTimers(ObjectName containerId, ClassLoader loader) throws IllegalStateException { assert persistencePolicy != null : "persistencePolicy is not set"; // find out all the persisted handles, for the specified container List handles = persistencePolicy.listTimerHandles(containerId, loader); if (handles.isEmpty() == false) { // first remove the persisted handles from the db for (Iterator i = handles.iterator(); i.hasNext(); ) { TimerHandleImpl handle = (TimerHandleImpl)i.next(); persistencePolicy.deleteTimer(handle.getTimerId(), handle.getTimedObjectId()); } // make a second pass to re-create the timers; use the container // itself to retrieve the correct TimerService/ for each handle, // then use the standard ejb timer API to recreate the timer for (Iterator i = handles.iterator(); i.hasNext(); ) { TimerHandleImpl handle = (TimerHandleImpl)i.next(); try { TimedObjectId targetId = handle.getTimedObjectId(); ContainerMBean container = (ContainerMBean)MBeanProxyExt.create(ContainerMBean.class, containerId, server); TimerService timerService = container.getTimerService(targetId.getInstancePk()); timerService.createTimer(handle.getFirstTime(), handle.getPeriode(), handle.getInfo()); } catch (Exception e) { log.warn("Unable to restore timer record: " + handle, e); } } } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public TimerService createTimerService(ObjectName containerId, Object instancePk, Container container) throws IllegalStateException { try { TimerService timerService = mbeanEjbTimerService.createTimerService(containerId, instancePk, container); return timerService; } catch (Exception e) { log.error("Cannot createTimerService", e); return null; } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public TimerService createTimerService(ObjectName containerId, Object instancePk, TimedObjectInvoker invoker) throws IllegalStateException { try { TimerService timerService = mbeanEjbTimerService.createTimerService(containerId, instancePk, invoker); return timerService; } catch (Exception e) { log.error("Cannot createTimerService", e); return null; } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public TimerService getTimerService(ObjectName containerId, Object instancePk) throws IllegalStateException { try { TimerService timerService = mbeanEjbTimerService.getTimerService(containerId, instancePk); return timerService; } catch (Exception e) { log.error("Cannot getTimerService", e); return null; } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public void removeTimerService(ObjectName containerId, Object instancePk) throws IllegalStateException { try { mbeanEjbTimerService.removeTimerService(containerId, instancePk); } catch (Exception e) { log.error("Cannot removeTimerService", e); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public void removeTimerService(ObjectName containerId, boolean keepState) throws IllegalStateException { try { mbeanEjbTimerService.removeTimerService(containerId, keepState); } catch (Exception e) { log.error("Cannot removeTimerService", e); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public void restoreTimers(ObjectName containerId, ClassLoader loader) throws IllegalStateException { try { mbeanEjbTimerService.restoreTimers(containerId, loader); } catch (Exception e) { log.error("Cannot restoreTimer", e); } }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Object getBusinessObject(Class businessInterface) throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Class getInvokedBusinessInterface() throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getTimerService", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); return new TimerServiceWrapper(this, super.getTimerService()); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public MessageContext getMessageContext() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getMessageContext", IN_SERVICE_ENDPOINT_METHOD); return soapMessageContext; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getTimerService", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); return new TimerServiceWrapper(this, super.getTimerService()); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/Container.java
public TimerService getTimerService(Object pKey) throws IllegalStateException { if (this instanceof StatefulSessionContainer) throw new IllegalStateException("Statefull Session Beans are not allowed to access the TimerService"); // Validate that the bean implements the TimedObject interface if (TimedObject.class.isAssignableFrom(beanClass) == false) { // jbcts-381 return EJBTimerServiceImpl.FOR_NON_TIMED_OBJECT; } TimerService timerService = null; try { timerService = this.timerService.createTimerService(getJmxName(), pKey, this); } catch (Exception e) { throw new EJBException("Could not create timer service", e); } return timerService; }
// in src/main/java/org/jboss/ejb/Container.java
public void removeTimerService(Object pKey) throws IllegalStateException { try { if (pKey != null) { // entity bean->remove() timerService.removeTimerService(getJmxName(), pKey); } else { // container stop, we choose whether active timers // should be persisted (default), or not (legacy) timerService.removeTimerService(getJmxName(), getBeanMetaData().getTimerPersistence()); } } catch (Exception e) { log.error("Could not remove timer service", e); } }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getTimerService", IN_EJB_CREATE | IN_EJB_POST_CREATE | IN_EJB_REMOVE | IN_EJB_HOME | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_EJB_LOAD | IN_EJB_STORE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); return new TimerServiceWrapper(this, getContainer().getTimerService(id)); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(duration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createSingleActionTimer"); return timerService.createSingleActionTimer(expiration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long duration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(duration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(long initialDuration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialDuration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialDuration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date expiration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(expiration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createTimer(Date initialExpiration, long intervalDuration, Serializable info) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createTimer"); return timerService.createTimer(initialExpiration, intervalDuration, info); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createIntervalTimer"); return timerService.createIntervalTimer(initialExpiration, intervalDuration, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { assertAllowedIn("TimerService.createCalendarTimer"); return timerService.createCalendarTimer(schedule, timerConfig); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public Collection<Timer> getTimers() throws IllegalStateException, EJBException { assertAllowedIn("TimerService.getTimers"); return timerService.getTimers(); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public Object getBusinessObject(Class businessInterface) throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public Class getInvokedBusinessInterface() throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { throw new IllegalStateException("getTimerService should not be access from a stateful session bean"); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public MessageContext getMessageContext() throws IllegalStateException { AllowedOperationsAssociation.assertAllowedIn("getMessageContext", NOT_ALLOWED); return null; }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public TimerService getTimerService() throws IllegalStateException { return getContainer().getTimerService(null); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx commit: " + tx); int status = tm.getStatus(); tm.commit(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx rollback: " + tx); tm.rollback(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void setRollbackOnly() throws IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx setRollbackOnly: " + tx); tm.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
private void checkSetForeignKey(EntityEnterpriseContext myCtx, Object newValue) throws IllegalStateException { JDBCFieldBridge[] pkFields = entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCCMP2xFieldBridge pkField = (JDBCCMP2xFieldBridge) pkFields[i]; JDBCCMP2xFieldBridge relatedPkField = (JDBCCMP2xFieldBridge) relatedPKFieldsByMyPKFields.get(pkField); if(relatedPkField != null) { Object comingValue = relatedPkField.getPrimaryKeyValue(newValue); Object currentValue = pkField.getInstanceValue(myCtx); // they shouldn't be null if(!comingValue.equals(currentValue)) { throw new IllegalStateException("Can't create relationship: CMR field " + entity.getEntityName() + "." + getFieldName() + " has foreign key fields mapped to the primary key columns." + " Primary key may only be set once in ejbCreate [EJB 2.0 Spec. 10.3.5]." + " primary key value is " + currentValue + " overriding value is " + comingValue); } } } }
7
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.IllegalStateException ex) { finished = false; throw ex; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (IllegalStateException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); }
// in src/main/java/org/jboss/web/deployers/MergedJBossWebMetaDataDeployer.java
catch (IllegalStateException e) { DeploymentException.rethrowAsDeploymentException("Invalid ordering", e); }
4
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (IllegalStateException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.IllegalStateException ex) { finished = false; throw ex; }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
0
unknown (Lib) IndexOutOfBoundsException 3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeSimple.java
public final Object getColumnValue(int index, Object value) { if(index != 0) { throw new IndexOutOfBoundsException("JDBCSimpleType does not support an index>0."); } return mapper == null ? value : mapper.toColumnValue(value); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeSimple.java
public final Object setColumnValue(int index, Object value, Object columnValue) { if(index != 0) { throw new IndexOutOfBoundsException("JDBCSimpleType does not support an index>0."); } return mapper == null ? columnValue : mapper.toFieldValue(columnValue); }
// in src/main/java/org/jboss/verifier/Section.java
public String getSectionToken( int index ) { if( section.length >= index ) throw new IndexOutOfBoundsException(GET_SECTION_INDEX_ERROR); return section[index]; }
0 0 0 0 0
unknown (Lib) InstanceNotFoundException 0 0 2
            
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void addNotificationListener(ObjectName name, RMINotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("addNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = new NotificationListenerDelegate(listener, name); remoteListeners.put(listener, delegate); getServer().addNotificationListener(name, delegate, filter, handback); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void removeNotificationListener(ObjectName name, RMINotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("removeNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = (NotificationListenerDelegate) remoteListeners.remove(listener); if( delegate == null ) throw new ListenerNotFoundException("No listener matches: "+listener); getServer().removeNotificationListener(name, delegate); }
1
            
// in src/main/java/org/jboss/naming/JNDIView.java
catch (InstanceNotFoundException e1) { // this is expected if HA-JNDI service isn't deployed - do not report it return null; }
0 0
unknown (Lib) InstantiationException 0 0 3
            
// in src/main/java/org/jboss/naming/NamingService.java
public void setClientSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setClientSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void setServerSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setServerSocketFactory(factoryClassName); }
// in src/main/java/org/jboss/naming/NamingService.java
public void setJNPServerSocketFactory(String factoryClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException { namingMain.setJNPServerSocketFactory(factoryClassName); }
5
            
// in src/main/java/org/jboss/invocation/unified/interfaces/JavaSerializationManager.java
catch (InstantiationException e) { log.error(e); }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (InstantiationException e) { //Not sure what condition this is at the moment - JMW //fireSpecViolationEvent(entity, new Section("9.2.9.a")); //status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (InstantiationException e) { //Not sure what condition this is at the moment - JMW //fireSpecViolationEvent(entity, new Section("9.2.9.a")); //status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (InstantiationException e) { //fireSpecViolationEvent(entity, new Section("9.2.9.a")); //status = false; }
1
            
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (InstantiationException e) { throw new EJBException("Could not instantiate bean", e); }
0
unknown (Lib) InternalError 1
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public Object getTransactionPropagationContext(Transaction tx) { // No need to implement in a stand-alone client. throw new InternalError("Should not have been used."); }
0 0 0 0 0
unknown (Lib) InterruptedException 0 0 3
            
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
protected boolean acquireNonReentrant(long waitTime, Transaction miTx) throws ApplicationDeadlockException, InterruptedException, ReentranceException { synchronized(lock) { final Thread curThread = Thread.currentThread(); if(lockHolder != null) { if(lockHolder == curThread) { if(inNonReentrant) { throw new ReentranceException("The same thread reentered: thread-holder=" + lockHolder + ", holding tx=" + holdingTx + ", current tx=" + miTx); } } else if(miTx != null && miTx.equals(holdingTx)) { if(inNonReentrant) { throw new ReentranceException("The same tx reentered: tx=" + miTx + ", holding thread=" + lockHolder + ", current thread=" + curThread); } } else { // Always upgrade deadlock holder to Tx so that we can detect lock properly Object deadlocker = curThread; if(miTx != null) deadlocker = miTx; try { DeadlockDetector.singleton.deadlockDetection(deadlocker, this); while(lockHolder != null) { if(waitTime < 1) { lock.wait(); } else { lock.wait(waitTime); } // If we waited and never got lock, abort if(waitTime > 0 && lockHolder != null) return false; } } finally { DeadlockDetector.singleton.removeWaiting(deadlocker); } } } ++held; lockHolder = curThread; holdingTx = miTx; inNonReentrant = true; } return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
protected boolean acquireReentrant(long waitTime, Transaction miTx) throws ApplicationDeadlockException, InterruptedException, ReentranceException { synchronized(lock) { final Thread curThread = Thread.currentThread(); if(lockHolder != null) { if(lockHolder != curThread && (miTx == null || miTx.equals(holdingTx))) { // Always upgrade deadlock holder to Tx so that we can detect lock properly Object deadlocker = curThread; if(miTx != null) deadlocker = miTx; try { DeadlockDetector.singleton.deadlockDetection(deadlocker, this); while(lockHolder != null) { if(waitTime < 1) { lock.wait(); } else { lock.wait(waitTime); } // If we waited and never got lock, abort if(waitTime > 0 && lockHolder != null) return false; } } finally { DeadlockDetector.singleton.removeWaiting(deadlocker); } } } ++held; lockHolder = curThread; holdingTx = miTx; } return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
public boolean attempt(long waitTime, Transaction miTx, boolean nonReentrant) throws ApplicationDeadlockException, InterruptedException, ReentranceException { return nonReentrant ? acquireNonReentrant(waitTime, miTx) : acquireReentrant(waitTime, miTx); }
7
            
// in src/main/java/org/jboss/ejb/plugins/lock/SimpleReadWriteEJBLock.java
catch (InterruptedException e) { Thread.currentThread().interrupt(); }
// in src/main/java/org/jboss/ejb/plugins/lock/BeanLockSupport.java
catch (InterruptedException ex) { intr = true; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
catch (InterruptedException ignored) { intr = true; }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (InterruptedException e) { intr = true; }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (InterruptedException e) { // kill this thread intr = true; running = false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/PartitionedTableCache.java
catch(InterruptedException e) { intr = true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
catch(InterruptedException e) { intr = true; }
0 0
checked (Domain) InvocationException
public class InvocationException
    extends Exception
{
   private Throwable cause = null;

   public InvocationException(Throwable cause)
   {
      super();
      this.cause = cause;
   }
   
   public InvocationException(String msg, Throwable cause)
   {
      super(msg);
      this.cause = cause;
   }

   public Throwable getTargetException()
   {
      return cause;
   }

}
1
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
public static Object invoke(URL externalURL, Invocation mi) throws Exception { if( log.isTraceEnabled() ) log.trace("invoke, externalURL="+externalURL); /* Post the MarshalledInvocation data. This is using the URL class for now but this should be improved to a cluster aware layer with full usage of HTTP 1.1 features, pooling, etc. */ HttpURLConnection conn = (HttpURLConnection) externalURL.openConnection(); configureHttpsHostVerifier(conn); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestProperty("ContentType", REQUEST_CONTENT_TYPE); conn.setRequestMethod("POST"); // @todo this should be configurable conn.setRequestProperty("Accept-Encoding", "x-gzip,x-deflate,gzip,deflate"); OutputStream os = conn.getOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(os); try { oos.writeObject(mi); oos.flush(); } catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); } // Get the response MarshalledValue object InputStream is = conn.getInputStream(); // Check the headers for gzip Content-Encoding String encoding = conn.getHeaderField("Content-Encoding"); if( encoding != null && encoding.indexOf("gzip") >= 0 ) is = new GZIPInputStream(is); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); // A hack for jsse connection pooling (see patch ). ois.read(); ois.close(); oos.close(); // If the encoded value is an exception throw it Object value = mv.get(); if( value instanceof Exception ) { throw (Exception) value; } return value; }
1
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); }
0 1
            
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); }
3
            
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); }
0
unknown (Lib) InvocationTargetException 2
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
public static void configureSSLSocketFactory(HttpURLConnection conn) throws InvocationTargetException { Class connClass = conn.getClass(); if ( conn instanceof HttpsURLConnection && sslSocketFactoryBuilder != null) { try { SSLSocketFactory socketFactory = sslSocketFactoryBuilder.getSocketFactory(); Class[] sig = {SSLSocketFactory.class}; Method method = connClass.getMethod("setSSLSocketFactory", sig); Object[] args = {socketFactory}; method.invoke(conn, args); log.trace("Socket factory set on connection"); } catch(Exception e) { throw new InvocationTargetException(e); } } }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { // We are going to go through a Remote invocation, switch to a Marshalled Invocation MarshalledInvocation mi = new MarshalledInvocation(invocation); if( externalURL == null ) externalURL = Util.resolveURL(externalURLValue); try { Object value = Util.invoke(externalURL, mi); return value; } catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); } catch (IOException e) { throw new ServerException("IOE", e); } }
2
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(Exception e) { throw new InvocationTargetException(e); }
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); }
3
            
// in src/main/java/org/jboss/invocation/Invocation.java
public Object performCall(Object instance, Method m, Object[] arguments) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, Exception { return m.invoke(instance,arguments); }
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
public static void configureSSLSocketFactory(HttpURLConnection conn) throws InvocationTargetException { Class connClass = conn.getClass(); if ( conn instanceof HttpsURLConnection && sslSocketFactoryBuilder != null) { try { SSLSocketFactory socketFactory = sslSocketFactoryBuilder.getSocketFactory(); Class[] sig = {SSLSocketFactory.class}; Method method = connClass.getMethod("setSSLSocketFactory", sig); Object[] args = {socketFactory}; method.invoke(conn, args); log.trace("Socket factory set on connection"); } catch(Exception e) { throw new InvocationTargetException(e); } } }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
private Naming getNamingServer(URL providerURL) throws ClassNotFoundException, IOException, InvocationTargetException, IllegalAccessException { // Initialize the proxy Util class to integrate JAAS authentication Util.init(); if( log.isTraceEnabled() ) log.trace("Retrieving content from : "+providerURL); HttpURLConnection conn = (HttpURLConnection) providerURL.openConnection(); Util.configureHttpsHostVerifier(conn); Util.configureSSLSocketFactory(conn); int length = conn.getContentLength(); String type = conn.getContentType(); if( log.isTraceEnabled() ) log.trace("ContentLength: "+length+"\nContentType: "+type); InputStream is = conn.getInputStream(); ObjectInputStream ois = new ObjectInputStream(is); MarshalledValue mv = (MarshalledValue) ois.readObject(); ois.close(); Object obj = mv.get(); if( (obj instanceof Naming) == false ) { String msg = "Invalid reply content seen: "+obj.getClass(); Throwable t = null; if( obj instanceof Throwable ) { t = (Throwable) obj; if( t instanceof InvocationException ) t = ((InvocationException)t).getTargetException(); } if( t != null ) log.warn(msg, t); else log.warn(msg); IOException e = new IOException(msg); throw e; } Naming namingServer = (Naming) obj; return namingServer; }
24
            
// in src/main/java/org/jboss/client/ReflectionLauncher.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
catch (InvocationTargetException e) { Throwable ex = e.getTargetException(); if (ex instanceof EJBException) throw (Exception)ex; else if (ex instanceof RuntimeException) throw new EJBException((Exception)ex); // Transform runtime exception into what a bean *should* have thrown else if (ex instanceof Exception) throw (Exception)ex; else throw (Error)ex; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(InvocationTargetException e) { // Whatever, I guess non-binary will not work for this field. }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
71
            
// in src/main/java/org/jboss/client/ReflectionLauncher.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(InvocationTargetException e) { throw e.getTargetException(); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
catch (InvocationTargetException e) { Throwable ex = e.getTargetException(); if (ex instanceof EJBException) throw (Exception)ex; else if (ex instanceof RuntimeException) throw new EJBException((Exception)ex); // Transform runtime exception into what a bean *should* have thrown else if (ex instanceof Exception) throw (Exception)ex; else throw (Error)ex; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (InvocationTargetException e) { ctx.setId(null); Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) throw (EJBException) t; // Wrap runtime exceptions throw new EJBException((Exception) t); } else if (t instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) t; } else if (t instanceof Error) { throw (Error) t; } else { throw new org.jboss.util.UnexpectedThrowable(t); } }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof CreateException) { // Rethrow exception throw (CreateException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof FinderException) { // Rethrow exception throw (FinderException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } else if(e instanceof Exception) { throw (Exception)e; } else { throw (Error)e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(InvocationTargetException ite) { Throwable e = ite.getTargetException(); if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else if(e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception) e); } else if(e instanceof Exception) { // Remote, Create, or custom app. exception throw (Exception) e; } else { throw (Error) e; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCCustomFinderQuery.java
catch(InvocationTargetException e) { // Throw the exception if its a FinderException Throwable ex = e.getTargetException(); if( ex instanceof FinderException ) { throw (FinderException) ex; } else { throw new FinderException("Errror invoking cutom finder " + finderMethod.getName() + ": " + ex); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
catch (InvocationTargetException e) { throw e.getTargetException(); }
0
checked (Domain) InvokerAdaptorException
public class InvokerAdaptorException extends Exception implements Serializable
{
   // Constants -----------------------------------------------------
   
   private static final long serialVersionUID = 24842201105890823L;
   
   // Attributes ----------------------------------------------------
   
   /** The wrapped exception */
   private Throwable wrapped;
   
   // Constructors --------------------------------------------------

   public InvokerAdaptorException()
   {
      // For serialization
   }
   
   public InvokerAdaptorException(Throwable wrapped)
   {
      this.wrapped = wrapped;
   }
   
   // Public --------------------------------------------------------

   public Throwable getWrapped() 
   {
      return wrapped;
   }

   // Private -------------------------------------------------------
   
   // Inner classes -------------------------------------------------
}
1
            
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public Object invoke(Invocation invocation) throws Exception { try { // Make sure we have the correct classloader before unmarshalling ClassLoader oldCL = SecurityActions.getContextClassLoader(); ClassLoader newCL = null; // Get the MBean this operation applies to ObjectName objectName = (ObjectName) invocation.getValue("JMX_OBJECT_NAME"); if (objectName != null) { newCL = server.getClassLoaderFor(objectName); } if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(newCL); //JBAS-6449: Cache the incoming security context to be retained on exit SecurityContext previousSecurityContext = SecurityActions.getSecurityContext(); try { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the MBeanServer method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Principal principal = invocation.getPrincipal(); Object credential = invocation.getCredential(); Object value = null; SecurityContext sc = SecurityActions.createSecurityContext(SecurityConstants.DEFAULT_APPLICATION_POLICY); SecurityActions.setSecurityContext(sc); // Associate the method SecurityActions.pushSubjectContext(principal, credential, null); try { if( addNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; NotificationFilter filter = (NotificationFilter) args[2]; Object handback = args[3]; addNotificationListener(name, listener, filter, handback); } else if( removeNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; removeNotificationListener(name, listener); } else { String name = method.getName(); Class[] paramTypes = method.getParameterTypes(); Method mbeanServerMethod = MBeanServer.class.getMethod(name, paramTypes); value = mbeanServerMethod.invoke(server, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; } finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); } } catch (Throwable t) { throw new InvokerAdaptorException(t); } }
1
            
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch (Throwable t) { throw new InvokerAdaptorException(t); }
0 1
            
// in src/main/java/org/jboss/jmx/connector/invoker/client/InvokerAdaptorClientInterceptor.java
catch (InvokerAdaptorException e) { throw e.getWrapped(); }
1
            
// in src/main/java/org/jboss/jmx/connector/invoker/client/InvokerAdaptorClientInterceptor.java
catch (InvokerAdaptorException e) { throw e.getWrapped(); }
0
runtime (Domain) JBossLazyUnmarshallingException
public class JBossLazyUnmarshallingException extends RuntimeException
{
   public JBossLazyUnmarshallingException(String msg)
   {
      super(msg);
   }
}
0 0 0 1
            
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
2
            
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
0
unknown (Domain) JBossTransactionRolledbackException
public class JBossTransactionRolledbackException
   extends TransactionRolledbackException
   implements NestedThrowable, Serializable
{

   public JBossTransactionRolledbackException()
   {
      super();
   }

   public JBossTransactionRolledbackException(final String message)
   {
      super(message);
   }


   public JBossTransactionRolledbackException(final Throwable t)
   {
      super();
      this.detail = t;
   }

   public JBossTransactionRolledbackException(final String message, final Throwable t)
   {
      super(message);
      this.detail = t;
   }


   // Implementation of org.jboss.util.NestedThrowable

   public Throwable getNested()
   {
      return detail;
   }

   public Throwable getCause()
   {
      return detail;
   }

   /**
    * Returns the composite throwable message.
    *
    * @return  The composite throwable message.
    */
   public String getMessage()
   {
      return NestedThrowable.Util.getMessage(super.getMessage(), detail);
   }

   /**
    * Prints the composite message and the embedded stack trace to the
    * specified print stream.
    *
    * @param stream  Stream to print to.
    */
   public void printStackTrace(final PrintStream stream)
   {
      if (detail == null || NestedThrowable.PARENT_TRACE_ENABLED)
      {
         super.printStackTrace(stream);
      }
      NestedThrowable.Util.print(detail, stream);
   }

   /**
    * Prints the composite message and the embedded stack trace to the
    * specified print writer.
    *
    * @param writer  Writer to print to.
    */
   public void printStackTrace(final PrintWriter writer)
   {
      if (detail == null || NestedThrowable.PARENT_TRACE_ENABLED)
      {
         super.printStackTrace(writer);
      }
      NestedThrowable.Util.print(detail, writer);
   }

   /**
    * Prints the composite message and the embedded stack trace to
    * <tt>System.err</tt>.
    */
   public void printStackTrace()
   {
      printStackTrace(System.err);
   }

}
1
            
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
protected void throwJBossException(Exception e, InvocationType type) throws TransactionRolledbackException { // Unwrap a nested exception if possible. There is no // point in the extra wrapping, and the EJB spec should have // just used javax.transaction exceptions if (e instanceof NestedException) { NestedException rollback = (NestedException) e; if(rollback.getCause() instanceof Exception) { e = (Exception) rollback.getCause(); } } if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new JBossTransactionRolledbackLocalException(e); } else { throw new JBossTransactionRolledbackException(e); } }
0 0 0 0 0
unknown (Domain) JBossTransactionRolledbackLocalException
public class JBossTransactionRolledbackLocalException
   extends TransactionRolledbackLocalException
   implements NestedThrowable
{
   public JBossTransactionRolledbackLocalException()
   {
      super();
   }

   public JBossTransactionRolledbackLocalException(final Exception e)
   {
      super(null, e);
   }

   public JBossTransactionRolledbackLocalException(final String message)
   {
      super(message);
   }

   public JBossTransactionRolledbackLocalException(final String message, final Exception e)
   {
      super(message, e);
   }

   // Implementation of org.jboss.util.NestedThrowable

   public Throwable getNested()
   {
      return getCausedByException();
   }

   public Throwable getCause()
   {
      return getCausedByException();
   }

   /**
    * Returns the composite throwable message.
    *
    * @return  The composite throwable message.
    */
   public String getMessage() {
      return NestedThrowable.Util.getMessage(super.getMessage(), getCausedByException());
   }

   /**
    * Prints the composite message and the embedded stack trace to the
    * specified print stream.
    *
    * @param stream  Stream to print to.
    */
   public void printStackTrace(final PrintStream stream)
   {
      if (getCausedByException() == null || NestedThrowable.PARENT_TRACE_ENABLED)
      {
         super.printStackTrace(stream);
      }
      NestedThrowable.Util.print(getCausedByException(), stream);
   }

   /**
    * Prints the composite message and the embedded stack trace to the
    * specified print writer.
    *
    * @param writer  Writer to print to.
    */
   public void printStackTrace(final PrintWriter writer)
   {
      if (getCausedByException() == null || NestedThrowable.PARENT_TRACE_ENABLED)
      {
         super.printStackTrace(writer);
      }
      NestedThrowable.Util.print(getCausedByException(), writer);
   }

   /**
    * Prints the composite message and the embedded stack trace to
    * <tt>System.err</tt>.
    */
   public void printStackTrace()
   {
      printStackTrace(System.err);
   }

}
1
            
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
protected void throwJBossException(Exception e, InvocationType type) throws TransactionRolledbackException { // Unwrap a nested exception if possible. There is no // point in the extra wrapping, and the EJB spec should have // just used javax.transaction exceptions if (e instanceof NestedException) { NestedException rollback = (NestedException) e; if(rollback.getCause() instanceof Exception) { e = (Exception) rollback.getCause(); } } if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new JBossTransactionRolledbackLocalException(e); } else { throw new JBossTransactionRolledbackException(e); } }
0 0 0 0 0
unknown (Lib) JBossXBException 0 0 0 2
            
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); }
2
            
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared web.xml", e); }
// in src/main/java/org/jboss/web/deployers/SharedJBossWebMetaDataDeployer.java
catch (JBossXBException e) { throw new DeploymentException("Error parsing shared jboss-web.xml", e); }
0
unknown (Lib) JMException 0 0 1
            
// in src/main/java/org/jboss/monitor/BeanCacheMonitor.java
public Collection listSnapshots() throws JMException { ArrayList cacheSnapshots = new ArrayList(); Collection ejbModules = m_mbeanServer.queryNames(EjbModule.EJB_MODULE_QUERY_NAME, null); // For each application, getContainers() for (Iterator i = ejbModules.iterator(); i.hasNext(); ) { ObjectName ejbModule = (ObjectName) i.next(); String name = ejbModule.getKeyProperty("jndiName"); // Loop on each container of the application //Since we are just totaling everything, do a query on container object names Collection containers = (Collection)m_mbeanServer.getAttribute(ejbModule, "Containers"); for (Iterator cs = containers.iterator(); cs.hasNext();) { // Get the cache for each container InstanceCache cache = null; Object container = cs.next(); if (container instanceof EntityContainer) { cache = ((EntityContainer)container).getInstanceCache(); } else if (container instanceof StatefulSessionContainer) { cache = ((StatefulSessionContainer)container).getInstanceCache(); } // Take a cache snapshot if (cache instanceof Monitorable) { BeanCacheSnapshot snapshot = new BeanCacheSnapshot(); snapshot.m_application = name; snapshot.m_container = ((Container)container).getBeanMetaData().getEjbName(); ((Monitorable)cache).sample(snapshot); cacheSnapshots.add(snapshot); } } } return cacheSnapshots; }
1
            
// in src/main/java/org/jboss/monitor/BeanCacheMonitor.java
catch (JMException e) { log.error("Problem getting bean cache snapshots", e); return null; }
0 0
unknown (Lib) JMSException 0 0 6
            
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static Connection createConnection(final Object factory, final String username, final String password) throws JMSException { if (factory == null) throw new IllegalArgumentException("factory is null"); log.debug("using connection factory: " + factory); log.debug("using username/password: " + String.valueOf(username) + "/-- not shown --"); Connection connection; if (factory instanceof XAConnectionFactory) { XAConnectionFactory qFactory = (XAConnectionFactory) factory; if (username != null) connection = qFactory.createXAConnection(username, password); else connection = qFactory.createXAConnection(); log.debug("created XAConnection: " + connection); } else if (factory instanceof ConnectionFactory) { ConnectionFactory qFactory = (ConnectionFactory) factory; if (username != null) connection = qFactory.createConnection(username, password); else connection = qFactory.createConnection(); log.debug("created Connection: " + connection); } else { throw new IllegalArgumentException("factory is invalid"); } return connection; }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static Connection createConnection(final Object factory) throws JMSException { return createConnection(factory, null, null); }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static QueueConnection createQueueConnection(final Object factory, final String username, final String password) throws JMSException { if (factory == null) throw new IllegalArgumentException("factory is null"); log.debug("using connection factory: " + factory); log.debug("using username/password: " + String.valueOf(username) + "/-- not shown --"); QueueConnection connection; if (factory instanceof XAQueueConnectionFactory) { XAQueueConnectionFactory qFactory = (XAQueueConnectionFactory) factory; if (username != null) connection = qFactory.createXAQueueConnection(username, password); else connection = qFactory.createXAQueueConnection(); log.debug("created XAQueueConnection: " + connection); } else if (factory instanceof QueueConnectionFactory) { QueueConnectionFactory qFactory = (QueueConnectionFactory) factory; if (username != null) connection = qFactory.createQueueConnection(username, password); else connection = qFactory.createQueueConnection(); log.debug("created QueueConnection: " + connection); } else throw new IllegalArgumentException("factory is invalid"); return connection; }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static QueueConnection createQueueConnection(final Object factory) throws JMSException { return createQueueConnection(factory, null, null); }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static TopicConnection createTopicConnection(final Object factory, final String username, final String password) throws JMSException { if (factory == null) throw new IllegalArgumentException("factory is null"); log.debug("using connection factory: " + factory); log.debug("using username/password: " + String.valueOf(username) + "/-- not shown --"); TopicConnection connection; if (factory instanceof XATopicConnectionFactory) { XATopicConnectionFactory tFactory = (XATopicConnectionFactory) factory; if (username != null) connection = tFactory.createXATopicConnection(username, password); else connection = tFactory.createXATopicConnection(); log.debug("created XATopicConnection: " + connection); } else if (factory instanceof TopicConnectionFactory) { TopicConnectionFactory tFactory = (TopicConnectionFactory) factory; if (username != null) connection = tFactory.createTopicConnection(username, password); else connection = tFactory.createTopicConnection(); log.debug("created TopicConnection: " + connection); } else throw new IllegalArgumentException("factory is invalid"); return connection; }
// in src/main/java/org/jboss/jms/ConnectionFactoryHelper.java
public static TopicConnection createTopicConnection(final Object factory) throws JMSException { return createTopicConnection(factory, null, null); }
3
            
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (JMSException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (JMSException e) { log.warn(e); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
catch (JMSException ex) { log.debug("failed to publish seppuku event: ", ex); }
0 0
unknown (Lib) ListenerNotFoundException 1
            
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void removeNotificationListener(ObjectName name, RMINotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("removeNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = (NotificationListenerDelegate) remoteListeners.remove(listener); if( delegate == null ) throw new ListenerNotFoundException("No listener matches: "+listener); getServer().removeNotificationListener(name, delegate); }
0 1
            
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void removeNotificationListener(ObjectName name, RMINotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("removeNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = (NotificationListenerDelegate) remoteListeners.remove(listener); if( delegate == null ) throw new ListenerNotFoundException("No listener matches: "+listener); getServer().removeNotificationListener(name, delegate); }
0 0 0
unknown (Lib) LoginException 0 0 0 1
            
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(LoginException e) { AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol); ex.setRootCause(e); throw ex; }
1
            
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
catch(LoginException e) { AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol); ex.setRootCause(e); throw ex; }
0
unknown (Lib) MBeanException 1
            
// in src/main/java/org/jboss/ejb/Container.java
public Object invoke(Invocation mi) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); long start = System.currentTimeMillis(); Method m = null; Object type = null; String contextID = getJaccContextID(); try { pushENC(); // JBAS-3732 - Remove classloader.equals optimization SecurityActions.setContextClassLoader(this.classLoader); // Set the JACC context id mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID); contextID = SecurityActions.setContextID(contextID); // Set the standard JACC policy context handler data is not a SEI msg if (mi.getType() != InvocationType.SERVICE_ENDPOINT) { EJBArgsPolicyContextHandler.setArgs(mi.getArguments()); } else { SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE); SOAPMsgPolicyContextHandler.setMessage(msg); } // Set custom JACC policy handlers BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData()); // Check against home, remote, localHome, local, getHome, // getRemote, getLocalHome, getLocal type = mi.getType(); // stat gathering: concurrent calls this.invokeStats.callIn(); if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || // web service calls come in as "ordinary" application invocations type == InvocationType.SERVICE_ENDPOINT) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD REMOTE INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||"); } } m = mi.getMethod(); Object obj = internalInvoke(mi); return obj; } else if (type == InvocationType.HOME || type == InvocationType.LOCALHOME) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD HOME INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||" + mi.getArguments().toString()); } } m = mi.getMethod(); Object obj = internalInvokeHome(mi); return obj; } else { throw new MBeanException(new IllegalArgumentException("Unknown invocation type: " + type)); } } /** * Having to catch this exception here in case can not * unmarshall arguments, values, etc. Then, convert to * UnmarshalException as defined by spec (JBAS-2999) */ catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } } finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); } }
0 3
            
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public Object getAttribute (String attribute) throws javax.management.AttributeNotFoundException, javax.management.MBeanException, javax.management.ReflectionException { if (attribute == null || attribute.equals ("")) throw new IllegalArgumentException ("null or empty attribute name"); if (attribute.equals ("AsynchronousInvalidation")) return new Boolean(this.asynchronous); else throw new javax.management.AttributeNotFoundException(attribute + " is not a known attribute"); }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public java.lang.Object invoke (java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature) throws javax.management.MBeanException, javax.management.ReflectionException { if ("invalidate".equals (actionName)) { if (params.length == 1) { if (params[0] instanceof Serializable[]) this.invalidate ((Serializable[])params[0]); else if (params[0] instanceof Serializable) this.invalidate ((Serializable)params[0]); else throw new IllegalArgumentException ("First argument must be Serializable (or array of)"); } else if (params.length == 2) { if (params[0] instanceof Serializable[]) this.invalidate ((Serializable[])params[0], ((Boolean)params[1]).booleanValue ()); else if (params[0] instanceof Serializable) this.invalidate ((Serializable)params[0], ((Boolean)params[1]).booleanValue ()); else throw new IllegalArgumentException ("First argument must be Serializable (or array of)"); } else { throw new IllegalArgumentException ("Unknown operation with these parameters: " + actionName); } } else if("invalidateAll".equals(actionName)) { if(params == null || params.length == 0) { this.invalidateAll(); } else if (params.length == 1) { this.invalidateAll (((Boolean)params[1]).booleanValue ()); } else { throw new IllegalArgumentException ("invalidateAll can take zero or one parameter but got " + params.length); } } else { throw new IllegalArgumentException ("Unknown operation: " + actionName); } return null; }
// in src/main/java/org/jboss/cache/invalidation/InvalidationManager.java
public void setAttribute (javax.management.Attribute attribute) throws javax.management.AttributeNotFoundException, javax.management.InvalidAttributeValueException, javax.management.MBeanException, javax.management.ReflectionException { String attrName = attribute.getName(); if (attrName == null || attrName.equals ("")) throw new IllegalArgumentException ("null or empty attribute name"); if (attrName.equals ("AsynchronousInvalidation")) { Object value = attribute.getValue (); if (value instanceof Boolean) this.asynchronous = ((Boolean)value).booleanValue (); else throw new javax.management.InvalidAttributeValueException("Attribute is of boolean type"); } else throw new javax.management.AttributeNotFoundException(attrName + " is not a known attribute"); }
0 0 0
unknown (Lib) MalformedLinkException 9
            
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getGUID() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(guidAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getRemoteLinkName() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(remoteAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getLocalLinkName() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(localAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
0 3
            
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getGUID() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(guidAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getRemoteLinkName() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(remoteAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
// in src/main/java/org/jboss/naming/LinkRefPair.java
public String getLocalLinkName() throws MalformedLinkException { if (className != null && className.equals(linkRefPairClassName)) { RefAddr refAddr = get(localAddress); if (refAddr != null && refAddr instanceof StringRefAddr) { Object content = refAddr.getContent(); if (content != null && content instanceof String) return (String) content; else throw new MalformedLinkException("Content is not a string: " + content); } else throw new MalformedLinkException("RefAddr is not a string reference: " + refAddr); } else throw new MalformedLinkException("Class is not a LinkRefPair: " + className); }
0 0 0
unknown (Lib) MalformedObjectNameException 0 0 3
            
// in src/main/java/org/jboss/naming/JNDIView.java
protected ObjectName getObjectName(MBeanServer server, ObjectName name) throws javax.management.MalformedObjectNameException { return name == null ? OBJECT_NAME : name; }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
protected ObjectName getObjectName(VFSDeploymentUnit unit, JBossMetaData metaData) throws MalformedObjectNameException { String name = metaData.getJmxName(); if( name == null ) { StringBuilder objectName = new StringBuilder(EjbModule.BASE_EJB_MODULE_NAME); // Get the top level unit for this unit (ex: the top level might be an ear and this unit might be the jar // in that ear VFSDeploymentUnit toplevelUnit = unit.getTopLevel(); if (toplevelUnit != null) { // if top level is an ear, then create the name with the ear reference if (isEar(toplevelUnit)) { String earName = ObjectName.quote(toplevelUnit.getSimpleName()); objectName.append(",ear="); objectName.append(earName); } } String unitShortName = unit.getName(); if (unitShortName.endsWith("/")) { unitShortName = unitShortName.substring(0, unitShortName.length() - 1); } if(unitShortName.endsWith("!")) { unitShortName = unitShortName.substring(0, unitShortName.length() - 1); } unitShortName = unitShortName.substring(unitShortName.lastIndexOf("/") + 1); // unitShortName = ObjectName.quote(unitShortName); objectName.append(",module="); objectName.append(unitShortName); name = objectName.toString(); log.debug("Generated ObjectName for EjbModule, in unit " + unit.getName() + " is " + name); } return new ObjectName(name); }
// in src/main/java/org/jboss/web/WebService.java
protected ObjectName getObjectName(MBeanServer server, ObjectName name) throws javax.management.MalformedObjectNameException { return name == null ? OBJECT_NAME : name; }
8
            
// in src/main/java/org/jboss/deployment/EarClassLoaderDeployer.java
catch (MalformedObjectNameException ignored) { // Not a JMX ObjectName??? }
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (MalformedObjectNameException e) { log.trace("Ignored malformed invoker mbean '" + invokerName + "' " + e.toString()); }
// in src/main/java/org/jboss/ejb/Container.java
catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create EJB module " + unit.getName() + ": malformed EjbModule name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployer.java
catch (MalformedObjectNameException ignored) { }
5
            
// in src/main/java/org/jboss/deployment/LoaderRepositoryMetaDataHelper.java
catch (MalformedObjectNameException e) { throw new DeploymentException("Loader repository name is malformed: " + name, e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create EJB module " + unit.getName() + ": malformed EjbModule name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Invalid object name for SQLExceptionProcessor: ", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(MalformedObjectNameException e) { throw new DeploymentException("Failed to create ObjectName for datasource metadata MBean: " + str, e); }
1
unknown (Lib) MalformedURLException 0 0 1
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
public static URL resolveURL(String urlValue) throws MalformedURLException { if( urlValue == null ) return null; URL externalURL = null; try { externalURL = new URL(urlValue); } catch(MalformedURLException e) { // See if externalURL refers to a property String urlProperty = System.getProperty(urlValue); if( urlProperty == null ) throw e; externalURL = new URL(urlProperty); } return externalURL; }
6
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(MalformedURLException e) { // See if externalURL refers to a property String urlProperty = System.getProperty(urlValue); if( urlProperty == null ) throw e; externalURL = new URL(urlProperty); }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (MalformedURLException mue) { log.warn("Can't construct URL for: " + ourPath); return null; }
// in src/main/java/org/jboss/ejb/EjbUtil50.java
catch (MalformedURLException mue) { log.warn("Can't construct URL for: " + ourPath); return null; }
// in src/main/java/org/jboss/web/WebServer.java
catch (MalformedURLException e) { log.error("invalid url", e); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
3
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch(MalformedURLException e) { // See if externalURL refers to a property String urlProperty = System.getProperty(urlValue); if( urlProperty == null ) throw e; externalURL = new URL(urlProperty); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
0
unknown (Lib) MarshalException 1
            
// in src/main/java/org/jboss/ejb/Container.java
public Object invoke(Invocation mi) throws Exception { ClassLoader callerClassLoader = SecurityActions.getContextClassLoader(); long start = System.currentTimeMillis(); Method m = null; Object type = null; String contextID = getJaccContextID(); try { pushENC(); // JBAS-3732 - Remove classloader.equals optimization SecurityActions.setContextClassLoader(this.classLoader); // Set the JACC context id mi.setValue(InvocationKey.JACC_CONTEXT_ID, contextID); contextID = SecurityActions.setContextID(contextID); // Set the standard JACC policy context handler data is not a SEI msg if (mi.getType() != InvocationType.SERVICE_ENDPOINT) { EJBArgsPolicyContextHandler.setArgs(mi.getArguments()); } else { SOAPMessage msg = (SOAPMessage)mi.getValue(InvocationKey.SOAP_MESSAGE); SOAPMsgPolicyContextHandler.setMessage(msg); } // Set custom JACC policy handlers BeanMetaDataPolicyContextHandler.setMetaData(this.getBeanMetaData()); // Check against home, remote, localHome, local, getHome, // getRemote, getLocalHome, getLocal type = mi.getType(); // stat gathering: concurrent calls this.invokeStats.callIn(); if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || // web service calls come in as "ordinary" application invocations type == InvocationType.SERVICE_ENDPOINT) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD REMOTE INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||"); } } m = mi.getMethod(); Object obj = internalInvoke(mi); return obj; } else if (type == InvocationType.HOME || type == InvocationType.LOCALHOME) { if (mi instanceof MarshalledInvocation) { ((MarshalledInvocation)mi).setMethodMap(marshalledInvocationMapping); if (log.isTraceEnabled()) { log.trace("METHOD HOME INVOKE " + mi.getObjectName() + "||" + mi.getMethod().getName() + "||" + mi.getArguments().toString()); } } m = mi.getMethod(); Object obj = internalInvokeHome(mi); return obj; } else { throw new MBeanException(new IllegalArgumentException("Unknown invocation type: " + type)); } } /** * Having to catch this exception here in case can not * unmarshall arguments, values, etc. Then, convert to * UnmarshalException as defined by spec (JBAS-2999) */ catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } } finally { if (m != null) { long end = System.currentTimeMillis(); long elapsed = end - start; this.invokeStats.updateStats(m, elapsed); } // stat gathering: concurrent calls this.invokeStats.callOut(); popENC(); // Restore the incoming class loader SecurityActions.setContextClassLoader(callerClassLoader); // Restore the incoming context id contextID = SecurityActions.setContextID(contextID); if (mi.getType() == InvocationType.SERVICE_ENDPOINT) { // Remove msg from ThreadLocal to prevent leakage into the thread pool SOAPMsgPolicyContextHandler.setMessage(null); } else { // Remove args from ThreadLocal to prevent leakage into the thread pool EJBArgsPolicyContextHandler.setArgs(null); } // Remove metadata from ThreadLocal to prevent leakage into the thread pool BeanMetaDataPolicyContextHandler.setMetaData(null); } }
1
            
// in src/main/java/org/jboss/ejb/Container.java
catch (JBossLazyUnmarshallingException e) { InvocationType calltype = mi.getType(); boolean isLocal = calltype == InvocationType.LOCAL || calltype == InvocationType.LOCALHOME; // handle unmarshalling exception which should only come if problem unmarshalling // invocation payload, arguments, or value on remote end. if (isLocal) { throw new EJBException("UnmarshalException", e); } else { throw new MarshalException("MarshalException", e); } }
0 0 0 0
unknown (Lib) MissingResourceException 2
            
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
private Map loadErrorMessages() { try { InputStream in = getClass().getResourceAsStream( msgBundle ); Properties props = new Properties(); props.load(in); return props; } catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); } catch (NullPointerException e) { throw new MissingResourceException( "Resource not found.", msgBundle, "" ); } }
2
            
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (IOException e) { throw new MissingResourceException( "I/O failure: " + e.getMessage(), msgBundle, "" ); }
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (NullPointerException e) { throw new MissingResourceException( "Resource not found.", msgBundle, "" ); }
0 0 0 0
unknown (Lib) NameNotFoundException 0 0 0 2
            
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
catch (NameNotFoundException e) { ctx = ctx.createSubcontext(ctxName); }
// in src/main/java/org/jboss/deployment/dependency/JndiDependencyItem.java
catch(NameNotFoundException e) { // ignore }
0 0
unknown (Lib) NamingException 12
            
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env) throws Exception { // Get the j2ee.clientName value String clientName = (String) env.get(J2EE_CLIENT_NAME_PROP); if (clientName == null) { // Look for the name as a system property clientName = (String) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { try { return System.getProperty(J2EE_CLIENT_NAME_PROP); } catch (SecurityException e) { return null; } } } ); if (clientName == null) throw new NamingException("Failed to find j2ee.clientName in jndi env"); }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object getSpecialObject(Name name) throws NamingException { if (name.size() > 0 && "java:comp".equals(name.get(0))) { if (name.size() == 2 && "ORB".equals(name.get(1))) return ORBFactory.getORB(); else if (name.size() == 2 && "HandleDelegate".equals(name.get(1))) return HandleDelegateFactory.getHandleDelegateSingleton(); } throw new NamingException("Name not found " + name); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx) throws NamingException { for (ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs) { String resourceName = ref.getJndiName(); String refName = ref.getResourceEnvRefName(); if (ref.getType().equals("java.net.URL")) { try { log.debug("Binding '" + refName + "' to URL: " + resourceName); URL url = new URL(resourceName); Util.bind(envCtx, refName, url); } catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); } } else if (resourceName != null) { log.debug("Linking '" + refName + "' to JNDI name: " + resourceName); Util.bind(envCtx, refName, new LinkRef(resourceName)); } else { throw new NamingException("resource-env-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-env-ref."); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx) throws NamingException { for (ResourceReferenceMetaData ref : resourceRefs) { String jndiName = ref.getJndiName(); String refName = ref.getResourceName(); if (ref.getType().equals("java.net.URL")) { try { String resURL = ref.getResUrl(); if (resURL != null) { log.debug("Binding '" + refName + "' to URL: " + resURL); URL url = new URL(resURL); Util.bind(envCtx, refName, url); } else { log.debug("Linking '" + refName + "' to URL: " + resURL); LinkRef urlLink = new LinkRef(jndiName); Util.bind(envCtx, refName, urlLink); } } catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); } } else if (jndiName != null) { log.debug("Linking '" + refName + "' to JNDI name: " + jndiName); Util.bind(envCtx, refName, new LinkRef(jndiName)); } else { throw new NamingException("resource-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-ref."); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx) throws NamingException { for (MessageDestinationReferenceMetaData ref : msgRefs) { String refName = ref.getName(); String jndiName = ref.getJndiName(); String link = ref.getLink(); if (link != null) { if (jndiName == null) { MessageDestinationMetaData messageDestination = EjbUtil50.findMessageDestination(mainDeployer, unit, link); if (messageDestination == null) throw new NamingException("message-destination-ref '" + refName + "' message-destination-link '" + link + "' not found and no jndi-name in jboss-web.xml"); else { String linkJNDIName = messageDestination.getJndiName(); if (linkJNDIName == null) log.warn("message-destination '" + link + "' has no jndi-name in jboss-web.xml"); else jndiName = linkJNDIName; } } else log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml"); } else if (jndiName == null) throw new NamingException("message-destination-ref '" + refName + "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml"); Util.bind(envCtx, refName, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx) throws NamingException { for (EJBReferenceMetaData ejb : ejbRefs) { String name = ejb.getName(); String linkName = ejb.getLink(); String jndiName = null; // use ejb-link if it is specified if (linkName != null) { jndiName = EjbUtil50.findEjbLink(mainDeployer, unit, linkName); // if flag does not allow misconfigured ejb-links, it is an error if ((jndiName == null) && !(getLenientEjbLink())) throw new NamingException("ejb-ref: " + name + ", no ejb-link match"); } // fall through to the jndiName if (jndiName == null) { jndiName = ejb.getJndiName(); if (jndiName == null) throw new NamingException("ejb-ref: " + name + ", no ejb-link in web.xml and no jndi-name in jboss-web.xml"); } log.debug("Linking ejb-ref: " + name + " to JNDI name: " + jndiName); Util.bind(envCtx, name, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx) throws NamingException { for (EJBLocalReferenceMetaData ejb : ejbLocalRefs) { String name = ejb.getName(); String linkName = ejb.getLink(); String jndiName = null; // use the ejb-link field if it is specified if (linkName != null) { jndiName = EjbUtil50.findLocalEjbLink(mainDeployer, unit, linkName); // if flag does not allow misconfigured ejb-links, it is an error if ((jndiName == null) && !(getLenientEjbLink())) throw new NamingException("ejb-ref: " + name + ", no ejb-link match"); } if (jndiName == null) { jndiName = ejb.getJndiName(); if (jndiName == null) { String msg = null; if (linkName == null) { msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and " + "no local-jndi-name in jboss-web.xml"; } else { msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '" + linkName + "' failed to resolve to an ejb with a LocalHome"; } throw new NamingException(msg); } } log.debug("Linking ejb-local-ref: " + name + " to JNDI name: " + jndiName); Util.bind(envCtx, name, new LinkRef(jndiName)); } }
2
            
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); }
35
            
// in src/main/java/org/jboss/metadata/EnvEntryBinder.java
public static void bindEnvEntry(Context ctx, EnvEntryMetaData entry) throws ClassNotFoundException, NamingException { ClassLoader loader = EnvEntryMetaData.class.getClassLoader(); Class type = loader.loadClass(entry.getType()); if (type == String.class) { Util.bind(ctx, entry.getName(), entry.getValue()); } else if (type == Integer.class) { Util.bind(ctx, entry.getName(), new Integer(entry.getValue())); } else if (type == Long.class) { Util.bind(ctx, entry.getName(), new Long(entry.getValue())); } else if (type == Double.class) { Util.bind(ctx, entry.getName(), new Double(entry.getValue())); } else if (type == Float.class) { Util.bind(ctx, entry.getName(), new Float(entry.getValue())); } else if (type == Byte.class) { Util.bind(ctx, entry.getName(), new Byte(entry.getValue())); } else if (type == Character.class) { Object value = null; String input = entry.getValue(); if (input == null || input.length() == 0) { value = new Character((char) 0); } else { value = new Character(input.charAt(0)); } Util.bind(ctx, entry.getName(), value); } else if (type == Short.class) { Util.bind(ctx, entry.getName(), new Short(entry.getValue())); } else if (type == Boolean.class) { Util.bind(ctx, entry.getName(), new Boolean(entry.getValue())); } else { // Default to a String type Util.bind(ctx, entry.getName(), entry.getValue()); } }
// in src/main/java/org/jboss/jms/jndi/JNDIProviderAdapter.java
public Context getInitialContext() throws NamingException { if (properties == null) return new InitialContext(); else return new InitialContext(properties); }
// in src/main/java/org/jboss/jms/jndi/JMSProviderLoader.java
private void bind(Context ctx, String name, Object val) throws NamingException { log.debug("attempting to bind " + val + " to " + name); // Bind val to name in ctx, and make sure that all // intermediate contexts exist Name n = ctx.getNameParser("").parse(name); while (n.size() > 1) { String ctxName = n.get(0); try { ctx = (Context) ctx.lookup(ctxName); } catch (NameNotFoundException e) { ctx = ctx.createSubcontext(ctxName); } n = n.getSuffix(1); } ctx.bind(n.get(0), val); }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object getSpecialObject(Name name) throws NamingException { if (name.size() > 0 && "java:comp".equals(name.get(0))) { if (name.size() == 2 && "ORB".equals(name.get(1))) return ORBFactory.getORB(); else if (name.size() == 2 && "HandleDelegate".equals(name.get(1))) return HandleDelegateFactory.getHandleDelegateSingleton(); } throw new NamingException("Name not found " + name); }
// in src/main/java/org/jboss/naming/NamingAlias.java
public void setFromName(String name) throws NamingException { removeLinkRef(fromName); this.fromName = name; createLinkRef(); }
// in src/main/java/org/jboss/naming/NamingAlias.java
public void setToName(String name) throws NamingException { this.toName = name; createLinkRef(); }
// in src/main/java/org/jboss/naming/NamingAlias.java
private void createLinkRef() throws NamingException { if( super.getState() == ServiceMBean.STARTING || super.getState() == ServiceMBean.STARTED ) Util.createLinkRef(fromName, toName); }
// in src/main/java/org/jboss/naming/NamingAlias.java
private void removeLinkRef(String name) throws NamingException { if(super.getState() == ServiceMBean.STOPPING) Util.removeLinkRef(name); }
// in src/main/java/org/jboss/naming/ExternalContext.java
public void setJndiName(String jndiName) throws NamingException { contextInfo.setJndiName(jndiName); if( super.getState() == STARTED ) { unbind(jndiName); try { rebind(); } catch(Exception e) { NamingException ne = new NamingException("Failed to update jndiName"); ne.setRootCause(e); throw ne; } } }
// in src/main/java/org/jboss/naming/ExternalContext.java
private static Context createContext(Context rootContext, Name name) throws NamingException { Context subctx = rootContext; for(int n = 0; n < name.size(); n ++) { String atom = name.get(n); try { Object obj = subctx.lookup(atom); subctx = (Context) obj; } catch(NamingException e) { // No binding exists, create a subcontext subctx = subctx.createSubcontext(atom); } } return subctx; }
// in src/main/java/org/jboss/naming/ExternalContext.java
public Reference getReference() throws NamingException { Reference ref = new Reference(Context.class.getName(), this, this.getClass().getName(), null); return ref; }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
public Context getInitialContext(Hashtable env) throws NamingException { // Parse the Context.PROVIDER_URL String provider = (String) env.get(Context.PROVIDER_URL); if( provider.startsWith("jnp:") == true ) provider = "http:" + provider.substring(4); else if( provider.startsWith("jnps:") == true ) provider = "https:" + provider.substring(5); else if( provider.startsWith("jnp-http:") == true ) provider = "http:" + provider.substring(9); else if( provider.startsWith("jnp-https:") == true ) provider = "https:" + provider.substring(10); tryLogin(env); URL providerURL = null; Naming namingServer = null; try { providerURL = new URL(provider); // Retrieve the Naming interface namingServer = getNamingServer(providerURL); } catch(Exception e) { NamingException ex = new NamingException("Failed to retrieve Naming interface for provider " + provider); ex.setRootCause(e); throw ex; } // Copy the context env env = (Hashtable) env.clone(); return new NamingContext(env, null, namingServer); }
// in src/main/java/org/jboss/naming/HttpNamingContextFactory.java
private void tryLogin(Hashtable env) throws NamingException { // Get the login configuration name to use, initially set to default. String protocol = SecurityConstants.DEFAULT_APPLICATION_POLICY; Object prop = env.get(Context.SECURITY_PROTOCOL); if( prop != null ) protocol = prop.toString(); // Get the login principal and credentials from the JNDI env Object credentials = env.get(Context.SECURITY_CREDENTIALS); Object principal = env.get(Context.SECURITY_PRINCIPAL); if(principal == null || credentials == null) { return; //don't bother and don't throw any exceptions } try { // Get the principal username String username; if( principal instanceof Principal ) { Principal p = (Principal) principal; username = p.getName(); } else { username = principal.toString(); } UsernamePasswordHandler handler = new UsernamePasswordHandler(username, credentials); Configuration conf = getConfiguration(); // Do the JAAS login LoginContext lc = new LoginContext(protocol, null, handler, conf); lc.login(); } catch(LoginException e) { AuthenticationException ex = new AuthenticationException("Failed to login using protocol="+protocol); ex.setRootCause(e); throw ex; } }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
public void addBindings() throws NamingException { Context ctx = new InitialContext(); if( rootName != null ) ctx = (Context) ctx.lookup(rootName); JNDIBinding[] values = bindings.getBindings(); for(int n = 0; n < values.length; n ++) { String name = values[n].getName(); Object value; try { value = values[n].getValue(); } catch(Exception e) { NamingException ne = new NamingException("Failed to obtain value from binding: "+name); ne.setRootCause(e); throw ne; } Util.bind(ctx, name, value); } ctx.close(); }
// in src/main/java/org/jboss/naming/JNDIBindingService.java
public void removeBindings() throws NamingException { Context ctx = new InitialContext(); if( rootName != null ) ctx = (Context) ctx.lookup(rootName); JNDIBinding[] values = bindings.getBindings(); for(int n = 0; n < values.length; n ++) { String name = values[n].getName(); Util.unbind(ctx, name); } ctx.close(); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public Reference getReference() throws NamingException { Reference ref = new Reference("org.jboss.tm.usertx.client.ClientUserTransaction", "org.jboss.tm.usertx.client.ClientUserTransactionObjectFactory", null); return ref; }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void initializeContainer(Container container, ConfigurationMetaData conf, BeanMetaData bean, int transType, DeploymentUnit unit) throws NamingException, DeploymentException { // Create local classloader for this container // For loading resources that must come from the local jar. Not for loading classes! // The VFS should be used for this // container.setLocalClassLoader(new URLClassLoader(new URL[0], localCl)); // Set metadata (do it *before* creating the container's WebClassLoader) container.setEjbModule(this); container.setBeanMetaData(bean); ClassLoader unitCl = unit.getClassLoader(); // Create the container's WebClassLoader // and register it with the web service. String webClassLoaderName = getWebClassLoader(conf, bean); log.debug("Creating WebClassLoader of class " + webClassLoaderName); WebClassLoader wcl = null; try { Class clazz = unitCl.loadClass(webClassLoaderName); wcl = WebClassLoaderFactory.createWebClassLoader(clazz, container.getJmxName(), (RealClassLoader) unitCl); } catch (Exception e) { throw new DeploymentException("Failed to create WebClassLoader of class " + webClassLoaderName + ": ", e); } if (webServiceName != null) { WebServiceMBean webServer = (WebServiceMBean) MBeanProxyExt.create(WebServiceMBean.class, webServiceName); URL[] codebase = {webServer.addClassLoader(wcl)}; wcl.setWebURLs(codebase); } // end of if () container.setWebClassLoader(wcl); // Create classloader for this container // Only used to unique the bean ENC and does not augment class loading container.setClassLoader(new DelegatingClassLoader(wcl)); // Set transaction manager InitialContext iniCtx = new InitialContext(); container.setTransactionManager(tmFactory.getTransactionManager()); // Set container.setTimerService(timerService); // Set security domain manager String securityDomain = bean.getApplicationMetaData().getSecurityDomain(); // JBAS-5960: Set default security domain if there is security metadata boolean hasSecurityMetaData = hasSecurityMetaData(bean); if (securityDomain == null && hasSecurityMetaData) { securityDomain = SecurityConstants.DEFAULT_EJB_APPLICATION_POLICY; } String confSecurityDomain = conf.getSecurityDomain(); // Default the config security to the application security manager if (confSecurityDomain == null) confSecurityDomain = securityDomain; // Check for an empty confSecurityDomain which signifies to disable security if (confSecurityDomain != null && confSecurityDomain.length() == 0) confSecurityDomain = null; if (confSecurityDomain != null) { // Either the application has a security domain or the container has security setup try { String unprefixed = SecurityUtil.unprefixSecurityDomain(confSecurityDomain); log.debug("Setting security domain from: " + confSecurityDomain); String domainCtx = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + unprefixed + "/domainContext"; SecurityDomainContext sdc = (SecurityDomainContext) iniCtx.lookup(domainCtx); Object securityMgr = sdc.getSecurityManager(); // Object securityMgr = iniCtx.lookup(confSecurityDomain); AuthenticationManager ejbS = (AuthenticationManager) securityMgr; RealmMapping rM = (RealmMapping) securityMgr; container.setSecurityManager(ejbS); container.setRealmMapping(rM); container.setSecurityManagement(securityManagement); container.setPolicyRegistration(policyRegistration); container.setDefaultSecurityDomain((String) unit.getAttachment("EJB.defaultSecurityDomain")); container.setSecurityContextClassName((String) unit.getAttachment("EJB.securityContextClassName")); } catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); } catch (Exception e) { throw new DeploymentException("Invalid security-domain specified, name=" + confSecurityDomain, e); } } else { if ("".equals(securityDomain) && hasSecurityMetaData) log.warn("EJB configured to bypass security. Please verify if this is intended. Bean=" + bean.getEjbName() + " Deployment=" + unit.getName()); } // Load the security proxy instance if one was configured String securityProxyClassName = bean.getSecurityProxy(); if (securityProxyClassName != null) { try { Class proxyClass = unitCl.loadClass(securityProxyClassName); Object proxy = proxyClass.newInstance(); container.setSecurityProxy(proxy); log.debug("setSecurityProxy, " + proxy); } catch (Exception e) { throw new DeploymentException("Failed to create SecurityProxy of type: " + securityProxyClassName, e); } } // Install the container interceptors based on the configuration addInterceptors(container, transType, conf.getContainerInterceptorsConf()); }
// in src/main/java/org/jboss/ejb/Container.java
public Context getEnvContext() throws NamingException { pushENC(); try { return (Context)new InitialContext().lookup("java:comp/env"); } finally { popENC(); } }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
protected InitialContext getInitialContext() throws NamingException { if (providerUrl == null) { return new InitialContext(); } else { log.debug("Using Context.PROVIDER_URL: " + providerUrl); java.util.Properties props = new java.util.Properties(System.getProperties()); props.put(Context.PROVIDER_URL, providerUrl); return new InitialContext(props); } }
// in src/main/java/org/jboss/monitor/EntityLockMonitor.java
private void bind() throws NamingException { Context ctx = new InitialContext(); // Ah ! We aren't serializable, so we use a helper class NonSerializableFactory.bind(JNDI_NAME, this); // The helper class NonSerializableFactory uses address type nns, we go on to // use the helper class to bind ourselves in JNDI StringRefAddr addr = new StringRefAddr("nns", JNDI_NAME); Reference ref = new Reference(EntityLockMonitor.class.getName(), addr, NonSerializableFactory.class.getName(), null); ctx.bind(JNDI_NAME, ref); }
// in src/main/java/org/jboss/monitor/EntityLockMonitor.java
private void unbind() throws NamingException { new InitialContext().unbind(JNDI_NAME); NonSerializableFactory.unbind(JNDI_NAME); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void processEncReferences(WebApplication webApp, Context envCtx) throws ClassNotFoundException, NamingException { DeploymentUnit unit = webApp.getDeploymentUnit(); JBossWebMetaData metaData = webApp.getMetaData(); EnvironmentEntriesMetaData envEntries = metaData.getEnvironmentEntries(); log.debug("addEnvEntries"); addEnvEntries(envEntries, envCtx); ResourceEnvironmentReferencesMetaData resourceEnvRefs = metaData.getResourceEnvironmentReferences(); log.debug("linkResourceEnvRefs"); linkResourceEnvRefs(resourceEnvRefs, envCtx); ResourceReferencesMetaData resourceRefs = metaData.getResourceReferences(); log.debug("linkResourceRefs"); linkResourceRefs(resourceRefs, envCtx); log.debug("linkMessageDestinationRefs"); MessageDestinationReferencesMetaData msgRefs = metaData.getMessageDestinationReferences(); linkMessageDestinationRefs(unit, msgRefs, envCtx); EJBReferencesMetaData ejbRefs = metaData.getEjbReferences(); log.debug("linkEjbRefs"); linkEjbRefs(unit, ejbRefs, envCtx); EJBLocalReferencesMetaData ejbLocalRefs = metaData.getEjbLocalReferences(); log.debug("linkEjbLocalRefs"); linkEjbLocalRefs(unit, ejbLocalRefs, envCtx); log.debug("linkServiceRefs"); ServiceReferencesMetaData serviceRefs = metaData.getServiceReferences(); linkServiceRefs(unit, serviceRefs, envCtx); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
private void linkServiceRefs(DeploymentUnit unit, ServiceReferencesMetaData serviceRefs, Context envCtx) throws NamingException { if (unit instanceof VFSDeploymentUnit) { VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit; ClassLoader loader = unit.getClassLoader(); UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(vfsUnit.getRoot()); for (ServiceReferenceMetaData sref : serviceRefs) { String refName = sref.getServiceRefName(); new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void addEnvEntries(EnvironmentEntriesMetaData envEntries, Context envCtx) throws ClassNotFoundException, NamingException { for (EnvironmentEntryMetaData entry : envEntries) { log.debug("Binding env-entry: " + entry.getName() + " of type: " + entry.getType() + " to value:" + entry.getValue()); bindEnvEntry(envCtx, entry); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkResourceEnvRefs(ResourceEnvironmentReferencesMetaData resourceEnvRefs, Context envCtx) throws NamingException { for (ResourceEnvironmentReferenceMetaData ref : resourceEnvRefs) { String resourceName = ref.getJndiName(); String refName = ref.getResourceEnvRefName(); if (ref.getType().equals("java.net.URL")) { try { log.debug("Binding '" + refName + "' to URL: " + resourceName); URL url = new URL(resourceName); Util.bind(envCtx, refName, url); } catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); } } else if (resourceName != null) { log.debug("Linking '" + refName + "' to JNDI name: " + resourceName); Util.bind(envCtx, refName, new LinkRef(resourceName)); } else { throw new NamingException("resource-env-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-env-ref."); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkResourceRefs(ResourceReferencesMetaData resourceRefs, Context envCtx) throws NamingException { for (ResourceReferenceMetaData ref : resourceRefs) { String jndiName = ref.getJndiName(); String refName = ref.getResourceName(); if (ref.getType().equals("java.net.URL")) { try { String resURL = ref.getResUrl(); if (resURL != null) { log.debug("Binding '" + refName + "' to URL: " + resURL); URL url = new URL(resURL); Util.bind(envCtx, refName, url); } else { log.debug("Linking '" + refName + "' to URL: " + resURL); LinkRef urlLink = new LinkRef(jndiName); Util.bind(envCtx, refName, urlLink); } } catch (MalformedURLException e) { throw new NamingException("Malformed URL:" + e.getMessage()); } } else if (jndiName != null) { log.debug("Linking '" + refName + "' to JNDI name: " + jndiName); Util.bind(envCtx, refName, new LinkRef(jndiName)); } else { throw new NamingException("resource-ref: " + refName + " has no valid JNDI binding. Check the jboss-web/resource-ref."); } } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkMessageDestinationRefs(DeploymentUnit unit, MessageDestinationReferencesMetaData msgRefs, Context envCtx) throws NamingException { for (MessageDestinationReferenceMetaData ref : msgRefs) { String refName = ref.getName(); String jndiName = ref.getJndiName(); String link = ref.getLink(); if (link != null) { if (jndiName == null) { MessageDestinationMetaData messageDestination = EjbUtil50.findMessageDestination(mainDeployer, unit, link); if (messageDestination == null) throw new NamingException("message-destination-ref '" + refName + "' message-destination-link '" + link + "' not found and no jndi-name in jboss-web.xml"); else { String linkJNDIName = messageDestination.getJndiName(); if (linkJNDIName == null) log.warn("message-destination '" + link + "' has no jndi-name in jboss-web.xml"); else jndiName = linkJNDIName; } } else log.warn("message-destination-ref '" + refName + "' ignoring message-destination-link '" + link + "' because it has a jndi-name in jboss-web.xml"); } else if (jndiName == null) throw new NamingException("message-destination-ref '" + refName + "' has no message-destination-link in web.xml and no jndi-name in jboss-web.xml"); Util.bind(envCtx, refName, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkEjbRefs(DeploymentUnit unit, EJBReferencesMetaData ejbRefs, Context envCtx) throws NamingException { for (EJBReferenceMetaData ejb : ejbRefs) { String name = ejb.getName(); String linkName = ejb.getLink(); String jndiName = null; // use ejb-link if it is specified if (linkName != null) { jndiName = EjbUtil50.findEjbLink(mainDeployer, unit, linkName); // if flag does not allow misconfigured ejb-links, it is an error if ((jndiName == null) && !(getLenientEjbLink())) throw new NamingException("ejb-ref: " + name + ", no ejb-link match"); } // fall through to the jndiName if (jndiName == null) { jndiName = ejb.getJndiName(); if (jndiName == null) throw new NamingException("ejb-ref: " + name + ", no ejb-link in web.xml and no jndi-name in jboss-web.xml"); } log.debug("Linking ejb-ref: " + name + " to JNDI name: " + jndiName); Util.bind(envCtx, name, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkEjbLocalRefs(DeploymentUnit unit, EJBLocalReferencesMetaData ejbLocalRefs, Context envCtx) throws NamingException { for (EJBLocalReferenceMetaData ejb : ejbLocalRefs) { String name = ejb.getName(); String linkName = ejb.getLink(); String jndiName = null; // use the ejb-link field if it is specified if (linkName != null) { jndiName = EjbUtil50.findLocalEjbLink(mainDeployer, unit, linkName); // if flag does not allow misconfigured ejb-links, it is an error if ((jndiName == null) && !(getLenientEjbLink())) throw new NamingException("ejb-ref: " + name + ", no ejb-link match"); } if (jndiName == null) { jndiName = ejb.getJndiName(); if (jndiName == null) { String msg = null; if (linkName == null) { msg = "ejb-local-ref: '" + name + "', no ejb-link in web.xml and " + "no local-jndi-name in jboss-web.xml"; } else { msg = "ejb-local-ref: '" + name + "', with web.xml ejb-link: '" + linkName + "' failed to resolve to an ejb with a LocalHome"; } throw new NamingException(msg); } } log.debug("Linking ejb-local-ref: " + name + " to JNDI name: " + jndiName); Util.bind(envCtx, name, new LinkRef(jndiName)); } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void linkSecurityDomain(String securityDomain, Context javaCompCtx) throws NamingException { if (securityDomain == null) { securityDomain = getDefaultSecurityDomain(); log.debug("No security-domain given, using default: " + securityDomain); } // JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix if (securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false) securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain; log.debug("Linking security/securityMgr to JNDI name: " + securityDomain); Util.bind(javaCompCtx, "env/security/securityMgr", new LinkRef(securityDomain)); Util.bind(javaCompCtx, "env/security/realmMapping", new LinkRef(securityDomain + "/realmMapping")); Util.bind(javaCompCtx, "env/security/authorizationMgr", new LinkRef(securityDomain + "/authorizationMgr")); Util.bind(javaCompCtx, "env/security/security-domain", new LinkRef(securityDomain)); Util.bind(javaCompCtx, "env/security/subject", new LinkRef(securityDomain + "/subject")); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
protected void unlinkSecurityDomain(String securityDomain, Context javaCompCtx) throws NamingException { log.debug("UnLinking security/securityMgr from JNDI "); Util.unbind(javaCompCtx, "env/security/securityMgr"); Util.unbind(javaCompCtx, "env/security/realmMapping"); Util.unbind(javaCompCtx, "env/security/authorizationMgr"); Util.unbind(javaCompCtx, "env/security/security-domain"); Util.unbind(javaCompCtx, "env/security/subject"); }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
public static void bindEnvEntry(Context ctx, EnvironmentEntryMetaData entry) throws ClassNotFoundException, NamingException { ClassLoader loader = EnvironmentEntryMetaData.class.getClassLoader(); Class type = loader.loadClass(entry.getType()); if (type == String.class) { Util.bind(ctx, entry.getName(), entry.getValue()); } else if (type == Integer.class) { Util.bind(ctx, entry.getName(), new Integer(entry.getValue())); } else if (type == Long.class) { Util.bind(ctx, entry.getName(), new Long(entry.getValue())); } else if (type == Double.class) { Util.bind(ctx, entry.getName(), new Double(entry.getValue())); } else if (type == Float.class) { Util.bind(ctx, entry.getName(), new Float(entry.getValue())); } else if (type == Byte.class) { Util.bind(ctx, entry.getName(), new Byte(entry.getValue())); } else if (type == Character.class) { Object value = null; String input = entry.getValue(); if (input == null || input.length() == 0) { value = new Character((char)0); } else { value = new Character(input.charAt(0)); } Util.bind(ctx, entry.getName(), value); } else if (type == Short.class) { Util.bind(ctx, entry.getName(), new Short(entry.getValue())); } else if (type == Boolean.class) { Util.bind(ctx, entry.getName(), new Boolean(entry.getValue())); } else { // Default to a String type Util.bind(ctx, entry.getName(), entry.getValue()); } }
// in src/main/java/org/jboss/proxy/ejb/GenericEJBInterceptor.java
protected EJBHome getEJBHome(Invocation invocation) throws NamingException { // Look to the context for the home InvocationContext ctx = invocation.getInvocationContext(); EJBHome home = (EJBHome) ctx.getValue(InvocationKey.EJB_HOME); // If there is no home use the legacy lookup method if( home == null ) { String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME); InitialContext iniCtx = new InitialContext(); home = (EJBHome) iniCtx.lookup(jndiName); } return home; }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void rebindHomeProxy() throws NamingException { // (Re-)Bind the home in the JNDI naming space log.debug("(re-)Binding Home " + jndiBinding); Util.rebind( // The context new InitialContext(), // Jndi name jndiBinding, // The Home getEJBHome() ); log.info("Bound EJB Home '" + container.getBeanMetaData().getEjbName() + "' to jndi '" + jndiBinding + "'"); }
35
            
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (NamingException ignore) { }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
catch(NamingException e) { // ignore log.trace("No env sub context found", e); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(NamingException e) { // No binding exists, create a subcontext subctx = subctx.createSubcontext(atom); }
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(NamingException e) { log.error("unbind failed", e); }
// in src/main/java/org/jboss/naming/java/javaURLContextFactory.java
catch (NamingException e) { e.printStackTrace(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("lookup for java: failed", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); buffer.append("Failed to get InitialContext, " + e.toString(true)); formatException(buffer, e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { log.error("Failed to get InitialContext", ne); buffer.append("Failed to get InitialContext, " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { buffer.append("Failed on lookup, " + e.toString(true)); formatException(buffer, e); continue; }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext for (java:)", e); appendErrorTag(buffer, "Failed to get InitialContext for (java:), " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { log.error("Failed to get InitialContext", e); appendErrorTag(buffer, "Failed to get InitialContext, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (ClassNotFoundException cnfe) { // If this is a $Proxy* class its a proxy if (className.startsWith("$Proxy")) { isProxy = true; // We have to get the class from the binding try { Object p = ctx.lookup(name); c = p.getClass(); } catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } } } }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException) { // Get the class name from the exception msg String msg = t.getMessage(); if (msg != null) { // Reset the class name to the CNFE class className = msg; } } }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true)); formatException(buffer, ne); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException ne) { appendErrorTag(buffer, "error while listing context " + ctx.toString() + ": " + ne.toString(true)); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (NamingException e) { appendErrorTag(buffer, "Failed to getLinkName, " + e.toString(true)); }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(NamingException e) { throw e; }
// in src/main/java/org/jboss/naming/JndiBinder.java
catch (NamingException e) { NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo); namingException.setRootCause(e); throw namingException; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (NamingException ex) { log.error("java:/TransactionManager lookup failed", ex); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (NamingException ignored) { }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (NamingException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (NamingException ignored) { }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); }
// in src/main/java/org/jboss/ejb/plugins/MetricsInterceptor.java
catch (NamingException e) { log.warn(Thread.currentThread().getName() + " exiting", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(NamingException e) { throw new DeploymentException("Filed to lookup: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NamingException e) { throw new EJBException("Data source for relationship named " + relationName + " not found " + dataSourceName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException e) { throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch (NamingException e) { log.warn("Problem closing naming context used for reaquiring invoker: " + e.getClass() + " -- " + e.getLocalizedMessage()); }
13
            
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(NamingException e) { throw e; }
// in src/main/java/org/jboss/naming/JndiBinder.java
catch (NamingException e) { NamingException namingException = new NamingException("Could not bind JndiBinder service into JNDI under jndiName:" + ctx.getNameInNamespace() + "/" + bindTo); namingException.setRootCause(e); throw namingException; }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (NamingException e) { throw new DeploymentException("Could not find the security-domain, name=" + confSecurityDomain, e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (NamingException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
catch(NamingException e) { throw new Exception("Failed to lookup data source: " + dataSource); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(NamingException e) { throw new DeploymentException("Filed to lookup: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NamingException e) { throw new EJBException("Data source for relationship named " + relationName + " not found " + dataSourceName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
catch(NamingException e) { throw new DeploymentException("Error: can't find data source: " + metadata.getDataSourceName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCKeyGenVersionFieldBridge.java
catch(NamingException e) { throw new DeploymentException("Could not lookup key generator factory: " + keygenFactoryName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCKeyGeneratorCreateCommand.java
catch(NamingException e) { throw new DeploymentException("Error: can't find key generator factory: " + factoryName, e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException e) { throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (BAD_OPERATION e) { try { // Reconnect Stub stub = (Stub) object; ORB orb = (ORB) new InitialContext().lookup("java:comp/ORB"); stub.connect(orb); } catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException ne) { throw new IOException("Unable to lookup java:comp/ORB"); }
1
unknown (Lib) NestedError 2
            
// in src/main/java/org/jboss/ejb/Container.java
protected void rethrow(Exception e) throws Exception { if (e instanceof IllegalAccessException) { // Throw this as a bean exception...(?) throw new EJBException(e); } else if (e instanceof InvocationTargetException) { Throwable t = ((InvocationTargetException)e).getTargetException(); if (t instanceof EJBException) { throw (EJBException)t; } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new NestedError("Unexpected Throwable", t); } } throw e; }
1
            
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof RuntimeException) { if (t instanceof EJBException) { throw (EJBException)t; } else { // Transform runtime exception into what a bean *should* have thrown throw new EJBException((RuntimeException)t); } } else if (t instanceof Exception) { throw (Exception)t; } else if (t instanceof Error) { throw (Error)t; } else { throw new org.jboss.util.NestedError("Unexpected Throwable", t); } }
0 0 0 0
unknown (Lib) NestedRuntimeException 12
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
protected void register(EntityEnterpriseContext ctx, Transaction tx) { boolean trace = log.isTraceEnabled(); if(trace) log.trace("register, ctx=" + ctx + ", tx=" + tx); EntityContainer ctxContainer = null; try { ctxContainer = (EntityContainer)ctx.getContainer(); if(!ctx.hasTxSynchronization()) { // Create a new synchronization Synchronization synch = createSynchronization(tx, ctx); // We want to be notified when the transaction commits tx.registerSynchronization(synch); ctx.hasTxSynchronization(true); } //mark it dirty in global tx entity map if it is not read only if(!ctxContainer.isReadOnly()) { ctx.getTxAssociation().scheduleSync(tx, ctx); } } catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); } catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public EJBLocalObject getStatefulSessionEJBLocalObject(Object id) { InvocationHandler handler = new StatefulSessionProxy(localJndiName, id, this); try { return (EJBLocalObject) proxyClassConstructor.newInstance(new Object[]{handler}); } catch(Exception ex) { throw new NestedRuntimeException(ex); } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
private EJBLocalObject createEJBLocalObject(Object id) { InvocationHandler handler = new EntityProxy(localJndiName, id, this); try { return (EJBLocalObject) proxyClassConstructor.newInstance(new Object[]{handler}); } catch(Exception ex) { throw new NestedRuntimeException(ex); } }
// in src/main/java/org/jboss/proxy/compiler/Proxy.java
public static Object newProxyInstance(final ClassLoader loader, final Class[] interfaces, final InvocationHandler h) { // Make all proxy instances implement Serializable Class[] interfaces2 = new Class[interfaces.length + 1]; System.arraycopy(interfaces, 0, interfaces2, 0, interfaces.length); interfaces2[interfaces2.length - 1] = Serializable.class; try { // create a new proxy return Proxies.newTarget(loader, h, interfaces2); } catch (Exception e) { throw new NestedRuntimeException("Failed to create new proxy target", e); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
public static HandleDelegate getDelegate() { try { InitialContext ctx = new InitialContext(); return (HandleDelegate) ctx.lookup("java:comp/HandleDelegate"); } catch (NamingException e) { throw new NestedRuntimeException(e); } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public Object getStatefulSessionEJBObject(Object id) { // Create a stack from the description (in the future) for now we hardcode it InvocationContext context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setCacheId(id); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); context.setInvoker(beanInvoker); log.debug("seting invoker proxy binding for stateful session: " + invokerMetaData.getName()); context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); context.setValue("InvokerID", Invoker.ID); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } ClientContainer client; if( includeIClientIface ) { client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } try { loadInterceptorChain(beanInterceptorClasses, client); } catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); } try { return (EJBObject) proxyClassConstructor.newInstance(new Object[]{client}); } catch(Exception ex) { throw new NestedRuntimeException(ex); } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public Object getEntityEJBObject(Object id) { Object result; if(id == null) { result = null; } else { // Create a stack from the description (in the future) for now we hardcode it InvocationContext context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setCacheId(id); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); context.setInvoker(beanInvoker); context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } ClientContainer client; if( includeIClientIface ) { client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } try { loadInterceptorChain(beanInterceptorClasses, client); } catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); } try { result = proxyClassConstructor.newInstance(new Object[]{client}); } catch(Exception ex) { throw new NestedRuntimeException(ex); } } return result; }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
public Object createProxy(Object id, ObjectName targetName, Invoker invoker, String jndiName, String proxyBindingName, ArrayList interceptorClasses, ClassLoader loader, Class[] ifaces, HashMap ctx) { InvocationContext context; if (ctx != null) context = new InvocationContext(ctx); else context = new InvocationContext(); Integer nameHash = new Integer(targetName.hashCode()); if (log.isTraceEnabled()) { log.trace("Target name " + targetName + " and corresponding hash code" + nameHash); } context.setObjectName(nameHash); context.setCacheId(id); if( jndiName != null ) context.setValue(InvocationKey.JNDI_NAME, jndiName); if( invoker == null ) throw new RuntimeException("Null invoker given for name: " + targetName); context.setInvoker(invoker); if( proxyBindingName != null ) context.setInvokerProxyBinding(proxyBindingName); // If the IClientContainer interceptor was specified, use the ClientContainerEx boolean wantIClientAccess = false; for(int n = 0; wantIClientAccess == false && n < interceptorClasses.size(); n ++) { Class type = (Class) interceptorClasses.get(n); wantIClientAccess = type.isAssignableFrom(IClientContainer.class); } ClientContainer client; if( wantIClientAccess ) { client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } try { loadInterceptorChain(interceptorClasses, client); } catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); } ArrayList tmp = new ArrayList(Arrays.asList(ifaces)); Class[] ifaces2 = new Class[tmp.size()]; tmp.toArray(ifaces2); return Proxy.newProxyInstance( // Classloaders loader, // Interfaces ifaces2, // Client container as invocation handler client); }
12
            
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/compiler/Proxy.java
catch (Exception e) { throw new NestedRuntimeException("Failed to create new proxy target", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HandleDelegateImpl.java
catch (NamingException e) { throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception ex) { throw new NestedRuntimeException(ex); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); }
0 0 0 0
unknown (Lib) NoClassDefFoundError 0 0 0 1
            
// in src/main/java/org/jboss/deployment/AnnotatedClassFilter.java
catch(NoClassDefFoundError ignored) { log.debug("Incomplete class: "+className+", NCDFE: "+ignored); }
0 0
unknown (Lib) NoSuchElementException 3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
public Object next() { if(!hasNext()) { throw new NoSuchElementException(); } hasNext = false; cursor = readNext(); results.add(cursor); return cursor; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public JDBCCMPFieldBridge next() { if(!hasNext()) throw new NoSuchElementException(); curIndex = nextIndex; return tableFields[nextIndex++]; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public JDBCCMPFieldBridge next() { throw new NoSuchElementException(); }
0 0 0 0 0
unknown (Lib) NoSuchEntityException 3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public Row loadRow(Object id) throws SQLException { View view = getView(); Row row = view.getRowByPk(id, false); if(row != null) { if(log.isTraceEnabled()) { log.trace("row is already loaded: pk=" + id); } return row; } JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + selectSql); } con = dataSource.getConnection(); ps = con.prepareStatement(selectSql); int paramInd = 1; for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object pkValue = pkField.getPrimaryKeyValue(id); paramInd = pkField.setArgumentParameters(ps, paramInd, pkValue); } rs = ps.executeQuery(); if(!rs.next()) { throw new NoSuchEntityException("Row not found: " + id); } return view.loadRow(rs, id, false); } catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private Object loadField(int i) { JDBCCMPFieldBridge2 field = (JDBCCMPFieldBridge2)entity.getFields().get(i); StringBuffer query = new StringBuffer(); query.append("select ") .append(field.getColumnName()) .append(" from ") .append(tableName) .append(" where "); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[])entity.getPrimaryKeyFields(); for(int pkI = 0; pkI < pkFields.length; ++pkI) { if(pkI > 0) { query.append(" and "); } query.append(pkFields[pkI].getColumnName()).append("=?"); } if(log.isDebugEnabled()) { log.debug("executing: " + query.toString()); } Object value = null; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = dataSource.getConnection(); ps = con.prepareStatement(query.toString()); for(int pkI = 0; pkI < pkFields.length; ++pkI) { JDBCCMPFieldBridge2 pkField = pkFields[pkI]; Object fieldValue = fields[pkField.getRowIndex()]; pkField.setArgumentParameters(ps, pkI + 1, fieldValue); } rs = ps.executeQuery(); if(!rs.next()) { throw new NoSuchEntityException("Row not found: " + pk); } value = field.loadArgumentResults(rs, 1); } catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } fields[field.getRowIndex()] = value; return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCLoadEntityCommand.java
private boolean execute(JDBCCMPFieldBridge requiredField, EntityEnterpriseContext ctx, boolean failIfNotFound) { // load the instance primary key fields into the context Object id = ctx.getId(); // TODO: when exactly do I need to do the following? entity.injectPrimaryKeyIntoInstance(ctx, id); // get the read ahead cache ReadAheadCache readAheadCache = manager.getReadAheadCache(); // load any preloaded fields into the context if(readAheadCache.load(ctx)) { if(requiredField == null || (requiredField != null && requiredField.isLoaded(ctx))) { return true; } } // get the finder results associated with this context, if it exists ReadAheadCache.EntityReadAheadInfo info = readAheadCache.getEntityReadAheadInfo(id); // determine the fields to load JDBCEntityBridge.FieldIterator loadIter = entity.getLoadIterator(requiredField, info.getReadAhead(), ctx); if(!loadIter.hasNext()) return true; // get the keys to load List loadKeys = info.getLoadKeys(); // generate the sql String sql = (rowLockingTemplate != null ? getRawLockingSQL(loadIter, loadKeys.size()) : getSQL(loadIter, loadKeys.size())); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { // create the statement if (log.isDebugEnabled()) { log.debug("Executing SQL: " + sql); } // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql); // Set the fetch size of the statement if (entity.getFetchSize() > 0) { ps.setFetchSize(entity.getFetchSize()); } // set the parameters int paramIndex = 1; for (int i = 0; i < loadKeys.size(); i++) { paramIndex = entity.setPrimaryKeyParameters(ps, paramIndex, loadKeys.get(i)); } // execute statement rs = ps.executeQuery(); // load results boolean mainEntityLoaded = false; Object[] ref = new Object[1]; while (rs.next()) { // reset the column index for this row int index = 1; // ref must be reset to null before load ref[0] = null; // if we are loading more then one entity, load the pk from the row Object pk = null; if (loadKeys.size() > 1) { // load the pk index = entity.loadPrimaryKeyResults(rs, index, ref); pk = ref[0]; } // is this the main entity or a preload entity if (loadKeys.size() == 1 || pk.equals(id)) { // main entity; load the values into the context loadIter.reset(); while(loadIter.hasNext()) { JDBCCMPFieldBridge field = loadIter.next(); index = field.loadInstanceResults(rs, index, ctx); field.setClean(ctx); } mainEntityLoaded = true; } else { // preload entity; load the values into the read ahead cahce loadIter.reset(); while(loadIter.hasNext()) { JDBCCMPFieldBridge field = loadIter.next(); // ref must be reset to null before load ref[0] = null; // load the result of the field index = field.loadArgumentResults(rs, index, ref); // cache the field value readAheadCache.addPreloadData(pk, field, ref[0]); } } } // clear LOAD_REQUIRED flag loadIter.removeAll(); // did we load the main results if (!mainEntityLoaded) { if (failIfNotFound) throw new NoSuchEntityException("Entity not found: primaryKey=" + ctx.getId()); else return false; } else return true; } catch (EJBException e) { throw e; } catch (Exception e) { throw new EJBException("Load failed", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
0 0 0 0 0
unknown (Lib) NoSuchFieldError 0 0 0 1
            
// in src/main/java/org/jboss/proxy/ejb/SecurityContextInterceptor.java
catch(NoSuchFieldError nsfe) { //Probably we are in 4.2.x return false; }
0 0
unknown (Lib) NoSuchFieldException 0 0 0 7
            
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (NoSuchFieldException e) { // will be here with dependant value object's private attributes // should not be a problem }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (NoSuchFieldException e) { // will be here with dependant value object's private attributes // should not be a problem }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(NoSuchFieldException e) { // Non recoverable internal exception throw new DeploymentException("No field named '" + getFieldName() + "' found in entity class."); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NoSuchFieldException e) { fireSpecViolationEvent(entity, new Section("9.4.7.1.b")); status = false; }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchFieldException ee) { throw new IllegalArgumentException(ee+" in "+c); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
4
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NoSuchFieldException e) { throw new DeploymentException("No field named '" + fieldName + "' found in entity class." + entity.getEntityClass().getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
catch(NoSuchFieldException e) { // Non recoverable internal exception throw new DeploymentException("No field named '" + getFieldName() + "' found in entity class."); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchFieldException ee) { throw new IllegalArgumentException(ee+" in "+c); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
2
unknown (Lib) NoSuchMethodError 0 0 0 1
            
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); }
0 0
unknown (Lib) NoSuchMethodException 4
            
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void setUpBeanMappingImpl(Map map, Method[] methods, String declaringClass) throws NoSuchMethodException { for (int i = 0; i < methods.length; i++) { Method m = methods[i]; if (m.getDeclaringClass().getName().equals(declaringClass) == false) { // Implemented by bean try { Method beanMethod = beanClass.getMethod(m.getName(), m.getParameterTypes()); map.put(m, beanMethod); } catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); } log.debug("Mapped " + m.getName() + " HASH " + m.hashCode() + "to " + map.get(m)); } else { // Implemented by container try { Method containerMethod = getClass().getMethod(m.getName(), new Class[]{Invocation.class}); map.put(m, containerMethod); } catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); } log.debug("Mapped Container method " + m.getName() + " HASH " + m.hashCode()); } } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void createMethodCache(Method[] methods) throws NoSuchMethodException { // Create cache of create methods Class beanClass = con.getBeanClass(); for(int i = 0; i < methods.length; i++) { String name = methods[i].getName(); if(name.startsWith("create")) { Class[] types = methods[i].getParameterTypes(); try { String nameSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); Method beanMethod = beanClass.getMethod("ejb" + nameSuffix, types); createMethods.put(methods[i], beanMethod); beanMethod = beanClass.getMethod("ejbPost" + nameSuffix, types); postCreateMethods.put(methods[i], beanMethod); } catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); } } } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
private void setupHomeMappingImpl(Method[] m, String finderName, String append) throws Exception { // Adrian Brock: This should go away when we don't support EJB1x boolean isEJB1x = metaData.getApplicationMetaData().isEJB1x(); for (int i = 0; i < m.length; i++) { String methodName = m[i].getName(); try { try // Try home method { String ejbHomeMethodName = "ejbHome" + methodName.substring(0,1).toUpperCase() + methodName.substring(1); homeMapping.put(m[i], beanClass.getMethod(ejbHomeMethodName, m[i].getParameterTypes())); continue; } catch (NoSuchMethodException ignore) {} // just go on with other types of methods // Implemented by container (in both cases) if (methodName.startsWith("find")) { homeMapping.put(m[i], this.getClass().getMethod(finderName, new Class[] { Invocation.class })); } else if (methodName.equals("create") || (isEJB1x == false && methodName.startsWith("create"))) { homeMapping.put(m[i], this.getClass().getMethod("create"+append, new Class[] { Invocation.class })); beanMapping.put(m[i], this.getClass().getMethod("postCreate"+append, new Class[] { Invocation.class })); } else { homeMapping.put(m[i], this.getClass().getMethod(methodName+append, new Class[] { Invocation.class })); } } catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); } } }
4
            
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); }
6
            
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void setUpBeanMappingImpl(Map map, Method[] methods, String declaringClass) throws NoSuchMethodException { for (int i = 0; i < methods.length; i++) { Method m = methods[i]; if (m.getDeclaringClass().getName().equals(declaringClass) == false) { // Implemented by bean try { Method beanMethod = beanClass.getMethod(m.getName(), m.getParameterTypes()); map.put(m, beanMethod); } catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); } log.debug("Mapped " + m.getName() + " HASH " + m.hashCode() + "to " + map.get(m)); } else { // Implemented by container try { Method containerMethod = getClass().getMethod(m.getName(), new Class[]{Invocation.class}); map.put(m, containerMethod); } catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); } log.debug("Mapped Container method " + m.getName() + " HASH " + m.hashCode()); } } }
// in src/main/java/org/jboss/ejb/SessionContainer.java
protected void setupBeanMapping() throws NoSuchMethodException { Map map = new HashMap(); if (remoteInterface != null) { Method[] m = remoteInterface.getMethods(); setUpBeanMappingImpl(map, m, "javax.ejb.EJBObject"); } if (localInterface != null) { Method[] m = localInterface.getMethods(); setUpBeanMappingImpl(map, m, "javax.ejb.EJBLocalObject"); } if (TimedObject.class.isAssignableFrom(beanClass)) { Method[] m = new Method[]{TimedObject.class.getMethod("ejbTimeout", new Class[]{Timer.class})}; setUpBeanMappingImpl(map, m, "javax.ejb.Timer"); } if (serviceEndpoint != null) { Method[] m = serviceEndpoint.getMethods(); setUpBeanMappingImpl(map, m, "java.rmi.Remote"); } beanMapping = map; }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
protected void setupHomeMapping() throws NoSuchMethodException { Map map = new HashMap(); if (homeInterface != null) { Method[] m = homeInterface.getMethods(); for (int i = 0; i < m.length; i++) { // Implemented by container log.debug("Mapping " + m[i].getName()); map.put(m[i], getClass().getMethod(m[i].getName() + "Home", m[i].getParameterTypes())); } } if (localHomeInterface != null) { Method[] m = localHomeInterface.getMethods(); for (int i = 0; i < m.length; i++) { // Implemented by container log.debug("Mapping " + m[i].getName()); map.put(m[i], getClass().getMethod(m[i].getName() + "LocalHome", m[i].getParameterTypes())); } } homeMapping = map; }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException { boolean result = false; int transType = metaData.getMethodTransactionType(method.getName(), method.getParameterTypes(), InvocationType.LOCAL); if (transType == MetaData.TX_REQUIRED) result = true; if (trace) log.trace("isDeliveryTransacted " + container.getBeanMetaData().getContainerObjectNameJndiName() + " method=" + method + " result=" + result); return result; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
private void createMethodCache( Method[] methods ) throws NoSuchMethodException { for (int i = 0; i < methods.length; i++) { String name = methods[i].getName(); if (name.startsWith("create")) { String nameSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); try { createMethods.put(methods[i], con.getBeanClass().getMethod("ejb" + nameSuffix, methods[i].getParameterTypes())); } catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); throw e; } try { postCreateMethods.put(methods[i], con.getBeanClass().getMethod("ejbPost" + nameSuffix, methods[i].getParameterTypes())); } catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; } } } // Create cache of finder methods for (int i = 0; i < methods.length; i++) { if (methods[i].getName().startsWith("find")) { try { finderMethods.put(methods[i], con.getBeanClass().getMethod("ejbF" + methods[i].getName().substring(1), methods[i].getParameterTypes())); } catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class"); throw e; } } } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void createMethodCache(Method[] methods) throws NoSuchMethodException { // Create cache of create methods Class beanClass = con.getBeanClass(); for(int i = 0; i < methods.length; i++) { String name = methods[i].getName(); if(name.startsWith("create")) { Class[] types = methods[i].getParameterTypes(); try { String nameSuffix = name.substring(0, 1).toUpperCase() + name.substring(1); Method beanMethod = beanClass.getMethod("ejb" + nameSuffix, types); createMethods.put(methods[i], beanMethod); beanMethod = beanClass.getMethod("ejbPost" + nameSuffix, types); postCreateMethods.put(methods[i], beanMethod); } catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); } } } }
63
            
// in src/main/java/org/jboss/naming/ExternalContext.java
catch(NoSuchMethodException e) { ctx = newLdapContext(contextClass, contextProps); }
// in src/main/java/org/jboss/ejb/txtimer/TimedObjectInvokerImpl.java
catch (NoSuchMethodException ignore) { }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.info(m[i].getName() + " in bean has not been mapped"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (NoSuchMethodException e) { log.debug("Couldn't find getEJBObject method on container"); }
// in src/main/java/org/jboss/ejb/CacheKey.java
catch(NoSuchMethodException ex) { // Rely on the MarshalledObject for equals and hashCode mo = new MarshalledObject(id); // Precompute the hashCode (speed) hashCode = mo.hashCode(); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
catch (NoSuchMethodException ignored) {}
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException ignored) {}
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class"); throw e; }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
catch (NoSuchMethodException ignored) {}
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCQueryMetaDataFactory.java
catch(NoSuchMethodException e) { // that's cool }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(NoSuchMethodException e) { throw new IllegalStateException( "Failed to find a ctor in " + valueType + " that takes an instance of " + argType + " as an argument." ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(NoSuchMethodException e) { // Should never happen log.error(SQL_ERROR, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { // this is ok method may not be defined on this interface }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
catch (NoSuchMethodException ignore) { }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (NoSuchMethodException ignore) {}
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { fireSpecViolationEvent(entity, new Section("10.6.2.g", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NoSuchMethodException e) { // The primary keyfield MUST be a CMP field within the // entity bean. // // Spec 10.8.1 // status = false; fireSpecViolationEvent(entity, new Section("10.8.1.b")); }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasDefaultConstructor("); tmp.append(") failure, "); Classes.displayClassInfo(c, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingMethod("); tmp.append(method.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBPostCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBCreate("); tmp.append(create.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { return null; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { return null; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBFind("); tmp.append(finder.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { return null; }
// in src/main/java/org/jboss/verifier/strategy/AbstractVerifier.java
catch (NoSuchMethodException e) { if( log.isTraceEnabled() ) { StringBuffer tmp = new StringBuffer("hasMatchingEJBHome("); tmp.append(home.toString()); tmp.append(") failure, "); Classes.displayClassInfo(bean, tmp); log.trace(tmp.toString(), e); } return false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { fireSpecViolationEvent(entity, new Section("10.6.2.g", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme) { // Try with java.util.Collection // // FIXME: This should only be tried for CMR methods; a CMP // setter cannot accept a Collection! try { args[0] = classloader.loadClass("java.util.Collection"); Method m = bean.getMethod(setName, args); } catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; } catch (ClassNotFoundException cnfe) { // Something is really broken } }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException nsme2) { fireSpecViolationEvent(entity, new Section("10.6.2.h", "Field: " + fieldName)); status = false; }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException e) { // The primary keyfield MUST be a CMP field within the // entity bean. // // Spec 10.8.1 // status = false; fireSpecViolationEvent(entity, new Section("10.8.1.b")); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NoSuchMethodException ignored) { }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchMethodException ee) { throw new IllegalArgumentException(ee+" in "+c); }
18
            
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException ex) { throw new NoSuchMethodException("Not found in bean class: " + m); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Not found in container class: " + m); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejb" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class " + con.getBeanClass() + " looking for method named: ejbPost" + nameSuffix); throw e; }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
catch (NoSuchMethodException e) { log.error("Home Method " + methods[i] + " not implemented in bean class"); throw e; }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
catch(NoSuchMethodException nsme) { throw new NoSuchMethodException("Can't find ejb[Post]Create in " + beanClass.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface " + home.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/QueryFactory.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface " + local.getClass().getName() + " does not contain findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
catch(NoSuchMethodException e) { throw new IllegalStateException( "Failed to find a ctor in " + valueType + " that takes an instance of " + argType + " as an argument." ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Compiler class does not have a constructor which takes " + Catalog.class.getName()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Home interface does not have a findByPrimaryKey method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCQueryManager.java
catch(NoSuchMethodException e) { throw new DeploymentException("Local home interface does " + "not have the method findByPrimaryKey(" + entity.getPrimaryKeyClass().getName() + ")"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("Driver does not have method: " + methodName + "()"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (NoSuchMethodException e) { throw new DeploymentException("StatementAccess.getUnderlyingStatement not found", e); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch (NoSuchMethodException e) { throw new NoSuchMethodException("Could not find matching method for "+m[i]); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (NoSuchMethodException ee) { throw new IllegalArgumentException(ee+" in "+c); }
2
unknown (Lib) NoSuchObjectException 2
            
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if (id == null) throw new IllegalArgumentException("Can't get an object with a null key"); EnterpriseContext ctx; synchronized (getCacheLock()) { CachePolicy cache = getCache(); ctx = (EnterpriseContext)cache.get(id); if (ctx == null) { try { ctx = acquireContext(); setKey(id, ctx); if (doActivate(ctx) == false) // This is a recursive activation return ctx; logActivation(id); // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here cache.insert(id, ctx); } catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if(id == null) throw new IllegalArgumentException("Can't get an object with a null key"); Map cache = getLocalCache(); EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id); if(instance == null) { try { // acquire instance = (EntityEnterpriseContext) container.getInstancePool().get(); // set key instance.setId(id); instance.setCacheKey(id); // activate container.getPersistenceManager().activateEntity(instance); // insert cache.put(id, instance); } catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); } } return instance; }
2
            
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); }
3
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { EnterpriseContext rtn = null; rtn = super.get(id); return rtn; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if (id == null) throw new IllegalArgumentException("Can't get an object with a null key"); EnterpriseContext ctx; synchronized (getCacheLock()) { CachePolicy cache = getCache(); ctx = (EnterpriseContext)cache.get(id); if (ctx == null) { try { ctx = acquireContext(); setKey(id, ctx); if (doActivate(ctx) == false) // This is a recursive activation return ctx; logActivation(id); // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here cache.insert(id, ctx); } catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if(id == null) throw new IllegalArgumentException("Can't get an object with a null key"); Map cache = getLocalCache(); EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id); if(instance == null) { try { // acquire instance = (EntityEnterpriseContext) container.getInstancePool().get(); // set key instance.setId(id); instance.setCacheKey(id); // activate container.getPersistenceManager().activateEntity(instance); // insert cache.put(id, instance); } catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); } } return instance; }
4
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
6
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
0
unknown (Lib) NoSuchObjectLocalException 10
            
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
public Timer getTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { EJBTimerService ejbTimerService = EJBTimerServiceLocator.getEjbTimerService(); ObjectName containerId = timedObjectId.getContainerId(); Object instancePk = timedObjectId.getInstancePk(); TimerServiceImpl timerService = (TimerServiceImpl)ejbTimerService.getTimerService(containerId, instancePk); if (timerService == null) throw new NoSuchObjectLocalException("TimerService not available: " + timedObjectId); TimerImpl timer = (TimerImpl)timerService.getTimer(this); if (timer == null || timer.isActive() == false) throw new NoSuchObjectLocalException("Timer not available: " + timedObjectId); return timer; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
private void assertTimedOut() { if (timerState == EXPIRED) throw new NoSuchObjectLocalException("Timer has expired"); if (timerState == CANCELED_IN_TX || timerState == CANCELED) throw new NoSuchObjectLocalException("Timer was canceled"); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/EntityProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { if(removed) { throw new javax.ejb.NoSuchObjectLocalException("The instance has been removed: " + toStringImpl()); } if (args == null) args = EMPTY_ARGS; Object retValue = super.invoke( proxy, m, args ); if( retValue == null ) { // If not taken care of, go on and call the container retValue = factory.invoke(cacheKey, m, args); } if(m.equals(REMOVE)) { removed = true; } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public Object getFieldValue(int i) { if(state == DELETED) { throw new NoSuchObjectLocalException("The instance was removed: " + pk); } Object value = fields[i]; if(value == NOT_LOADED) { value = loadField(i); } return value; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { InstanceCache cache = container.getInstanceCache(); InstancePool pool = container.getInstancePool(); Object methodID = mi.getId(); EnterpriseContext ctx = null; BeanLock lock = container.getLockManager().getLock(methodID); boolean callerRunAsIdentityPresent = SecurityActions.peekRunAsIdentity() != null; boolean pushSecurityContext = SecurityActions.getSecurityContext() == null; try { /* The security context must be established before the cache lookup because the activation of a session should have the caller's security context as ejbActivate is allowed to call other secured resources. Since the pm makes the ejbActivate call, we need to set the caller's security context. The only reason this shows up for stateful session is that we moved the SecurityInterceptor to after the instance interceptor to allow security exceptions to result in invalidation of the session. This may be too literal an interpretation of the ejb spec requirement that runtime exceptions should invalidate the session. */ if(!callerRunAsIdentityPresent && pushSecurityContext) { AuthenticationManager am = container.getSecurityManager(); String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(am != null) securityDomain = am.getSecurityDomain(); SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain , null); //SecurityActions.pushSubjectContext(mi.getPrincipal(), mi.getCredential(), null); } lock.sync(); try { // Get context try { ctx = cache.get(methodID); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } // Associate it with the method invocation mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // BMT beans will lock and replace tx no matter what, CMT do work on transaction boolean isBMT = ((SessionMetaData)container.getBeanMetaData()).isBeanManagedTx(); if (isBMT == false) { // Do we have a running transaction with the context if (ctx.getTransaction() != null && // And are we trying to enter with another transaction !ctx.getTransaction().equals(mi.getTransaction())) { // Calls must be in the same transaction StringBuffer msg = new StringBuffer("Application Error: " + "tried to enter Stateful bean with different tx context"); msg.append(", contextTx: " + ctx.getTransaction()); msg.append(", methodTx: " + mi.getTransaction()); throw new EJBException(msg.toString()); } //If the instance will participate in a new transaction we register a sync for it if (ctx.getTransaction() == null && mi.getTransaction() != null) { register(ctx, mi.getTransaction(), lock); } } if (!ctx.isLocked()) { //take it! ctx.lock(); } else { if (!isCallAllowed(mi)) { // Concurent calls are not allowed throw new EJBException("Application Error: no concurrent " + "calls on stateful beans"); } else { ctx.lock(); } } } finally { lock.releaseSync(); } // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); boolean validContext = true; try { // Invoke through interceptors Object ret = getNext().invoke(mi); return ret; } catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } } } finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
4
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; }
6
            
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
public Timer getTimer() throws IllegalStateException, NoSuchObjectLocalException, EJBException { EJBTimerService ejbTimerService = EJBTimerServiceLocator.getEjbTimerService(); ObjectName containerId = timedObjectId.getContainerId(); Object instancePk = timedObjectId.getInstancePk(); TimerServiceImpl timerService = (TimerServiceImpl)ejbTimerService.getTimerService(containerId, instancePk); if (timerService == null) throw new NoSuchObjectLocalException("TimerService not available: " + timedObjectId); TimerImpl timer = (TimerImpl)timerService.getTimer(this); if (timer == null || timer.isActive() == false) throw new NoSuchObjectLocalException("Timer not available: " + timedObjectId); return timer; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public void cancel() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.cancel"); registerTimerWithTx(); cancelInTx(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public long getTimeRemaining() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getTimeRemaining"); return nextExpire - System.currentTimeMillis(); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Date getNextTimeout() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getNextTimeout"); return new Date(nextExpire); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public Serializable getInfo() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getInfo"); return info; }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public TimerHandle getHandle() throws IllegalStateException, NoSuchObjectLocalException, EJBException { assertTimedOut(); assertAllowedOperation("Timer.getHandle"); return new TimerHandleImpl(this); }
3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/RelationSet.java
catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); }
3
unknown (Lib) NotSupportedException 1
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void begin() throws NotSupportedException, SystemException { if(getStatus() != Status.STATUS_NO_TRANSACTION) throw new NotSupportedException("Attempt to start a nested transaction (the transaction started previously hasn't been ended yet)."); ThreadInfo info = getThreadInfo(); trace = log.isTraceEnabled(); // Only check for trace enabled once per transaction if (trace) { log.trace("Calling UserTransaction.begin()"); } try { Object tpc = getSession().begin(info.getTimeout()); info.push(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
0 4
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void begin() throws NotSupportedException, SystemException { if(getStatus() != Status.STATUS_NO_TRANSACTION) throw new NotSupportedException("Attempt to start a nested transaction (the transaction started previously hasn't been ended yet)."); ThreadInfo info = getThreadInfo(); trace = log.isTraceEnabled(); // Only check for trace enabled once per transaction if (trace) { log.trace("Calling UserTransaction.begin()"); } try { Object tpc = getSession().begin(info.getTimeout()); info.push(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public Object begin(int timeout) throws RemoteException, NotSupportedException, SystemException { TransactionManager tm = getTransactionManager(); // Set timeout value tm.setTransactionTimeout(timeout); // Start tx, and get its TPC. tm.begin(); Object tpc = getTPCFactory().getTransactionPropagationContext(); // Suspend thread association. Transaction tx = tm.suspend(); // Remember that a new tx is now active. activeTx.put(tpc, tx); // return the TPC return tpc; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void begin() throws NotSupportedException, SystemException { TransactionManager tm = con.getTransactionManager(); int oldTimeout = -1; if (tm instanceof TransactionTimeoutConfiguration) oldTimeout = ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); // Set the timeout value tm.setTransactionTimeout(timeout); try { // Start the transaction tm.begin(); //notify checked out connections EJB2UserTransactionProvider.getSingleton().userTransactionStarted(); if (tsl != null) tsl.userTransactionStarted(); Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx begin: " + tx); // keep track of the transaction in enterprise context for BMT setTransaction(tx); } finally { // Reset the transaction timeout (if we know what it was) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); } }
0 0 0
unknown (Lib) NullArgumentException 1
            
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void setInstancePool(final InstancePool instancePool) { if (instancePool == null) throw new NullArgumentException("instancePool"); this.instancePool = instancePool; }
0 0 0 0 0
runtime (Lib) NullPointerException 0 0 0 8
            
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (NullPointerException e) { throw new MissingResourceException( "Resource not found.", msgBundle, "" ); }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NullPointerException e) { // That's OK - the implementor expected the fields to // have values }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier20.java
catch (NullPointerException e) { // That's OK - the implementor expected the fields to have values }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NullPointerException e) { // That's OK - the implementor expected the fields to // have values }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier21.java
catch (NullPointerException e) { // That's OK - the implementor expected the fields to have values }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NullPointerException e) { }
// in src/main/java/org/jboss/verifier/strategy/EJBVerifier11.java
catch (NullPointerException e) { }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
2
            
// in src/main/java/org/jboss/verifier/factory/DefaultEventFactory.java
catch (NullPointerException e) { throw new MissingResourceException( "Resource not found.", msgBundle, "" ); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
1
unknown (Lib) NumberFormatException 0 0 0 14
            
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "alias-max-length " + aliasMaxLengthString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Failed to parse int value '" + str + "' for max-keys-in-delete", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCReadAheadMetaData.java
catch(NumberFormatException ex) { throw new DeploymentException("Invalid number format in read-ahead page-size '" + pageSizeStr + "': " + ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in read-" + "ahead list-cache-max '" + listCacheMaxStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "fetch-size '" + fetchSizeStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
catch(NumberFormatException e) { throw new IllegalArgumentException("The parameter must begin with a number"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
14
            
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "alias-max-length " + aliasMaxLengthString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Failed to parse int value '" + str + "' for max-keys-in-delete", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCRelationMetaData.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutString + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCReadAheadMetaData.java
catch(NumberFormatException ex) { throw new DeploymentException("Invalid number format in read-ahead page-size '" + pageSizeStr + "': " + ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in read-" + "ahead list-cache-max '" + listCacheMaxStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCEntityMetaData.java
catch(NumberFormatException e) { throw new DeploymentException( "Invalid number format in " + "fetch-size '" + fetchSizeStr + "': " + e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCCMPFieldMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid number format in " + "read-time-out '" + readTimeOutStr + "': " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCFunctionMappingMetaData.java
catch(NumberFormatException e) { throw new DeploymentException("Invalid parameter number in function-sql: number=" + number + " sql=" + sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
catch(NumberFormatException e) { throw new IllegalArgumentException("The parameter must begin with a number"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (NumberFormatException x) { throw new DeploymentException("Can't parse policy configuration", x); }
1
unknown (Lib) ObjectNotFoundException 4
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/FindByPrimaryKeyCommand.java
public Object fetchOne(Schema schema, GenericEntityObjectFactory factory, Object[] args) throws FinderException { Object pk = args[0]; if(pk == null) { throw new IllegalArgumentException("Null argument for findByPrimaryKey"); } Object instance; boolean cached = entity.getTable().hasRow(pk); if(!cached) { instance = super.executeFetchOne(args, factory); if(instance == null) { throw new ObjectNotFoundException("Instance not find: entity=" + entity.getEntityName() + ", pk=" + pk); } } else { instance = factory.getEntityEJBObject(pk); } return instance; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
static Object fetchOne(JDBCEntityBridge2 entity, String sql, QueryParameter[] params, ResultReader resultReader, Object[] args, GenericEntityObjectFactory factory, Logger log) throws FinderException { Object pk; Connection con = null; PreparedStatement ps = null; ResultSet rs = null; boolean throwRuntimeExceptions = entity.getMetaData().getThrowRuntimeExceptions(); // if metadata is true, the getconnection is done inside // its own try catch block to throw a runtime exception (EJBException) if (throwRuntimeExceptions) { try { con = entity.getDataSource().getConnection(); } catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; } } try { if(log.isDebugEnabled()) { log.debug("executing: " + sql); } // if metadata is false, the getconnection is done inside this try catch block if ( ! throwRuntimeExceptions) { con = entity.getDataSource().getConnection(); } ps = con.prepareStatement(sql); if(params != null) { for(int i = 0; i < params.length; i++) { params[i].set(log, ps, i + 1, args); } } rs = ps.executeQuery(); if(rs.next()) { pk = resultReader.readRow(rs, factory); if(rs.next()) { List list = new ArrayList(); list.add(pk); list.add(resultReader.readRow(rs, factory)); while(rs.next()) { list.add(resultReader.readRow(rs, factory)); } throw new FinderException("More than one instance matches the single-object finder criteria: " + list); } } else { throw new ObjectNotFoundException(); } } catch(FinderException e) { throw e; } catch(Exception e) { FinderException fe = new FinderException(e.getMessage()); fe.initCause(e); throw fe; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } return pk; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCFindEntityCommand.java
public Object execute(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws FinderException { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(finderMethod); Collection result = query.execute(finderMethod, args, ctx, factory); if(result.isEmpty()) { throw new ObjectNotFoundException(NO_SUCH_ENTITY); } else if(result.size() == 1) { return result.iterator().next(); } else { throw new FinderException("More than one entity matches the finder criteria: " + result); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCSelectorBridge.java
public Object execute(Object[] args) throws FinderException { Collection retVal; Method method = getMethod(); try { JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(method); EntityContainer selectedContainer = query.getSelectManager().getContainer(); GenericEntityObjectFactory factory; if(queryMetaData.isResultTypeMappingLocal() && selectedContainer.getLocalHomeClass() != null) { factory = selectedContainer.getLocalProxyFactory(); } else { factory = selectedContainer.getProxyFactory(); } retVal = query.execute(method, args, null, factory); } catch(FinderException e) { throw e; } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in " + getSelectorName(), e); } if(!Collection.class.isAssignableFrom(getReturnType())) { // single object if(retVal.size() == 0) { throw new ObjectNotFoundException(); } if(retVal.size() > 1) { throw new FinderException(getSelectorName() + " returned " + retVal.size() + " objects"); } Object o = retVal.iterator().next(); if(o == null && method.getReturnType().isPrimitive()) { throw new FinderException( "Cannot return null as a value of primitive type " + method.getReturnType().getName() ); } return o; } else { // collection or set if(Set.class.isAssignableFrom(getReturnType())) { return new HashSet(retVal); } else { return retVal; } } }
0 0 0 0 0
unknown (Lib) ObjectStreamException 0 0 8
            
// in src/main/java/org/jboss/invocation/InvocationType.java
Object readResolve() throws ObjectStreamException { return values[ordinal]; }
// in src/main/java/org/jboss/invocation/PayloadKey.java
Object readResolve() throws ObjectStreamException { return values[ordinal]; }
// in src/main/java/org/jboss/invocation/InvocationKey.java
Object readResolve() throws ObjectStreamException { return values[ordinal]; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private Object readResolve() throws ObjectStreamException { server = MBeanServerLocator.locateJBoss(); tm = TransactionManagerLocator.getInstance().locate(); try { ds = lookupDataSource(dataSource); } catch(Exception e) { throw new IllegalStateException("Failed to lookup the DataSource " + dataSource, e); } return this; }
// in src/main/java/org/jboss/ejb/plugins/lock/Entrancy.java
Object readResolve() throws ObjectStreamException { if(value) { return ENTRANT; } else { return NON_ENTRANT; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/RelationInterceptor.java
Object readResolve() throws ObjectStreamException { return VALUES[ordinal]; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/CMPMessage.java
Object readResolve() throws ObjectStreamException { return VALUES[ordinal]; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/CMRMessage.java
Object readResolve() throws ObjectStreamException { return VALUES[ordinal]; }
1
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); }
1
            
// in src/main/java/org/jboss/invocation/http/interfaces/Util.java
catch (ObjectStreamException e) { // This generally represents a programming/deployment error, // not a communication problem throw new InvocationException(e); }
0
unknown (Lib) OperationNotSupportedException 1
            
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); if (methodName.equals("toString") == true) return "Client ENC(" + clientName + ")"; if (methodName.equals("lookup") == false) throw new OperationNotSupportedException("Only lookup is supported, op=" + method); NameParser parser = lookupCtx.getNameParser(""); Name name = null; if (args[0] instanceof String) name = parser.parse((String) args[0]); else name = (Name) args[0]; // Check for special objects not in the env if (name.size() < 2 || "java:comp".equals(name.get(0)) == false || "env".equals(name.get(1)) == false) return getSpecialObject(name); // Lookup the client application context from the server Context clientCtx = (Context) lookupCtx.lookup(clientName); // JBAS-3967: EJB3 Client container hack try { clientCtx = (Context) clientCtx.lookup("env"); } catch(NamingException e) { // ignore log.trace("No env sub context found", e); } // Strip the comp/env prefix Name bindingName = name.getSuffix(2); Object binding = clientCtx.lookup(bindingName); return binding; }
0 0 0 0 0
unknown (Lib) ParseException 0 0 1
            
// in src/main/java/org/jboss/verifier/Section.java
private String[] parseSection( String id ) throws ParseException { StringTokenizer tokenizer = new StringTokenizer( id, DELIMETER ); String[] token = new String[ tokenizer.countTokens() ]; for (int i = 0; tokenizer.hasMoreTokens(); ++i) { token[i] = tokenizer.nextToken(); } return token; }
2
            
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
catch (ParseException e) { throw new IllegalArgumentException("Cannot parse date/time in: " + externalForm); }
// in src/main/java/org/jboss/verifier/Section.java
catch ( ParseException e ) { throw new IllegalArgumentException( CONSTRUCTION_ERROR ); }
2
            
// in src/main/java/org/jboss/ejb/txtimer/TimerHandleImpl.java
catch (ParseException e) { throw new IllegalArgumentException("Cannot parse date/time in: " + externalForm); }
// in src/main/java/org/jboss/verifier/Section.java
catch ( ParseException e ) { throw new IllegalArgumentException( CONSTRUCTION_ERROR ); }
2
unknown (Lib) PolicyContextException 0 0 34
            
// in src/main/java/org/jboss/deployment/security/EarPolicyConfigurationFacade.java
Override protected void createPermissions(JBossAppMetaData metaData, PolicyConfiguration policyConfiguration) throws PolicyContextException { return; //No need for permissions }
// in src/main/java/org/jboss/deployment/security/EjbJaccPolicy.java
Override protected void createPermissions(JBossMetaData metaData, PolicyConfiguration policyConfiguration) throws PolicyContextException { JBossEnterpriseBeansMetaData beans = metaData.getEnterpriseBeans(); for(JBossEnterpriseBeanMetaData jBossEnterpriseBeanMetaData : beans) { EJBPermissionMapping.createPermissions(jBossEnterpriseBeanMetaData, policyConfiguration); } }
// in src/main/java/org/jboss/deployment/security/WarJaccPolicy.java
Override protected void createPermissions(JBossWebMetaData metaData, PolicyConfiguration policyConfiguration) throws PolicyContextException { WebPermissionMapping.createPermissions(metaData, policyConfiguration); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
private void createPolicyConfiguration() throws PolicyContextException, ClassNotFoundException { if(parentPC == null) { PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory(); parentPC = pcf.getPolicyConfiguration(contextID, false); } }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
protected void createPermissions(T metaData, PolicyConfiguration policyConfiguration) throws PolicyContextException { throw new RuntimeException("Need to override"); }
// in src/main/java/org/jboss/deployment/security/WarPolicyConfigurationFacade.java
Override protected void createPermissions(JBossWebMetaData metaData, PolicyConfiguration policyConfiguration) throws PolicyContextException { WebPermissionMapping.createPermissions(metaData, policyConfiguration); }
// in src/main/java/org/jboss/deployment/security/EjbPolicyConfigurationFacade.java
Override protected void createPermissions(JBossMetaData metaData, PolicyConfiguration policyConfiguration) throws PolicyContextException { JBossEnterpriseBeansMetaData beans = metaData.getEnterpriseBeans(); for(JBossEnterpriseBeanMetaData jBossEnterpriseBeanMetaData : beans) { EJBPermissionMapping.createPermissions(jBossEnterpriseBeanMetaData, policyConfiguration); } }
// in src/main/java/org/jboss/deployment/security/JaccPolicyUtil.java
public static void createPermissions(PolicyConfiguration policyConfiguration, Object metadata) throws PolicyContextException { if(metadata == null) throw new IllegalArgumentException("Meta Data is null"); if(policyConfiguration == null) throw new IllegalArgumentException("Policy Configuration is null"); if(metadata instanceof JBossWebMetaData) { JBossWebMetaData wmd = (JBossWebMetaData)metadata; WebPermissionMapping.createPermissions(wmd, policyConfiguration); } else if(metadata instanceof JBossEnterpriseBeanMetaData) { JBossEnterpriseBeanMetaData bmd = (JBossEnterpriseBeanMetaData)metadata; EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } else if(metadata instanceof JBossMetaData) { JBossMetaData jmd = (JBossMetaData)metadata; JBossEnterpriseBeansMetaData beans = jmd.getEnterpriseBeans(); for(JBossEnterpriseBeanMetaData bmd : beans) { EJBPermissionMapping.createPermissions(bmd, policyConfiguration); } } else throw new IllegalStateException("Unknown metadata"); }
// in src/main/java/org/jboss/deployment/security/EarJaccPolicy.java
Override protected void createPermissions(JBossAppMetaData metaData, PolicyConfiguration policyConfiguration) throws PolicyContextException { //nothing to do here }
// in src/main/java/org/jboss/ejb/BeanMetaDataPolicyContextHandler.java
public Object getContext(String key, Object data) throws PolicyContextException { Object context = null; if( key.equalsIgnoreCase(METADATA_CONTEXT_KEY) == true ) context = metaDataContext.get(); return context; }
// in src/main/java/org/jboss/ejb/BeanMetaDataPolicyContextHandler.java
public String[] getKeys() throws PolicyContextException { String[] keys = {METADATA_CONTEXT_KEY}; return keys; }
// in src/main/java/org/jboss/ejb/BeanMetaDataPolicyContextHandler.java
public boolean supports(String key) throws PolicyContextException { return key.equalsIgnoreCase(METADATA_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { try { return (Subject) AccessController.doPrivileged(exAction); } catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); } }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
static Subject getContextSubject() throws PolicyContextException { if(System.getSecurityManager() == null) { return PolicyContextActions.NON_PRIVILEGED.getContextSubject(); } else { return PolicyContextActions.PRIVILEGED.getContextSubject(); } }
// in src/main/java/org/jboss/ejb/EjbModule.java
void createMissingPermissions(Container con, BeanMetaData bean) throws ClassNotFoundException, PolicyContextException { String contextID = con.getJaccContextID(); PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); PolicyConfiguration pc = pcFactory.getPolicyConfiguration(contextID, false); Class clazz = con.getHomeClass(); // If there is no security domain mark all methods as unchecked boolean hasSecurityDomain = con.getSecurityManager() != null; boolean exclude = hasSecurityDomain ? bean.isExcludeMissingMethods() : false; if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.HOME, pc); } clazz = con.getLocalHomeClass(); if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.LOCALHOME, pc); } clazz = con.getLocalClass(); if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.LOCAL, pc); } clazz = con.getRemoteClass(); if (clazz != null) { addMissingMethodPermissions(bean, exclude, clazz, InvocationType.REMOTE, pc); } if (pc.inService() == false) pc.commit(); // Allow the policy to incorporate the policy configs Policy.getPolicy().refresh(); }
// in src/main/java/org/jboss/ejb/EjbModule.java
private void addMissingMethodPermissions(BeanMetaData bean, boolean exclude, Class iface, InvocationType type, PolicyConfiguration pc) throws PolicyContextException { String ejbName = bean.getEjbName(); HashSet tmp = new HashSet(); getInterfaces(iface, tmp); Class[] ifaces = new Class[tmp.size()]; tmp.toArray(ifaces); for (int n = 0; n < ifaces.length; n++) { Class c = ifaces[n]; Method[] methods = c.getDeclaredMethods(); for (int m = 0; m < methods.length; m++) { String methodName = methods[m].getName(); Class[] params = methods[m].getParameterTypes(); // See if there is a method-permission if (bean.hasMethodPermission(methodName, params, type)) continue; // Create a permission for the missing method-permission EJBMethodPermission p = new EJBMethodPermission(ejbName, type.toInterfaceString(), methods[m]); if (exclude) pc.addToExcludedPolicy(p); else pc.addToUncheckedPolicy(p); } } }
// in src/main/java/org/jboss/ejb/SOAPMsgPolicyContextHandler.java
public Object getContext(String key, Object data) throws PolicyContextException { Object context = null; if( key.equalsIgnoreCase(SEI_ARGS_KEY) == true ) context = ejbContext.get(); return context; }
// in src/main/java/org/jboss/ejb/SOAPMsgPolicyContextHandler.java
public String[] getKeys() throws PolicyContextException { String[] keys = {SEI_ARGS_KEY}; return keys; }
// in src/main/java/org/jboss/ejb/SOAPMsgPolicyContextHandler.java
public boolean supports(String key) throws PolicyContextException { return key.equalsIgnoreCase(SEI_ARGS_KEY); }
// in src/main/java/org/jboss/ejb/plugins/EnterpriseBeanPolicyContextHandler.java
public Object getContext(String key, Object data) throws PolicyContextException { Object context = null; if( key.equalsIgnoreCase(EJB_CONTEXT_KEY) == true ) context = ejbContext.get(); return context; }
// in src/main/java/org/jboss/ejb/plugins/EnterpriseBeanPolicyContextHandler.java
public String[] getKeys() throws PolicyContextException { String[] keys = {EJB_CONTEXT_KEY}; return keys; }
// in src/main/java/org/jboss/ejb/plugins/EnterpriseBeanPolicyContextHandler.java
public boolean supports(String key) throws PolicyContextException { return key.equalsIgnoreCase(EJB_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { try { return (Subject) AccessController.doPrivileged(exAction); } catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
static Subject getContextSubject() throws PolicyContextException { if(System.getSecurityManager() == null) { return PolicyContextActions.NON_PRIVILEGED.getContextSubject(); } else { return PolicyContextActions.PRIVILEGED.getContextSubject(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { try { return (Subject) AccessController.doPrivileged(exAction); } catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
static Subject getContextSubject() throws PolicyContextException { if(System.getSecurityManager() == null) { return PolicyContextActions.NON_PRIVILEGED.getContextSubject(); } else { return PolicyContextActions.PRIVILEGED.getContextSubject(); } }
// in src/main/java/org/jboss/ejb/EJBPermissionMapping.java
public static void createPermissions(JBossEnterpriseBeanMetaData bean, PolicyConfiguration pc) throws PolicyContextException { // Process the method-permission MethodMetaData MethodPermissionsMetaData perms = bean.getMethodPermissions(); if (perms != null) for (MethodPermissionMetaData perm : perms) { MethodsMetaData methods = perm.getMethods(); if (methods != null) for (org.jboss.metadata.ejb.spec.MethodMetaData mmd : methods) { String[] params = {}; if (mmd.getMethodParams() != null) params = mmd.getMethodParams().toArray(params); else params = null; String methodName = mmd.getMethodName(); if (methodName != null && methodName.equals("*")) methodName = null; MethodInterfaceType miType = mmd.getMethodIntf(); String iface = miType != null ? miType.name() : null; EJBMethodPermission p = new EJBMethodPermission(mmd.getEjbName(), methodName, iface, params); if (perm.getUnchecked() != null) { pc.addToUncheckedPolicy(p); } else { Set<String> roles = perm.getRoles(); Iterator riter = roles.iterator(); while (riter.hasNext()) { String role = (String) riter.next(); pc.addToRole(role, p); } } } } // Process the exclude-list MethodMetaData ExcludeListMetaData excluded = bean.getExcludeList(); if (excluded != null) { MethodsMetaData methods = excluded.getMethods(); if (methods != null) for (org.jboss.metadata.ejb.spec.MethodMetaData mmd : methods) { String[] params = {}; if (mmd.getMethodParams() != null) params = mmd.getMethodParams().toArray(params); else params = null; String methodName = mmd.getMethodName(); if (methodName != null && methodName.equals("*")) methodName = null; MethodInterfaceType miType = mmd.getMethodIntf(); String iface = miType != null ? miType.name() : null; EJBMethodPermission p = new EJBMethodPermission(mmd.getEjbName(), methodName, iface, params); pc.addToExcludedPolicy(p); } } // Process the security-role-ref SecurityRoleRefMetaData SecurityRoleRefsMetaData refs = bean.getSecurityRoleRefs(); if (refs != null) for (org.jboss.metadata.javaee.spec.SecurityRoleRefMetaData ref : refs) { EJBRoleRefPermission p = new EJBRoleRefPermission(bean.getEjbName(), ref.getRoleName()); pc.addToRole(ref.getRoleLink(), p); } /* Special handling of stateful session bean getEJBObject due how the stateful session handles acquire the proxy by sending an invocation to the ejb container. */ if (bean.isSession()) { JBossSessionBeanMetaData smd = (JBossSessionBeanMetaData) bean; if (smd.isStateful()) { EJBMethodPermission p = new EJBMethodPermission(bean.getEjbName(), "getEJBObject", "Home", null); pc.addToUncheckedPolicy(p); } } }
// in src/main/java/org/jboss/ejb/EJBArgsPolicyContextHandler.java
public Object getContext(String key, Object data) throws PolicyContextException { Object context = null; if( key.equalsIgnoreCase(EJB_ARGS_KEY) == true ) context = ejbContext.get(); return context; }
// in src/main/java/org/jboss/ejb/EJBArgsPolicyContextHandler.java
public String[] getKeys() throws PolicyContextException { String[] keys = {EJB_ARGS_KEY}; return keys; }
// in src/main/java/org/jboss/ejb/EJBArgsPolicyContextHandler.java
public boolean supports(String key) throws PolicyContextException { return key.equalsIgnoreCase(EJB_ARGS_KEY); }
// in src/main/java/org/jboss/web/WebPermissionMapping.java
public static void createPermissions(JBossWebMetaData metaData, PolicyConfiguration pc) throws PolicyContextException { HashMap<String, PatternInfo> patternMap = qualifyURLPatterns(metaData); log.debug("Qualified url patterns: "+patternMap); List<SecurityConstraintMetaData> constraints = metaData.getSecurityConstraints(); if(constraints != null) { for(SecurityConstraintMetaData sc : constraints) { WebResourceCollectionsMetaData resources = sc.getResourceCollections(); TransportGuaranteeType transport = sc.getTransportGuarantee(); if( sc.isExcluded() || sc.isUnchecked() ) { // Process the permissions for the excluded/unchecked resources if(resources != null) for(WebResourceCollectionMetaData wrc : resources) { List<String> httpMethods = wrc.getHttpMethods(); List<String> urlPatterns = wrc.getUrlPatterns(); int length = urlPatterns != null ? urlPatterns.size() : 0; for(int n = 0; n < length; n ++) { String url = urlPatterns.get(n); PatternInfo info = (PatternInfo) patternMap.get(url); // Add the excluded methods if( sc.isExcluded() ) { info.addExcludedMethods(httpMethods); } } } } else { // Process the permission for the resources x roles if(resources != null) for(WebResourceCollectionMetaData wrc : resources) { List<String> httpMethods = wrc.getHttpMethods(); List<String> urlPatterns = wrc.getUrlPatterns(); int length = urlPatterns != null ? urlPatterns.size() : 0; for(int n = 0; n < length; n ++) { String url = urlPatterns.get(n); // Get the qualified url pattern PatternInfo info = (PatternInfo) patternMap.get(url); HashSet<String> mappedRoles = new HashSet<String>(); if(sc.getRoleNames() != null) for(String role : sc.getRoleNames()) { if( role.equals("*") ) { //JBAS-1824: Allow "*" to provide configurable authorization bypass if(metaData.isJaccAllStoreRole()) mappedRoles.add("*"); else { // The wildcard ref maps to all declared security-role names for(SecurityRoleMetaData srmd : metaData.getSecurityRoles()) { role = srmd.getRoleName(); mappedRoles.add(role); } } } else { mappedRoles.add(role); } } info.addRoles(mappedRoles, httpMethods); // Add the transport to methods info.addTransport(transport.name(), httpMethods); //SECURITY-63: Missing auth-constraint needs unchecked policy if(sc.getAuthConstraint() == null) info.isMissingAuthConstraint = true; } } } } } // Create the permissions for(PatternInfo info : patternMap.values()) { String qurl = info.getQualifiedPattern(); if( info.isOverriden == true ) { log.debug("Dropping overriden pattern: "+info); continue; } // Create the excluded permissions String[] httpMethods = info.getExcludedMethods(); if( httpMethods != null ) { // There were excluded security-constraints WebResourcePermission wrp = new WebResourcePermission(qurl, httpMethods); WebUserDataPermission wudp = new WebUserDataPermission(qurl, httpMethods, null); pc.addToExcludedPolicy(wrp); pc.addToExcludedPolicy(wudp); //!(excluded methods) [JACC 1.1] String excludedString = "!" + getCommaSeparatedString(httpMethods); WebResourcePermission wrp1 = new WebResourcePermission(info.pattern, excludedString); WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern,excludedString); pc.addToUncheckedPolicy(wrp1); pc.addToUncheckedPolicy(wudp1); } // Create the role permissions Iterator<Map.Entry<String, Set<String>>> roles = info.getRoleMethods(); while( roles.hasNext() ) { Map.Entry<String, Set<String>> roleMethods = roles.next(); String role = (String) roleMethods.getKey(); WebResourcePermission wrp; if("*".equals(role)) { //JBAS-1824: <role-name>*</role-name> wrp = new WebResourcePermission(qurl, (String)null); } else { Set<String> methods = roleMethods.getValue(); httpMethods = new String[methods.size()]; methods.toArray(httpMethods); wrp = new WebResourcePermission(qurl, httpMethods); } pc.addToRole(role, wrp); //JACC 1.1: create !(httpmethods) in unchecked perms if(httpMethods != null) { final String pattern = info.pattern; final String methodsAsString = "!" + getCommaSeparatedString(httpMethods); WebResourcePermission wrpUnchecked = null; try { wrpUnchecked = new WebResourcePermission(pattern, methodsAsString); } catch (final IllegalArgumentException iae) { throw new IllegalArgumentException("Could not create resource permission with pattern \"" + pattern + "\" and methods: " + methodsAsString, iae); } pc.addToUncheckedPolicy(wrpUnchecked); } } // Create the unchecked permissions String[] missingHttpMethods = info.getMissingMethods(); if( missingHttpMethods.length > 0 ) { // Create the unchecked permissions WebResourcePermissions WebResourcePermission wrp = new WebResourcePermission(qurl, missingHttpMethods); pc.addToUncheckedPolicy(wrp); } else pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null)); //SECURITY-63: Missing auth-constraint needs unchecked policy if(info.isMissingAuthConstraint) { pc.addToUncheckedPolicy(new WebResourcePermission(qurl, (String)null)); } // Create the unchecked permissions WebUserDataPermissions Iterator<Map.Entry<String, Set<String>>> transportContraints = info.getTransportMethods(); while( transportContraints.hasNext() ) { Map.Entry<String, Set<String>> transportMethods = transportContraints.next(); String transport = transportMethods.getKey(); Set<String> methods = transportMethods.getValue(); httpMethods = new String[methods.size()]; methods.toArray(httpMethods); WebUserDataPermission wudp = new WebUserDataPermission(qurl, httpMethods, transport); pc.addToUncheckedPolicy(wudp); //If the transport is "NONE", then add an exlusive WebUserDataPermission //with the url pattern and null if("NONE".equals(transport)) { WebUserDataPermission wudp1 = new WebUserDataPermission(info.pattern, null); pc.addToUncheckedPolicy(wudp1); } else { //JACC 1.1: Transport is CONFIDENTIAL/INTEGRAL, add a !(http methods) if(httpMethods != null) { WebUserDataPermission wudpNonNull = new WebUserDataPermission(info.pattern, "!" + getCommaSeparatedString(httpMethods)); pc.addToUncheckedPolicy(wudpNonNull); } } } } /* Create WebRoleRefPermissions for all servlet/security-role-refs along with all the cross product of servlets and security-role elements that are not referenced via a security-role-ref as described in JACC section 3.1.3.2 */ JBossServletsMetaData servlets = metaData.getServlets(); for(JBossServletMetaData servlet : servlets) { String servletName = servlet.getServletName(); SecurityRoleRefsMetaData roleRefs = servlet.getSecurityRoleRefs(); //Perform the unreferenced roles processing for every servlet name Set<String> unreferencedRoles = metaData.getSecurityRoleNames(); if(roleRefs != null) for(SecurityRoleRefMetaData roleRef : roleRefs) { String roleName = roleRef.getRoleLink(); WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, roleRef.getName()); pc.addToRole(roleName, wrrp); /* A bit of a hack due to how tomcat calls out to its Realm.hasRole() with a role name that has been mapped to the role-link value. We may need to handle this with a custom request wrapper. */ wrrp = new WebRoleRefPermission(servletName, roleName); pc.addToRole(roleRef.getName(), wrrp); // Remove the role from the unreferencedRoles unreferencedRoles.remove(roleName); } //Spec 3.1.3.2: For each servlet element in the deployment descriptor //a WebRoleRefPermission must be added to each security-role of the //application whose name does not appear as the rolename //in a security-role-ref within the servlet element. if(unreferencedRoles != null) for(String unrefRole : unreferencedRoles) { WebRoleRefPermission unrefP = new WebRoleRefPermission(servletName,unrefRole); pc.addToRole(unrefRole, unrefP); } } Set<String> unreferencedRoles = metaData.getSecurityRoleNames(); //JACC 1.1:Spec 3.1.3.2: For each security-role defined in the deployment descriptor, an //additional WebRoleRefPermission must be added to the corresponding role by //calling the addToRole method on the PolicyConfiguration object. The //name of all such permissions must be the empty string, and the actions of each //such permission must be the role-name of the corresponding role. if(unreferencedRoles != null) for(String unreferencedRole : unreferencedRoles) { WebRoleRefPermission wrrep = new WebRoleRefPermission("", unreferencedRole); pc.addToRole(unreferencedRole, wrrep); } // Now build the cross product of the unreferencedRoles and servlets Set<String> servletNames = servlets.keySet(); if(servletNames != null) for(String servletName : servletNames) { if(unreferencedRoles != null) for(String role : unreferencedRoles) { WebRoleRefPermission wrrp = new WebRoleRefPermission(servletName, role); pc.addToRole(role, wrrp); } } /** * The programmatic security checks are made from jsps. * JBAS-3054:Use of isCallerInRole from jsp does not work for JACC */ if(unreferencedRoles != null) for(String role : unreferencedRoles) { WebRoleRefPermission wrrp = new WebRoleRefPermission("", role); pc.addToRole(role, wrrp); } }
7
            
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException("Cannot create permissions:",e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/PolicyConfigurationFacade.java
catch (PolicyContextException e) { new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/PolicyConfigurationFacade.java
catch (PolicyContextException e) { new RuntimeException(e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (PolicyContextException pe) { if(log.isTraceEnabled()) log.trace("PolicyContextException in getting caller subject:",pe); }
4
            
// in src/main/java/org/jboss/deployment/EARInitializingDeployer.java
catch (PolicyContextException e) { throw new DeploymentException("PolicyContextException generated in deploy", e); }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException("Cannot create permissions:",e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException(e); }
3
unknown (Lib) PrivilegedActionException 0 0 8
            
// in src/main/java/org/jboss/jmx/connector/invoker/SecurityActions.java
static SecurityContext createSecurityContext(final String domain) throws PrivilegedActionException { return (SecurityContext)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return SecurityContextFactory.createSecurityContext(domain); }}); }
// in src/main/java/org/jboss/ejb/txtimer/SecurityActions.java
static SecurityContext createSecurityContext(final String securityDomain) throws PrivilegedActionException { return (SecurityContext)AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(securityDomain); SecurityContextAssociation.setSecurityContext(sc); return sc; } }); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
static boolean isCallerInRole(final SecurityContext sc, final String roleName, final String ejbName, final Principal principal, final Subject contextSubject, final String jaccContextID, final Set<SecurityRoleRef> securityRoleRefs) throws PrivilegedActionException { return AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() { public Boolean run() throws Exception { AbstractEJBAuthorizationHelper helper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); return helper.isCallerInRole(roleName, ejbName, principal, contextSubject, jaccContextID, securityRoleRefs); } }); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain, final Subject subject) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(p, cred, null, domain); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
static void createAndSetSecurityContext(final Principal p, final Object cred, final String domain, final Subject subject) throws PrivilegedActionException { AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain); sc.getUtil().createSubjectInfo(p, cred, subject); SecurityContextAssociation.setSecurityContext(sc); return null; }}); }
// in src/main/java/org/jboss/ejb/plugins/security/SecurityActions.java
static SecurityContext createAndSetSecurityContext(final String domain, final String fqnClassName) throws PrivilegedActionException { return AccessController.doPrivileged(new PrivilegedExceptionAction<SecurityContext>() { public SecurityContext run() throws Exception { SecurityContext sc = SecurityContextFactory.createSecurityContext(domain, fqnClassName); setSecurityContext(sc); return sc; }} ); }
8
            
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { throw e.getException(); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/Container.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
11
            
// in src/main/java/org/jboss/invocation/local/LocalInvoker.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { throw e.getException(); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/Container.java
catch (PrivilegedActionException e) { Exception ex = e.getException(); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
catch(PrivilegedActionException e) { throw (FileNotFoundException) e.getException(); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
0
checked (Domain) ReentranceException
public static class ReentranceException extends Exception
   {
      public ReentranceException()
      {
      }

      public ReentranceException(String message)
      {
         super(message);
      }
   }
2
            
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
protected boolean acquireNonReentrant(long waitTime, Transaction miTx) throws ApplicationDeadlockException, InterruptedException, ReentranceException { synchronized(lock) { final Thread curThread = Thread.currentThread(); if(lockHolder != null) { if(lockHolder == curThread) { if(inNonReentrant) { throw new ReentranceException("The same thread reentered: thread-holder=" + lockHolder + ", holding tx=" + holdingTx + ", current tx=" + miTx); } } else if(miTx != null && miTx.equals(holdingTx)) { if(inNonReentrant) { throw new ReentranceException("The same tx reentered: tx=" + miTx + ", holding thread=" + lockHolder + ", current thread=" + curThread); } } else { // Always upgrade deadlock holder to Tx so that we can detect lock properly Object deadlocker = curThread; if(miTx != null) deadlocker = miTx; try { DeadlockDetector.singleton.deadlockDetection(deadlocker, this); while(lockHolder != null) { if(waitTime < 1) { lock.wait(); } else { lock.wait(waitTime); } // If we waited and never got lock, abort if(waitTime > 0 && lockHolder != null) return false; } } finally { DeadlockDetector.singleton.removeWaiting(deadlocker); } } } ++held; lockHolder = curThread; holdingTx = miTx; inNonReentrant = true; } return true; }
0 3
            
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
protected boolean acquireNonReentrant(long waitTime, Transaction miTx) throws ApplicationDeadlockException, InterruptedException, ReentranceException { synchronized(lock) { final Thread curThread = Thread.currentThread(); if(lockHolder != null) { if(lockHolder == curThread) { if(inNonReentrant) { throw new ReentranceException("The same thread reentered: thread-holder=" + lockHolder + ", holding tx=" + holdingTx + ", current tx=" + miTx); } } else if(miTx != null && miTx.equals(holdingTx)) { if(inNonReentrant) { throw new ReentranceException("The same tx reentered: tx=" + miTx + ", holding thread=" + lockHolder + ", current thread=" + curThread); } } else { // Always upgrade deadlock holder to Tx so that we can detect lock properly Object deadlocker = curThread; if(miTx != null) deadlocker = miTx; try { DeadlockDetector.singleton.deadlockDetection(deadlocker, this); while(lockHolder != null) { if(waitTime < 1) { lock.wait(); } else { lock.wait(waitTime); } // If we waited and never got lock, abort if(waitTime > 0 && lockHolder != null) return false; } } finally { DeadlockDetector.singleton.removeWaiting(deadlocker); } } } ++held; lockHolder = curThread; holdingTx = miTx; inNonReentrant = true; } return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
protected boolean acquireReentrant(long waitTime, Transaction miTx) throws ApplicationDeadlockException, InterruptedException, ReentranceException { synchronized(lock) { final Thread curThread = Thread.currentThread(); if(lockHolder != null) { if(lockHolder != curThread && (miTx == null || miTx.equals(holdingTx))) { // Always upgrade deadlock holder to Tx so that we can detect lock properly Object deadlocker = curThread; if(miTx != null) deadlocker = miTx; try { DeadlockDetector.singleton.deadlockDetection(deadlocker, this); while(lockHolder != null) { if(waitTime < 1) { lock.wait(); } else { lock.wait(waitTime); } // If we waited and never got lock, abort if(waitTime > 0 && lockHolder != null) return false; } } finally { DeadlockDetector.singleton.removeWaiting(deadlocker); } } } ++held; lockHolder = curThread; holdingTx = miTx; } return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/NonReentrantLock.java
public boolean attempt(long waitTime, Transaction miTx, boolean nonReentrant) throws ApplicationDeadlockException, InterruptedException, ReentranceException { return nonReentrant ? acquireNonReentrant(waitTime, miTx) : acquireReentrant(waitTime, miTx); }
1
            
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
2
            
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
0
unknown (Lib) RejectedExecutionException 1
            
// in src/main/java/org/jboss/executor/ControllerExecutorInstaller.java
public void execute(Runnable command) { Executor exec = mainExecutor; if (exec != null) { exec.execute(command); return; } exec = bootstrapExecutor; if (exec != null) { exec.execute(command); return; } throw new RejectedExecutionException("No executor available in " + this.getClass().getName()); }
0 0 0 0 0
unknown (Lib) RemoteException 16
            
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); ejbObject.remove(); return null; } else throw new RemoveException("EJBHome.remove(Object) not allowed for session beans"); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object getPrimaryKey() throws RemoteException { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { // All we need is an EJBObject for this Id, the first argument is the Id EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Object id = mi.getArguments()[0]; if (id == null) throw new IllegalStateException("Cannot get a session interface with a null id"); // Does the session still exist? InstanceCache cache = getInstanceCache(); BeanLock lock = getLockManager().getLock(id); lock.sync(); try { if (cache.get(id) == null) throw new RemoteException("Session no longer exists: " + id); } finally { lock.releaseSync(); getLockManager().removeLockRef(id); } // Ok lets create the proxy return (EJBObject) ci.getStatefulSessionEJBObject(id); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); // The key Object key = mi.getId(); // The context EntityEnterpriseContext ctx; try { ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } if (trace) log.trace("Begin invoke, key=" + key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor // Don't set the transction if a read-only method. With a read-only method, the ctx can be shared // between multiple transactions. Transaction tx = mi.getTransaction(); if (!container.isReadOnly()) { Method method = mi.getMethod(); if (method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { ctx.setTransaction(tx); } } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); Throwable exceptionThrown = null; boolean discardContext = false; try { Object obj = getNext().invoke(mi); return obj; } catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; } catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; } catch (Error e) { exceptionThrown = e; discardContext = true; throw e; } catch (Exception e) { exceptionThrown = e; throw e; } catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); // Make sure we clear the transaction on an error before synchronization. // But avoid a race with a transaction rollback on a synchronization // that may have moved the context onto a different transaction if (exceptionThrown != null && tx != null) { Transaction ctxTx = ctx.getTransaction(); if (tx.equals(ctxTx) && ctx.hasTxSynchronization() == false) ctx.setTransaction(null); } // If an exception has been thrown, if (exceptionThrown != null && // if tx, the ctx has been registered in an InstanceSynchronization. // that will remove the context, so we shouldn't. // if no synchronization then we need to do it by hand // But not for application exceptions !ctx.hasTxSynchronization() && discardContext) { // Discard instance // EJB 1.1 spec 12.3.1 container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown); } else if (ctx.getId() == null) { // The key from the Invocation still identifies the right cachekey container.getInstanceCache().remove(key); if (trace) log.trace("Ending invoke, cache removal, ctx=" + ctx); // no more pool return } EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); if (trace) log.trace("End invoke, key=" + key + ", ctx=" + ctx); }// end finally }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); boolean nonReentrant = !(reentrant || isReentrantMethod(mi)); // Not a reentrant method like getPrimaryKey NonReentrantLock methodLock = ctx.getMethodLock(); Transaction miTx = ctx.getTransaction(); boolean locked = false; try { while (!locked) { if (methodLock.attempt(5000, miTx, nonReentrant)) { locked = true; } else { if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } } } catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } } try { ctx.lock(); return getNext().invoke(mi); } finally { ctx.unlock(); methodLock.release(nonReentrant); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
public Object invoke(final Invocation mi) throws Exception { // Get context InstancePool pool = container.getInstancePool(); StatelessSessionEnterpriseContext ctx = null; try { ctx = (StatelessSessionEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Use this context mi.setEnterpriseContext(ctx); // JAXRPC/JAXWS message context Object msgContext = mi.getValue(InvocationKey.SOAP_MESSAGE_CONTEXT); // Timer invocation if (ejbTimeout.equals(mi.getMethod())) { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); } // Service Endpoint invocation else if (msgContext != null) { if (msgContext instanceof javax.xml.rpc.handler.MessageContext) ctx.setMessageContext((javax.xml.rpc.handler.MessageContext)msgContext); AllowedOperationsAssociation.pushInMethodFlag(IN_SERVICE_ENDPOINT_METHOD); } // Business Method Invocation else { AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); } // There is no need for synchronization since the instance is always fresh also there should // never be a tx associated with the instance. try { Object obj = getNext().invoke(mi); return obj; } catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } catch (Error e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); // Return context if (mi.getEnterpriseContext() != null) { pool.free(((EnterpriseContext) mi.getEnterpriseContext())); } else { pool.discard(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/local/StatefulSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { if (args == null) args = EMPTY_ARGS; // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (m.equals(GET_PRIMARY_KEY)) { if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } Object retValue = super.invoke( proxy, m, args ); if (retValue == null) { // If not taken care of, go on and call the container retValue = factory.invoke(id, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/local/StatelessSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { Object retValue = null; if (args == null) args = EMPTY_ARGS; // Implement local methods if (m.equals(TO_STRING)) { retValue = jndiName + ":Stateless"; } else if (m.equals(EQUALS)) { retValue = invoke(proxy, IS_IDENTICAL, args); } else if (m.equals(HASH_CODE)) { // We base the stateless hash on the hash of the proxy... // MF XXX: it could be that we want to return the hash of the name? retValue = new Integer(this.hashCode()); } else if (m.equals(GET_PRIMARY_KEY)) { // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } else if (m.equals(GET_EJB_HOME)) { InitialContext ctx = new InitialContext(); return ctx.lookup(jndiName); } else if (m.equals(IS_IDENTICAL)) { // All stateless beans are identical within a home, // if the names are equal we are equal retValue = isIdentical(args[0], jndiName + ":Stateless"); } // If not taken care of, go on and call the container else { retValue = factory.invoke(jndiName, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // The key Object key = mi.getId(); EntityEnterpriseContext ctx = null; EntityContainer ec = (EntityContainer) container; if (mi.getTransaction() != null) { //ctx = ec.getTxEntityMap().getCtx(mi.getTransaction(), key); } if (ctx == null) { InstancePool pool = ec.getInstancePool(); try { ctx = (EntityEnterpriseContext) pool.get(); } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); } ctx.setCacheKey(key); ctx.setId(key); EntityPersistenceManager pm = ec.getPersistenceManager(); pm.activateEntity(ctx); } boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Begin invoke, key="+key); // Associate transaction, in the new design the lock already has the transaction from the // previous interceptor ctx.setTransaction(mi.getTransaction()); // Set the current security information ctx.setPrincipal(mi.getPrincipal()); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // Set context on the method invocation mi.setEnterpriseContext(ctx); if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); try { Object ret = getNext().invoke(mi); return ret; } finally { AllowedOperationsAssociation.popInMethodFlag(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
private void checkStatelessDone() throws RemoteException { int status = Status.STATUS_NO_TRANSACTION; try { status = tm.getStatus(); } catch (SystemException ex) { log.error("Failed to get status", ex); } try { switch (status) { case Status.STATUS_ACTIVE : case Status.STATUS_COMMITTING : case Status.STATUS_MARKED_ROLLBACK : case Status.STATUS_PREPARING : case Status.STATUS_ROLLING_BACK : try { tm.rollback(); } catch (Exception ex) { log.error("Failed to rollback", ex); } // fall through... case Status.STATUS_PREPARED : String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before" + " returning (ejb1.1 spec, 11.6.1)"; log.error(msg); // the instance interceptor will discard the instance throw new RemoteException(msg); } } finally { Transaction tx = null; try { tx = tm.suspend(); } catch (SystemException ex) { log.error("Failed to suspend transaction", ex); } if (tx != null) { String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ; log.error(msg); throw new RemoteException(msg); } } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
public Object invoke(Invocation mi) throws Exception { InstanceCache cache = container.getInstanceCache(); InstancePool pool = container.getInstancePool(); Object methodID = mi.getId(); EnterpriseContext ctx = null; BeanLock lock = container.getLockManager().getLock(methodID); boolean callerRunAsIdentityPresent = SecurityActions.peekRunAsIdentity() != null; boolean pushSecurityContext = SecurityActions.getSecurityContext() == null; try { /* The security context must be established before the cache lookup because the activation of a session should have the caller's security context as ejbActivate is allowed to call other secured resources. Since the pm makes the ejbActivate call, we need to set the caller's security context. The only reason this shows up for stateful session is that we moved the SecurityInterceptor to after the instance interceptor to allow security exceptions to result in invalidation of the session. This may be too literal an interpretation of the ejb spec requirement that runtime exceptions should invalidate the session. */ if(!callerRunAsIdentityPresent && pushSecurityContext) { AuthenticationManager am = container.getSecurityManager(); String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if(am != null) securityDomain = am.getSecurityDomain(); SecurityActions.createAndSetSecurityContext(mi.getPrincipal(), mi.getCredential(), securityDomain , null); //SecurityActions.pushSubjectContext(mi.getPrincipal(), mi.getCredential(), null); } lock.sync(); try { // Get context try { ctx = cache.get(methodID); } catch (NoSuchObjectException e) { if (mi.isLocal()) throw new NoSuchObjectLocalException(e.getMessage()); else throw e; } catch (EJBException e) { throw e; } catch (RemoteException e) { throw e; } catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); } // Associate it with the method invocation mi.setEnterpriseContext(ctx); // Set the JACC EnterpriseBean PolicyContextHandler data EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance()); // BMT beans will lock and replace tx no matter what, CMT do work on transaction boolean isBMT = ((SessionMetaData)container.getBeanMetaData()).isBeanManagedTx(); if (isBMT == false) { // Do we have a running transaction with the context if (ctx.getTransaction() != null && // And are we trying to enter with another transaction !ctx.getTransaction().equals(mi.getTransaction())) { // Calls must be in the same transaction StringBuffer msg = new StringBuffer("Application Error: " + "tried to enter Stateful bean with different tx context"); msg.append(", contextTx: " + ctx.getTransaction()); msg.append(", methodTx: " + mi.getTransaction()); throw new EJBException(msg.toString()); } //If the instance will participate in a new transaction we register a sync for it if (ctx.getTransaction() == null && mi.getTransaction() != null) { register(ctx, mi.getTransaction(), lock); } } if (!ctx.isLocked()) { //take it! ctx.lock(); } else { if (!isCallAllowed(mi)) { // Concurent calls are not allowed throw new EJBException("Application Error: no concurrent " + "calls on stateful beans"); } else { ctx.lock(); } } } finally { lock.releaseSync(); } // Set the current security information /** * JBAS-3976: Setting principal on the context has been moved to a separate interceptor */ if (ejbTimeout.equals(mi.getMethod())) AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT); else AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD); boolean validContext = true; try { // Invoke through interceptors Object ret = getNext().invoke(mi); return ret; } catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } catch (Error e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; } finally { AllowedOperationsAssociation.popInMethodFlag(); if (validContext) { // Still a valid instance lock.sync(); try { // release it ctx.unlock(); // if removed, remove from cache if (ctx.getId() == null) { // Remove from cache cache.remove(methodID); pool.free(ctx); } } finally { lock.releaseSync(); } } } } finally { container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext(); EnterpriseBeanPolicyContextHandler.setEnterpriseBean(null); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Map to EJBHome.remove(Object) to EJBObject.remove() InvocationType type = mi.getType(); if (type == InvocationType.HOME) mi.setType(InvocationType.REMOTE); else if (type == InvocationType.LOCALHOME) mi.setType(InvocationType.LOCAL); mi.setMethod(EJBOBJECT_REMOVE); // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); mi.setId(ejbObject.getPrimaryKey()); } else mi.setId(arg); mi.setArguments(new Object[0]); return getInterceptor().invoke(mi); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
protected EJBObject getEjbObjectViaJndi() throws RemoteException { try { if (log.isTraceEnabled()) { log.trace("Using JNDI method for getEJBObject() invocation."); } InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); Proxy proxy = (Proxy) ic.lookup(jndiName); // call findByPrimary on the target InvocationHandler ih = Proxy.getInvocationHandler(proxy); return (EJBObject) ih.invoke(proxy, GET_EJB_OBJECT, new Object[] {id}); } catch (RemoteException e) { throw e; } catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); } }
// in src/main/java/org/jboss/proxy/ejb/StatelessSessionInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return toString(ctx); } else if (m.equals(EQUALS)) { Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { // We base the stateless hash on the hash of the proxy... // MF XXX: it could be that we want to return the hash of the name? return new Integer(this.hashCode()); } // Implement local EJB calls else if (m.equals(GET_HANDLE)) { return new StatelessHandleImpl( (String)ctx.getValue(InvocationKey.JNDI_NAME)); } else if (m.equals(GET_PRIMARY_KEY)) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } else if (m.equals(GET_EJB_HOME)) { return getEJBHome(invocation); } else if (m.equals(IS_IDENTICAL)) { // All stateless beans are identical within a home, // if the names are equal we are equal Object[] args = invocation.getArguments(); String argsString = args[0].toString(); String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } // If not taken care of, go on and call the container else { invocation.setType(InvocationType.REMOTE); return getNext().invoke(invocation); } }
// in src/main/java/org/jboss/proxy/ejb/StatefulSessionInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return toString(ctx); } else if (m.equals(EQUALS)) { Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { return new Integer(ctx.getCacheId().hashCode()); } // Implement local EJB calls else if (m.equals(GET_HANDLE)) { int objectName = ((Integer) ctx.getObjectName()).intValue(); String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME); Invoker invoker = ctx.getInvoker(); Object id = ctx.getCacheId(); return createHandle(objectName, jndiName, invoker, id, ctx); } else if (m.equals(GET_EJB_HOME)) { return getEJBHome(invocation); } else if (m.equals(GET_PRIMARY_KEY)) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } else if (m.equals(IS_IDENTICAL)) { Object[] args = invocation.getArguments(); String argsString = args[0].toString(); String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } // If not taken care of, go on and call the container else { // It is a remote invocation invocation.setType(InvocationType.REMOTE); // On this entry in cache invocation.setId(ctx.getCacheId()); return getNext().invoke(invocation); } }
6
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool", e); else throw new RemoteException("Unable to get an intance from the pool", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (Exception e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Unable to get an instance from the pool/cache", e); else throw new RemoteException("Unable to get an intance from the pool/cache", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); }
89
            
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void addNotificationListener(ObjectName name, RMINotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("addNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = new NotificationListenerDelegate(listener, name); remoteListeners.put(listener, delegate); getServer().addNotificationListener(name, delegate, filter, handback); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public void removeNotificationListener(ObjectName name, RMINotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, RemoteException { if( log.isTraceEnabled() ) log.trace("removeNotificationListener, name="+name+", listener="+listener); NotificationListenerDelegate delegate = (NotificationListenerDelegate) remoteListeners.remove(listener); if( delegate == null ) throw new ListenerNotFoundException("No listener matches: "+listener); getServer().removeNotificationListener(name, delegate); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void destroy() throws RemoteException { unreferenced(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public Object begin(int timeout) throws RemoteException, NotSupportedException, SystemException { TransactionManager tm = getTransactionManager(); // Set timeout value tm.setTransactionTimeout(timeout); // Start tx, and get its TPC. tm.begin(); Object tpc = getTPCFactory().getTransactionPropagationContext(); // Suspend thread association. Transaction tx = tm.suspend(); // Remember that a new tx is now active. activeTx.put(tpc, tx); // return the TPC return tpc; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void setRollbackOnly(Object tpc) throws RemoteException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); tx.setRollbackOnly(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public int getStatus(Object tpc) throws RemoteException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) return Status.STATUS_NO_TRANSACTION; return tx.getStatus(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionFactoryImpl.java
public UserTransactionSession newInstance() throws RemoteException { return new UserTransactionSessionImpl(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Handle getHandle(Invocation mi) throws RemoteException { // TODO return null; }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object getPrimaryKey(Invocation mi) throws RemoteException { return getPrimaryKey(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object getPrimaryKey() throws RemoteException { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBHome getEJBHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return (EJBHome) ci.getEJBHome(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public boolean isIdentical(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.isIdentical(this, mi); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBMetaData getEJBMetaDataHome(Invocation mi) throws RemoteException { return getEJBMetaDataHome(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public EJBMetaData getEJBMetaDataHome() throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.getEJBMetaData(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public HomeHandle getHomeHandleHome(Invocation mi) throws RemoteException { return getHomeHandleHome(); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
public HomeHandle getHomeHandleHome() throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } EJBHome home = (EJBHome) ci.getEJBHome(); return home.getHomeHandle(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { log.debug("Useless invocation of remove() for stateless session bean"); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public EJBObject createHome() throws RemoteException, CreateException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } createCount++; Object obj = ci.getStatelessSessionEJBObject(); return (EJBObject) obj; }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Handle handle) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Object primaryKey) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void discard() throws RemoteException { ((SessionBean)instance).ejbRemove(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // if the session is removed already then let the user know they have a problem StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); if (ctx.getId() == null) { throw new RemoveException("SFSB has been removed already"); } // Remove from storage try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); getPersistenceManager().removeSession(ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // We signify "removed" with a null id ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { // All we need is an EJBObject for this Id, the first argument is the Id EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } Object id = mi.getArguments()[0]; if (id == null) throw new IllegalStateException("Cannot get a session interface with a null id"); // Does the session still exist? InstanceCache cache = getInstanceCache(); BeanLock lock = getLockManager().getLock(id); lock.sync(); try { if (cache.get(id) == null) throw new RemoteException("Session no longer exists: " + id); } finally { lock.releaseSync(); getLockManager().removeLockRef(id); } // Ok lets create the proxy return (EJBObject) ci.getStatefulSessionEJBObject(id); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/MessageDrivenEnterpriseContext.java
public void discard() throws RemoteException { ((MessageDrivenBean)instance).ejbRemove(); }
// in src/main/java/org/jboss/ejb/EntityEnterpriseContext.java
public void discard() throws RemoteException { ((EntityBean)instance).unsetEntityContext(); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public void discard() throws RemoteException { // Do nothing }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBObject createHome() throws java.rmi.RemoteException, CreateException { throw new Error("createHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Handle handle) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Object primaryKey) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public EJBMetaData getEJBMetaDataHome() throws java.rmi.RemoteException { // TODO //return null; throw new Error("getEJBMetaDataHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public HomeHandle getHomeHandleHome() throws java.rmi.RemoteException { // TODO //return null; throw new Error("getHomeHandleHome not valid for MessageDriven beans"); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void activateEntity(EntityEnterpriseContext ctx) throws RemoteException { // Create a new CacheKey Object id = ctx.getId(); Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id ); // Give it to the context ctx.setCacheKey(cacheKey); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); ejbActivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void loadEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_LOAD); ejbLoad.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void invokeEjbStore(EntityEnterpriseContext ctx) throws RemoteException { try { if(!isStoreRequired(ctx)) { return; } } catch(Exception e) { throw new EJBException("Failed to invoke isModified().", e); } try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE); ejbStore.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void storeEntity(EntityEnterpriseContext ctx) throws RemoteException { }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void passivateEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); ejbPassivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } ctx.setEJBObject(null); ctx.setEJBLocalObject(null); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); ejbRemove.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void activateSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to activate; ctx=" + ctx); } Object id = ctx.getId(); // Load state File file = getFile(id); if (trace) { log.trace("Reading session state from: " + file); } try { FileInputStream fis = FISAction.open(file); SessionObjectInputStream in = new SessionObjectInputStream(ctx, new BufferedInputStream(fis)); try { Object obj = in.readObject(); if (trace) { log.trace("Session state: " + obj); } ctx.setInstance(obj); } finally { in.close(); } } catch(Exception e) { throw new EJBException("Could not activate; failed to " + "restore state", e); } removePassivated(id); try { // Instruct the bean to perform activation logic AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbActivate(); } finally { AllowedOperationsAssociation.popInMethodFlag(); } if (trace) { log.trace("Activation complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void passivateSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to passivate; ctx=" + ctx); } try { // Instruct the bean to perform passivation logic AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbPassivate(); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // Store state File file = getFile(ctx.getId()); if (trace) { log.trace("Saving session state to: " + file); } try { FileOutputStream fos = FOSAction.open(file); SessionObjectOutputStream out = new SessionObjectOutputStream( new BufferedOutputStream(fos)); Object obj = ctx.getInstance(); if (trace) { log.trace("Writing session state: " + obj); } try { out.writeObject(obj); } finally { out.close(); } } catch(Exception e) { throw new EJBException("Could not passivate; failed to save state", e); } if (trace) { log.trace("Passivation complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void removeSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException, RemoveException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to remove; ctx=" + ctx); } // Instruct the bean to perform removal logic SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbRemove(); if (trace) { log.trace("Removal complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { EnterpriseContext rtn = null; rtn = super.get(id); return rtn; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
protected void passivate(EnterpriseContext ctx) throws RemoteException { removeTimerServiceIfAllCancelledOrExpired(ctx); m_container.getPersistenceManager().passivateEntity((EntityEnterpriseContext)ctx); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceCache.java
protected void activate(EnterpriseContext ctx) throws RemoteException { m_container.getPersistenceManager().activateEntity((EntityEnterpriseContext)ctx); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if (id == null) throw new IllegalArgumentException("Can't get an object with a null key"); EnterpriseContext ctx; synchronized (getCacheLock()) { CachePolicy cache = getCache(); ctx = (EnterpriseContext)cache.get(id); if (ctx == null) { try { ctx = acquireContext(); setKey(id, ctx); if (doActivate(ctx) == false) // This is a recursive activation return ctx; logActivation(id); // the cache will throw an IllegalStateException if we try to insert // something that is in the cache already, so we don't check here cache.insert(id, ctx); } catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
protected boolean doActivate(EnterpriseContext ctx) throws RemoteException { activate(ctx); return true; }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void activateEntity(EntityEnterpriseContext ctx) throws RemoteException { // Create a new CacheKey Object id = ctx.getId(); Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id); // Give it to the context ctx.setCacheKey(cacheKey); try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_ACTIVATE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbActivate(); } catch(Exception e) { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } // The implementation of the call can be left absolutely empty, the // propagation of the call is just a notification for stores that would // need to know that an instance is being activated store.activateEntity(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void loadEntity(EntityEnterpriseContext ctx) throws RemoteException { //long lStart = System.currentTimeMillis(); // Have the store load the fields of the instance store.loadEntity(ctx); //mLoad.add( System.currentTimeMillis() - lStart ); invokeLoad(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void storeEntity(EntityEnterpriseContext ctx) throws RemoteException { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE); try { store.storeEntity(ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void invokeEjbStore(EntityEnterpriseContext ctx) throws RemoteException { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_STORE); try { // if call-ejb-store-for-clean=true then invoke ejbStore first (the last chance to modify the instance) if(ejbStoreForClean) { ejbStore(ctx); } else { // else check whether the instance is dirty and invoke ejbStore only if it is really dirty boolean modified = false; try { modified = isStoreRequired(ctx); } catch(Exception e) { throwRemoteException(e); } if(modified) { ejbStore(ctx); } } } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void passivateEntity(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_PASSIVATE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbPassivate(); } catch(Exception e) { throwRemoteException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); } store.passivateEntity(ctx); ctx.setEJBObject(null); ctx.setEJBLocalObject(null); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbRemove(); } catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } store.removeEntity(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
protected void invokeLoad(EntityEnterpriseContext ctx) throws RemoteException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_LOAD); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbLoad(); } catch(Exception e) { throwRemoteException(e); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void ejbStore(EntityEnterpriseContext ctx) throws RemoteException { try { EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbStore(); } catch(Exception e) { throwRemoteException(e); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
private void throwRemoteException(Exception e) throws RemoteException { if(e instanceof RemoteException) { // Rethrow exception throw (RemoteException) e; } else if(e instanceof EJBException) { // Rethrow exception throw (EJBException) e; } else { // Wrap runtime exceptions throw new EJBException((Exception) e); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
protected void passivate(EnterpriseContext ctx) throws RemoteException { m_container.getPersistenceManager().passivateSession((StatefulSessionEnterpriseContext) ctx); passivatedIDs.put(ctx.getId(), new Long(System.currentTimeMillis())); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
protected void activate(EnterpriseContext ctx) throws RemoteException { m_container.getPersistenceManager().activateSession((StatefulSessionEnterpriseContext) ctx); passivatedIDs.remove(ctx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
protected boolean doActivate(EnterpriseContext ctx) throws RemoteException { Object id = ctx.getId(); synchronized (activating) { // This is a recursive invocation if (activating.contains(id)) return false; activating.add(id); } try { return super.doActivate(ctx); } finally { synchronized (activating) { activating.remove(id); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); } else if(trace) { log.trace(oldValue + " already removed"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); } else if(trace) { log.trace(oldValue + " already removed"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean didDelete = false; boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); didDelete = true; } else if(trace) { log.trace(oldValue + " already removed"); } } if(didDelete) { executeDeleteSQL(batchCascadeDeleteSql, ctx.getId()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void invokeRemoveRelated(Object relatedId) throws RemoveException, RemoteException { EntityContainer container = relatedManager.getContainer(); /* try { EntityCache instanceCache = (EntityCache) container.getInstanceCache(); SecurityActions actions = SecurityActions.UTIL.getSecurityActions(); org.jboss.invocation.Invocation invocation = new org.jboss.invocation.Invocation(); invocation.setId(instanceCache.createCacheKey(relatedId)); invocation.setArguments(new Object[]{}); invocation.setTransaction(container.getTransactionManager().getTransaction()); invocation.setPrincipal(actions.getPrincipal()); invocation.setCredential(actions.getCredential()); invocation.setType(invocationType); invocation.setMethod(removeMethod); container.invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in remove instance", e); } */ /** * Have to remove through EJB[Local}Object interface since the proxy contains the 'removed' flag * to be set on removal. */ if(container.getLocalProxyFactory() != null) { final EJBLocalObject ejbObject = container.getLocalProxyFactory().getEntityEJBLocalObject(relatedId); ejbObject.remove(); } else { final EJBObject ejbObject = (EJBObject)container.getProxyFactory().getEntityEJBObject(relatedId); ejbObject.remove(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
public void execute(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { if(entity.isRemoved(ctx)) { throw new IllegalStateException("Instance was already removed: id=" + ctx.getId()); } entity.setIsBeingRemoved(ctx); // remove entity from all relations Object[] oldRelationsRef = new Object[1]; boolean needsSync = entity.removeFromRelations(ctx, oldRelationsRef); // update the related entities (stores the removal from relationships) // if one of the store fails an EJBException will be thrown if(!syncOnCommitOnly && needsSync) { EntityContainer.synchronizeEntitiesWithinTransaction(ctx.getTransaction()); } if(!batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.trace("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } // cascate-delete to old relations, if relation uses cascade. if(oldRelationsRef[0] != null) { Map oldRelations = (Map)oldRelationsRef[0]; entity.cascadeDelete(ctx, oldRelations); } if(batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.debug("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } entity.setRemoved(ctx); manager.getReadAheadCache().removeCachedData(ctx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { removeEntityCommand.execute(ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void cascadeDelete(EntityEnterpriseContext ctx, Map oldRelations) throws RemoveException, RemoteException { for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge cmrField = cmrFields[i]; Object value = oldRelations.get(cmrField); if(value != null) cmrField.cascadeDelete(ctx, (List)value); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { cascadeDeleteStrategy.cascadeDelete(ctx, oldValues); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if(id == null) throw new IllegalArgumentException("Can't get an object with a null key"); Map cache = getLocalCache(); EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id); if(instance == null) { try { // acquire instance = (EntityEnterpriseContext) container.getInstancePool().get(); // set key instance.setId(id); instance.setCacheKey(id); // activate container.getPersistenceManager().activateEntity(instance); // insert cache.put(id, instance); } catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); } } return instance; }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
private void checkStatelessDone() throws RemoteException { int status = Status.STATUS_NO_TRANSACTION; try { status = tm.getStatus(); } catch (SystemException ex) { log.error("Failed to get status", ex); } try { switch (status) { case Status.STATUS_ACTIVE : case Status.STATUS_COMMITTING : case Status.STATUS_MARKED_ROLLBACK : case Status.STATUS_PREPARING : case Status.STATUS_ROLLING_BACK : try { tm.rollback(); } catch (Exception ex) { log.error("Failed to rollback", ex); } // fall through... case Status.STATUS_PREPARED : String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before" + " returning (ejb1.1 spec, 11.6.1)"; log.error(msg); // the instance interceptor will discard the instance throw new RemoteException(msg); } } finally { Transaction tx = null; try { tx = tm.suspend(); } catch (SystemException ex) { log.error("Failed to suspend transaction", ex); } if (tx != null) { String msg = "Application error: BMT stateless bean " + container.getBeanMetaData().getEjbName() + " should complete transactions before " + " returning (ejb1.1 spec, 11.6.1), suspended tx=" + tx ; log.error(msg); throw new RemoteException(msg); } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
private void checkBadStateful() throws RemoteException { int status = Status.STATUS_NO_TRANSACTION; try { status = tm.getStatus(); } catch (SystemException ex) { log.error("Failed to get status", ex); } switch (status) { case Status.STATUS_COMMITTING : case Status.STATUS_MARKED_ROLLBACK : case Status.STATUS_PREPARING : case Status.STATUS_ROLLING_BACK : try { tm.rollback(); } catch (Exception ex) { log.error("Failed to rollback", ex); } String msg = "BMT stateful bean '" + container.getBeanMetaData().getEjbName() + "' did not complete user transaction properly status=" + TxUtils.getStatusAsString(status); log.error(msg); } }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // synchronize entities with the datastore before the bean is removed // this will write queued updates so datastore will be consistent before removal Transaction tx = mi.getTransaction(); if (!getBeanMetaData().getContainerConfiguration().getSyncOnCommitOnly()) synchronizeEntitiesWithinTransaction(tx); // Get the persistence manager to do the dirty work EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().removeEntity(ctx); final Object pk = ctx.getId(); AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { removeTimerService(pk); return null; } }); // We signify "removed" with a null id // There is no need to synchronize on the context since all the threads reaching here have // gone through the InstanceInterceptor so the instance is locked and we only have one thread // the case of reentrant threads is unclear (would you want to delete an instance in reentrancy) ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Handle getHandle(Invocation mi) throws RemoteException { // TODO throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object getPrimaryKey(Invocation mi) throws RemoteException { return mi.getId(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBHome getEJBHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return (EJBHome) ci.getEJBHome(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public boolean isIdentical(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.isIdentical(this, mi); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBObject getEJBObject(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } // All we need is an EJBObject for this Id; return (EJBObject)ci.getEntityEJBObject(((EntityCache) instanceCache).createCacheKey(mi.getId())); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public EJBMetaData getEJBMetaDataHome(Invocation mi) throws RemoteException { EJBProxyFactory ci = getProxyFactory(); if (ci == null) { String msg = "No ProxyFactory, check for ProxyFactoryFinderInterceptor"; throw new IllegalStateException(msg); } return ci.getEJBMetaData(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public HomeHandle getHomeHandleHome(Invocation mi) throws RemoteException { // TODO throw new Error("Not yet implemented"); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
public EJBObject getEJBObject() throws RemoteException { if (invokerProxyBinding != null) { try { return getEjbObjectViaInvoker(); } catch(Exception e) { log.debug("Exception reported, try JNDI method to recover EJB object instead", e); return getEjbObjectViaJndi(); } } return getEjbObjectViaJndi(); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
protected EJBObject getEjbObjectViaJndi() throws RemoteException { try { if (log.isTraceEnabled()) { log.trace("Using JNDI method for getEJBObject() invocation."); } InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); Proxy proxy = (Proxy) ic.lookup(jndiName); // call findByPrimary on the target InvocationHandler ih = Proxy.getInvocationHandler(proxy); return (EJBObject) ih.invoke(proxy, GET_EJB_OBJECT, new Object[] {id}); } catch (RemoteException e) { throw e; } catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
public EJBHome getEJBHome() throws RemoteException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); return home; } catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); } }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
public EJBObject getEJBObject() throws RemoteException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); Class type = home.getClass(); Method method = type.getMethod("findByPrimaryKey", new Class[]{home.getEJBMetaData().getPrimaryKeyClass()}); // call findByPrimary on the target return (EJBObject) method.invoke(home, new Object[]{id}); } catch (Exception e) { throw new ServerException("Could not get EJBObject", e); } }
23
            
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException ex) { // Ignore. }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
catch (RemoteException e) { // DEBUG Logger.exception(e); }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (RemoteException e) { if( log.isTraceEnabled() ) log.trace("Ctx.discard error", e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); }
21
            
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RemoteException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RemoteException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/EntityMultiInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RemoteException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (RemoteException e) { throw e; }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
catch (RemoteException e) { e.printStackTrace(); throw new EJBException(e); }
0
runtime (Domain) RemoveException
class RemoveException extends RuntimeException
   {
      public RemoveException()
      {
      }

      public RemoveException(String message)
      {
         super(message);
      }

      public RemoveException(Throwable cause)
      {
         super(cause);
      }

      public RemoveException(String message, Throwable cause)
      {
         super(message, cause);
      }
   }
11
            
// in src/main/java/org/jboss/ejb/SessionContainer.java
public Object internalInvokeHome(Invocation mi) throws Exception { Method method = mi.getMethod(); if (method != null && method.getName().equals("remove")) { // Handle or primary key? Object arg = mi.getArguments()[0]; if (arg instanceof Handle) { if (arg == null) throw new RemoteException("Null handle"); Handle handle = (Handle) arg; EJBObject ejbObject = handle.getEJBObject(); ejbObject.remove(); return null; } else throw new RemoveException("EJBHome.remove(Object) not allowed for session beans"); } // Invoke through interceptors return getInterceptor().invokeHome(mi); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // if the session is removed already then let the user know they have a problem StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); if (ctx.getId() == null) { throw new RemoveException("SFSB has been removed already"); } // Remove from storage try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); getPersistenceManager().removeSession(ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // We signify "removed" with a null id ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) getBeanMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // wire the transaction on the context, this is how the instance remember the tx // Unlike Entity beans we can't do that in the previous interceptors (ordering) EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); else if(ejbObjectRemove.equals(miMethod) || ejbLocalObjectRemove.equals(miMethod)) { throw new RemoveException("An attempt to remove a session " + "object while the object is in a transaction " + "(EJB2.1, 7.6.4 Restrictions for Transactions): ejb-name=" + metaData.getEjbName() + ", method=" + mi.getMethod() + ", tx=" + ctx.getTransaction()); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(StatefulSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { // Invoke and handle exceptions try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public void removeEntity (EntityEnterpriseContext ctx) throws javax.ejb.RemoveException { if (this.beans.remove (ctx.getId ()) == null) throw new javax.ejb.RemoveException ("Could not remove bean:" + ctx.getId ()); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public void removeEntity(final EntityEnterpriseContext ctx) throws RemoveException { // Remove file File file = getFile(ctx.getId()); if (!file.delete()) { throw new RemoveException("Could not remove file: " + file); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/TableCache.java
public void remove(Transaction tx, Object pk) { CachedRow row = (CachedRow) rowsById.remove(pk); if(row == null || row.locker != null && !tx.equals(row.locker)) { String msg = "removal of " + pk + " rejected for " + tx + ": " + (row == null ? "the entry could not be found" : "the entry is locked for update by " + row.locker); throw new RemoveException(msg); } dereference(row); row.locker = null; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
protected void executeDeleteSQL(String sql, Object key) throws RemoveException { Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { if(log.isDebugEnabled()) log.debug("Executing SQL: " + sql); // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql); // set the parameters entity.setPrimaryKeyParameters(ps, 1, key); // execute statement rowsAffected = ps.executeUpdate(); } catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected == 0) { log.error("Could not remove entity " + key); throw new RemoveException("Could not remove entity"); } if(log.isDebugEnabled()) log.debug("Remove: Rows affected = " + rowsAffected); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
private void executeDeleteSQL(EntityEnterpriseContext ctx) throws RemoveException { Object key = ctx.getId(); Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { if(log.isDebugEnabled()) log.debug("Executing SQL: " + removeEntitySQL); // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(removeEntitySQL); // set the parameters entity.setPrimaryKeyParameters(ps, 1, key); // execute statement rowsAffected = ps.executeUpdate(); } catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected == 0) { log.error("Could not remove entity " + key); throw new RemoveException("Could not remove entity"); } if(log.isTraceEnabled()) log.trace("Remove: Rows affected = " + rowsAffected); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home"; } else if (m.equals(EQUALS)) { // equality of the proxy home is based on names... Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home"; return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { return new Integer(this.hashCode()); } // Implement local EJB calls else if (m.equals(GET_HOME_HANDLE)) { return new HomeHandleImpl( (String)ctx.getValue(InvocationKey.JNDI_NAME)); } else if (m.equals(GET_EJB_META_DATA)) { return ctx.getValue(InvocationKey.EJB_METADATA); } else if (m.equals(REMOVE_BY_HANDLE)) { // First get the EJBObject EJBObject object = ((Handle) invocation.getArguments()[0]).getEJBObject(); // remove the object from here object.remove(); // Return Void return Void.TYPE; } else if (m.equals(REMOVE_BY_PRIMARY_KEY)) { // Session beans must throw RemoveException (EJB 1.1, 5.3.2) if(((EJBMetaData)ctx.getValue(InvocationKey.EJB_METADATA)).isSession()) throw new RemoveException("Session beans cannot be removed " + "by primary key."); // The trick is simple we trick the container in believe it // is a remove() on the instance Object id = invocation.getArguments()[0]; // Just override the Invocation going out invocation.setId(id); invocation.setType(InvocationType.REMOTE); invocation.setMethod(REMOVE_OBJECT); invocation.setArguments(EMPTY_ARGS); return getNext().invoke(invocation); } // If not taken care of, go on and call the container else { invocation.setType(InvocationType.HOME); // Create an Invocation return getNext().invoke(invocation); } }
2
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); }
31
            
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { log.debug("Useless invocation of remove() for stateless session bean"); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Handle handle) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Object primaryKey) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // if the session is removed already then let the user know they have a problem StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); if (ctx.getId() == null) { throw new RemoveException("SFSB has been removed already"); } // Remove from storage try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); getPersistenceManager().removeSession(ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // We signify "removed" with a null id ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Handle handle) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public void removeHome(Object primaryKey) throws java.rmi.RemoteException, RemoveException { throw new Error("removeHome not valid for MessageDriven beans"); // TODO }
// in src/main/java/org/jboss/ejb/plugins/CMPInMemoryPersistenceManager.java
public void removeEntity (EntityEnterpriseContext ctx) throws javax.ejb.RemoveException { if (this.beans.remove (ctx.getId ()) == null) throw new javax.ejb.RemoveException ("Could not remove bean:" + ctx.getId ()); }
// in src/main/java/org/jboss/ejb/plugins/BMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); ejbRemove.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) { // Throw this as a bean exception...(?) throw new EJBException(e); } catch (InvocationTargetException ite) { Throwable e = ite.getTargetException(); if (e instanceof RemoveException) { // Rethrow exception throw (RemoveException)e; } else if (e instanceof RemoteException) { // Rethrow exception throw (RemoteException)e; } else if (e instanceof EJBException) { // Rethrow exception throw (EJBException)e; } else if (e instanceof RuntimeException) { // Wrap runtime exceptions throw new EJBException((Exception)e); } } finally{ AllowedOperationsAssociation.popInMethodFlag(); } }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
public void removeSession(final StatefulSessionEnterpriseContext ctx) throws RemoteException, RemoveException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("Attempting to remove; ctx=" + ctx); } // Instruct the bean to perform removal logic SessionBean bean = (SessionBean) ctx.getInstance(); bean.ejbRemove(); if (trace) { log.trace("Removal complete; ctx=" + ctx); } }
// in src/main/java/org/jboss/ejb/plugins/CMPPersistenceManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoteException, RemoveException { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); EntityBean eb = (EntityBean) ctx.getInstance(); eb.ejbRemove(); } catch(Exception e) { if(e instanceof RemoveException) { // Rethrow exception throw (RemoveException) e; } else { throwRemoteException(e); } } finally { AllowedOperationsAssociation.popInMethodFlag(); } store.removeEntity(ctx); }
// in src/main/java/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
public void removeEntity(final EntityEnterpriseContext ctx) throws RemoveException { // Remove file File file = getFile(ctx.getId()); if (!file.delete()) { throw new RemoveException("Could not remove file: " + file); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JDBCStoreManager2.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoveException { entityBridge.remove(ctx); PersistentContext pctx = (PersistentContext)ctx.getPersistenceContext(); pctx.remove(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void remove(EntityEnterpriseContext ctx) throws RemoveException { if(metadata.getRelatedRole().isCascadeDelete()) { FieldState state = getFieldState(ctx); state.cascadeDelete(ctx); } else { destroyExistingRelationships(ctx); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void cascadeDelete(EntityEnterpriseContext ctx) throws RemoveException { if(manager.registerCascadeDelete(ctx.getId(), ctx.getId())) { EJBLocalObject value = (EJBLocalObject)getValue(ctx); if(value != null) { changeValue(null); final Object relatedId = value.getPrimaryKey(); final JDBCStoreManager2 relatedManager = (JDBCStoreManager2)relatedEntity.getManager(); if(!relatedManager.isCascadeDeleted(relatedId)) { value.remove(); } } manager.unregisterCascadeDelete(ctx.getId()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void cascadeDelete(EntityEnterpriseContext ctx) throws RemoveException { Collection value = (Collection)getValue(ctx); if(!value.isEmpty()) { EJBLocalObject[] locals = (EJBLocalObject[])value.toArray(); for(int i = 0; i < locals.length; ++i) { locals[i].remove(); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public void remove(EntityEnterpriseContext ctx) throws RemoveException { if(cmrFields != null) { for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].remove(ctx); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); } else if(trace) { log.trace(oldValue + " already removed"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); } else if(trace) { log.trace(oldValue + " already removed"); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { boolean didDelete = false; boolean trace = log.isTraceEnabled(); for(int i = 0; i < oldValues.size(); ++i) { Object oldValue = oldValues.get(i); if(relatedManager.unscheduledCascadeDelete(oldValue)) { if(trace) { log.trace("Removing " + oldValue); } invokeRemoveRelated(oldValue); didDelete = true; } else if(trace) { log.trace(oldValue + " already removed"); } } if(didDelete) { executeDeleteSQL(batchCascadeDeleteSql, ctx.getId()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
protected void executeDeleteSQL(String sql, Object key) throws RemoveException { Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { if(log.isDebugEnabled()) log.debug("Executing SQL: " + sql); // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(sql); // set the parameters entity.setPrimaryKeyParameters(ps, 1, key); // execute statement rowsAffected = ps.executeUpdate(); } catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected == 0) { log.error("Could not remove entity " + key); throw new RemoveException("Could not remove entity"); } if(log.isDebugEnabled()) log.debug("Remove: Rows affected = " + rowsAffected); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/CascadeDeleteStrategy.java
public void invokeRemoveRelated(Object relatedId) throws RemoveException, RemoteException { EntityContainer container = relatedManager.getContainer(); /* try { EntityCache instanceCache = (EntityCache) container.getInstanceCache(); SecurityActions actions = SecurityActions.UTIL.getSecurityActions(); org.jboss.invocation.Invocation invocation = new org.jboss.invocation.Invocation(); invocation.setId(instanceCache.createCacheKey(relatedId)); invocation.setArguments(new Object[]{}); invocation.setTransaction(container.getTransactionManager().getTransaction()); invocation.setPrincipal(actions.getPrincipal()); invocation.setCredential(actions.getCredential()); invocation.setType(invocationType); invocation.setMethod(removeMethod); container.invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in remove instance", e); } */ /** * Have to remove through EJB[Local}Object interface since the proxy contains the 'removed' flag * to be set on removal. */ if(container.getLocalProxyFactory() != null) { final EJBLocalObject ejbObject = container.getLocalProxyFactory().getEntityEJBLocalObject(relatedId); ejbObject.remove(); } else { final EJBObject ejbObject = (EJBObject)container.getProxyFactory().getEntityEJBObject(relatedId); ejbObject.remove(); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
public void execute(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { if(entity.isRemoved(ctx)) { throw new IllegalStateException("Instance was already removed: id=" + ctx.getId()); } entity.setIsBeingRemoved(ctx); // remove entity from all relations Object[] oldRelationsRef = new Object[1]; boolean needsSync = entity.removeFromRelations(ctx, oldRelationsRef); // update the related entities (stores the removal from relationships) // if one of the store fails an EJBException will be thrown if(!syncOnCommitOnly && needsSync) { EntityContainer.synchronizeEntitiesWithinTransaction(ctx.getTransaction()); } if(!batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.trace("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } // cascate-delete to old relations, if relation uses cascade. if(oldRelationsRef[0] != null) { Map oldRelations = (Map)oldRelationsRef[0]; entity.cascadeDelete(ctx, oldRelations); } if(batchCascadeDelete) { if(!entity.isScheduledForBatchCascadeDelete(ctx)) { executeDeleteSQL(ctx); } else { if(log.isTraceEnabled()) log.debug("Instance is scheduled for cascade delete. id=" + ctx.getId()); } } entity.setRemoved(ctx); manager.getReadAheadCache().removeCachedData(ctx.getId()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCRemoveEntityCommand.java
private void executeDeleteSQL(EntityEnterpriseContext ctx) throws RemoveException { Object key = ctx.getId(); Connection con = null; PreparedStatement ps = null; int rowsAffected = 0; try { if(log.isDebugEnabled()) log.debug("Executing SQL: " + removeEntitySQL); // get the connection con = entity.getDataSource().getConnection(); ps = con.prepareStatement(removeEntitySQL); // set the parameters entity.setPrimaryKeyParameters(ps, 1, key); // execute statement rowsAffected = ps.executeUpdate(); } catch(Exception e) { log.error("Could not remove " + key, e); throw new RemoveException("Could not remove " + key + ": " + e.getMessage()); } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } // check results if(rowsAffected == 0) { log.error("Could not remove entity " + key); throw new RemoveException("Could not remove entity"); } if(log.isTraceEnabled()) log.trace("Remove: Rows affected = " + rowsAffected); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStoreManager.java
public void removeEntity(EntityEnterpriseContext ctx) throws RemoveException, RemoteException { removeEntityCommand.execute(ctx); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void cascadeDelete(EntityEnterpriseContext ctx, Map oldRelations) throws RemoveException, RemoteException { for(int i = 0; i < cmrFields.length; ++i) { JDBCCMRFieldBridge cmrField = cmrFields[i]; Object value = oldRelations.get(cmrField); if(value != null) cmrField.cascadeDelete(ctx, (List)value); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void cascadeDelete(EntityEnterpriseContext ctx, List oldValues) throws RemoveException, RemoteException { cascadeDeleteStrategy.cascadeDelete(ctx, oldValues); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void remove(Invocation mi) throws RemoteException, RemoveException { // synchronize entities with the datastore before the bean is removed // this will write queued updates so datastore will be consistent before removal Transaction tx = mi.getTransaction(); if (!getBeanMetaData().getContainerConfiguration().getSyncOnCommitOnly()) synchronizeEntitiesWithinTransaction(tx); // Get the persistence manager to do the dirty work EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().removeEntity(ctx); final Object pk = ctx.getId(); AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { removeTimerService(pk); return null; } }); // We signify "removed" with a null id // There is no need to synchronize on the context since all the threads reaching here have // gone through the InstanceInterceptor so the instance is locked and we only have one thread // the case of reentrant threads is unclear (would you want to delete an instance in reentrancy) ctx.setId(null); removeCount++; }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not Yet Implemented"); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public void removeHome(Invocation mi) throws RemoteException, RemoveException { throw new Error("Not yet implemented"); }
3
            
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(Cache.RemoveException e) { log.trace(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(Cache.RemoveException e) { if(log.isTraceEnabled()) { log.trace(e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(Cache.RemoveException e) { if(trace) { log.trace(e.getMessage()); } }
0 0
unknown (Lib) ResourceException 2
            
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void before(Invocation mi) throws Throwable { // Called out of sequence if (getBeforeDeliveryInvoke()) throw new IllegalStateException("Missing afterDelivery from the previous beforeDelivery for message endpoint " + getProxyString(mi)); // Set the classloader MessageDrivenContainer container = getContainer(mi); synchronized (this) { oldClassLoader = GetTCLAction.getContextClassLoader(inUseThread); SetTCLAction.setContextClassLoader(inUseThread, container.getClassLoader()); } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " set context classloader to " + container.getClassLoader()); // start any transaction try { startTransaction("beforeDelivery", mi, container); setBeforeDeliveryInvoke(true); } catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void after(Invocation mi) throws Throwable { // Called out of sequence if(!getBeforeDeliveryInvoke()) { throw new IllegalStateException("afterDelivery without a previous beforeDelivery for message endpoint " + getProxyString(mi)); } // Finish this delivery committing if we can try { finish("afterDelivery", mi, true); } catch (Throwable t) { throw new ResourceException(t); } }
2
            
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { throw new ResourceException(t); }
0 0 0 0
unknown (Lib) RollbackException 0 0 9
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/ejb/TxEntityMap.java
public void associate(Transaction tx, EntityEnterpriseContext entity) throws RollbackException, SystemException { HashMap entityMap = (HashMap) m_map.get(tx); if(entityMap == null) { entityMap = new HashMap(); m_map.set(tx, entityMap); } //EntityContainer.getGlobalTxEntityMap().associate(tx, entity); entityMap.put(entity.getCacheKey(), entity); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx commit: " + tx); int status = tm.getStatus(); tm.commit(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
private void registerTimer(Invocation invocation) throws RollbackException, SystemException { Timer timer = (Timer) invocation.getArguments()[0]; Transaction transaction = invocation.getTransaction(); if (transaction != null && timer instanceof Synchronization) transaction.registerSynchronization((Synchronization) timer); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void scheduleSync(Transaction tx, EntityEnterpriseContext instance) throws SystemException, RollbackException { EntityContainer.getGlobalTxEntityMap().associate(tx, instance); instance.setTxAssociation(SYNC_SCHEDULED); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public GlobalTxSynchronization getGlobalSynchronization(Transaction tx) throws RollbackException, SystemException { GlobalTxSynchronization globalSync = (GlobalTxSynchronization) txSynch.get(tx); if(globalSync == null) { globalSync = new GlobalTxSynchronization(tx); txSynch.set(tx, globalSync); tx.registerSynchronization(globalSync); } return globalSync; }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
private void associate(Transaction tx, EntityEnterpriseContext entity) throws RollbackException, SystemException { GlobalTxSynchronization globalSync = getGlobalSynchronization(tx); //There should be only one thread associated with this tx at a time. //Therefore we should not need to synchronize on entityFifoList to ensure exclusive //access. entityFifoList is correct since it was obtained in a synch block. globalSync.associate(entity); }
6
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RollbackException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (RollbackException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RollbackException e) { throw new EJBException("Error while creating RelationSet", e); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RollbackException e) { }
4
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RollbackException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(RollbackException e) { // The state in the instance is to be discarded, we force a reload of state synchronized(ctx) { ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); } throw new EJBException(e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(RollbackException e) { throw new EJBException("Transaction already marked to roll back: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RollbackException e) { throw new EJBException("Error while creating RelationSet", e); }
0
runtime (Lib) RuntimeException 45
            
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
protected void startService() throws Exception { log.debug("Starting unified invoker service."); InvokerLocator locator = null; if(serverInvoker != null) { locator = serverInvoker.getLocator(); if(!serverInvoker.isStarted()) { serverInvoker.start(); } } else if(connector != null) { locator = connector.getLocator(); } else { /** * This will happen in one of two scenarios. One, the unified invoker was not declared in as * service before the connector AND was not specified as the handler within the connector config. * Two, the unified invoker service config did not use the proxy-type attribute within the depends * tag to have the container set the connector upon creating the unified invoker. */ log.error("Error referencing either remoting connector or server invoker to be used. " + "Please check configuration to make sure proper dependancies are set."); throw new RuntimeException("Error getting locator because server invoker is null."); } proxy = new UnifiedInvokerProxy(locator, strictRMIException); jmxBind(); }
// in src/main/java/org/jboss/deployment/EARStructure.java
public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException { ContextInfo context; boolean valid; boolean trace = log.isTraceEnabled(); VirtualFile file = structureContext.getFile(); try { if (hasValidName(file) == false) return false; context = createContext(structureContext, "META-INF"); context.setComparatorClassName(comparatorClassName); VirtualFile applicationXml = getMetaDataFile(file, "META-INF/application.xml"); VirtualFile jbossAppXml = getMetaDataFile(file, "META-INF/jboss-app.xml"); VirtualFile lib; boolean scan = true; Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller(); unmarshaller.setValidation(useValidation); EarMetaData specMetaData = null; JBossAppMetaData appMetaData = null; if (applicationXml != null) { InputStream in = applicationXml.openStream(); try { specMetaData = (EarMetaData) unmarshaller.unmarshal(in, resolver); } finally { in.close(); } scan = false; } if (jbossAppXml != null) { InputStream in = jbossAppXml.openStream(); try { appMetaData = (JBossAppMetaData) unmarshaller.unmarshal(in, resolver); } finally { in.close(); } } // Need a metadata instance and there will not be one if there are no descriptors if (appMetaData == null) { appMetaData = new JBossAppMetaData(); } // Create the merged view appMetaData.merge(appMetaData, specMetaData); String libDir = appMetaData.getLibraryDirectory(); if (libDir == null || libDir.length() > 0) { if (libDir == null) libDir = "lib"; // Add the ear lib contents to the classpath if(trace) log.trace("Checking for ear lib directory: "+libDir); try { lib = file.getChild(libDir); if (lib.exists()) { if(trace) log.trace("Found ear lib directory: "+lib); List<VirtualFile> archives = lib.getChildren(earLibFilter); for (VirtualFile archive : archives) { Automounter.mount(file, archive); addClassPath(structureContext, archive, true, true, context); // add any jars with persistence.xml as a deployment VirtualFile child = archive.getChild("META-INF/persistence.xml"); if (child.exists()) { log.trace(archive.getName() + " in ear lib directory has persistence units"); addMetaDataPath(structureContext, context, child.getParent().getPathNameRelativeTo(file), MetaDataType.ALTERNATIVE); } else if (trace) log.trace(archive.getPathName() + " does not contain META-INF/persistence.xml"); } } else if (trace) log.trace("No lib directory in ear archive."); } catch (IOException e) { // TODO - should we throw this fwd? log.warn("Exception while searching for lib dir: " + e); } } else if (trace) { log.trace("Ignoring library directory, got empty library-directory element."); } // Add the ear manifest locations? addClassPath(structureContext, file, includeEarRootInClasspath, true, context); // TODO: need to scan for annotationss if( scan ) { scanEar(file, appMetaData); } // Create subdeployments for the ear modules ModulesMetaData modules = appMetaData.getModules(); if(modules != null) { for (ModuleMetaData mod : modules) { String fileName = mod.getFileName(); if (fileName != null && (fileName = fileName.trim()).length() > 0) { if (log.isTraceEnabled()) log.trace("Checking application.xml module: " + fileName); VirtualFile module = file.getChild(fileName); if (module.exists() == false) { throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + file.toURI()); } // Ask the deployers to analyze this if(structureContext.determineChildStructure(module) == false) { throw new RuntimeException(fileName + " module listed in application.xml is not a recognized deployment, .ear: " + file.getName()); } } } if (appMetaData.getModuleOrderEnum() == ModuleOrder.STRICT || (specMetaData instanceof Ear6xMetaData && ((Ear6xMetaData)specMetaData).getInitializeInOrder())) { context.setComparatorClassName(RelativeDeploymentContextComparator.class.getName()); int i = 0; for (ContextInfo ctx : structureContext.getMetaData().getContexts()) { ctx.setRelativeOrder(i++); } } } valid = true; } catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); } return valid; }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
protected void deploy(VFSDeploymentUnit unit, VirtualFile root, VirtualFile file) { try { JBossAppMetaData j2eeMetaData = new JBoss50AppMetaData(); // TODO: need to scan for annotationss scanEar(unit, file, j2eeMetaData); unit.addAttachment(JBossAppMetaData.class, j2eeMetaData); } catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); } }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { PolicyConfiguration pc = unit.getAttachment(PolicyConfiguration.class); if (pc == null) return; DeploymentUnit parent = unit.getParent(); if (parent == null) throw new IllegalStateException("Unit has not parent: " + unit); PolicyConfiguration parentPc = parent.getAttachment(PolicyConfiguration.class); try { if (parentPc != null && pc != parentPc) { parentPc.linkConfiguration(pc); } pc.commit(); } catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); } }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
public void internalDeploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException { boolean accepted = false; for (String accept : acceptedAttachments) { if (unit.isAttachmentPresent(accept)) { accepted = true; break; } } if (accepted == false) return; String contextID = unit.getName(); PolicyConfiguration pc = null; try { PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); pc = pcFactory.getPolicyConfiguration(contextID, true); } catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); } unit.addAttachment(PolicyConfiguration.class, pc); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
public void create() { try { createPolicyConfiguration(); } catch (Exception e) { throw new RuntimeException(e); } if(this.standaloneDeployment == Boolean.TRUE) { try { if (metaData != null) createPermissions(metaData,parentPC); else log.warn("Cannot create permissions with 'null' metaData for id=" + contextID); } catch (PolicyContextException e) { throw new RuntimeException("Cannot create permissions:",e); } } if(trace) log.trace("create():" + this.contextID); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
public void stop() { try { //The linked PCs will delete themselves via the PolicyConfigurationFacade this.parentPC.delete(); } catch (PolicyContextException e) { throw new RuntimeException(e); } if(trace) log.trace("stop():" + this.contextID); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
protected void createPermissions(T metaData, PolicyConfiguration policyConfiguration) throws PolicyContextException { throw new RuntimeException("Need to override"); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
public void deploy(DeploymentUnit unit) throws DeploymentException { T metaData = unit.getAttachment(getMetaDataClassType()); if (metaData == null) return; String contextId = unit.getSimpleName(); // Is the war the top level deployment? // DeploymentUnit topUnit = unit.getTopLevel(); if (unit.getParent() == null || getParentJaccPolicyBean(unit) == null) { createTopLevelServiceBeanWithMetaData(contextId, unit, metaData); } else { ServiceMetaData subjaccPolicy = getServiceMetaData(); String deploymentName = unit.getSimpleName(); try { subjaccPolicy.setObjectName(new ObjectName(getObjectName(unit))); } catch (Exception e) { throw new RuntimeException(e); } // Provide a constructor for the service bean ServiceConstructorMetaData serviceConstructor = new ServiceConstructorMetaData(); serviceConstructor.setSignature(new String[]{String.class.getName(), getMetaDataClassType().getName()}); serviceConstructor.setParameters(new Object[]{deploymentName, metaData}); subjaccPolicy.setConstructor(serviceConstructor); ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>(); services.add(subjaccPolicy); unit.addAttachment(JACC_ATTACHMENT_NAME, subjaccPolicy, ServiceMetaData.class); // Add a dependence into the parent JaccPolicy ServiceMetaData parentServiceMetaData = this.getParentJaccPolicyBean(unit); if (parentServiceMetaData != null) { ServiceDependencyMetaData serviceDependencyMetaData = new ServiceDependencyMetaData(); serviceDependencyMetaData.setIDependOnObjectName(subjaccPolicy.getObjectName()); parentServiceMetaData.addDependency(serviceDependencyMetaData); // Add an attribute in the parent service ServiceAttributeMetaData serviceAttributeMetaData = new ServiceAttributeMetaData(); serviceAttributeMetaData.setName("PolicyConfigurationFacadeMBean"); ServiceDependencyValueMetaData dependencyValue = new ServiceDependencyValueMetaData(); dependencyValue.setDependency(subjaccPolicy.getObjectName().toString()); dependencyValue.setProxyType("attribute"); serviceAttributeMetaData.setValue(dependencyValue); parentServiceMetaData.addAttribute(serviceAttributeMetaData); } } /** Register XACML/ACL policies if present in the deployment */ if(this.policyRegistration != null) { String xacmlType = PolicyRegistration.XACML; JAXBElement<?> policyConfig = (JAXBElement<?>) unit.getAttachment(XACML_ATTACHMENT_NAME); if(policyConfig != null) this.policyRegistration.registerPolicyConfig(contextId, xacmlType, policyConfig); String aclType = PolicyRegistration.ACL; ACLConfiguration aclConfig = (ACLConfiguration) unit.getAttachment(ACLConfiguration.class.getName()); if(aclConfig != null) this.policyRegistration.registerPolicyConfig(contextId, aclType, aclConfig); } }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
private void createJaccPolicyBean(ServiceConstructorMetaData serviceConstructor, DeploymentUnit unit) { // Create a Service Bean for the JACC Policy ServiceMetaData jaccPolicy = new ServiceMetaData(); jaccPolicy.setCode(getJaccPolicyName()); try { jaccPolicy.setObjectName(new ObjectName(getObjectName(unit))); } catch (Exception e) { throw new RuntimeException(e); } // Provide a constructor for the service bean jaccPolicy.setConstructor(serviceConstructor); ArrayList<ServiceMetaData> services = new ArrayList<ServiceMetaData>(); services.add(jaccPolicy); unit.addAttachment(JACC_ATTACHMENT_NAME, jaccPolicy, ServiceMetaData.class); }
// in src/main/java/org/jboss/naming/NamingService.java
protected void startService() throws Exception { boolean debug = log.isDebugEnabled(); // Read jndi.properties into system properties ClassLoader loader = Thread.currentThread().getContextClassLoader(); InputStream is = loader.getResourceAsStream("jndi.properties"); if (is == null) throw new RuntimeException("Cannot find jndi.properties, it should be at conf/jndi.properties by default."); Properties props = new Properties(); try { props.load(is); } finally { is.close(); } for (Enumeration keys = props.propertyNames(); keys.hasMoreElements(); ) { String key = (String) keys.nextElement(); String value = props.getProperty(key); if (debug) { log.debug("System.setProperty, key="+key+", value="+value); } System.setProperty(key, value); } if( proxyFactory != null ) namingMain.setNamingProxy(proxyFactory.getProxy()); if( startNamingBean ) namingMain.start(); // Build the Naming interface method map HashMap tmpMap = new HashMap(13); Method[] methods = Naming.class.getMethods(); for(int m = 0; m < methods.length; m ++) { Method method = methods[m]; Long hash = new Long(MarshalledInvocation.calculateHash(method)); tmpMap.put(hash, method); } marshalledInvocationMapping = Collections.unmodifiableMap(tmpMap); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
private synchronized void createSession() { // Destroy any old session. if (session != null) destroySession(); try { // Get a reference to the UT session factory. UserTransactionSessionFactory factory; Hashtable env = (Hashtable) NamingContextFactory.lastInitialContextEnv.get(); InitialContext ctx = new InitialContext(env); factory = (UserTransactionSessionFactory) ctx.lookup("UserTransactionSessionFactory"); // Call factory to get a UT session. session = factory.newInstance(); } catch (Exception ex) { throw new RuntimeException("UT factory lookup failed", ex); } }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
public static EJBTimerService getEjbTimerService() { try { // First try the MBean server MBeanServer server = MBeanServerLocator.locateJBoss(); if (server != null && server.isRegistered(EJBTimerService.OBJECT_NAME)) ejbTimerService = new MBeanDelegate(server); } catch (Exception ignore) { } // This path can be used for standalone test cases if (ejbTimerService == null) { EJBTimerServiceImpl ejbTimerServiceImpl = new EJBTimerServiceImpl(); ejbTimerService = ejbTimerServiceImpl; try { ejbTimerServiceImpl.create(); ejbTimerServiceImpl.start(); } catch (Exception e) { throw new RuntimeException("Cannot start EJBTimerService", e); } } return ejbTimerService; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Object getBusinessObject(Class businessInterface) throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public Class getInvokedBusinessInterface() throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/Container.java
public ObjectName getJmxName() { if (jmxName == null) { BeanMetaData beanMetaData = getBeanMetaData(); if (beanMetaData == null) { throw new IllegalStateException("Container metaData is null"); } String jndiName = beanMetaData.getContainerObjectNameJndiName(); if (jndiName == null) { throw new IllegalStateException("Container jndiName is null"); } // The name must be escaped since the jndiName may be arbitrary String name = BASE_EJB_CONTAINER_NAME + ",jndiName=" + jndiName; try { jmxName = ObjectNameConverter.convert(name); } catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); } } return jmxName; }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
public BeanLock getLock(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to get lock ref with a null object"); HashMap mapInUse = getHashMap(id); synchronized (mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock!=null) { lock.addRef(); return lock; } } try { BeanLock lock2 = (BeanLock)createLock(id); synchronized(mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); // in case of bad luck, this might happen if (lock != null) { lock.addRef(); return lock; } mapInUse.put(id, lock2); lock2.addRef(); return lock2; } } catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); } }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public Object getBusinessObject(Class businessInterface) throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public Class getInvokedBusinessInterface() throws IllegalStateException { throw new RuntimeException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
private InitialContext getContext() { if (ctx==null) { try { ctx = new InitialContext(); } catch (NamingException e) { throw new RuntimeException(e); } } return ctx; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public Object invokeHome(Invocation invocation) throws Exception { Transaction oldTransaction = invocation.getTransaction(); for (int i = 0; i < MAX_RETRIES; i++) { try { return runWithTransactions(invocation); } catch (Exception ex) { checkRetryable(i, ex, oldTransaction); } } throw new RuntimeException("Unreachable"); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
public Object invoke(Invocation invocation) throws Exception { Transaction oldTransaction = invocation.getTransaction(); for (int i = 0; i < MAX_RETRIES; i++) { try { return runWithTransactions(invocation); } catch (Exception ex) { checkRetryable(i, ex, oldTransaction); } } throw new RuntimeException("Unreachable"); }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean doSchedule(Invocation mi) throws Exception { boolean wasThreadScheduled = false; Transaction miTx = mi.getTransaction(); boolean trace = log.isTraceEnabled(); this.sync(); try { if (trace) log.trace("Begin schedule, key=" + mi.getId()); if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } //Next test is independent of whether the context is locked or not, it is purely transactional // Is the instance involved with another transaction? if so we implement pessimistic locking long startWait = System.currentTimeMillis(); try { wasThreadScheduled = waitForTx(miTx, trace); if (wasThreadScheduled && lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } } catch (Exception throwable) { if (lockMonitor != null && isTxExpired(miTx)) { lockMonitor.increaseTimeouts(); } if (lockMonitor != null) { long endWait = System.currentTimeMillis() - startWait; lockMonitor.finishedContending(endWait); } throw throwable; } } finally { if (miTx == null // non-transactional && wasThreadScheduled) { // if this non-transctional thread was // scheduled in txWaitQueue, we need to call nextTransaction // Otherwise, threads in txWaitQueue will never wake up. nextTransaction(); } this.releaseSync(); } //If we reach here we are properly scheduled to go through so return true return true; }
// in src/main/java/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
protected boolean waitForTx(Transaction miTx, boolean trace) throws Exception { boolean intr = false; try { boolean wasScheduled = false; // Do we have a running transaction with the context? // We loop here until either until success or until transaction timeout // If we get out of the loop successfully, we can successfully // set the transaction on this puppy. TxLock txLock = null; Object deadlocker = miTx; if (deadlocker == null) deadlocker = Thread.currentThread(); while (getTransaction() != null && // And are we trying to enter with another transaction? !getTransaction().equals(miTx)) { // Check for a deadlock on every cycle try { if( deadlockDetection == true ) DeadlockDetector.singleton.deadlockDetection(deadlocker, this); } catch (Exception e) { // We were queued, not any more if (txLock != null && txLock.isQueued) { txLocks.remove(txLock); txWaitQueue.remove(txLock); } throw e; } wasScheduled = true; if (lockMonitor != null) lockMonitor.contending(); // That's no good, only one transaction per context // Let's put the thread to sleep the transaction demarcation will wake them up if (trace) log.trace("Transactional contention on context" + id); // Only queue the lock on the first iteration if (txLock == null) txLock = getTxLock(miTx); if (trace) log.trace("Begin wait on Tx=" + getTransaction()); // And lock the threads on the lock corresponding to the Tx in MI synchronized (txLock) { releaseSync(); try { txLock.wait(txTimeout); } catch (InterruptedException ignored) { intr = true; } } // end synchronized(txLock) this.sync(); if (trace) log.trace("End wait on TxLock=" + getTransaction()); if (isTxExpired(miTx)) { log.error(Thread.currentThread() + "Saw rolled back tx=" + miTx + " waiting for txLock" // +" On method: " + mi.getMethod().getName() // +" txWaitQueue size: " + txWaitQueue.size() ); if (txLock.isQueued) { // Remove the TxLock from the queue because this thread is exiting. // Don't worry about notifying other threads that share the same transaction. // They will timeout and throw the below RuntimeException txLocks.remove(txLock); txWaitQueue.remove(txLock); } else if (getTransaction() != null && getTransaction().equals(miTx)) { // We're not qu nextTransaction(); } if (miTx != null) { if( deadlockDetection == true ) DeadlockDetector.singleton.removeWaiting(deadlocker); } throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } // end while(tx!=miTx) // If we get here, this means that we have the txlock if (!wasScheduled) { setTransaction(miTx); } return wasScheduled; } finally { if (intr) Thread.currentThread().interrupt(); } }
// in src/main/java/org/jboss/ejb/plugins/EntityReentranceInterceptor.java
public Object invoke(Invocation mi) throws Exception { // We are going to work with the context a lot EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); boolean nonReentrant = !(reentrant || isReentrantMethod(mi)); // Not a reentrant method like getPrimaryKey NonReentrantLock methodLock = ctx.getMethodLock(); Transaction miTx = ctx.getTransaction(); boolean locked = false; try { while (!locked) { if (methodLock.attempt(5000, miTx, nonReentrant)) { locked = true; } else { if (isTxExpired(miTx)) { log.error("Saw rolled back tx=" + miTx); throw new RuntimeException("Transaction marked for rollback, possibly a timeout"); } } } } catch (NonReentrantLock.ReentranceException re) { if (mi.getType() == InvocationType.REMOTE) { throw new RemoteException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } else { throw new EJBException("Reentrant method call detected: " + container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString()); } } try { ctx.lock(); return getNext().invoke(mi); } finally { ctx.unlock(); methodLock.release(nonReentrant); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(SimpleNode node, Object data) { throw new RuntimeException("Internal error: Found unknown node type in " + "EJB-QL abstract syntax tree: node=" + node); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(SimpleNode node, Object data) { throw new RuntimeException("Internal error: Found unknown node type in " + "EJB-QL abstract syntax tree: node=" + node); }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
public void setAcknowledgeMode (int ackMode) { if (ackMode > 3 || ackMode < 1) throw new RuntimeException ("Value AcknowledgeMode must be between 1 and 3"); switch (ackMode) { case 1: this.acknowledgeMode = TopicSession.AUTO_ACKNOWLEDGE; break; case 2: this.acknowledgeMode = TopicSession.CLIENT_ACKNOWLEDGE; break; case 3: this.acknowledgeMode = TopicSession.DUPS_OK_ACKNOWLEDGE; break; } }
// in src/main/java/org/jboss/cache/invalidation/bridges/JMSCacheInvalidationBridge.java
public void setPropagationMode (int propMode) { if (propMode > 3 || propMode < 1) throw new RuntimeException ("Value PropagationMode must be between 1 and 3"); this.propagationMode = propMode; }
// in src/main/java/org/jboss/proxy/compiler/ProxyCompiler.java
public byte[] getCode() { boolean trace = log.isTraceEnabled(); final String proxyClassName = getProxyClassName(); final String superClassName = superclass.getName(); int icount = 1; // don't forget ProxyTarget for (int i = 0; i < targetTypes.length; i++) { Class targetType = targetTypes[i]; if (targetType.isInterface()) { icount++; } } String interfaceNames[] = new String[icount]; interfaceNames[0] = Proxies.ProxyTarget.class.getName(); icount = 1; for (int i = 0; i < targetTypes.length; i++) { Class targetType = targetTypes[i]; if (targetType.isInterface()) { interfaceNames[icount++] = targetType.getName(); } else if (!superclass.isAssignableFrom(targetType)) { throw new RuntimeException("unexpected: " + targetType); } } ClassGen cg = new ClassGen(proxyClassName, superClassName, "<generated>", Constants.ACC_PUBLIC | Constants.ACC_FINAL, interfaceNames); ProxyImplementationFactory factory = new ProxyImplementationFactory(superClassName, proxyClassName, cg); cg.addField(factory.createInvocationHandlerField()); cg.addField(factory.createRuntimeField()); cg.addMethod(factory.createConstructor()); // ProxyTarget implementation cg.addMethod(factory.createGetInvocationHandler()); cg.addMethod(factory.createGetTargetTypes()); boolean haveToString = false; if (trace) log.trace("Creating proxy methods..."); // Implement the methods of the target types. for (int i = 0; i < methods.length; i++) { Method m = methods[i]; if (trace) log.trace("Reflected method: " + m); String name = m.getName(); Class rTypeClass = m.getReturnType(); String rTypeName = rTypeClass.getName(); Type rType = Utility.getType(rTypeClass); Type[] pTypes = Utility.getTypes(m.getParameterTypes()); String[] exceptionNames = getNames(m.getExceptionTypes()); if (name.equals("toString") && pTypes.length == 0) { haveToString = true; } org.apache.bcel.classfile.Method proxyMethod = factory.createProxyMethod(name, i, rType, pTypes, exceptionNames); if (trace) log.trace("Created proxy method: " + proxyMethod); cg.addMethod(proxyMethod); } if (!haveToString) { cg.addMethod(factory.createToString()); } JavaClass jclass = cg.getJavaClass(); if (trace) log.trace("Generated Java class: " + jclass); // dump the class if we have been configured todo so if (CLASS_DUMP_PATH != null) { try { String filename = CLASS_DUMP_PATH + java.io.File.separator + proxyClassName + ".class"; log.info("Dumping generated proxy class to " + filename); jclass.dump(filename); } catch (Exception e) { log.error("Failed to dump class file", e); } } return jclass.getBytes(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public short getUtfIndex(String x) { Object n = ut.get(x); if (n == null) { n = new Short(cn++); ut.put(x, n); int xlen = 2 + x.length(); // x.utfLength(), really ByteArrayOutputStream bytes = new ByteArrayOutputStream(xlen); DataOutputStream ds = new DataOutputStream(bytes); try { ds.writeByte(CONSTANT_UTF8); ds.writeUTF(x); } catch (IOException ee) { throw new RuntimeException(ee.toString()); } cv.addElement(bytes.toByteArray()); } return ((Short)n).shortValue(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public void pushConstant(Object x) { int op = opc_ldc_w; if (x instanceof Integer) { declare(Integer.TYPE); int v = ((Integer)x).intValue(); if (v >= -1 && v <= 5) { code.write(opc_iconst_0 + v); return; } else if ((v > -(1 << 7)) && (v < (1 << 7))) { code.write(opc_bipush); code.write(v); return; } else if ((v > -(1 << 15)) && (v < (1 << 15))) { code.write(opc_sipush); codeShort(v); return; } } else if (x instanceof Float) { declare(Float.TYPE); } else if (x instanceof String) { declare(String.class); } else if (x instanceof Long) { declare(Long.TYPE); op = opc_ldc2_w; } else if (x instanceof Double) { declare(Double.TYPE); op = opc_ldc2_w; } else { throw new RuntimeException("unexpected: "+x); } int xi = getIndex(x); if (op == opc_ldc_w && xi < (1 << 8)) { code.write(opc_ldc); code.write(xi); } else { code.write(op); codeShort(xi); } }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public byte[] getCode() { try { return internalGetCode(); } catch (IOException ee) { throw new RuntimeException(ee.toString()); } }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
public byte[] internalGetCode() throws IOException { // first, flush out all references to the cpool getIndex(this); getIndex(superClass); for (int i = 0; i < interfaces.length; i++) { getIndex(interfaces[i]); } int nfields = 0; int nmethods = 0; for (int i = 0; i < members.size(); i++) { AMember m = (AMember) members.elementAt(i); if (m.code != null) { byte[] codeAttr = getMethodCode(m, m.code); if (codeAttr != null) { addAttribute(m, "Code", codeAttr); } } for (int j = 0; j < m.attr.size(); j++) { Attr a = (Attr) m.attr.elementAt(j); getUtfIndex(a.name); } if (m.name.length() == 0) { continue; } getUtfIndex(m.name); getUtfIndex(m.sig); if (isMethodSig(m.sig)) { nmethods += 1; } else { nfields += 1; } } // next, deal with internal references in the cpool for (int i = 0; i < cv.size(); i++) { Object x = cv.elementAt(i); if (x == null) { continue; } else if (x instanceof String) { String s = (String)x; short si = getUtfIndex(s); short data[] = { CONSTANT_STRING, si }; x = data; } else if (x instanceof Class) { Class c = (Class)x; short ci = getUtfIndex(c.getName().replace('.', '/')); short data[] = { CONSTANT_CLASS, ci }; x = data; } else if (x instanceof Field) { Field m = (Field)x; short ci = getIndex(m.getDeclaringClass()); short nt = getNTIndex(m.getName(), getSig(m.getType())); short data[] = { CONSTANT_FIELD, ci, nt }; x = data; } else if (x instanceof Constructor) { Constructor m = (Constructor)x; short ci = getIndex(m.getDeclaringClass()); short nt = getNTIndex("<init>", getSig(Void.TYPE, m.getParameterTypes())); short data[] = { CONSTANT_METHOD, ci, nt }; x = data; } else if (x instanceof Method) { Method m = (Method)x; Class c = m.getDeclaringClass(); short kind = c.isInterface() ? CONSTANT_INTERFACEMETHOD : CONSTANT_METHOD; short ci = getIndex(c); short nt = getNTIndex(m.getName(), getSig(m.getReturnType(), m.getParameterTypes())); short data[] = { kind, ci, nt }; x = data; } else if (x instanceof ProxyAssembler) { ProxyAssembler asm = (ProxyAssembler)x; short ci = getUtfIndex(asm.className.replace('.', '/')); short data[] = { CONSTANT_CLASS, ci }; x = data; } else if (x instanceof AMember) { AMember m = (AMember) x; short kind = !isMethodSig(m.sig) ? CONSTANT_FIELD : m.asm.isInterface() ? CONSTANT_INTERFACEMETHOD : CONSTANT_METHOD; short ci = getIndex(m.asm); short nt = getNTIndex(m.name, m.sig); short data[] = { kind, ci, nt }; x = data; } else if (x instanceof NameAndType) { NameAndType nt = (NameAndType) x; short data[] = { CONSTANT_NAMEANDTYPE, nt.name, nt.sig }; x = data; } cv.setElementAt(x, i); // update } ByteArrayOutputStream bytes = new ByteArrayOutputStream(400); DataOutputStream ds = new DataOutputStream(bytes); ds.writeInt(JAVA_MAGIC); ds.writeShort(JAVA_MINOR_VERSION); ds.writeShort(JAVA_VERSION); int cvsize = cv.size(); ds.writeShort(cvsize); for (int i = 0; i < cv.size(); i++) { Object x = cv.elementAt(i); if (x == null) { continue; } else if (x instanceof short[]) { short data[] = (short[])x; ds.writeByte(data[0]); for (int j = 1; j < data.length; j++) { ds.writeShort(data[j]); } } else if (x instanceof byte[]) { ds.write((byte[])x); } else if (x instanceof Integer) { ds.writeByte(CONSTANT_INTEGER); ds.writeInt(((Integer)x).intValue()); // (do other primitive literal types?) } else { throw new RuntimeException("unexpected"); } } ds.writeShort(modifiers); ds.writeShort(getIndex(this)); ds.writeShort(getIndex(superClass)); ds.writeShort(interfaces.length); for (int i = 0; i < interfaces.length; i++) { ds.writeShort(getIndex(interfaces[i])); } for (int pass = 0; pass <= 1; pass++) { boolean methods = (pass > 0); ds.writeShort(methods ? nmethods : nfields); for (int i = 0; i < members.size(); i++) { AMember m = (AMember) members.elementAt(i); if (m.name.length() == 0 || isMethodSig(m.sig) != methods) { continue; } ds.writeShort(m.mods); ds.writeShort(getUtfIndex(m.name)); ds.writeShort(getUtfIndex(m.sig)); writeAttrs(ds, m.attr); } } AMember m0 = (AMember) members.elementAt(0); writeAttrs(ds, (Vector) m0.attr); // sanity check if (cvsize != cv.size()) { throw new RuntimeException("cvsize"); } return bytes.toByteArray(); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
private void writeAttrs(DataOutputStream ds, Vector attrs) throws IOException { ds.writeShort(attrs.size()); for (int i = 0; i < attrs.size(); i++) { Attr a = (Attr) attrs.elementAt(i); ds.writeShort(getUtfIndex(a.name)); if (a.data instanceof byte[]) { byte[] xa = (byte[])a.data; ds.writeInt(xa.length); ds.write(xa); } else { throw new RuntimeException("unexpected"); } } }
// in src/main/java/org/jboss/proxy/ejb/EJBMetaDataImpl.java
public Class getPrimaryKeyClass() { if (session == true) throw new RuntimeException("A session bean does not have a primary key class"); return pkClass; }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public void create() throws Exception { jmxName = container.getJmxName(); jmxNameHash = jmxName.hashCode(); jmxNameHashInteger = new Integer(jmxNameHash); // Create metadata BeanMetaData bmd = container.getBeanMetaData(); boolean isSession = !(bmd instanceof EntityMetaData); boolean isStatelessSession = false; if(isSession) { SessionMetaData smd = (SessionMetaData) bmd; if(bmd.getRemote() == null) { isServiceEndpointOnly = true; // nothing more to do return; } isStatelessSession = smd.isStateless(); } Class pkClass = null; if(!isSession) { EntityMetaData metaData = (EntityMetaData) bmd; String pkClassName = metaData.getPrimaryKeyClass(); try { if(pkClassName != null) { pkClass = container.getClassLoader().loadClass(pkClassName); } else { pkClass = container.getClassLoader() .loadClass(metaData.getEjbClass()) .getField(metaData.getPrimKeyField()) .getClass(); } } catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); } catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); } } ejbMetaData = new EJBMetaDataImpl( ((EJBProxyFactoryContainer) container).getRemoteClass(), ((EJBProxyFactoryContainer) container).getHomeClass(), pkClass, //null if not entity isSession, //Session isStatelessSession, //Stateless new HomeHandleImpl(jndiBinding) ); log.debug("Proxy Factory for " + jndiBinding + " initialized"); initInterceptorClasses(); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void setupInvokers() throws Exception { ObjectName oname = new ObjectName(invokerMetaData.getInvokerMBean()); Invoker invoker = (Invoker) Registry.lookup(oname); if(invoker == null) { throw new RuntimeException("invoker is null: " + oname); } homeInvoker = beanInvoker = invoker; }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
public Object createProxy(Object id, ObjectName targetName, ObjectName invokerName, String jndiName, String proxyBindingName, ArrayList interceptorClasses, ClassLoader loader, Class[] ifaces) { Invoker invoker = (Invoker) Registry.lookup(invokerName); if (invoker == null) throw new RuntimeException("Failed to find invoker for name: " + invokerName); return createProxy(id, targetName, invoker, jndiName, proxyBindingName, interceptorClasses, loader, ifaces, null); }
// in src/main/java/org/jboss/proxy/GenericProxyFactory.java
public Object createProxy(Object id, ObjectName targetName, Invoker invoker, String jndiName, String proxyBindingName, ArrayList interceptorClasses, ClassLoader loader, Class[] ifaces, HashMap ctx) { InvocationContext context; if (ctx != null) context = new InvocationContext(ctx); else context = new InvocationContext(); Integer nameHash = new Integer(targetName.hashCode()); if (log.isTraceEnabled()) { log.trace("Target name " + targetName + " and corresponding hash code" + nameHash); } context.setObjectName(nameHash); context.setCacheId(id); if( jndiName != null ) context.setValue(InvocationKey.JNDI_NAME, jndiName); if( invoker == null ) throw new RuntimeException("Null invoker given for name: " + targetName); context.setInvoker(invoker); if( proxyBindingName != null ) context.setInvokerProxyBinding(proxyBindingName); // If the IClientContainer interceptor was specified, use the ClientContainerEx boolean wantIClientAccess = false; for(int n = 0; wantIClientAccess == false && n < interceptorClasses.size(); n ++) { Class type = (Class) interceptorClasses.get(n); wantIClientAccess = type.isAssignableFrom(IClientContainer.class); } ClientContainer client; if( wantIClientAccess ) { client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } try { loadInterceptorChain(interceptorClasses, client); } catch(Exception e) { throw new NestedRuntimeException("Failed to load interceptor chain", e); } ArrayList tmp = new ArrayList(Arrays.asList(ifaces)); Class[] ifaces2 = new Class[tmp.size()]; tmp.toArray(ifaces2); return Proxy.newProxyInstance( // Classloaders loader, // Interfaces ifaces2, // Client container as invocation handler client); }
18
            
// in src/main/java/org/jboss/deployment/EARStructure.java
catch(Exception e) { throw new RuntimeException("Error determining structure: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/EARContentsDeployer.java
catch(Exception e) { throw new RuntimeException("Error determining ear contents: " + file.getName(), e); }
// in src/main/java/org/jboss/deployment/JaccCommitDeployer.java
catch (PolicyContextException e) { throw new RuntimeException("Failed to commit PolicyConfiguration for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/JaccInitializationDeployer.java
catch (Exception e) { throw new RuntimeException("failed to initialize JACC for unit: " + unit.getName(), e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException("Cannot create permissions:",e); }
// in src/main/java/org/jboss/deployment/security/JaccPolicy.java
catch (PolicyContextException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/deployment/security/AbstractSecurityDeployer.java
catch (Exception e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception ex) { throw new RuntimeException("UT factory lookup failed", ex); }
// in src/main/java/org/jboss/ejb/txtimer/EJBTimerServiceLocator.java
catch (Exception e) { throw new RuntimeException("Cannot start EJBTimerService", e); }
// in src/main/java/org/jboss/ejb/Container.java
catch (MalformedObjectNameException e) { throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); }
// in src/main/java/org/jboss/ejb/BeanLockManager.java
catch (Exception e) { // schrouf: should we really proceed with lock object // in case of exception ?? log.warn("Failed to initialize lock:"+id, e); throw new RuntimeException (e); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (NamingException e) { throw new RuntimeException(e); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/compiler/ProxyAssembler.java
catch (IOException ee) { throw new RuntimeException(ee.toString()); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NoSuchFieldException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(NullPointerException e) { log.error( "Unable to identify Bean's Primary Key class!" + " Did you specify a primary key class and/or field? Does that field exist?" ); throw new RuntimeException("Primary Key Problem"); }
0 13
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( RuntimeException e ) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
13
            
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (RuntimeException e) { exceptionThrown = e; discardContext = true; throw e; }
// in src/main/java/org/jboss/ejb/plugins/MessageDrivenInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatelessSessionInstanceInterceptor.java
catch (RuntimeException e) // Instance will be GC'ed at MI return { mi.setEnterpriseContext(null); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/bridge/EntityBridgeInvocationHandler.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
catch(RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
catch( RuntimeException e ) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
catch (RuntimeException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceInterceptor.java
catch (RuntimeException e) { // Discard instance cache.remove(methodID); pool.discard(ctx); validContext = false; throw e; }
0
unknown (Lib) SAXException 0 0 4
            
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
public static void parse(final DeploymentUnit unit, final URL facesConfigXmlURL, final JSFDeployment jsfDeployment) throws Exception { logger.debug("Checking for the presence of JSF managed-bean(s) in JSF config file: " + facesConfigXmlURL + " in deployment unit: " + unit); // get the parser factory SAXParserFactory parserFactory = getParserFactory(); // create a parser SAXParser saxParser = parserFactory.newSAXParser(); InputStream inputStream = null; try { // get the input stream and the input source for the faces config file inputStream = getInputStream(facesConfigXmlURL); InputSource inputSource = new InputSource(getInputStream(facesConfigXmlURL)); inputSource.setSystemId(facesConfigXmlURL.toExternalForm()); // parse it! saxParser.parse(inputSource, new DefaultHandler() { /** * Flag to keep track of managed-bean-class element being processed */ private boolean managedBeanClassElementProcessingInProgress; /** * Uses the {@link JBossEntityResolver} to resolve the entity. If it cannot be resolved by the {@link JBossEntityResolver} * then this method lets the {@link DefaultHandler} to resolve it. * * @param publicId * @param systemId * @return * @throws IOException * @throws SAXException */ @Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { // try resolving it with the JBossEntityResolver InputSource source = jBossJSFEntityResolver.resolveEntity(publicId, systemId); if (source != null) { return source; } // we couldn't resolve, so let the default handler try to resolve it return super.resolveEntity(publicId, systemId); } @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // we are only interested in managed-bean-class element. if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = true; } // let the super do its job super.startElement(uri, localName, qName, attributes); } @Override public void endElement(String uri, String localName, String qName) throws SAXException { // reset the flag when the managed-bean-class element ends if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = false; } // let super do its job super.endElement(uri, localName, qName); } @Override public void characters(char[] ch, int start, int length) throws SAXException { // if we are currently processing the managed-bean-class element, then fetch the managed bean // class name text if (this.managedBeanClassElementProcessingInProgress) { // get the managed bean class name String managedBeanClassName = new String(ch, start, length); if (!managedBeanClassName.trim().isEmpty()) { logger.debug("Found JSF managed bean class: " + managedBeanClassName + " in unit " + unit); // add it to the jsf deployment jsfDeployment.addManagedBean(managedBeanClassName); } } // let super do its job now super.characters(ch, start, length); } }); } finally { if (inputStream != null) { inputStream.close(); } } return; }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
Override public InputSource resolveEntity(String publicId, String systemId) throws IOException, SAXException { // try resolving it with the JBossEntityResolver InputSource source = jBossJSFEntityResolver.resolveEntity(publicId, systemId); if (source != null) { return source; } // we couldn't resolve, so let the default handler try to resolve it return super.resolveEntity(publicId, systemId); }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // we are only interested in managed-bean-class element. if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = true; } // let the super do its job super.startElement(uri, localName, qName, attributes); }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
Override public void endElement(String uri, String localName, String qName) throws SAXException { // reset the flag when the managed-bean-class element ends if (localName.equals("managed-bean-class")) { this.managedBeanClassElementProcessingInProgress = false; } // let super do its job super.endElement(uri, localName, qName); }
// in src/main/java/org/jboss/web/deployers/FacesConfigParsingUtil.java
Override public void characters(char[] ch, int start, int length) throws SAXException { // if we are currently processing the managed-bean-class element, then fetch the managed bean // class name text if (this.managedBeanClassElementProcessingInProgress) { // get the managed bean class name String managedBeanClassName = new String(ch, start, length); if (!managedBeanClassName.trim().isEmpty()) { logger.debug("Found JSF managed bean class: " + managedBeanClassName + " in unit " + unit); // add it to the jsf deployment jsfDeployment.addManagedBean(managedBeanClassName); } } // let super do its job now super.characters(ch, start, length); }
1
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
1
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXException e) { throw new DeploymentException("Invalid XML: file=" + inPath, e); }
0
unknown (Lib) SAXParseException 0 0 0 1
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); }
1
            
// in src/main/java/org/jboss/metadata/XmlFileLoader.java
catch (SAXParseException e) { String msg = "Invalid XML: file=" + inPath+"@"+e.getColumnNumber()+":"+e.getLineNumber(); throw new DeploymentException(msg, e); }
0
unknown (Lib) SQLException 18
            
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSourceName) throws SQLException { this.server = server; this.dataSourceName = dataSourceName; // Get the DataSource from JNDI try { String dsJndiTx = (String)server.getAttribute(dataSourceName, "BindName"); ds = (DataSource)new InitialContext().lookup(dsJndiTx); } catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); } // Get the DataSource meta data String dsName = dataSourceName.getKeyProperty("name"); metaDataName = ObjectNameFactory.create("jboss.jdbc:datasource=" + dsName + ",service=metadata"); if (this.server.isRegistered(metaDataName) == false) throw new IllegalStateException("Cannot find datasource meta data: " + metaDataName); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void initSequence(String tableName, String sequenceColumn, String sequenceName, String idColumnName) throws SQLException, DeploymentException { if(createTable) { createTableIfNotExists(tableName); } Connection con = null; Statement st = null; ResultSet rs = null; try { String sql = "select " + idColumnName + " from " + tableName + " where " + sequenceColumn + "='" + sequenceName + "'"; log.debug("Executing SQL: " + sql); con = ds.getConnection(); st = con.createStatement(); rs = st.executeQuery(sql); if(!rs.next()) { sql = "insert into " + tableName + "(" + sequenceColumn + ", " + idColumnName + ") values ('" + sequenceName + "', 0)"; log.debug("Executing SQL: " + sql); final Statement insertSt = con.createStatement(); try { final int i = insertSt.executeUpdate(sql); if(i != 1) { throw new SQLException("Expected one updated row but got: " + i); } } finally { JDBCUtil.safeClose(insertSt); } } else { HiLoKeyGenerator.setHighestHi(rs.getLong(1)); } } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static byte[] convertObjectToByteArray(Object value) throws SQLException { // Do we already have a byte array? if(value instanceof byte[]) { return (byte[])value; } ByteArrayOutputStream baos = null; ObjectOutputStream oos = null; try { // ejb-reference: store the handle if(value instanceof EJBObject) { value = ((EJBObject)value).getHandle(); } // Marshall the object using MashalledValue to handle classloaders value = new MarshalledValue(value); // return the serialize the value baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(value); return baos.toByteArray(); } catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); } catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); } finally { safeClose(oos); safeClose(baos); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object convertToObject(InputStream input) throws SQLException { Object value = null; if(input != null) { ObjectInputStream ois = null; try { // deserialize result ois = new ObjectInputStream(input); value = ois.readObject(); // de-marshall value if possible if(value instanceof MarshalledValue) { value = ((MarshalledValue)value).get(); } else if(value instanceof MarshalledObject) { value = ((MarshalledObject)value).get(); } // ejb-reference: get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } finally { // ois will close the input stream it wraps safeClose(ois); } } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static String getLongString(ResultSet rs, int index) throws SQLException { String value; Reader textData = rs.getCharacterStream(index); if(textData != null) { try { // Use a modest buffer here to reduce function call overhead // when reading extremely large data. StringBuffer textBuffer = new StringBuffer(); char[] tmpBuffer = new char[1000]; int charsRead; while((charsRead = textData.read(tmpBuffer)) != -1) textBuffer.append(tmpBuffer, 0, charsRead); value = textBuffer.toString(); } catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); } finally { safeClose(textData); } } else value = null; return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static byte[] getByteArray(InputStream input) throws SQLException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { // Use a modest buffer here to reduce function call overhead // when reading extremely large data. byte[] tmpBuffer = new byte[1000]; int bytesRead; while((bytesRead = input.read(tmpBuffer)) != -1) baos.write(tmpBuffer, 0, bytesRead); return baos.toByteArray(); } catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); } finally { safeClose(baos); safeClose(input); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
private static Object coerceToJavaType( Object value, Class destination) throws SQLException { try { // // null // if(value == null) { return null; } // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // // Primitive wrapper classes // // We have a primitive wrapper and we want a real primitive // just return the wrapper and the vm will convert it at the proxy if(destination.isPrimitive()) { if(value == null) throw new IllegalStateException("Loaded NULL value for a field of a primitive type."); if((destination.equals(Byte.TYPE) && value instanceof Byte) || (destination.equals(Short.TYPE) && value instanceof Short) || (destination.equals(Character.TYPE) && value instanceof Character) || (destination.equals(Boolean.TYPE) && value instanceof Boolean) || (destination.equals(Integer.TYPE) && value instanceof Integer) || (destination.equals(Long.TYPE) && value instanceof Long) || (destination.equals(Float.TYPE) && value instanceof Float) || (destination.equals(Double.TYPE) && value instanceof Double) ) { return value; } } // // java.util.Date // // make new copy as sub types have problems in comparions if(destination == java.util.Date.class && value instanceof java.util.Date) { // handle timestamp special becauses it hoses the milisecond values if(value instanceof java.sql.Timestamp) { java.sql.Timestamp ts = (java.sql.Timestamp)value; // Timestamp returns whole seconds from getTime and partial // seconds are retrieved from getNanos() // Adrian Brock: Not in 1.4 it doesn't long temp = ts.getTime(); if(temp % 1000 == 0) temp += ts.getNanos() / 1000000; return new java.util.Date(temp); } else { return new java.util.Date(((java.util.Date)value).getTime()); } } // // java.sql.Time // // make a new copy object; you never know what a driver will return if(destination == java.sql.Time.class && value instanceof java.sql.Time) { return new java.sql.Time(((java.sql.Time)value).getTime()); } // // java.sql.Date // // make a new copy object; you never know what a driver will return if(destination == java.sql.Date.class && value instanceof java.sql.Date) { return new java.sql.Date(((java.sql.Date)value).getTime()); } // // java.sql.Timestamp // // make a new copy object; you never know what a driver will return if(destination == java.sql.Timestamp.class && value instanceof java.sql.Timestamp) { // make a new Timestamp object; you never know // what a driver will return java.sql.Timestamp orignal = (java.sql.Timestamp)value; java.sql.Timestamp copy = new java.sql.Timestamp(orignal.getTime()); copy.setNanos(orignal.getNanos()); return copy; } // // java.lang.String --> java.lang.Character or char // // just grab first character if(value instanceof String && (destination == Character.class || destination == Character.TYPE)) { return new Character(((String)value).charAt(0)); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do throw new SQLException("Got a " + value.getClass().getName() + "[cl=" + System.identityHashCode(value.getClass().getClassLoader()) + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + System.identityHashCode(destination) + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Clob clob = rs.getClob(index); String content; if(clob == null) { content = null; } else { final Reader reader = clob.getCharacterStream(); if(reader != null) { int intLength = (int)clob.length(); char[] chars; try { if(intLength <= 8192) { chars = new char[intLength]; reader.read(chars); content = String.valueOf(chars); } else { StringBuffer buf = new StringBuffer(intLength); chars = new char[8192]; int i = reader.read(chars); while(i > 0) { buf.append(chars, 0, i); i = reader.read(chars); } content = buf.toString(); } } catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); } finally { JDBCUtil.safeClose(reader); } } else { content = null; } } return content; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object coerceToJavaType(Object value, Class destination) throws SQLException { try { // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do String className = null; Object interfaces = null; ClassLoader cl = null; if (value != null) { Class valueClass = value.getClass(); className = valueClass.getName(); interfaces = Arrays.asList(valueClass.getInterfaces()); cl = valueClass.getClassLoader(); } throw new SQLException("Got a " + className + "[cl=" + cl + " + interfaces=" + interfaces + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + destination.getClassLoader() + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
15
            
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); }
112
            
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSource, String tableName) throws SQLException { if (tableName == null) throw new IllegalArgumentException("Timers tableName is null"); if (tableName.length() == 0) throw new IllegalArgumentException("Timers tableName is empty"); this.tableName = tableName; init(server, dataSource); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void init(MBeanServer server, ObjectName dataSourceName) throws SQLException { this.server = server; this.dataSourceName = dataSourceName; // Get the DataSource from JNDI try { String dsJndiTx = (String)server.getAttribute(dataSourceName, "BindName"); ds = (DataSource)new InitialContext().lookup(dsJndiTx); } catch (Exception e) { throw new SQLException("Failed to lookup data source: " + dataSourceName); } // Get the DataSource meta data String dsName = dataSourceName.getKeyProperty("name"); metaDataName = ObjectNameFactory.create("jboss.jdbc:datasource=" + dsName + ",service=metadata"); if (this.server.isRegistered(metaDataName) == false) throw new IllegalStateException("Cannot find datasource meta data: " + metaDataName); }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void createTableIfNotExists() throws SQLException { Connection con = null; Statement st = null; try { JDBCTypeMappingMetaData typeMapping = (JDBCTypeMappingMetaData)server.getAttribute(metaDataName, "TypeMappingMetaData"); if (typeMapping == null) throw new IllegalStateException("Cannot obtain type mapping from: " + metaDataName); JDBCMappingMetaData objectMetaData = typeMapping.getTypeMappingMetaData(Object.class); binarySqlType = objectMetaData.getJdbcType(); if (!SQLUtil.tableExists(getTableName(), ds)) { con = ds.getConnection(); String dateType = typeMapping.getTypeMappingMetaData(Timestamp.class).getSqlType(); String longType = typeMapping.getTypeMappingMetaData(Long.class).getSqlType(); String objectType = objectMetaData.getSqlType(); // The create table DDL StringBuffer createTableDDL = new StringBuffer("create table " + getTableName() + " (" + " " + getColumnTimerID() + " varchar(80) not null," + " " + getColumnTargetID() + " varchar(250) not null," + " " + getColumnInitialDate() + " " + dateType + " not null," + " " + getColumnTimerInterval() + " " + longType + "," + " " + getColumnInstancePK() + " " + objectType + "," + " " + getColumnInfo() + " " + objectType + ", "); // Add the primary key constraint using the pk-constraint-template JDBCFunctionMappingMetaData pkConstraint = typeMapping.getPkConstraintTemplate(); String name = SQLUtil.unquote(getTableName(), ds) + "_PK"; name = SQLUtil.fixConstraintName(name, ds); String[] templateParams = new String[] { name, getColumnTimerID() + ", " + getColumnTargetID() }; pkConstraint.getFunctionSql(templateParams, createTableDDL); // Complete the statement createTableDDL.append(" )"); log.debug("Executing DDL: " + createTableDDL); st = con.createStatement(); st.executeUpdate(createTableDDL.toString()); } } catch (SQLException e) { throw e; } catch (Exception e) { log.error("Cannot create timer table", e); } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void insertTimer(String timerId, TimedObjectId timedObjectId, Date initialExpiration, long intervalDuration, Serializable info) throws SQLException { Connection con = null; PreparedStatement st = null; try { con = ds.getConnection(); String sql = "insert into " + getTableName() + " " + "(" + getColumnTimerID() + "," + getColumnTargetID() + "," + getColumnInitialDate() + "," + getColumnTimerInterval() + "," + getColumnInstancePK() + "," + getColumnInfo() + ") " + "values (?,?,?,?,?,?)"; st = con.prepareStatement(sql); st.setString(1, timerId); st.setString(2, timedObjectId.toString()); st.setTimestamp(3, new Timestamp(initialExpiration.getTime())); st.setLong(4, intervalDuration); byte[] bytes = serialize(timedObjectId.getInstancePk()); if(bytes == null) { st.setNull(5, binarySqlType); } else { st.setBytes(5, bytes); } bytes = serialize(info); if(bytes == null) { st.setNull(6, binarySqlType); } else { st.setBytes(6, bytes); } int rows = st.executeUpdate(); if (rows != 1) log.error("Unable to insert timer for: " + timedObjectId); } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public List selectTimers(ObjectName containerId) throws SQLException { Connection con = null; Statement st = null; ResultSet rs = null; try { con = ds.getConnection(); List list = new ArrayList(); st = con.createStatement(); rs = st.executeQuery("select * from " + getTableName()); while (rs.next()) { String timerId = rs.getString(getColumnTimerID()); TimedObjectId targetId = TimedObjectId.parse(rs.getString(getColumnTargetID())); // add this handle to the returned list, if a null containerId was used // or the containerId filter matches if (containerId == null || containerId.equals(targetId.getContainerId())) { Date initialDate = rs.getTimestamp(getColumnInitialDate()); long interval = rs.getLong(getColumnTimerInterval()); Serializable pKey = (Serializable)deserialize(rs.getBytes(getColumnInstancePK())); Serializable info = null; try { info = (Serializable)deserialize(rs.getBytes(getColumnInfo())); } catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); } // is this really needed? targetId encapsulates pKey as well! targetId = new TimedObjectId(targetId.getContainerId(), pKey); TimerHandleImpl handle = new TimerHandleImpl(timerId, targetId, initialDate, interval, info); list.add(handle); } } return list; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void deleteTimer(String timerId, TimedObjectId timedObjectId) throws SQLException { Connection con = null; PreparedStatement st = null; ResultSet rs = null; try { con = ds.getConnection(); String sql = "delete from " + getTableName() + " where " + getColumnTimerID() + "=? and " + getColumnTargetID() + "=?"; st = con.prepareStatement(sql); st.setString(1, timerId); st.setString(2, timedObjectId.toString()); int rows = st.executeUpdate(); // This appears when a timer is created & persisted inside a tx, // but then the tx is rolled back, at which point we go back // to remove the entry, but no entry is found. // Is this because we are "enlisting" the datasource in the tx, too? if (rows != 1) { log.debug("Unable to remove timer for: " + timerId); } } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
public void clearTimers() throws SQLException { Connection con = null; PreparedStatement st = null; ResultSet rs = null; try { con = ds.getConnection(); st = con.prepareStatement("delete from " + getTableName()); st.executeUpdate(); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
public void insertTimer( String timerId, TimedObjectId timedObjectId, Date initialExpiration, long intervalDuration, Serializable info) throws SQLException { Connection con = null; PreparedStatement st = null; try { con = ds.getConnection(); String sql = "insert into " + getTableName() + " " + "(" + getColumnTimerID() + "," + getColumnTargetID() + "," + getColumnInitialDate() + "," + getColumnTimerInterval() + "," + getColumnInstancePK() + "," + getColumnInfo() + ") " + "values (?,?,?,?,?,?)"; st = con.prepareStatement(sql); st.setString(1, timerId); st.setString(2, timedObjectId.toString()); st.setTimestamp(3, new Timestamp(initialExpiration.getTime())); st.setLong(4, intervalDuration); byte[] pkArr = serialize(timedObjectId.getInstancePk()); if (pkArr != null) { InputStream is = new ByteArrayInputStream(pkArr); st.setBinaryStream(5, is, pkArr.length); } else { st.setBytes(5, null); } byte[] infoArr = serialize(info); if (infoArr != null) { InputStream is = new ByteArrayInputStream(infoArr); st.setBinaryStream(6, is, infoArr.length); } else { st.setBytes(6, null); } int rows = st.executeUpdate(); if (rows != 1) log.error("Unable to insert timer for: " + timedObjectId); } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
public List selectTimers(ObjectName containerId) throws SQLException { Connection con = null; Statement st = null; ResultSet rs = null; try { con = ds.getConnection(); List list = new ArrayList(); st = con.createStatement(); rs = st.executeQuery("select * from " + getTableName()); while (rs.next()) { String timerId = rs.getString(getColumnTimerID()); TimedObjectId targetId = TimedObjectId.parse(rs.getString(getColumnTargetID())); // add this handle to the returned list, if a null containerId was used // or the containerId filter matches if (containerId == null || containerId.equals(targetId.getContainerId())) { Date initialDate = rs.getTimestamp(getColumnInitialDate()); long interval = rs.getLong(getColumnTimerInterval()); InputStream isPk = rs.getBinaryStream(getColumnInstancePK()); Serializable pKey = (Serializable)deserialize(isPk); Serializable info = null; try { InputStream isInfo = rs.getBinaryStream(getColumnInfo()); info = (Serializable)deserialize(isInfo); } catch (Exception e) { // may happen if listing all handles (containerId is null) // with a stored custom info object coming from a scoped // deployment. log.warn("Cannot deserialize custom info object", e); } // is this really needed? targetId encapsulates pKey as well! targetId = new TimedObjectId(targetId.getContainerId(), pKey); TimerHandleImpl handle = new TimerHandleImpl(timerId, targetId, initialDate, interval, info); list.add(handle); } } return list; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
public void resetAndRestoreTimers() throws SQLException { timersToRestore = dbpPlugin.selectTimers(null); log.debug("Found " + timersToRestore.size() + " timer(s)"); if (timersToRestore.size() > 0) { // delete all timers clearTimers(); } restoreTimers(); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void initSequence(String tableName, String sequenceColumn, String sequenceName, String idColumnName) throws SQLException, DeploymentException { if(createTable) { createTableIfNotExists(tableName); } Connection con = null; Statement st = null; ResultSet rs = null; try { String sql = "select " + idColumnName + " from " + tableName + " where " + sequenceColumn + "='" + sequenceName + "'"; log.debug("Executing SQL: " + sql); con = ds.getConnection(); st = con.createStatement(); rs = st.executeQuery(sql); if(!rs.next()) { sql = "insert into " + tableName + "(" + sequenceColumn + ", " + idColumnName + ") values ('" + sequenceName + "', 0)"; log.debug("Executing SQL: " + sql); final Statement insertSt = con.createStatement(); try { final int i = insertSt.executeUpdate(sql); if(i != 1) { throw new SQLException("Expected one updated row but got: " + i); } } finally { JDBCUtil.safeClose(insertSt); } } else { HiLoKeyGenerator.setHighestHi(rs.getLong(1)); } } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void createTableIfNotExists(String tableName) throws SQLException, DeploymentException { Connection con = null; Statement st = null; try { if(!SQLUtil.tableExists(tableName, ds)) { log.debug("Executing DDL: " + createTableDdl); con = ds.getConnection(); st = con.createStatement(); st.executeUpdate(createTableDdl); } } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGeneratorFactory.java
private void dropTableIfExists(String tableName) throws SQLException, DeploymentException { Connection con = null; Statement st = null; try { if(SQLUtil.tableExists(tableName, ds)) { final String ddl = "drop table " + tableName; log.debug("Executing DDL: " + ddl); con = ds.getConnection(); st = con.createStatement(); st.executeUpdate(ddl); } } finally { JDBCUtil.safeClose(st); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private void doGenerate() throws SQLException { long curHi; do { curHi = getCurrentHi(); lo = curHi + 1; hi = curHi + blockSize; } while(!updateHi(curHi, hi)); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private long getCurrentHi() throws SQLException { return selectHiSql != null ? selectHi() : getHighestHi(); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private boolean updateHi(long curHi, long newHi) throws SQLException { if(selectHiSql == null) { setHighestHi(newHi); } return updateTable(curHi, newHi); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private long selectHi() throws SQLException { Connection con = null; PreparedStatement selectHiSt = null; ResultSet rs = null; if(log.isTraceEnabled()) { log.trace("Executing SQL: " + selectHiSql); } try { con = ds.getConnection(); selectHiSt = con.prepareStatement(selectHiSql); rs = selectHiSt.executeQuery(); if(!rs.next()) { throw new IllegalStateException("The sequence has not been initialized in the service start phase!"); } return rs.getLong(1); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(selectHiSt); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
private boolean updateTable(long curHi, long newHi) throws SQLException { Connection con = null; PreparedStatement updateHi = null; if(log.isTraceEnabled()) { log.trace("Executing SQL: " + updateHiSql + ", [" + newHi + "," + curHi + "]"); } try { con = ds.getConnection(); updateHi = con.prepareStatement(updateHiSql); updateHi.setLong(1, newHi); updateHi.setLong(2, curHi); return updateHi.executeUpdate() == 1; } finally { JDBCUtil.safeClose(updateHi); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/ASTSqrt.java
public Object readResult(ResultSet rs) throws SQLException { return JDBCResultSetReader.DOUBLE_READER.get(rs, 1, Double.class, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/ASTLocate.java
public Object readResult(ResultSet rs) throws SQLException { return JDBCResultSetReader.LONG_READER.get(rs, 1, Long.class, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/AbstractMappedTypeFunction.java
public void setJDBCType(final JDBCType jdbcType) { if(resultReader != null) { final JDBCResultSetReader jdbcResultReader = this.resultReader; resultReader = new JDBCResultSetReader() { public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { Object jdbcResult = jdbcResultReader.get(rs, index, destination, log); return jdbcType.setColumnValue(0, null, jdbcResult); } }; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/AbstractMappedTypeFunction.java
public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { Object jdbcResult = jdbcResultReader.get(rs, index, destination, log); return jdbcType.setColumnValue(0, null, jdbcResult); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/AbstractMappedTypeFunction.java
public Object readResult(ResultSet rs) throws SQLException { return resultReader.get(rs, 1, resultType, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/ejbql/ASTLength.java
public Object readResult(ResultSet rs) throws SQLException { return JDBCResultSetReader.LONG_READER.get(rs, 1, Long.class, log); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
private void delete(View view) throws SQLException { if(view.deleted == null) { if(log.isTraceEnabled()) { log.trace("no rows to delete"); } return; } Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + deleteSql); } con = ds.getConnection(); ps = con.prepareStatement(deleteSql); int batchCount = 0; while(view.deleted != null) { RelationKeys keys = view.deleted; int paramInd = 1; JDBCCMPFieldBridge2[] keyFields = (JDBCCMPFieldBridge2[])leftField.getTableKeyFields(); for(int pkInd = 0; pkInd < keyFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = keyFields[pkInd]; Object fieldValue = pkField.getPrimaryKeyValue(keys.leftKey); paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } keyFields = (JDBCCMPFieldBridge2[])rightField.getTableKeyFields(); for(int pkInd = 0; pkInd < keyFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = keyFields[pkInd]; Object fieldValue = pkField.getPrimaryKeyValue(keys.rightKey); paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } ps.addBatch(); ++batchCount; keys.dereference(); } ps.executeBatch(); if(view.deleted != null) { throw new IllegalStateException("There are still rows to delete!"); } if(log.isTraceEnabled()) { log.trace("deleted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
private void insert(View view) throws SQLException { if(view.created == null) { if(log.isTraceEnabled()) { log.trace("no rows to insert"); } return; } Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + insertSql); } con = ds.getConnection(); ps = con.prepareStatement(insertSql); int batchCount = 0; while(view.created != null) { RelationKeys keys = view.created; JDBCCMPFieldBridge2[] keyFields = (JDBCCMPFieldBridge2[])leftField.getTableKeyFields(); int paramInd = 1; for(int fInd = 0; fInd < keyFields.length; ++fInd) { JDBCCMPFieldBridge2 field = keyFields[fInd]; Object fieldValue = field.getPrimaryKeyValue(keys.leftKey); paramInd = field.setArgumentParameters(ps, paramInd, fieldValue); } keyFields = (JDBCCMPFieldBridge2[])rightField.getTableKeyFields(); for(int fInd = 0; fInd < keyFields.length; ++fInd) { JDBCCMPFieldBridge2 field = keyFields[fInd]; Object fieldValue = field.getPrimaryKeyValue(keys.rightKey); paramInd = field.setArgumentParameters(ps, paramInd, fieldValue); } ps.addBatch(); ++batchCount; keys.dereference(); } ps.executeBatch(); if(log.isTraceEnabled()) { log.trace("inserted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
public void flushDeleted(Schema.Views views) throws SQLException { delete(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
public void flushCreated(Schema.Views views) throws SQLException { insert(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
public void flushUpdated() throws SQLException { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public Row loadRow(Object id) throws SQLException { View view = getView(); Row row = view.getRowByPk(id, false); if(row != null) { if(log.isTraceEnabled()) { log.trace("row is already loaded: pk=" + id); } return row; } JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { if(log.isDebugEnabled()) { log.debug("executing sql: " + selectSql); } con = dataSource.getConnection(); ps = con.prepareStatement(selectSql); int paramInd = 1; for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object pkValue = pkField.getPrimaryKeyValue(id); paramInd = pkField.setArgumentParameters(ps, paramInd, pkValue); } rs = ps.executeQuery(); if(!rs.next()) { throw new NoSuchEntityException("Row not found: " + id); } return view.loadRow(rs, id, false); } catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void delete(View view) throws SQLException { JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + deleteSql); } con = dataSource.getConnection(); ps = con.prepareStatement(deleteSql); int batchCount = 0; while(view.deleted != null) { Row row = view.deleted; int paramInd = 1; for(int pkInd = 0; pkInd < pkFields.length; ++pkInd) { JDBCCMPFieldBridge2 pkField = pkFields[pkInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } deleteStrategy.executeUpdate(ps); ++batchCount; row.flushStatus(); } deleteStrategy.executeBatch(ps); if(view.deleted != null) { throw new IllegalStateException("There are still rows to delete!"); } if(log.isTraceEnabled()) { log.trace("deleted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void update(View view) throws SQLException { JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + updateSql); } con = dataSource.getConnection(); ps = con.prepareStatement(updateSql); int batchCount = 0; while(view.dirty != null) { Row row = view.dirty; int paramInd = 1; for(int fInd = 0; fInd < tableFields.length; ++fInd) { JDBCCMPFieldBridge2 field = tableFields[fInd]; if(!field.isPrimaryKeyMember()) { Object fieldValue = row.fields[field.getRowIndex()]; paramInd = field.setArgumentParameters(ps, paramInd, fieldValue); } } for(int fInd = 0; fInd < pkFields.length; ++fInd) { JDBCCMPFieldBridge2 pkField = pkFields[fInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(ps, paramInd, fieldValue); } JDBCCMPFieldBridge2 versionField = entity.getVersionField(); if(versionField != null) { int versionIndex = versionField.getVersionIndex(); Object curVersion = row.fields[versionIndex]; paramInd = versionField.setArgumentParameters(ps, paramInd, curVersion); Object newVersion = row.fields[versionField.getRowIndex()]; row.fields[versionIndex] = newVersion; } updateStrategy.executeUpdate(ps); ++batchCount; row.flushStatus(); } updateStrategy.executeBatch(ps); if(log.isTraceEnabled()) { log.trace("updated rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to update: table=" + tableName, e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void insert(View view) throws SQLException { JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); Connection con = null; PreparedStatement ps = null; try { if(log.isDebugEnabled()) { log.debug("executing : " + insertSql); } con = dataSource.getConnection(); ps = con.prepareStatement(insertSql); int batchCount = 0; while(view.created != null) { Row row = view.created; int paramInd = 1; for(int fInd = 0; fInd < tableFields.length; ++fInd) { JDBCCMPFieldBridge2 field = tableFields[fInd]; Object fieldValue = row.fields[field.getRowIndex()]; paramInd = field.setArgumentParameters(ps, paramInd, fieldValue); } insertStrategy.executeUpdate(ps); ++batchCount; row.flushStatus(); } insertStrategy.executeBatch(ps); if(log.isTraceEnabled()) { log.trace("inserted rows: " + batchCount); } } catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(ps); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flushDeleted(Schema.Views views) throws SQLException { if(rowsWithNullFks != null) { nullifyForeignKeys(); rowsWithNullFks = null; } if(deleted == null) { if(log.isTraceEnabled()) { log.trace("no rows to delete"); } return; } if(referencedBy != null) { if(inFlush) { if(log.isTraceEnabled()) { log.trace("inFlush, ignoring flushDeleted"); } return; } inFlush = true; try { for(int i = 0; i < referencedBy.length; ++i) { final Table.View view = views.entityViews[referencedBy[i]]; if(view != null) { view.flushDeleted(views); } } } finally { inFlush = false; } } delete(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flushCreated(Schema.Views views) throws SQLException { if(created == null || dontFlushCreated) { if(log.isTraceEnabled()) { log.trace("no rows to insert"); } return; } if(references != null) { if(inFlush) { if(log.isTraceEnabled()) { log.trace("inFlush, ignorning flushCreated"); } return; } else if(log.isTraceEnabled()) { log.trace("flushing created references"); } inFlush = true; try { for(int i = 0; i < references.length; ++i) { final Table.View view = views.entityViews[references[i]]; if(view != null) { view.flushCreated(views); } } } finally { inFlush = false; } } insert(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flushUpdated() throws SQLException { if(dirtyRelations != null) { while(dirtyRelations != null) { Row row = dirtyRelations; row.flushStatus(); } } if(dirty == null) { if(log.isTraceEnabled()) { log.trace("no rows to update"); } return; } update(this); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
private void nullifyForeignKeys() throws SQLException { if(log.isTraceEnabled()) { log.trace("nullifying foreign keys"); } Connection con = null; PreparedStatement[] ps = new PreparedStatement[fkConstraints.length]; try { final JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); con = dataSource.getConnection(); for(int i = 0; i < rowsWithNullFks.size(); ++i) { final Row row = (Row) rowsWithNullFks.get(i); final ForeignKeyConstraint[] cons = row.fkUpdates; for (int c = 0; c < fkConstraints.length; ++c) { if (cons[c] == null || row.state == DELETED && !cons[c].selfReference) continue; PreparedStatement s = ps[c]; if (s == null) { if (log.isDebugEnabled()) { log.debug("nullifying fk: " + cons[c].nullFkSql); } s = con.prepareStatement(cons[c].nullFkSql); ps[c] = s; } int paramInd = 1; for (int fInd = 0; fInd < pkFields.length; ++fInd) { JDBCCMPFieldBridge2 pkField = pkFields[fInd]; Object fieldValue = row.fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(s, paramInd, fieldValue); } final int affected = s.executeUpdate(); if (affected != 1) { throw new EJBException("Affected " + affected + " rows while expected just one"); } } } } finally { for(int i = 0; i < ps.length; ++i) { JDBCUtil.safeClose(ps[i]); } JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void flush() throws SQLException, DuplicateKeyException { // todo needs refactoring if(state != CREATED) { if(log.isTraceEnabled()) { log.trace("The row is already inserted: pk=" + pk); } return; } Connection con = null; PreparedStatement duplicatePkPs = null; PreparedStatement insertPs = null; ResultSet rs = null; try { int paramInd; con = dataSource.getConnection(); // check for duplicate key /* if(log.isDebugEnabled()) { log.debug("executing : " + duplicatePkSql); } duplicatePkPs = con.prepareStatement(duplicatePkSql); paramInd = 1; JDBCCMPFieldBridge2[] pkFields = (JDBCCMPFieldBridge2[]) entity.getPrimaryKeyFields(); for(int i = 0; i < pkFields.length; ++i) { JDBCCMPFieldBridge2 pkField = pkFields[i]; Object fieldValue = fields[pkField.getRowIndex()]; paramInd = pkField.setArgumentParameters(duplicatePkPs, paramInd, fieldValue); } rs = duplicatePkPs.executeQuery(); if(rs.next()) { throw new DuplicateKeyException("Table " + tableName + ", pk=" + pk); } */ // insert if(log.isDebugEnabled()) { log.debug("executing : " + insertSql); } insertPs = con.prepareStatement(insertSql); paramInd = 1; JDBCCMPFieldBridge2[] tableFields = (JDBCCMPFieldBridge2[]) entity.getTableFields(); for(int fInd = 0; fInd < tableFields.length; ++fInd) { JDBCCMPFieldBridge2 field = tableFields[fInd]; Object fieldValue = fields[field.getRowIndex()]; paramInd = field.setArgumentParameters(insertPs, paramInd, fieldValue); } insertPs.executeUpdate(); flushStatus(); } catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(duplicatePkPs); JDBCUtil.safeClose(insertPs); JDBCUtil.safeClose(con); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeUpdate(PreparedStatement ps) throws SQLException { ps.addBatch(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeBatch(PreparedStatement ps) throws SQLException { int[] updates = ps.executeBatch(); for(int i = 0; i < updates.length; ++i) { int status = updates[i]; if(status != 1 && status != -2 /* java.sql.Statement.SUCCESS_NO_INFO since jdk1.4*/) { String msg = (status == -3 /* java.sql.Statement.EXECUTE_FAILED since jdk1.4 */ ? "One of the commands in the batch failed to execute" : "Each command in the batch should update exactly 1 row but " + "one of the commands updated " + updates[i] + " rows."); throw new EJBException(msg); } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
public void executeUpdate(PreparedStatement ps) throws SQLException { int rows = ps.executeUpdate(); if(rows != 1) { throw new EJBException("Expected one updated row but got: " + rows); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PersistentContext.java
public void flush() throws SQLException, DuplicateKeyException { row.flush(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Object readRow(ResultSet rs, GenericEntityObjectFactory factory) throws SQLException { return field.loadArgumentResults(rs, 1); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
public Object readRow(ResultSet rs, GenericEntityObjectFactory factory) throws SQLException { return function.readResult(rs); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected PreparedStatement prepareStatement(Connection c, String sql, EntityEnterpriseContext ctx) throws SQLException { return c.prepareStatement(sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { return ps.executeUpdate(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
public void set(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { if(log.isTraceEnabled()) { log.trace("param: " + "i=" + index + ", " + "type=" + JDBCUtil.getJDBCTypeName(jdbcType) + ", " + "value=" + ((value == null) ? "NULL" : value)); } if(value == null) { ps.setNull(index, jdbcType); } else { value = JDBCUtil.coerceToSQLType(jdbcType, value); setNotNull(ps, index, jdbcType, value, log); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { String string = value.toString(); ps.setCharacterStream(index, new StringReader(string), string.length()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { byte[] bytes = JDBCUtil.convertObjectToByteArray(value); ps.setBytes(index, bytes); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { byte[] bytes = JDBCUtil.convertObjectToByteArray(value); ps.setBinaryStream(index, new ByteArrayInputStream(bytes), bytes.length); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { if(value instanceof BigDecimal) { ps.setBigDecimal(index, (BigDecimal)value); } else { ps.setObject(index, value, jdbcType, 0); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCParameterSetter.java
protected void setNotNull(PreparedStatement ps, int index, int jdbcType, Object value, Logger log) throws SQLException { ps.setObject(index, value, jdbcType); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static byte[] convertObjectToByteArray(Object value) throws SQLException { // Do we already have a byte array? if(value instanceof byte[]) { return (byte[])value; } ByteArrayOutputStream baos = null; ObjectOutputStream oos = null; try { // ejb-reference: store the handle if(value instanceof EJBObject) { value = ((EJBObject)value).getHandle(); } // Marshall the object using MashalledValue to handle classloaders value = new MarshalledValue(value); // return the serialize the value baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(value); return baos.toByteArray(); } catch(RemoteException e) { throw new SQLException("Cannot get Handle of EJBObject: " + e); } catch(IOException e) { throw new SQLException("Can't serialize binary object: " + e); } finally { safeClose(oos); safeClose(baos); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object convertToObject(byte[] input) throws SQLException { ByteArrayInputStream bais = new ByteArrayInputStream(input); try { return convertToObject(bais); } finally { safeClose(bais); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object convertToObject(InputStream input) throws SQLException { Object value = null; if(input != null) { ObjectInputStream ois = null; try { // deserialize result ois = new ObjectInputStream(input); value = ois.readObject(); // de-marshall value if possible if(value instanceof MarshalledValue) { value = ((MarshalledValue)value).get(); } else if(value instanceof MarshalledObject) { value = ((MarshalledObject)value).get(); } // ejb-reference: get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } finally { // ois will close the input stream it wraps safeClose(ois); } } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static String getLongString(ResultSet rs, int index) throws SQLException { String value; Reader textData = rs.getCharacterStream(index); if(textData != null) { try { // Use a modest buffer here to reduce function call overhead // when reading extremely large data. StringBuffer textBuffer = new StringBuffer(); char[] tmpBuffer = new char[1000]; int charsRead; while((charsRead = textData.read(tmpBuffer)) != -1) textBuffer.append(tmpBuffer, 0, charsRead); value = textBuffer.toString(); } catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); } finally { safeClose(textData); } } else value = null; return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static byte[] getByteArray(InputStream input) throws SQLException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { // Use a modest buffer here to reduce function call overhead // when reading extremely large data. byte[] tmpBuffer = new byte[1000]; int bytesRead; while((bytesRead = input.read(tmpBuffer)) != -1) baos.write(tmpBuffer, 0, bytesRead); return baos.toByteArray(); } catch(java.io.IOException ioException) { throw new SQLException(ioException.getMessage()); } finally { safeClose(baos); safeClose(input); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object getParameter(Logger log, CallableStatement cs, int index, int jdbcType, Class destination) throws SQLException { Object value = null; switch(jdbcType) { // // Large types // case Types.CLOB: case Types.LONGVARCHAR: case Types.BLOB: case Types.LONGVARBINARY: throw new UnsupportedOperationException(); // // Small binary types // case Types.BINARY: case Types.VARBINARY: { byte[] bytes = cs.getBytes(index); if(!cs.wasNull()) { if(destination == byte[].class) value = bytes; else value = convertToObject(bytes); } if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Binary, value=" + value); } } break; // // Specialist types that the // driver should handle // case Types.JAVA_OBJECT: case Types.STRUCT: case Types.ARRAY: case Types.OTHER: { value = cs.getObject(index); if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Object, value=" + value); } } break; // // Non-binary types // default: Method method = (Method)csTypes.get(destination.getName()); if(method != null) { try { value = method.invoke(cs, new Object[]{new Integer(index)}); if(cs.wasNull()) { value = null; } if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Simple, value=" + value); } } catch(IllegalAccessException e) { // Whatever, I guess non-binary will not work for this field. } catch(InvocationTargetException e) { // Whatever, I guess non-binary will not work for this field. } } else { value = cs.getObject(index); if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Object, value=" + value); } } } return coerceToJavaType(value, destination); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
private static Object coerceToJavaType( Object value, Class destination) throws SQLException { try { // // null // if(value == null) { return null; } // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // // Primitive wrapper classes // // We have a primitive wrapper and we want a real primitive // just return the wrapper and the vm will convert it at the proxy if(destination.isPrimitive()) { if(value == null) throw new IllegalStateException("Loaded NULL value for a field of a primitive type."); if((destination.equals(Byte.TYPE) && value instanceof Byte) || (destination.equals(Short.TYPE) && value instanceof Short) || (destination.equals(Character.TYPE) && value instanceof Character) || (destination.equals(Boolean.TYPE) && value instanceof Boolean) || (destination.equals(Integer.TYPE) && value instanceof Integer) || (destination.equals(Long.TYPE) && value instanceof Long) || (destination.equals(Float.TYPE) && value instanceof Float) || (destination.equals(Double.TYPE) && value instanceof Double) ) { return value; } } // // java.util.Date // // make new copy as sub types have problems in comparions if(destination == java.util.Date.class && value instanceof java.util.Date) { // handle timestamp special becauses it hoses the milisecond values if(value instanceof java.sql.Timestamp) { java.sql.Timestamp ts = (java.sql.Timestamp)value; // Timestamp returns whole seconds from getTime and partial // seconds are retrieved from getNanos() // Adrian Brock: Not in 1.4 it doesn't long temp = ts.getTime(); if(temp % 1000 == 0) temp += ts.getNanos() / 1000000; return new java.util.Date(temp); } else { return new java.util.Date(((java.util.Date)value).getTime()); } } // // java.sql.Time // // make a new copy object; you never know what a driver will return if(destination == java.sql.Time.class && value instanceof java.sql.Time) { return new java.sql.Time(((java.sql.Time)value).getTime()); } // // java.sql.Date // // make a new copy object; you never know what a driver will return if(destination == java.sql.Date.class && value instanceof java.sql.Date) { return new java.sql.Date(((java.sql.Date)value).getTime()); } // // java.sql.Timestamp // // make a new copy object; you never know what a driver will return if(destination == java.sql.Timestamp.class && value instanceof java.sql.Timestamp) { // make a new Timestamp object; you never know // what a driver will return java.sql.Timestamp orignal = (java.sql.Timestamp)value; java.sql.Timestamp copy = new java.sql.Timestamp(orignal.getTime()); copy.setNanos(orignal.getNanos()); return copy; } // // java.lang.String --> java.lang.Character or char // // just grab first character if(value instanceof String && (destination == Character.class || destination == Character.TYPE)) { return new Character(((String)value).charAt(0)); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do throw new SQLException("Got a " + value.getClass().getName() + "[cl=" + System.identityHashCode(value.getClass().getClassLoader()) + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + System.identityHashCode(destination) + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public InputStream getBinaryStream() throws SQLException { return new ByteArrayInputStream(mBytes); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public byte[] getBytes(long pos, int length) throws SQLException { // Defensive code, parameter checks. if (length < 0 || length > mBytes.length || pos > mBytes.length) { return new byte[0]; } if (pos <= 0) { pos = 1; // One since the copy starts at pos. } byte[] buffer = new byte[length]; System.arraycopy(mBytes, (int)pos - 1, buffer, 0, length); return buffer; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public long length() throws SQLException { return mBytes.length; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public long position(Blob pattern , long start) throws SQLException { return position(pattern.getBytes(0, (int)pattern.length()), start); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public long position(byte pattern[], long start) throws SQLException { // Small optimization, no need to look beyond this. int max = mBytes.length - pattern.length; if (start < 0) { start = 0; // Cannot start negative, so put it at the beginning. } else if (start >= mBytes.length) { return -1; // Out of bounds, start was past the end of the buffer. } if (pattern.length == 0) { return -1; // Indicate that the pattern was not found. } byte first = pattern[0]; int i = (int)start; while (true) { // Look for the first character. while (i <= max && mBytes[i] != first) { i++; } if (i > max) { return -1; // Went to far, reject the pattern. } // Found the first character, now look for remainder of v2. int j = i + 1; int end = j + pattern.length - 1; int k = 1; boolean cont = true; // While the bytes remain equal and the end of v1 is not reached // continue the either rejecting this match, or accepting it. while (cont && j < end) { if (mBytes[j++] != pattern[k++]) { i++; cont = false; } } // If cont == false then the pattern was found. if (cont) { return i; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public void free() throws SQLException { }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public InputStream getBinaryStream(long pos, long length) throws SQLException { throw new UnsupportedOperationException("Unimplemented JDK6 method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public OutputStream setBinaryStream(long pos) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public int setBytes(long pos, byte[] bytes) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public int setBytes(long pos, byte[] bytes, int offset, int length) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public void truncate(long length) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCIdentityColumnCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); Connection c; Statement s = null; ResultSet rs = null; try { c = ps.getConnection(); s = c.createStatement(); rs = s.executeQuery(pkSQL); if (!rs.next()) { throw new EJBException("ResultSet was empty"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated key", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Clob clob = rs.getClob(index); String content; if(clob == null) { content = null; } else { final Reader reader = clob.getCharacterStream(); if(reader != null) { int intLength = (int)clob.length(); char[] chars; try { if(intLength <= 8192) { chars = new char[intLength]; reader.read(chars); content = String.valueOf(chars); } else { StringBuffer buf = new StringBuffer(intLength); chars = new char[8192]; int i = reader.read(chars); while(i > 0) { buf.append(chars, 0, i); i = reader.read(chars); } content = buf.toString(); } } catch(IOException e) { throw new SQLException("Failed to read CLOB character stream: " + e.getMessage()); } finally { JDBCUtil.safeClose(reader); } } else { content = null; } } return content; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return JDBCUtil.getLongString(rs, index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Object value = null; byte[] bytes = rs.getBytes(index); if(!rs.wasNull()) { if(destination == byte[].class) value = bytes; else value = JDBCUtil.convertToObject(bytes); } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Object value = null; byte[] bytes = rs.getBytes(index); if(!rs.wasNull()) { if(destination == byte[].class) value = bytes; else value = JDBCUtil.convertToObject(bytes); } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Blob blob = rs.getBlob(index); Object value; if(blob == null) { value = null; } else { InputStream binaryData = blob.getBinaryStream(); if(binaryData != null) { if(destination == byte[].class) value = JDBCUtil.getByteArray(binaryData); else value = JDBCUtil.convertToObject(binaryData); } else { value = null; } } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { Object value = null; InputStream binaryData = rs.getBinaryStream(index); if(binaryData != null && !rs.wasNull()) { if(destination == byte[].class) value = JDBCUtil.getByteArray(binaryData); else value = JDBCUtil.convertToObject(binaryData); } return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getTimestamp(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getDate(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getTime(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getTimestamp(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getBigDecimal(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getRef(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getBytes(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getObject(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { final String result = rs.getString(index); if(log.isTraceEnabled()) { log.trace("result: i=" + index + ", type=" + destination.getName() + ", value=" + result); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { Object result = readResult(rs, index, destination); if(rs.wasNull()) result = null; else result = coerceToJavaType(result, destination); if(log.isTraceEnabled()) { log.trace("result: i=" + index + ", type=" + destination.getName() + ", value=" + result); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object coerceToJavaType(Object value, Class destination) throws SQLException { return value; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return (rs.getBoolean(index) ? Boolean.TRUE : Boolean.FALSE); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Byte(rs.getByte(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return rs.getString(index); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Short(rs.getShort(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Integer(rs.getInt(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Long(rs.getLong(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Float(rs.getFloat(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object readResult(ResultSet rs, int index, Class destination) throws SQLException { return new Double(rs.getDouble(index)); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
public Object get(ResultSet rs, int index, Class destination, Logger log) throws SQLException { Object result = readResult(rs, index, destination); if(result != null) result = coerceToJavaType(result, destination); if(log.isTraceEnabled()) { log.trace("result: i=" + index + ", type=" + destination.getName() + ", value=" + result); } return result; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCResultSetReader.java
protected Object coerceToJavaType(Object value, Class destination) throws SQLException { try { // // java.rmi.MarshalledObject // // get unmarshalled value if(value instanceof MarshalledObject && !destination.equals(MarshalledObject.class)) { value = ((MarshalledObject)value).get(); } // // javax.ejb.Handle // // get the object back from the handle if(value instanceof Handle) { value = ((Handle)value).getEJBObject(); } // Did we get the desired result? if(destination.isAssignableFrom(value.getClass())) { return value; } if(destination == java.math.BigInteger.class && value.getClass() == java.math.BigDecimal.class) { return ((java.math.BigDecimal)value).toBigInteger(); } // oops got the wrong type - nothing we can do String className = null; Object interfaces = null; ClassLoader cl = null; if (value != null) { Class valueClass = value.getClass(); className = valueClass.getName(); interfaces = Arrays.asList(valueClass.getInterfaces()); cl = valueClass.getClassLoader(); } throw new SQLException("Got a " + className + "[cl=" + cl + " + interfaces=" + interfaces + ", value=" + value + "] while looking for a " + destination.getName() + "[cl=" + destination.getClassLoader() + "]"); } catch(RemoteException e) { throw new SQLException("Unable to load EJBObject back from Handle: " + e); } catch(IOException e) { throw new SQLException("Unable to load to deserialize result: " + e); } catch(ClassNotFoundException e) { throw new SQLException("Unable to load to deserialize result: " + e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCSQLServerCreateCommand.java
protected int executeInsert(int index, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { ps.execute(); ResultSet rs = null; try { int rows = ps.getUpdateCount(); if(rows != 1) { throw new EJBException("Expected updateCount of 1, got " + rows); } if(ps.getMoreResults() == false) { throw new EJBException("Expected ResultSet but got an updateCount. Is NOCOUNT set for all triggers?"); } rs = ps.getResultSet(); if(!rs.next()) { throw new EJBException("ResultSet was empty"); } pkField.loadInstanceResults(rs, 1, ctx); return rows; } catch(RuntimeException e) { throw e; } catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCInformixCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); // remove any JCA wrappers Statement stmt = ps; do { try { Object[] args = {}; stmt = (Statement) getUnderlyingStatement.invoke(stmt, args); } catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } } while (stmt != null && method.getDeclaringClass().isInstance(stmt) == false); try { Number pk = (Number)method.invoke(stmt, null); pkField.setInstanceValue(ctx, pk); return rows; } catch(RuntimeException e) { throw e; } catch(Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
protected PreparedStatement prepareStatement(Connection c, String sql, EntityEnterpriseContext ctx) throws SQLException { try { return (PreparedStatement) CONNECTION_PREPARE.invoke(c, new Object[] { sql, GENERATE_KEYS }); } catch (Exception e) { throw processException(e); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBC30GeneratedKeysCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); ResultSet rs = null; try { rs = (ResultSet) GET_GENERATED_KEYS.invoke(ps, null); if (!rs.next()) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("getGeneratedKeys returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCMySQLCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); // remove any JCA wrappers Statement stmt = ps; do { try { Object[] args = {}; stmt = (Statement) getUnderlyingStatement.invoke(stmt, args); } catch (IllegalAccessException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } catch (InvocationTargetException e) { SQLException ex = new SQLException("Failed to invoke getUnderlyingStatement"); ex.initCause(e); throw ex; } } while (stmt != null && method.getDeclaringClass().isInstance(stmt) == false); ResultSet rs = null; try { rs = (ResultSet) method.invoke(stmt, null); if (!rs.next()) { throw new EJBException("getGeneratedKeys returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCDB2IdentityValLocalCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx ) throws SQLException { int rows = ps.executeUpdate(); ResultSet results = null; try { Connection conn = ps.getConnection(); results = conn.prepareStatement( SQL ).executeQuery(); if( !results.next() ) { throw new EJBException( "identity_val_local() returned an empty ResultSet" ); } pkField.loadInstanceResults( results, 1, ctx ); } catch( RuntimeException e ) { throw e; } catch( Exception e ) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException( "Error extracting identity_val_local()", e ); } finally { JDBCUtil.safeClose( results ); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPostgreSQLCreateCommand.java
protected int executeInsert(int index, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { int rows = ps.executeUpdate(); Statement s = null; ResultSet rs = null; try { if (trace) { log.trace("Executing SQL :"+sequenceSQL); } Connection c = ps.getConnection(); s = c.createStatement(); rs = s.executeQuery(sequenceSQL); if (!rs.next()) { throw new EJBException("sequence sql returned an empty ResultSet"); } pkField.loadInstanceResults(rs, 1, ctx); } catch (RuntimeException e) { throw e; } catch (Exception e) { // throw EJBException to force a rollback as the row has been inserted throw new EJBException("Error extracting generated keys", e); } finally { JDBCUtil.safeClose(rs); JDBCUtil.safeClose(s); } return rows; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
protected PreparedStatement prepareStatement(Connection c, String sql, EntityEnterpriseContext ctx) throws SQLException { return c.prepareCall(sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleCreateCommand.java
protected int executeInsert(int paramIndex, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { CallableStatement cs = (CallableStatement) ps; cs.registerOutParameter(paramIndex, jdbcType); cs.execute(); Object pk = JDBCUtil.getParameter(log, cs, paramIndex, jdbcType, pkField.getFieldType()); pkField.setInstanceValue(ctx, pk); return 1; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
protected PreparedStatement prepareStatement(Connection c, String sql, EntityEnterpriseContext ctx) throws SQLException { return c.prepareCall(sql); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCOracleSequenceCreateCommand.java
protected int executeInsert(int paramInd, PreparedStatement ps, EntityEnterpriseContext ctx) throws SQLException { CallableStatement cs = (CallableStatement) ps; cs.registerOutParameter(pkIndex, jdbcType); cs.execute(); Object pk = JDBCUtil.getParameter(log, cs, pkIndex, jdbcType, pkField.getFieldType()); pkField.setInstanceValue(ctx, pk); return 1; }
45
            
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (SQLException e) { throw e; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { RuntimeException ex = new IllegalStateException("Unable to persist timer"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to delete timer", e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to get timer handles for containerId: " + containerId, e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to get timer handles", e); }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { log.warn("Unable to clear timers", e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to update: table=" + tableName, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(SQLException e) { throw new EJBException("Failed to read ResultSet.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCStopCommand.java
catch(SQLException e) { log.debug("Error getting database metadata for DROP TABLE command. " + " DROP TABLE will not be executed. ", e); return true; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); }
44
            
// in src/main/java/org/jboss/ejb/txtimer/GeneralPurposeDatabasePersistencePlugin.java
catch (SQLException e) { throw e; }
// in src/main/java/org/jboss/ejb/txtimer/DatabasePersistencePolicy.java
catch (SQLException e) { RuntimeException ex = new IllegalStateException("Unable to persist timer"); ex.initCause(e); throw ex; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/PkSqlCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/RelationTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to delete instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to update instances: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SQLException e) { throw new EJBException("Failed to create many-to-many relationships: " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to load row: table=" + tableName + ", pk=" + id); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to delete view: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to update: table=" + tableName, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { log.error("Failed to insert new rows: " + e.getMessage(), e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/EntityTable.java
catch(SQLException e) { throw new EJBException("Failed to load field " + entity.getEntityName() + "." + field.getFieldName() + ": " + e.getMessage(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/AbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); //ejbe.initCause(sqle); only for JBoss 4 and + throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
catch(SQLException e) { log.error("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); throw new EJBException("Failed to load related role: ejb-name=" + entity.getEntityName() + ", cmr-field=" + getFieldName() + ": " + e.getMessage(), e ); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/ApplicationPkCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { log.error("Failed to execute pk sql. error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState(), e); throw new CreateException("Failed to execute pk sql: " + e.getMessage() + ", error code: " + e.getErrorCode() + ", sql state: " + e.getSQLState()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/keygen/AbstractCreateCommand.java
catch(SQLException e) { if("23000".equals(e.getSQLState())) { throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); } else { throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractCreateCommand.java
catch(SQLException e) { if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e)) { log.error("Failed to create instance.", e); throw new CreateException( "Integrity constraint violation. Possibly unique key violation or invalid foreign key value." ); } else { log.error("Could not create entity", e); CreateException ce = new CreateException("Could not create entity: " + e); ce.initCause(e); throw ce; } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCInsertPKCreateCommand.java
catch(SQLException e) { log.error("Error checking if entity exists", e); throw new CreateException("Error checking if entity exists:" + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch (SQLException sqle) { javax.ejb.EJBException ejbe = new javax.ejb.EJBException("Could not get a connection; " + sqle); ejbe.initCause(sqle); throw ejbe; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCAbstractQueryCommand.java
catch(SQLException e) { throw new EJBException("Failed to read ResultSet.", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while fixing table name", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while checking if table aleady exists "+tableName, e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch (SQLException e) { // This should not happen. A J2EE compatiable JDBC driver is // required fully support metadata. throw new DeploymentException("Error while geting column names", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
catch(SQLException e) { throw new DeploymentException("Failed to get datasource connection"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error setting parameters for field " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMPFieldBridge.java
catch(SQLException e) { // Non recoverable internal exception throw new EJBException("Internal error getting results " + "for field member " + getFieldName(), e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/keygen/JDBCPkSqlCreateCommand.java
catch(SQLException e) { log.error("Error fetching the next primary key value", e); throw new CreateException("Error fetching the next primary key value:" + e); }
1
unknown (Lib) SecurityException 7
            
// in src/main/java/org/jboss/jmx/connector/invoker/RolesAuthorization.java
public void authorize(Principal caller, Subject subject, String objectname, String opname) { Set groups = subject.getPrincipals(Group.class); Group roles = null; Iterator iter = groups.iterator(); while( iter.hasNext() ) { Group grp = (Group) iter.next(); if( grp.getName().equals("Roles") ) { roles = grp; break; } } if( roles == null ) { throw new SecurityException("Subject has no Roles"); } iter = requiredRoles.iterator(); boolean hasRole = false; while( iter.hasNext() && hasRole == false ) { Principal p = (Principal) iter.next(); hasRole = roles.isMember(p); } if( hasRole == false ) { throw new SecurityException("Authorization failure, requiredRoles="+requiredRoles +", callerRoles="+roles); } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
private void checkAuthorization(Principal caller, String objname, String opname) throws Exception { // Get the active Subject Subject subject = SecurityActions.getActiveSubject(); if( subject == null ) throw new SecurityException("No active Subject found, add th AuthenticationInterceptor"); //We will try to use the authorizing class try { Object[] args = {caller, subject, objname, opname}; authorize.invoke(authenticator, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthenticationInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { SecurityContext previousSC = null; String type = invocation.getType(); Subject subject = null; if (!initialized) initialize(); if (type == Invocation.OP_INVOKE && securityMgr != null) { String opName = invocation.getName(); if (opName.equals("invoke")) { Object[] args = invocation.getArgs(); org.jboss.invocation.Invocation inv = (org.jboss.invocation.Invocation) args[0]; // Authenticate the caller based on the security association Principal caller = inv.getPrincipal(); Object credential = inv.getCredential(); subject = new Subject(); boolean isValid = securityMgr.isValid(caller, credential, subject); if (isValid == false) { String msg = "Failed to authenticate principal=" + caller + ", securityDomain=" + securityMgr.getSecurityDomain(); throw new SecurityException(msg); } String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if (securityMgr != null) securityDomain = securityMgr.getSecurityDomain(); // store current security context previousSC = SecurityActions.getSecurityContext(); SecurityContext sc = SecurityActions.createSecurityContext(securityDomain); SecurityActions.setSecurityContext(sc); // Push the caller security context SecurityActions.pushSubjectContext(caller, credential, subject); } } try { Interceptor i = invocation.nextInterceptor(); return i.invoke(invocation); } finally { // restore previous security context if (subject != null) SecurityActions.setSecurityContext(previousSC); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityInterceptor.java
private void checkSecurityContext(Invocation mi, RunAs callerRunAsIdentity) throws Exception { Principal principal = mi.getPrincipal(); Object credential = mi.getCredential(); boolean trace = log.isTraceEnabled(); // If there is not a security manager then there is no authentication required Method m = mi.getMethod(); boolean containerMethod = m == null || m.equals(ejbTimeout); if (containerMethod == true || securityManager == null || container == null) { // Allow for the propagation of caller info to other beans SecurityActions.pushSubjectContext(principal, credential, null); return; } if (realmMapping == null) { throw new SecurityException("Role mapping manager has not been set"); } SecurityContext sc = SecurityActions.getSecurityContext(); EJBAuthenticationHelper helper = SecurityHelperFactory.getEJBAuthenticationHelper(sc); boolean isTrusted = containsTrustableRunAs(sc) || helper.isTrusted(); if (!isTrusted) { // Check the security info from the method invocation Subject subject = new Subject(); if (SecurityActions.isValid(helper, subject, m.getName()) == false) { // Notify authentication observer if (authenticationObserver != null) authenticationObserver.authenticationFailed(); // Else throw a generic SecurityException String msg = "Authentication exception, principal=" + principal; throw new SecurityException(msg); } else { SecurityActions.pushSubjectContext(principal, credential, subject); if (trace) { log.trace("Authenticated principal=" + principal + " in security domain=" + sc.getSecurityDomain()); } } } else { // Duplicate the current subject context on the stack since //SecurityActions.dupSubjectContext(); SecurityActions.pushRunAsIdentity(callerRunAsIdentity); } Method ejbMethod = mi.getMethod(); // Ignore internal container calls if (ejbMethod == null) return; // Get the caller Subject caller = SecurityActions.getContextSubject(); if (caller == null) throw new IllegalStateException("Authenticated User. But caller subject is null"); //Establish the deployment rolename-principalset custom mapping(if available) SecurityRolesAssociation.setSecurityRoles(this.deploymentRoles); boolean isAuthorized = false; Set<Principal> methodRoles = container.getMethodPermissions(ejbMethod, mi.getType()); SecurityContext currentSC = SecurityActions.getSecurityContext(); if (SecurityActions.getSecurityManagement(currentSC) == null) SecurityActions.setSecurityManagement(currentSC, securityManagement); AbstractEJBAuthorizationHelper authorizationHelper = SecurityHelperFactory.getEJBAuthorizationHelper(sc); authorizationHelper.setPolicyRegistration(container.getPolicyRegistration()); isAuthorized = SecurityActions.authorize(authorizationHelper, ejbName, ejbMethod, mi.getPrincipal(), mi.getType().toInterfaceString(), ejbCS, caller, callerRunAsIdentity, container.getJaccContextID(), new SimpleRoleGroup(methodRoles)); if (!isAuthorized) { String msg = "Denied: caller with subject=" + caller + " and security context post-mapping roles=" + SecurityActions.getRolesFromSecurityContext(currentSC) + ": ejbMethod=" + ejbMethod; throw new SecurityException(msg); } }
0 8
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void rollback() throws SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.rollback(" + tpc + ")"); } try { getSession().rollback(tpc); } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx commit: " + tx); int status = tm.getStatus(); tm.commit(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx rollback: " + tx); tm.rollback(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
8
            
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(SecurityException e) { throw e; }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
catch (SecurityException e) { return null; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.SecurityException ex) { finished = false; throw ex; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/corba/ORBFactory.java
catch (SecurityException ignored) { log.trace("Unable to retrieve system properties", ignored); properties = null; }
6
            
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SecurityException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
catch (java.lang.SecurityException ex) { finished = false; throw ex; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; }
// in src/main/java/org/jboss/ejb/plugins/SecurityProxyInterceptor.java
catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; }
0
unknown (Lib) ServerException 6
            
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { // We are going to go through a Remote invocation, switch to a Marshalled Invocation MarshalledInvocation mi = new MarshalledInvocation(invocation); if( externalURL == null ) externalURL = Util.resolveURL(externalURLValue); try { Object value = Util.invoke(externalURL, mi); return value; } catch (InvocationException e) { // Unwrap the invoker servlet InvocationExceptions Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else if (t instanceof Error) throw (Error) t; throw new InvocationTargetException(t); } catch (IOException e) { throw new ServerException("IOE", e); } }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public Object invoke(Invocation invocation) throws Exception { Object response = null; // Earlier versions of InvokerLocator don't have a findSerializationType() method. try { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE",locator.findSerializationType()); } catch (NoSuchMethodError e) { invocation.getInvocationContext().setValue("SERIALIZATION_TYPE", "java"); } try { response = client.invoke(invocation, null); if(response instanceof Exception) { throw ((Exception) response); } if(response instanceof MarshalledObject) { return ((MarshalledObject) response).get(); } if (response instanceof IMarshalledValue) { return ((IMarshalledValue)response).get(); } return response; } catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } } catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); } }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
public EJBObject getEJBObject() throws ServerException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); Class type = home.getClass(); Method method = type.getMethod("create", new Class[0]); return (EJBObject) method.invoke(home, new Object[0]); } catch (Exception e) { throw new ServerException("Could not get EJBObject", e); } }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
public EJBHome getEJBHome() throws RemoteException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); return home; } catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); } }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
public EJBObject getEJBObject() throws RemoteException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); Class type = home.getClass(); Method method = type.getMethod("findByPrimaryKey", new Class[]{home.getEJBMetaData().getPrimaryKeyClass()}); // call findByPrimary on the target return (EJBObject) method.invoke(home, new Object[]{id}); } catch (Exception e) { throw new ServerException("Could not get EJBObject", e); } }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
protected void bindProxy() throws Exception { try { // Create a stack from the description (in the future) for now we hardcode it InvocationContext context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); // The behavior for home proxying should be isolated in an interceptor FIXME context.setInvoker(homeInvoker); context.setValue(InvocationKey.EJB_METADATA, ejbMetaData); context.setInvokerProxyBinding(invokerMetaData.getName()); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } ClientContainer client = null; EJBProxyFactoryContainer pfc = (EJBProxyFactoryContainer) container; Class[] ifaces = {pfc.getHomeClass(), Class.forName("javax.ejb.Handle")}; if( includeIClientIface ) { ifaces = new Class[] {IClientContainer.class, pfc.getHomeClass(), Class.forName("javax.ejb.Handle")}; client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } loadInterceptorChain(homeInterceptorClasses, client); // Create the EJBHome this.home = (EJBHome) Proxy.newProxyInstance( // Class loader pointing to the right classes from deployment pfc.getHomeClass().getClassLoader(), // The classes we want to implement home and handle ifaces, // The home proxy as invocation handler client); // Create stateless session object // Same instance is used for all objects if(ejbMetaData.isStatelessSession() == true) { // Create a stack from the description (in the future) for now we hardcode it context = new InvocationContext(); context.setObjectName(jmxNameHashInteger); context.setValue(InvocationKey.JNDI_NAME, jndiBinding); // The behavior for home proxying should be isolated in an interceptor FIXME context.setInvoker(beanInvoker); context.setInvokerProxyBinding(invokerMetaData.getName()); context.setValue(InvocationKey.EJB_HOME, home); if(container.getSecurityManager() != null) { String secDomain = container.getSecurityManager().getSecurityDomain(); context.setValue(InvocationKey.SECURITY_DOMAIN, secDomain); } Class[] ssifaces = {pfc.getRemoteClass()}; if( includeIClientIface ) { ssifaces = new Class[] {IClientContainer.class, pfc.getRemoteClass()}; client = new ClientContainerEx(context); } else { client = new ClientContainer(context); } loadInterceptorChain(beanInterceptorClasses, client); this.statelessObject = (EJBObject)Proxy.newProxyInstance( // Correct CL pfc.getRemoteClass().getClassLoader(), // Interfaces ssifaces, // SLSB proxy as invocation handler client ); } else { // this is faster than newProxyInstance Class[] intfs = {pfc.getRemoteClass()}; if( this.includeIClientIface ) { intfs = new Class[]{IClientContainer.class, pfc.getRemoteClass()}; } Class proxyClass = Proxy.getProxyClass(pfc.getRemoteClass().getClassLoader(), intfs); final Class[] constructorParams = {InvocationHandler.class}; proxyClassConstructor = proxyClass.getConstructor(constructorParams); } // Bind the home in the JNDI naming space rebindHomeProxy(); } catch(Exception e) { throw new ServerException("Could not bind home", e); } }
6
            
// in src/main/java/org/jboss/invocation/http/interfaces/HttpInvokerProxy.java
catch (IOException e) { throw new ServerException("IOE", e); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(RemoteException aex) { // per Jira issue JBREM-61 if(strictRMIException) { throw new ServerException(aex.getMessage(), aex); } else { throw aex; } }
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/HomeHandleImpl.java
catch (NamingException e) { throw new ServerException("Could not get EJBHome", e); }
// in src/main/java/org/jboss/proxy/ejb/handle/EntityHandleImpl.java
catch (Exception e) { throw new ServerException("Could not get EJBObject", e); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
catch(Exception e) { throw new ServerException("Could not bind home", e); }
1
            
// in src/main/java/org/jboss/proxy/ejb/handle/StatelessHandleImpl.java
public EJBObject getEJBObject() throws ServerException { try { InitialContext ic = null; if( jndiEnv != null ) ic = new InitialContext(jndiEnv); else ic = new InitialContext(); EJBHome home = (EJBHome) ic.lookup(jndiName); Class type = home.getClass(); Method method = type.getMethod("create", new Class[0]); return (EJBObject) method.invoke(home, new Object[0]); } catch (Exception e) { throw new ServerException("Could not get EJBObject", e); } }
0 0 0
unknown (Domain) ServiceUnavailableException
public class ServiceUnavailableException extends RemoteException
{
   public ServiceUnavailableException()
   {
      super();
   }

   public ServiceUnavailableException(String s)
   {
      super(s);
   }

   public ServiceUnavailableException(String s, Throwable cause)
   {
      super(s, cause);
   }
}
0 0 0 1
            
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(ServiceUnavailableException e) { if( trace ) log.trace("Invocation failed", e); InvocationType type = invocation.getType(); if ((maxRetries > -1 && retryCount >= maxRetries) || reestablishInvokerProxy(ctx, type) == false) { throw e; } retryCount++; }
1
            
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(ServiceUnavailableException e) { if( trace ) log.trace("Invocation failed", e); InvocationType type = invocation.getType(); if ((maxRetries > -1 && retryCount >= maxRetries) || reestablishInvokerProxy(ctx, type) == false) { throw e; } retryCount++; }
0
unknown (Lib) StreamCorruptedException 1
            
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { int version = in.readInt(); // Read in and map the version of the serialized data seen switch(version) { case VERSION_5_0: locator = new InvokerLocator(in.readUTF()); strictRMIException = in.readBoolean(); init(locator); break; default: throw new StreamCorruptedException("Unknown version seen: " + version); } }
0 0 0 0 0
unknown (Lib) SystemException 12
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void begin() throws NotSupportedException, SystemException { if(getStatus() != Status.STATUS_NO_TRANSACTION) throw new NotSupportedException("Attempt to start a nested transaction (the transaction started previously hasn't been ended yet)."); ThreadInfo info = getThreadInfo(); trace = log.isTraceEnabled(); // Only check for trace enabled once per transaction if (trace) { log.trace("Calling UserTransaction.begin()"); } try { Object tpc = getSession().begin(info.getTimeout()); info.push(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void rollback() throws SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.rollback(" + tpc + ")"); } try { getSession().rollback(tpc); } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void setRollbackOnly() throws IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.setRollbackOnly(" + tpc + ")"); } try { getSession().setRollbackOnly(tpc); } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public int getStatus() throws SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (log.isTraceEnabled()) { log.trace("Calling UserTransaction.getStatus(" + tpc + ")"); } if (tpc == null) { return Status.STATUS_NO_TRANSACTION; } try { return getSession().getStatus(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
12
            
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); }
33
            
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
public Object getTransactionPropagationContext() throws SystemException { TransactionPropagationContextFactory tpcFactory = TransactionPropagationContextUtil.getTPCFactoryClientSide(); return (tpcFactory == null) ? null : tpcFactory.getTransactionPropagationContext(); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
public Object getTransactionPropagationContext() throws SystemException { TransactionPropagationContextFactory tpcFactory = TransactionPropagationContextUtil.getTPCFactoryClientSide(); return (tpcFactory == null) ? null : tpcFactory.getTransactionPropagationContext(); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void begin() throws NotSupportedException, SystemException { if(getStatus() != Status.STATUS_NO_TRANSACTION) throw new NotSupportedException("Attempt to start a nested transaction (the transaction started previously hasn't been ended yet)."); ThreadInfo info = getThreadInfo(); trace = log.isTraceEnabled(); // Only check for trace enabled once per transaction if (trace) { log.trace("Calling UserTransaction.begin()"); } try { Object tpc = getSession().begin(info.getTimeout()); info.push(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.commit(" + tpc + ")"); } try { getSession().commit(tpc); } catch (RollbackException e) { throw e; } catch (HeuristicMixedException e) { throw e; } catch (HeuristicRollbackException e) { throw e; } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void rollback() throws SecurityException, IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.rollback(" + tpc + ")"); } try { getSession().rollback(tpc); } catch (SecurityException e) { throw e; } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch(CannotConnectException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } finally { info.pop(); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void setRollbackOnly() throws IllegalStateException, SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (trace) { log.trace("Calling UserTransaction.setRollbackOnly(" + tpc + ")"); } try { getSession().setRollbackOnly(tpc); } catch (SystemException e) { throw e; } catch (IllegalStateException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public int getStatus() throws SystemException { ThreadInfo info = getThreadInfo(); Object tpc = info.getTpc(); if (log.isTraceEnabled()) { log.trace("Calling UserTransaction.getStatus(" + tpc + ")"); } if (tpc == null) { return Status.STATUS_NO_TRANSACTION; } try { return getSession().getStatus(tpc); } catch (SystemException e) { throw e; } catch (RemoteException e) { // destroy session gone bad. destroySession(); logCauseException(e); throw new SystemException(e.toString()); } catch (Exception e) { logCauseException(e); throw new SystemException(e.toString()); } }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
public void setTransactionTimeout(int seconds) throws SystemException { getThreadInfo().setTimeout(seconds); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public Object begin(int timeout) throws RemoteException, NotSupportedException, SystemException { TransactionManager tm = getTransactionManager(); // Set timeout value tm.setTransactionTimeout(timeout); // Start tx, and get its TPC. tm.begin(); Object tpc = getTPCFactory().getTransactionPropagationContext(); // Suspend thread association. Transaction tx = tm.suspend(); // Remember that a new tx is now active. activeTx.put(tpc, tx); // return the TPC return tpc; }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void commit(Object tpc) throws RemoteException, RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); boolean finished = true; try { tm.commit(); } catch (java.lang.SecurityException ex) { finished = false; throw ex; } catch (java.lang.IllegalStateException ex) { finished = false; throw ex; } finally { activeTx.remove(tpc); } }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void rollback(Object tpc) throws RemoteException, SecurityException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); // Resume thread association TransactionManager tm = getTransactionManager(); tm.resume(tx); tm.rollback(); activeTx.remove(tpc); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public void setRollbackOnly(Object tpc) throws RemoteException, IllegalStateException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) throw new IllegalStateException("No transaction."); tx.setRollbackOnly(); }
// in src/main/java/org/jboss/tm/usertx/server/UserTransactionSessionImpl.java
public int getStatus(Object tpc) throws RemoteException, SystemException { Transaction tx = (Transaction)activeTx.get(tpc); if (tx == null) return Status.STATUS_NO_TRANSACTION; return tx.getStatus(); }
// in src/main/java/org/jboss/ejb/TxEntityMap.java
public void associate(Transaction tx, EntityEnterpriseContext entity) throws RollbackException, SystemException { HashMap entityMap = (HashMap) m_map.get(tx); if(entityMap == null) { entityMap = new HashMap(); m_map.set(tx, entityMap); } //EntityContainer.getGlobalTxEntityMap().associate(tx, entity); entityMap.put(entity.getCacheKey(), entity); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public UserTransaction getUserTransaction() { AllowedOperationsAssociation.assertAllowedIn("getUserTransaction", IN_EJB_CREATE | IN_EJB_REMOVE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT | IN_SERVICE_ENDPOINT_METHOD); final UserTransaction ut = super.getUserTransaction(); return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); } public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); } public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); } public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); } public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); } }; }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void begin() throws NotSupportedException, SystemException { checkUserTransactionMethods(); ut.begin(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { checkUserTransactionMethods(); ut.commit(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { checkUserTransactionMethods(); ut.rollback(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void setRollbackOnly() throws IllegalStateException, SystemException { checkUserTransactionMethods(); ut.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public int getStatus() throws SystemException { checkUserTransactionMethods(); return ut.getStatus(); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public void setTransactionTimeout(int seconds) throws SystemException { checkUserTransactionMethods(); ut.setTransactionTimeout(seconds); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void begin() throws NotSupportedException, SystemException { TransactionManager tm = con.getTransactionManager(); int oldTimeout = -1; if (tm instanceof TransactionTimeoutConfiguration) oldTimeout = ((TransactionTimeoutConfiguration) tm).getTransactionTimeout(); // Set the timeout value tm.setTransactionTimeout(timeout); try { // Start the transaction tm.begin(); //notify checked out connections EJB2UserTransactionProvider.getSingleton().userTransactionStarted(); if (tsl != null) tsl.userTransactionStarted(); Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx begin: " + tx); // keep track of the transaction in enterprise context for BMT setTransaction(tx); } finally { // Reset the transaction timeout (if we know what it was) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx commit: " + tx); int status = tm.getStatus(); tm.commit(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void rollback() throws IllegalStateException, SecurityException, SystemException { TransactionManager tm = con.getTransactionManager(); try { Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx rollback: " + tx); tm.rollback(); } finally { // According to the spec, after commit and rollback was called on // UserTransaction, the thread is associated with no transaction. // Since the BMT Tx interceptor will associate and resume the tx // from the context with the thread that comes in // on a subsequent invocation, we must set the context transaction to null setTransaction(null); } }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void setRollbackOnly() throws IllegalStateException, SystemException { TransactionManager tm = con.getTransactionManager(); Transaction tx = tm.getTransaction(); if (trace) log.trace("UserTx setRollbackOnly: " + tx); tm.setRollbackOnly(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public int getStatus() throws SystemException { TransactionManager tm = con.getTransactionManager(); return tm.getStatus(); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public void setTransactionTimeout(int seconds) throws SystemException { timeout = seconds; }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private void endTransaction(final Invocation invocation, final Transaction tx, final Transaction oldTx, final int oldTimeout) throws TransactionRolledbackException, SystemException { // Assert the correct transaction association Transaction current = tm.getTransaction(); if ((tx == null && current != null) || tx.equals(current) == false) throw new IllegalStateException("Wrong transaction association: expected " + tx + " was " + current); try { // Marked rollback if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) { tx.rollback(); } else { // Commit tx // This will happen if // a) everything goes well // b) app. exception was thrown tx.commit(); } } catch (RollbackException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicMixedException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicRollbackException e) { throwJBossException(e, invocation.getType()); } catch (SystemException e) { throwJBossException(e, invocation.getType()); } catch (IllegalStateException e) { throwJBossException(e, invocation.getType()); } finally { // reassociate the oldTransaction with the Invocation (even null) invocation.setTransaction(oldTx); // Always drop thread association even if committing or // rolling back the newTransaction because not all TMs // will drop thread associations when commit() or rollback() // are called through tx itself (see JTA spec that seems to // indicate that thread assoc is required to be dropped only // when commit() and rollback() are called through TransactionManager // interface) //tx has committed, so we can't throw txRolledbackException. tm.suspend(); // Reset the transaction timeout (unless we didn't set it) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
private void registerTimer(Invocation invocation) throws RollbackException, SystemException { Timer timer = (Timer) invocation.getArguments()[0]; Transaction transaction = invocation.getTransaction(); if (transaction != null && timer instanceof Synchronization) transaction.registerSynchronization((Synchronization) timer); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
Transaction getTransaction() throws javax.transaction.SystemException { if(transactionManager == null) { return null; } return transactionManager.getTransaction(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
private Transaction getTransaction() throws SystemException { return tm.getTransaction(); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void scheduleSync(Transaction tx, EntityEnterpriseContext instance) throws SystemException, RollbackException { EntityContainer.getGlobalTxEntityMap().associate(tx, instance); instance.setTxAssociation(SYNC_SCHEDULED); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public GlobalTxSynchronization getGlobalSynchronization(Transaction tx) throws RollbackException, SystemException { GlobalTxSynchronization globalSync = (GlobalTxSynchronization) txSynch.get(tx); if(globalSync == null) { globalSync = new GlobalTxSynchronization(tx); txSynch.set(tx, globalSync); tx.registerSynchronization(globalSync); } return globalSync; }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
private void associate(Transaction tx, EntityEnterpriseContext entity) throws RollbackException, SystemException { GlobalTxSynchronization globalSync = getGlobalSynchronization(tx); //There should be only one thread associated with this tx at a time. //Therefore we should not need to synchronize on entityFifoList to ensure exclusive //access. entityFifoList is correct since it was obtained in a synch block. globalSync.associate(entity); }
25
            
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
catch (SystemException e) { return null; }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (SystemException e) { log.warn("failed to get tx manager status; ignoring", e); return true; }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
catch (SystemException e) { log.warn("failed to set rollback only; ignoring", e); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e) { throw new IllegalStateException("Failed to suspend current transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e1) { log.error("Failed to rollback.", e1); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (SystemException e) { throwJBossException(e, invocation.getType()); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); }
// in src/main/java/org/jboss/ejb/plugins/StatefulSessionInstanceCache.java
catch (SystemException e) { // SA FIXME: not sure what to do here return false; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error getting transaction from the transaction manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error while creating RelationSet", e); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (SystemException ex) { log.error("Failed to get status", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (SystemException ex) { log.error("Failed to suspend transaction", ex); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptorBMT.java
catch (SystemException ex) { log.error("Failed to get status", ex); }
15
            
// in src/main/java/org/jboss/invocation/unified/marshall/InvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/invocation/unified/marshall/HTTPInvocationMarshaller.java
catch(SystemException e) { log.error("Error setting transaction propagation context.", e); throw new IOException("Error setting transaction context. Message: " + e.getMessage()); }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (SystemException e) { throw e; }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SystemException e) { throw new IllegalStateException("Failed to suspend current transaction."); }
// in src/main/java/org/jboss/ejb/plugins/keygenerator/hilo/HiLoKeyGenerator.java
catch(SQLException e) { log.error("Failed to update table: " + e.getMessage(), e); try { tm.rollback(); } catch(SystemException e1) { log.error("Failed to rollback.", e1); } throw new IllegalStateException(e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/Schema.java
catch(SystemException e) { throw new IllegalStateException("Failed to register transaction synchronization: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/schema/CacheInvalidator.java
catch(SystemException e) { log.error("Failed to obtain the current transaction", e); throw new IllegalStateException("Failed to obtain the current transaction: " + e.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ReadAheadCache.java
catch(SystemException e) { throw new IllegalStateException("An error occured while getting the " + "transaction associated with the current thread: " + e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error getting transaction from the transaction manager", e); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
catch(SystemException e) { throw new EJBException("Error while creating RelationSet", e); }
6
checked (Lib) Throwable 0 0 47
            
// in src/main/java/org/jboss/invocation/http/interfaces/ClientMethodInterceptor.java
public Object invoke(Invocation mi) throws Throwable { Method m = mi.getMethod(); String methodName = m.getName(); HttpInvokerProxy proxy = (HttpInvokerProxy) mi.getInvocationContext().getInvoker(); // Implement local methods if( methodName.equals("toString") ) { return toString(proxy); } if( methodName.equals("equals") ) { Object[] args = mi.getArguments(); String thisString = toString(proxy); String argsString = args[0] == null ? "" : args[0].toString(); return new Boolean(thisString.equals(argsString)); } if( methodName.equals("hashCode") ) { return (Integer) mi.getObjectName(); } return getNext().invoke(mi); }
// in src/main/java/org/jboss/invocation/unified/server/UnifiedInvoker.java
public Object invoke(InvocationRequest invocationReq) throws Throwable { Invocation invocation = (Invocation) invocationReq.getParameter(); Thread currentThread = Thread.currentThread(); ClassLoader oldCl = currentThread.getContextClassLoader(); ObjectName mbean = null; try { mbean = (ObjectName) Registry.lookup(invocation.getObjectName()); // The cl on the thread should be set in another interceptor Object obj = getServer().invoke(mbean, "invoke", new Object[]{invocation}, Invocation.INVOKE_SIGNATURE); return new MarshalledObject(obj); } catch(Exception e) { Throwable th = JMXExceptionDecoder.decode(e); if(log.isTraceEnabled()) { log.trace("Failed to invoke on mbean: " + mbean, th); } if(th instanceof Exception) { e = (Exception) th; } throw e; } finally { currentThread.setContextClassLoader(oldCl); } }
// in src/main/java/org/jboss/client/ReflectionLauncher.java
public void launch(String clientClass, String clientName, String[] args) throws Throwable { try { System.setProperty(javaURLContextFactory.J2EE_CLIENT_NAME_PROP, clientName); // invoke the client class Class cl = Class.forName(clientClass); Method main = cl.getDeclaredMethod("main", new Class[]{String[].class}); Object[] mainArgs = {args}; if( Modifier.isStatic(main.getModifiers()) ) { main.invoke(null, mainArgs); } else { Object client = cl.newInstance(); main.invoke(client, mainArgs); } log.debug("Client invoker success."); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
// in src/main/java/org/jboss/jmx/adaptor/rmi/RMIRemoteMBeanProxy.java
public Object invoke (final Object proxy, final java.lang.reflect.Method method, final Object[] args) throws Throwable { String methodName = method.getName(); // Get attribute if (methodName.startsWith("get") && args == null) { String attrName = methodName.substring(3); return remoteServer.getAttribute(name, attrName); } // Is attribute else if (methodName.startsWith("is") && args == null) { String attrName = methodName.substring(2); return remoteServer.getAttribute(name, attrName); } // Set attribute else if (methodName.startsWith("set") && args != null && args.length == 1) { String attrName = methodName.substring(3); remoteServer.setAttribute(name, new javax.management.Attribute(attrName, args[0])); return null; } // Operation // convert the parameter types to strings for JMX Class[] types = method.getParameterTypes(); String[] sig = new String[types.length]; for (int i = 0; i < types.length; i++) { sig[i] = types[i].getName(); } // invoke the server and decode JMX exceptions return remoteServer.invoke(name, methodName, args == null ? EMPTY_ARGS : args, sig); }
// in src/main/java/org/jboss/jmx/connector/invoker/serializablepolicy/StripModelMBeanInfoPolicy.java
public Object filter(MarshalledInvocation input, Object result) throws Throwable { if ("getMBeanInfo".equals(input.getMethod().getName()) && (result instanceof ModelMBeanInfo)) { MBeanInfo info = (MBeanInfo)result; result = new MBeanInfo( info.getClassName(), info.getDescription(), deepCopy(info.getAttributes()), // Strip the Descriptors info.getConstructors(), info.getOperations(), info.getNotifications()); } return result; }
// in src/main/java/org/jboss/jmx/connector/invoker/client/InvokerAdaptorClientInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { // Retrieve any relevent object name for this invocation ObjectName objectName = getObjectNameFromArguments(invocation); if (objectName != null) invocation.setValue("JMX_OBJECT_NAME", objectName, PayloadKey.AS_IS); try { return getNext().invoke(invocation); } catch (InvokerAdaptorException e) { throw e.getWrapped(); } }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { // Invoke the next in the sequence Object result = invocation.nextInterceptor().invoke(invocation); // If the invocation was an 'invoke(MarshalledInvocation)' // filter the result using the plugable policy if ("invoke".equals(invocation.getName())) { Object[] args = invocation.getArgs(); if ((args.length == 1) && (args[0] instanceof MarshalledInvocation)) { MarshalledInvocation mi = (MarshalledInvocation) args[0]; result = policy.filter(mi, result); } } return result; }
// in src/main/java/org/jboss/jmx/connector/invoker/SerializableInterceptor.java
public Object filter(MarshalledInvocation input, Object result) throws Throwable { return result; }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { String type = invocation.getType(); if (type == Invocation.OP_INVOKE) { String opName = invocation.getName(); if (opName.equals("invoke")) { Object[] args = invocation.getArgs(); org.jboss.invocation.Invocation inv = (org.jboss.invocation.Invocation) args[0]; // Authenticate the caller based on the security association Principal caller = inv.getPrincipal(); //Get the Method Name Object[] obj = inv.getArguments(); //Ignore calls like MBeanCount or getMBeanInfo if(obj != null && obj.length > 1) { ObjectName objname = (ObjectName) obj[0]; String opname = (String) obj[1]; try { checkAuthorization(caller, objname.getCanonicalName(), opname); } catch(SecurityException e) { throw e; } catch(Exception e) { String msg = "Failed to authorize principal=" + caller + ",MBean=" + objname + ", Operation=" + opname; SecurityException ex = new SecurityException(msg); ex.initCause(e); throw ex; } } } } Interceptor i = invocation.nextInterceptor(); return i.invoke(invocation); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthenticationInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { SecurityContext previousSC = null; String type = invocation.getType(); Subject subject = null; if (!initialized) initialize(); if (type == Invocation.OP_INVOKE && securityMgr != null) { String opName = invocation.getName(); if (opName.equals("invoke")) { Object[] args = invocation.getArgs(); org.jboss.invocation.Invocation inv = (org.jboss.invocation.Invocation) args[0]; // Authenticate the caller based on the security association Principal caller = inv.getPrincipal(); Object credential = inv.getCredential(); subject = new Subject(); boolean isValid = securityMgr.isValid(caller, credential, subject); if (isValid == false) { String msg = "Failed to authenticate principal=" + caller + ", securityDomain=" + securityMgr.getSecurityDomain(); throw new SecurityException(msg); } String securityDomain = SecurityConstants.DEFAULT_APPLICATION_POLICY; if (securityMgr != null) securityDomain = securityMgr.getSecurityDomain(); // store current security context previousSC = SecurityActions.getSecurityContext(); SecurityContext sc = SecurityActions.createSecurityContext(securityDomain); SecurityActions.setSecurityContext(sc); // Push the caller security context SecurityActions.pushSubjectContext(caller, credential, subject); } } try { Interceptor i = invocation.nextInterceptor(); return i.invoke(invocation); } finally { // restore previous security context if (subject != null) SecurityActions.setSecurityContext(previousSC); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected void finalize() throws Throwable { close(); }
// in src/main/java/org/jboss/naming/client/java/javaURLContextFactory.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); if (methodName.equals("toString") == true) return "Client ENC(" + clientName + ")"; if (methodName.equals("lookup") == false) throw new OperationNotSupportedException("Only lookup is supported, op=" + method); NameParser parser = lookupCtx.getNameParser(""); Name name = null; if (args[0] instanceof String) name = parser.parse((String) args[0]); else name = (Name) args[0]; // Check for special objects not in the env if (name.size() < 2 || "java:comp".equals(name.get(0)) == false || "env".equals(name.get(1)) == false) return getSpecialObject(name); // Lookup the client application context from the server Context clientCtx = (Context) lookupCtx.lookup(clientName); // JBAS-3967: EJB3 Client container hack try { clientCtx = (Context) clientCtx.lookup("env"); } catch(NamingException e) { // ignore log.trace("No env sub context found", e); } // Strip the comp/env prefix Name bindingName = name.getSuffix(2); Object binding = clientCtx.lookup(bindingName); return binding; }
// in src/main/java/org/jboss/naming/ExternalContext.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object value = null; if( method.getName().equals("close") ) { // We just ignore the close method } else { try { value = method.invoke(externalCtx, args); } catch(InvocationTargetException e) { throw e.getTargetException(); } } return value; }
// in src/main/java/org/jboss/naming/interceptors/ProxyFactoryInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { Object value = invocation.nextInterceptor().invoke(invocation); if( value instanceof NamingContext ) { initNamingProxy(); NamingContext ctx = (NamingContext) value; ctx.setNaming(proxy); } return value; }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
public Object invoke(Invocation mi) throws Throwable { Object value = null; try { value = getNext().invoke(mi); } catch(NamingException e) { throw e; } catch(IOException e) { CommunicationException ce = new CommunicationException("Operation failed"); ce.setRootCause(e); throw ce; } catch(Throwable t) { ServiceUnavailableException sue = new ServiceUnavailableException("Unexpected failure"); sue.setRootCause(t); throw sue; } return value; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
protected void finalize() throws Throwable { if (trace) { log.trace("Tpc stack: finalize " + this); } try { while (!tpcStack.isEmpty()) { Object tpc = getTpc(); pop(); try { getSession().rollback(tpc); } catch (Exception ex) { // ignore } } } catch (Throwable t) { // ignore } super.finalize(); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { this.method = method; this.args = args; Object value; try { value = AccessController.doPrivileged(this); } catch(PrivilegedActionException e) { throw e.getException(); } return value; }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
public Object invoke(Invocation mi) throws Throwable { // Are we still useable? if (released.get()) throw new IllegalStateException("This message endpoint + " + getProxyString(mi) + " has been released"); // Concurrent invocation? synchronized (this) { Thread currentThread = Thread.currentThread(); if (inUseThread != null && inUseThread.equals(currentThread) == false) throw new IllegalStateException("This message endpoint + " + getProxyString(mi) + " is already in use by another thread " + inUseThread); inUseThread = currentThread; } String method = mi.getMethod().getName(); if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " in use by " + method + " " + inUseThread); // Which operation? if (method.equals("release")) { release(mi); return null; } else if (method.equals("beforeDelivery")) { before(mi); return null; } else if (method.equals("afterDelivery")) { after(mi); return null; } else return delivery(mi); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void release(Invocation mi) throws Throwable { // We are now released released.set(true); if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " released"); // Tidyup any outstanding delivery if (getOldClassLoader() != null) { try { finish("release", mi, false); } catch (Throwable t) { log.warn("Error in release ", t); } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void before(Invocation mi) throws Throwable { // Called out of sequence if (getBeforeDeliveryInvoke()) throw new IllegalStateException("Missing afterDelivery from the previous beforeDelivery for message endpoint " + getProxyString(mi)); // Set the classloader MessageDrivenContainer container = getContainer(mi); synchronized (this) { oldClassLoader = GetTCLAction.getContextClassLoader(inUseThread); SetTCLAction.setContextClassLoader(inUseThread, container.getClassLoader()); } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " set context classloader to " + container.getClassLoader()); // start any transaction try { startTransaction("beforeDelivery", mi, container); setBeforeDeliveryInvoke(true); } catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void after(Invocation mi) throws Throwable { // Called out of sequence if(!getBeforeDeliveryInvoke()) { throw new IllegalStateException("afterDelivery without a previous beforeDelivery for message endpoint " + getProxyString(mi)); } // Finish this delivery committing if we can try { finish("afterDelivery", mi, true); } catch (Throwable t) { throw new ResourceException(t); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected Object delivery(Invocation mi) throws Throwable { // Have we already delivered a message? if (delivered.get()) throw new IllegalStateException("Multiple message delivery between before and after delivery is not allowed for message endpoint " + getProxyString(mi)); if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivering"); // Mark delivery if beforeDelivery was invoked if (getOldClassLoader() != null) delivered.set(true); MessageDrivenContainer container = getContainer(mi); boolean commit = true; try { // Check for starting a transaction if (getOldClassLoader() == null) startTransaction("delivery", mi, container); return getNext().invoke(mi); } catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; } finally { // No before/after delivery, end any transaction and release the lock if (getOldClassLoader() == null) { try { // Finish any transaction we started endTransaction(mi, commit); } finally { releaseThreadLock(mi); } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void finish(String context, Invocation mi, boolean commit) throws Throwable { try { endTransaction(mi, commit); } finally { setBeforeDeliveryInvoke(false); // Reset delivered flag delivered.set(false); // Change back to the original context classloader resetContextClassLoader(mi); // We no longer hold the lock releaseThreadLock(mi); } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void startTransaction(String context, Invocation mi, MessageDrivenContainer container) throws Throwable { // Get any passed resource XAResource resource = (XAResource) mi.getInvocationContext().getValue(MESSAGE_ENDPOINT_XARESOURCE); Method method = null; // Normal delivery if ("delivery".equals(context)) method = mi.getMethod(); // Before delivery else method = (Method) mi.getArguments()[0]; // Is the delivery transacted? boolean isTransacted = getMessageEndpointFactory(mi).isDeliveryTransacted(method); if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " " + context + " method=" + method + " xaResource=" + resource + " transacted=" + isTransacted); // Get the transaction status TransactionManager tm = container.getTransactionManager(); Transaction tx = tm.suspend(); synchronized (this) { suspended = tx; } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " " + context + " currentTx=" + suspended); // Delivery is transacted if (isTransacted) { // No transaction means we start a new transaction and enlist the resource if (suspended == null) { tm.begin(); tx = tm.getTransaction(); synchronized (this) { transaction = tx; } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " started transaction=" + transaction); // Enlist the XAResource in the transaction if (resource != null) { transaction.enlistResource(resource); if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " enlisted=" + resource); } } else { // If there is already a transaction we ignore the XAResource (by spec 12.5.9) try { tm.resume(suspended); } finally { synchronized (this) { suspended = null; } if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " transaction=" + suspended + " already active, IGNORED=" + resource); } } } }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
protected void endTransaction(Invocation mi, boolean commit) throws Throwable { TransactionManager tm = null; Transaction currentTx = null; try { // If we started the transaction, commit it Transaction transaction = getTransaction(); if (transaction != null) { tm = getContainer(mi).getTransactionManager(); currentTx = tm.getTransaction(); // Suspend any bad transaction - there is bug somewhere, but we will try to tidy things up if (currentTx != null && currentTx.equals(transaction) == false) { log.warn("Current transaction " + currentTx + " is not the expected transaction."); tm.suspend(); tm.resume(transaction); } else { // We have the correct transaction currentTx = null; } // Commit or rollback depending on the status if (commit == false || transaction.getStatus() == Status.STATUS_MARKED_ROLLBACK) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " rollback"); tm.rollback(); } else { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " commit"); tm.commit(); } } // If we suspended the incoming transaction, resume it Transaction suspended = getSuspended(); if (suspended != null) { try { tm = getContainer(mi).getTransactionManager(); tm.resume(suspended); } finally { synchronized (this) { this.suspended = null; } } } } finally { synchronized (this) { transaction = null; } // Resume any suspended transaction if (currentTx != null) { try { tm.resume(currentTx); } catch (Throwable t) { log.warn("MessageEndpoint " + getProxyString(mi) + " failed to resume old transaction " + currentTx); } } } }
// in src/main/java/org/jboss/ejb/plugins/local/StatefulSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { if (args == null) args = EMPTY_ARGS; // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (m.equals(GET_PRIMARY_KEY)) { if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } Object retValue = super.invoke( proxy, m, args ); if (retValue == null) { // If not taken care of, go on and call the container retValue = factory.invoke(id, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/local/StatelessSessionProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { Object retValue = null; if (args == null) args = EMPTY_ARGS; // Implement local methods if (m.equals(TO_STRING)) { retValue = jndiName + ":Stateless"; } else if (m.equals(EQUALS)) { retValue = invoke(proxy, IS_IDENTICAL, args); } else if (m.equals(HASH_CODE)) { // We base the stateless hash on the hash of the proxy... // MF XXX: it could be that we want to return the hash of the name? retValue = new Integer(this.hashCode()); } else if (m.equals(GET_PRIMARY_KEY)) { // The object identifier of a session object is, in general, opaque to the client. // The result of getPrimaryKey() on a session EJBObject reference results in java.rmi.RemoteException. // The result of getPrimaryKey() on a session EJBLocalObject reference results in javax.ejb.EJBException. if (proxy instanceof EJBObject) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } if (proxy instanceof EJBLocalObject) { throw new EJBException("Call to getPrimaryKey not allowed on session bean"); } } else if (m.equals(GET_EJB_HOME)) { InitialContext ctx = new InitialContext(); return ctx.lookup(jndiName); } else if (m.equals(IS_IDENTICAL)) { // All stateless beans are identical within a home, // if the names are equal we are equal retValue = isIdentical(args[0], jndiName + ":Stateless"); } // If not taken care of, go on and call the container else { retValue = factory.invoke(jndiName, m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalHomeProxy.java
public Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { Object retValue = null; if (args == null) args = EMPTY_ARGS; // Implement local methods if (m.equals(TO_STRING)) { retValue = jndiName + "Home"; } else if (m.equals(EQUALS)) { // equality of the proxy home is based on names... Object temp = invoke(proxy, TO_STRING, args); retValue = new Boolean(temp.equals(jndiName + "Home")); } else if (m.equals(HASH_CODE)) { retValue = new Integer(this.hashCode()); } else if (m.equals(REMOVE_BY_PRIMARY_KEY)) { try { // The trick is simple we trick the container in believe it // is a remove() on the instance Object id = args[0]; retValue = factory.invoke(id, REMOVE_OBJECT, EMPTY_ARGS); } catch (Exception e) { RemoveException re = new RemoveException(e.getMessage()); re.initCause(e); throw re; } } // If not taken care of, go on and call the container else { retValue = factory.invokeHome(m, args); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/local/LocalProxy.java
public Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { Object id = getId(); Object retValue = null; // Implement local methods if (m.equals(TO_STRING)) { retValue = toStringImpl(); } else if (m.equals(EQUALS)) { retValue = invoke(proxy, IS_IDENTICAL, args ); } else if (m.equals(HASH_CODE)) { retValue = new Integer(id.hashCode()); } // Implement local EJB calls else if (m.equals(GET_PRIMARY_KEY)) { retValue = id; } else if (m.equals(GET_EJB_HOME)) { InitialContext ctx = new InitialContext(); return ctx.lookup(jndiName); } else if (m.equals(IS_IDENTICAL)) { retValue = isIdentical(args[0], toStringImpl()); } return retValue; }
// in src/main/java/org/jboss/ejb/plugins/local/EntityProxy.java
public final Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { if(removed) { throw new javax.ejb.NoSuchObjectLocalException("The instance has been removed: " + toStringImpl()); } if (args == null) args = EMPTY_ARGS; Object retValue = super.invoke( proxy, m, args ); if( retValue == null ) { // If not taken care of, go on and call the container retValue = factory.invoke(cacheKey, m, args); } if(m.equals(REMOVE)) { removed = true; } return retValue; }
// in src/main/java/org/jboss/Shutdown.java
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); Class[] sigTypes = method.getParameterTypes(); ArrayList sigStrings = new ArrayList(); for(int s = 0; s < sigTypes.length; s ++) sigStrings.add(sigTypes[s].getName()); String[] sig = new String[sigTypes.length]; sigStrings.toArray(sig); Object value = null; try { value = server.invoke(serverName, methodName, args, sig); } catch(UndeclaredThrowableException e) { System.out.println("getUndeclaredThrowable: "+e.getUndeclaredThrowable()); throw e.getUndeclaredThrowable(); } return value; }
// in src/main/java/org/jboss/proxy/compiler/Runtime.java
public Object invoke(InvocationHandler invocationHandler, int methodNum, Object values[]) throws Throwable { return invocationHandler.invoke(null, methods[methodNum], values); }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
ProxyInvocationHandler newInvocationHandler(final Object target) { if (proxyString == null) { String s = "InvocationHandler@" + targetTypes[0].getName(); for (int i = 1; i < targetTypes.length; i++) { s += "," + targetTypes[i].getName(); } proxyString = s; } return new ProxyInvocationHandler() { // (ISSUE: Should this be made subclassable?) public Object getTarget() { return target; } public Class[] getTargetTypes() { return copyTargetTypes(); } public String toString() { return proxyString + "[" + target + "]"; } public Object invoke(Object dummy, Method method, Object values[]) throws Throwable { return Impl.this.invoke(target, method, values); } }; }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
public Object invoke(Object dummy, Method method, Object values[]) throws Throwable { return Impl.this.invoke(target, method, values); }
// in src/main/java/org/jboss/proxy/compiler/Proxies.java
Object invoke(Object target, Member method, Object values[]) throws Throwable { // Note: // // We will not invoke the method unless we are expecting it. // Thus, we cannot blindly call Method.invoke, but must first // check our list of allowed methods. try { Method methods[] = this.methods; // cache // use fast pointer equality (it usually succeeds) for (int i = methods.length; --i >= 0; ) { if (methods[i] == method) { return methods[i].invoke(target, values); } } // special case: allow a null method to select the unique one if (method == null) { if (methods.length == 1) { return methods[0].invoke(target, values); } throw new IllegalArgumentException("non-unique method"); } // try the slower form of equality for (int i = methods.length; --i >= 0; ) { if (methods[i].equals(method)) { return methods[i].invoke(target, values); } } } catch (InvocationTargetException e) { throw e.getTargetException(); } throw new IllegalArgumentException("method unexpected "+method); }
// in src/main/java/org/jboss/proxy/ejb/HomeInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home"; } else if (m.equals(EQUALS)) { // equality of the proxy home is based on names... Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = ctx.getValue(InvocationKey.JNDI_NAME).toString() + "Home"; return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { return new Integer(this.hashCode()); } // Implement local EJB calls else if (m.equals(GET_HOME_HANDLE)) { return new HomeHandleImpl( (String)ctx.getValue(InvocationKey.JNDI_NAME)); } else if (m.equals(GET_EJB_META_DATA)) { return ctx.getValue(InvocationKey.EJB_METADATA); } else if (m.equals(REMOVE_BY_HANDLE)) { // First get the EJBObject EJBObject object = ((Handle) invocation.getArguments()[0]).getEJBObject(); // remove the object from here object.remove(); // Return Void return Void.TYPE; } else if (m.equals(REMOVE_BY_PRIMARY_KEY)) { // Session beans must throw RemoveException (EJB 1.1, 5.3.2) if(((EJBMetaData)ctx.getValue(InvocationKey.EJB_METADATA)).isSession()) throw new RemoveException("Session beans cannot be removed " + "by primary key."); // The trick is simple we trick the container in believe it // is a remove() on the instance Object id = invocation.getArguments()[0]; // Just override the Invocation going out invocation.setId(id); invocation.setType(InvocationType.REMOTE); invocation.setMethod(REMOVE_OBJECT); invocation.setArguments(EMPTY_ARGS); return getNext().invoke(invocation); } // If not taken care of, go on and call the container else { invocation.setType(InvocationType.HOME); // Create an Invocation return getNext().invoke(invocation); } }
// in src/main/java/org/jboss/proxy/ejb/StatelessSessionInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return toString(ctx); } else if (m.equals(EQUALS)) { Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { // We base the stateless hash on the hash of the proxy... // MF XXX: it could be that we want to return the hash of the name? return new Integer(this.hashCode()); } // Implement local EJB calls else if (m.equals(GET_HANDLE)) { return new StatelessHandleImpl( (String)ctx.getValue(InvocationKey.JNDI_NAME)); } else if (m.equals(GET_PRIMARY_KEY)) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } else if (m.equals(GET_EJB_HOME)) { return getEJBHome(invocation); } else if (m.equals(IS_IDENTICAL)) { // All stateless beans are identical within a home, // if the names are equal we are equal Object[] args = invocation.getArguments(); String argsString = args[0].toString(); String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } // If not taken care of, go on and call the container else { invocation.setType(InvocationType.REMOTE); return getNext().invoke(invocation); } }
// in src/main/java/org/jboss/proxy/ejb/EntityInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return toString(ctx); } else if (m.equals(EQUALS)) { Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { return new Integer(ctx.getCacheId().hashCode()); } // Implement local EJB calls else if (m.equals(GET_HANDLE)) { String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME); Object id = ctx.getCacheId(); return new EntityHandleImpl(jndiName, id); } else if (m.equals(GET_PRIMARY_KEY)) { return ctx.getCacheId(); } else if (m.equals(GET_EJB_HOME)) { return getEJBHome(invocation); } else if (m.equals(IS_IDENTICAL)) { Object[] args = invocation.getArguments(); String argsString = args[0].toString(); String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } // If not taken care of, go on and call the container else { // We are a Remote invocation invocation.setType(InvocationType.REMOTE); // We pertain to this ID (represented by cache ID) invocation.setId(ctx.getCacheId()); return getNext().invoke(invocation); } }
// in src/main/java/org/jboss/proxy/ejb/StatelessSessionHomeInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { // Is this create()? boolean create = invocation.getMethod().getName().equals("create"); // Do we have a cached version? if (create && cached != null) return cached; // Not a cached create Object result = super.invoke(invocation); // We now have something to cache if (create) cached = result; return result; }
// in src/main/java/org/jboss/proxy/ejb/StatefulSessionInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { InvocationContext ctx = invocation.getInvocationContext(); Method m = invocation.getMethod(); // Implement local methods if (m.equals(TO_STRING)) { return toString(ctx); } else if (m.equals(EQUALS)) { Object[] args = invocation.getArguments(); String argsString = args[0] != null ? args[0].toString() : ""; String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } else if (m.equals(HASH_CODE)) { return new Integer(ctx.getCacheId().hashCode()); } // Implement local EJB calls else if (m.equals(GET_HANDLE)) { int objectName = ((Integer) ctx.getObjectName()).intValue(); String jndiName = (String) ctx.getValue(InvocationKey.JNDI_NAME); Invoker invoker = ctx.getInvoker(); Object id = ctx.getCacheId(); return createHandle(objectName, jndiName, invoker, id, ctx); } else if (m.equals(GET_EJB_HOME)) { return getEJBHome(invocation); } else if (m.equals(GET_PRIMARY_KEY)) { throw new RemoteException("Call to getPrimaryKey not allowed on session bean"); } else if (m.equals(IS_IDENTICAL)) { Object[] args = invocation.getArguments(); String argsString = args[0].toString(); String thisString = toString(ctx); return new Boolean(thisString.equals(argsString)); } // If not taken care of, go on and call the container else { // It is a remote invocation invocation.setType(InvocationType.REMOTE); // On this entry in cache invocation.setId(ctx.getCacheId()); return getNext().invoke(invocation); } }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { Object result = null; InvocationContext ctx = invocation.getInvocationContext(); retry = true; int retryCount = 0; while( retry == true ) { Interceptor next = getNext(); try { if( trace ) log.trace("invoke, method="+invocation.getMethod()); result = next.invoke(invocation); break; } catch(ServiceUnavailableException e) { if( trace ) log.trace("Invocation failed", e); InvocationType type = invocation.getType(); if ((maxRetries > -1 && retryCount >= maxRetries) || reestablishInvokerProxy(ctx, type) == false) { throw e; } retryCount++; } } return result; }
// in src/main/java/org/jboss/proxy/ejb/ListEntityInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { Object result; ReadAheadResult raResult; Object[] aheadResult; int from; int to; ReadAheadBuffer buf; Method m = invocation.getMethod(); if (m.equals(GET_READ_AHEAD_VALUES)) { return getReadAheadValues(); } // have we read ahead the result? if (readAheadValues != null) { result = readAheadValues.get(m); if (readAheadValues.containsKey(m)) { return readAheadValues.remove(m); } } result = super.invoke(invocation); // marcf : I think all these will map nicely to the in/out of real interceptor, i.e. do not "extend" if (result instanceof ReadAheadResult) { raResult = (ReadAheadResult) result; aheadResult = raResult.getAheadResult(); ListCacheKey key = (ListCacheKey) invocation.getInvocationContext().getCacheId(); from = key.getIndex() + 1; to = Math.min(from + aheadResult.length, list.size()); for (int i = from; i < to; i++) { buf = (ReadAheadBuffer) list.get(i); buf.getReadAheadValues().put(m, aheadResult[i - from]); } return raResult.getMainResult(); } else { return result; } }
// in src/main/java/org/jboss/proxy/ejb/SecurityContextInterceptor.java
Override public Object invoke(Invocation invocation) throws Throwable { SecurityContext sc = null; boolean compatib = validateASVersionCompatibility(invocation); if(compatib) { sc = SecurityActions.getSecurityContext(); RunAs callerRAI = SecurityActions.getCallerRunAsIdentity(); SecurityContext newSc = createSecurityContext(invocation); //Push the caller run-as identity onto the security context if(callerRAI != null) { SecurityActions.setOutgoingRunAs(newSc, callerRAI); SecurityActions.setIncomingRunAs(newSc, callerRAI); } /** * Push the security context on the invocation */ invocation.setSecurityContext(newSc); } try { return getNext().invoke(invocation); } finally { if(compatib && sc != null) SecurityActions.setSecurityContext(sc); } }
// in src/main/java/org/jboss/proxy/ClientMethodInterceptor.java
public Object invoke(Invocation mi) throws Throwable { Method m = mi.getMethod(); String methodName = m.getName(); // Implement local methods if (methodName.equals("toString")) { Object obj = getObject(mi); return obj.toString(); } if (methodName.equals("equals")) { Object obj = getObject(mi); Object[] args = mi.getArguments(); String thisString = obj.toString(); String argsString = args[0] == null ? "" : args[0].toString(); return new Boolean(thisString.equals(argsString)); } if( methodName.equals("hashCode") ) { Object obj = getObject(mi); return new Integer(obj.hashCode()); } return getNext().invoke(mi); }
// in src/main/java/org/jboss/proxy/ClientContainerEx.java
public Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { if( m.getDeclaringClass() == IClientContainer.class ) { return m.invoke(this, args); } return super.invoke(proxy, m, args); }
// in src/main/java/org/jboss/proxy/SecurityInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { // Get Principal and credentials SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); Principal principal = sa.getPrincipal(); if (principal != null) { invocation.setPrincipal(principal); } Object credential = sa.getCredential(); if (credential != null) { invocation.setCredential(credential); } return getNext().invoke(invocation); }
// in src/main/java/org/jboss/proxy/ClientContainer.java
public Object invoke(final Object proxy, final Method m, Object[] args) throws Throwable { // Normalize args to always be an array // Isn't this a bug in the proxy call?? if (args == null) args = EMPTY_ARGS; // Create the invocation object Invocation invocation = new Invocation(); // Contextual information for the interceptors invocation.setInvocationContext(context); invocation.setId(context.getCacheId()); invocation.setObjectName(context.getObjectName()); invocation.setMethod(m); invocation.setArguments(args); invocation.setValue(InvocationKey.INVOKER_PROXY_BINDING, context.getInvokerProxyBinding(), PayloadKey.AS_IS); // send the invocation down the client interceptor chain Object obj = next.invoke(invocation); return obj; }
// in src/main/java/org/jboss/proxy/TransactionInterceptor.java
public Object invoke(Invocation invocation) throws Throwable { if (tm != null) { Transaction tx = tm.getTransaction(); if (tx != null) invocation.setTransaction(tx); } return getNext().invoke(invocation); }
79
            
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
catch (Throwable e) { log.error("Failed", e); return; }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch (Throwable ignored) { }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch (Throwable ignored) { }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); }
// in src/main/java/org/jboss/client/AppClientMain.java
catch(Throwable t) { log.warn("Failed to launch using: "+launcherName, t); }
// in src/main/java/org/jboss/jmx/adaptor/rmi/NotificationListenerDelegate.java
catch(Throwable t) { log.warn("Failed to notify client", t); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch (Throwable t) { throw new InvokerAdaptorException(t); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(Throwable t) { log.debug("Failed to notify client, unregistering listener", t); try { removeNotificationListener(targetName, client); } catch(Exception e) { log.debug("Failed to unregister listener", e); } }
// in src/main/java/org/jboss/deployment/dependency/JndiDependencyItem.java
catch(Throwable ignored) { if (log.isTraceEnabled()) log.trace("Unexpected error", ignored); }
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.debug("Unable to list web applications ENC", e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getDeployedApplications failed", e); buffer.append("Failed to getDeployedApplications\n"); formatException(buffer, e); buffer.insert(0, "<pre>"); buffer.append("</pre>"); return buffer.toString(); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.error("getConainers failed", e); buffer.append("<pre>"); buffer.append("Failed to get ejbs in module\n"); formatException(buffer, e); buffer.append("</pre>"); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable e) { log.debug("Unable to list web applications ENC", e); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("getContainers failed", t); appendPreExceptionTag(buffer, "Failed to get ejbs in module", t); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed on list contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list contents of (java:)", t); appendErrorTag(buffer, "Failed to list contents of (java:), " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list global contents ", t); appendErrorTag(buffer, "Failed to list global contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Failed to list HA-JNDI contents ", t); appendErrorTag(buffer, "Failed to list HA-JNDI contents, " + t.toString()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.debug("Invalid LinkRef for: " + name, t); buffer.append("invalid]"); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { buffer.append("Failed to lookup: " + name + ", errmsg=" + t.getMessage()); buffer.append('\n'); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { log.error("Invalid LinkRef for: " + name, t); appendLinkRefErrorTag(buffer); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed to lookup: " + name + ", errmsg=" + t.getMessage()); }
// in src/main/java/org/jboss/naming/JNDIView.java
catch (Throwable t) { appendErrorTag(buffer, "Failed to list contents of: " + name + ", errmsg=" + t.getMessage()); }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(Throwable t) { ServiceUnavailableException sue = new ServiceUnavailableException("Unexpected failure"); sue.setRootCause(t); throw sue; }
// in src/main/java/org/jboss/tm/usertx/client/ClientUserTransaction.java
catch (Throwable t) { // ignore }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (Throwable t) { log.debug("Failed to register pool as mbean", t); }
// in src/main/java/org/jboss/ejb/SessionContainer.java
catch (Throwable ignore) { }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Throwable e) { log.warn("Failed to unregister webClassLoader", e); }
// in src/main/java/org/jboss/ejb/EjbModule.java
catch (Throwable e) { log.error("unexpected exception destroying Container: " + jmxName, e); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Throwable t) { log.debug("Failed to register cache as mbean", t); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
catch (Throwable ignore) { }
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); }
// in src/main/java/org/jboss/ejb/deployers/EjbDeployer.java
catch (Throwable t) { log.warn("Verify failed; continuing", t ); allOK = false; }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable t) { log.debug("Failed to register pool as mbean", t); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable t) { log.debug("Failed to register invoker binding as mbean", t); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable ignore) { }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
catch(Throwable ignore) { }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { DeploymentException.rethrowAsDeploymentException("Error loading interceptor class " + className, t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Unable to create activation spec ra=" + resourceAdapterObjectName + " messaging-type=" + messagingTypeClass.getName() + " properties=" + metaData.getActivationConfigProperties(), t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); DeploymentException.rethrowAsDeploymentException("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
catch (Throwable t) { t = JMXExceptionDecoder.decode(t); log.warn("Endpoint activation failed ra=" + resourceAdapterObjectName + " activationSpec=" + activationSpec, t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { log.warn("Error in release ", t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { log.warn("MessageEndpoint " + getProxyString(mi) + " failed to resume old transaction " + currentTx); }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
catch (Throwable t) { log.debug("Ignored error trying to retrieve transaction status", t); }
// in src/main/java/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
catch (Throwable t) { log.debug("Ignored error while trying to passivate ctx", t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch (Throwable t) { log.debug("Ignored error while trying to flush() entity cache", t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/EJBQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JBossQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCJBossQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL " + "statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/ejb/plugins/LRUStatefulContextCachePolicy.java
catch (Throwable t) { log.debug("Ignored error trying to remove passivated beans from cache", t); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable t) { log.debug("Failed to register cache as mbean", t); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable t) { log.debug("Failed to register cache as mbean", t); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable ignore) { }
// in src/main/java/org/jboss/ejb/EntityContainer.java
catch(Throwable ignore) { }
// in src/main/java/org/jboss/ejb/ContainerRelection.java
catch(Throwable e) { if( e instanceof RuntimeOperationsException ) { RuntimeOperationsException roe = (RuntimeOperationsException) e; e = roe.getTargetException(); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); buffer.append(sw.toString()); buffer.append("\n</pre>\n"); }
// in src/main/java/org/jboss/web/WebServer.java
catch (Throwable e) { try { log.trace("HTTP code=404, " + e.getMessage()); // Write out error response out.writeBytes("HTTP/1.0 404 Not Found\r\n"); out.writeBytes("Content-Type: text/html\r\n\r\n"); out.flush(); } catch (IOException ex) { // Ignore } }
// in src/main/java/org/jboss/web/deployers/AbstractWarDeployment.java
catch (Throwable t) { log.debug("Unable to retrieve orb" + t.toString()); }
// in src/main/java/org/jboss/corba/ORBFactory.java
catch (Throwable t) { log.warn("Unable to activate POA", t); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); }
// in src/main/java/org/jboss/proxy/ejb/RetryInterceptor.java
catch(Throwable t) { retryCount++; if( trace ) log.trace("Retry attempt " + retryCount + ": Failed to lookup proxy", t); if (maxRetries > -1 && retryCount >= maxRetries) { if ( trace) log.trace("Maximum retry attempts made"); break; } }
41
            
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/unified/interfaces/UnifiedInvokerProxy.java
catch(Throwable throwable) { // this is somewhat of a hack as remoting throws throwable, // so will let Exception types bubble up, but if Throwable type, // then have to wrap in new Exception, as this is the signature // of this invoke method. if(throwable instanceof Exception) { throw (Exception) throwable; } throw new Exception(throwable); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch (Throwable t) { throw new InvokerAdaptorException(t); }
// in src/main/java/org/jboss/deployment/Ejb2xComponentDeployer.java
catch (Throwable t) { throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); }
// in src/main/java/org/jboss/naming/interceptors/ExceptionInterceptor.java
catch(Throwable t) { ServiceUnavailableException sue = new ServiceUnavailableException("Unexpected failure"); sue.setRootCause(t); throw sue; }
// in src/main/java/org/jboss/ejb/Container.java
catch (Throwable t) { throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/EntityInstanceInterceptor.java
catch (Throwable e) { exceptionThrown = e; discardContext = true; throw new NestedRuntimeException(e); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { setBeforeDeliveryInvoke(false); resetContextClassLoader(mi); throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { throw new ResourceException(t); }
// in src/main/java/org/jboss/ejb/plugins/inflow/MessageEndpointInterceptor.java
catch (Throwable t) { if (trace) log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t); if (t instanceof Error || t instanceof RuntimeException) { Transaction transaction = getTransaction(); if (transaction != null) transaction.setRollbackOnly(); commit = false; } throw t; }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstanceCache.java
catch (Throwable x) { log.debug("Activation failure", x); throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/EntitySynchronizationInterceptor.java
catch(Throwable t) { // If anything goes wrong with the association remove the ctx-tx association ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t; else if(t instanceof Error) throw (Error)t; else if(t instanceof Exception) throw new EJBException((Exception)t); else throw new NestedRuntimeException(t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/EJBQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling EJBQL statement '" + metadata.getEjbQl() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/DynamicQueryCommand.java
catch(Throwable t) { log.error("Error compiling JBossQL statement '" + args[0] + "'", t); throw new FinderException("Error compiling JBossQL statement '" + args[0] + "'"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/JBossQLQueryCommand.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLQuery.java
catch(Throwable t) { log.error(t.getMessage(), t); throw new DeploymentException("Error compiling EJB-QL statement for EJB '" + manager.getContainer().getBeanMetaData().getEjbName() + "': " + metadata.getEjbQl(), t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCJBossQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new DeploymentException("Error compiling JBossQL " + "statement '" + metadata.getJBossQL() + "'", t); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCDynamicQLQuery.java
catch(Throwable t) { t.printStackTrace(); throw new FinderException("Error compiling ejbql: " + t); }
// in src/main/java/org/jboss/ejb/plugins/AbstractInstancePool.java
catch (Throwable e) { // Release the strict max size mutex if it exists if( strictMaxSize != null ) { strictMaxSize.release(); } // Don't wrap CreateExceptions if( e instanceof CreateException ) throw (CreateException) e; // Wrap e in an Exception if needed Exception ex = null; if(e instanceof Exception) { ex = (Exception)e; } else { ex = new UndeclaredThrowableException(e); } throw new EJBException("Could not instantiate bean", ex); }
// in src/main/java/org/jboss/ejb/plugins/PerTxEntityInstanceCache.java
catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/ejb/plugins/LogInterceptor.java
catch(Throwable e) { throw handleException(e, invocation); }
// in src/main/java/org/jboss/proxy/ejb/handle/StatefulHandleImpl.java
catch (Throwable t) { t.printStackTrace(); throw new RemoteException("Error during getEJBObject", t); }
0
unknown (Lib) TransactionRequiredException 1
            
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private Object runWithTransactions(Invocation invocation) throws Exception { // Old transaction is the transaction that comes with the MI Transaction oldTransaction = invocation.getTransaction(); // New transaction is the new transaction this might start Transaction newTransaction = null; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Current transaction in MI is " + oldTransaction); InvocationType type = invocation.getType(); byte transType = container.getBeanMetaData().getTransactionMethod(invocation.getMethod(), type); if ( trace ) printMethod(invocation.getMethod(), transType); // Thread arriving must be clean (jboss doesn't set the thread // previously). However optimized calls come with associated // thread for example. We suspend the thread association here, and // resume in the finally block of the following try. Transaction threadTx = tm.suspend(); if( trace ) log.trace("Thread came in with tx " + threadTx); try { switch (transType) { case MetaData.TX_NOT_SUPPORTED: { // Do not set a transaction on the thread even if in MI, just run try { invocation.setTransaction(null); return invokeNext(invocation, false); } finally { invocation.setTransaction(oldTransaction); } } case MetaData.TX_REQUIRED: { int oldTimeout = 0; Transaction theTransaction = oldTransaction; if (oldTransaction == null) { // No tx running // Create tx oldTimeout = startTransaction(invocation); // get the tx newTransaction = tm.getTransaction(); if( trace ) log.trace("Starting new tx " + newTransaction); // Let the method invocation know invocation.setTransaction(newTransaction); theTransaction = newTransaction; } else { // We have a tx propagated // Associate it with the thread tm.resume(oldTransaction); } // Continue invocation try { Object result = invokeNext(invocation, oldTransaction != null); checkTransactionStatus(theTransaction, type); return result; } finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); } } case MetaData.TX_SUPPORTS: { // Associate old transaction with the thread // Some TMs cannot resume a null transaction and will throw // an exception (e.g. Tyrex), so make sure it is not null if (oldTransaction != null) { tm.resume(oldTransaction); } try { Object result = invokeNext(invocation, oldTransaction != null); if (oldTransaction != null) checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } // Even on error we don't do anything with the tx, // we didn't start it } case MetaData.TX_REQUIRES_NEW: { // Always begin a transaction int oldTimeout = startTransaction(invocation); // get it newTransaction = tm.getTransaction(); // Set it on the method invocation invocation.setTransaction(newTransaction); // Continue invocation try { Object result = invokeNext(invocation, false); checkTransactionStatus(newTransaction, type); return result; } finally { // We started the transaction for sure so we commit or roll back endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); } } case MetaData.TX_MANDATORY: { if (oldTransaction == null) { if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new TransactionRequiredLocalException( "Transaction Required"); } else { throw new TransactionRequiredException( "Transaction Required"); } } // Associate it with the thread tm.resume(oldTransaction); try { Object result = invokeNext(invocation, true); checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } } case MetaData.TX_NEVER: { if (oldTransaction != null) { throw new EJBException("Transaction not allowed"); } return invokeNext(invocation, false); } default: log.error("Unknown TX attribute "+transType+" for method"+invocation.getMethod()); } } finally { // IN case we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } return null; }
0 0 2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
0
unknown (Lib) TransactionRequiredLocalException 3
            
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private Object runWithTransactions(Invocation invocation) throws Exception { // Old transaction is the transaction that comes with the MI Transaction oldTransaction = invocation.getTransaction(); // New transaction is the new transaction this might start Transaction newTransaction = null; boolean trace = log.isTraceEnabled(); if( trace ) log.trace("Current transaction in MI is " + oldTransaction); InvocationType type = invocation.getType(); byte transType = container.getBeanMetaData().getTransactionMethod(invocation.getMethod(), type); if ( trace ) printMethod(invocation.getMethod(), transType); // Thread arriving must be clean (jboss doesn't set the thread // previously). However optimized calls come with associated // thread for example. We suspend the thread association here, and // resume in the finally block of the following try. Transaction threadTx = tm.suspend(); if( trace ) log.trace("Thread came in with tx " + threadTx); try { switch (transType) { case MetaData.TX_NOT_SUPPORTED: { // Do not set a transaction on the thread even if in MI, just run try { invocation.setTransaction(null); return invokeNext(invocation, false); } finally { invocation.setTransaction(oldTransaction); } } case MetaData.TX_REQUIRED: { int oldTimeout = 0; Transaction theTransaction = oldTransaction; if (oldTransaction == null) { // No tx running // Create tx oldTimeout = startTransaction(invocation); // get the tx newTransaction = tm.getTransaction(); if( trace ) log.trace("Starting new tx " + newTransaction); // Let the method invocation know invocation.setTransaction(newTransaction); theTransaction = newTransaction; } else { // We have a tx propagated // Associate it with the thread tm.resume(oldTransaction); } // Continue invocation try { Object result = invokeNext(invocation, oldTransaction != null); checkTransactionStatus(theTransaction, type); return result; } finally { if( trace ) log.trace("TxInterceptorCMT: In finally"); // Only do something if we started the transaction if (newTransaction != null) endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); else tm.suspend(); } } case MetaData.TX_SUPPORTS: { // Associate old transaction with the thread // Some TMs cannot resume a null transaction and will throw // an exception (e.g. Tyrex), so make sure it is not null if (oldTransaction != null) { tm.resume(oldTransaction); } try { Object result = invokeNext(invocation, oldTransaction != null); if (oldTransaction != null) checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } // Even on error we don't do anything with the tx, // we didn't start it } case MetaData.TX_REQUIRES_NEW: { // Always begin a transaction int oldTimeout = startTransaction(invocation); // get it newTransaction = tm.getTransaction(); // Set it on the method invocation invocation.setTransaction(newTransaction); // Continue invocation try { Object result = invokeNext(invocation, false); checkTransactionStatus(newTransaction, type); return result; } finally { // We started the transaction for sure so we commit or roll back endTransaction(invocation, newTransaction, oldTransaction, oldTimeout); } } case MetaData.TX_MANDATORY: { if (oldTransaction == null) { if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new TransactionRequiredLocalException( "Transaction Required"); } else { throw new TransactionRequiredException( "Transaction Required"); } } // Associate it with the thread tm.resume(oldTransaction); try { Object result = invokeNext(invocation, true); checkTransactionStatus(oldTransaction, type); return result; } finally { tm.suspend(); } } case MetaData.TX_NEVER: { if (oldTransaction != null) { throw new EJBException("Transaction not allowed"); } return invokeNext(invocation, false); } default: log.error("Unknown TX attribute "+transType+" for method"+invocation.getMethod()); } } finally { // IN case we had a Tx associated with the thread reassociate if (threadTx != null) tm.resume(threadTx); } return null; }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); }
0 0 0 0
unknown (Lib) TransactionRolledbackException 0 0 3
            
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
private void endTransaction(final Invocation invocation, final Transaction tx, final Transaction oldTx, final int oldTimeout) throws TransactionRolledbackException, SystemException { // Assert the correct transaction association Transaction current = tm.getTransaction(); if ((tx == null && current != null) || tx.equals(current) == false) throw new IllegalStateException("Wrong transaction association: expected " + tx + " was " + current); try { // Marked rollback if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) { tx.rollback(); } else { // Commit tx // This will happen if // a) everything goes well // b) app. exception was thrown tx.commit(); } } catch (RollbackException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicMixedException e) { throwJBossException(e, invocation.getType()); } catch (HeuristicRollbackException e) { throwJBossException(e, invocation.getType()); } catch (SystemException e) { throwJBossException(e, invocation.getType()); } catch (IllegalStateException e) { throwJBossException(e, invocation.getType()); } finally { // reassociate the oldTransaction with the Invocation (even null) invocation.setTransaction(oldTx); // Always drop thread association even if committing or // rolling back the newTransaction because not all TMs // will drop thread associations when commit() or rollback() // are called through tx itself (see JTA spec that seems to // indicate that thread assoc is required to be dropped only // when commit() and rollback() are called through TransactionManager // interface) //tx has committed, so we can't throw txRolledbackException. tm.suspend(); // Reset the transaction timeout (unless we didn't set it) if (oldTimeout != -1) tm.setTransactionTimeout(oldTimeout); } }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
protected void throwJBossException(Exception e, InvocationType type) throws TransactionRolledbackException { // Unwrap a nested exception if possible. There is no // point in the extra wrapping, and the EJB spec should have // just used javax.transaction exceptions if (e instanceof NestedException) { NestedException rollback = (NestedException) e; if(rollback.getCause() instanceof Exception) { e = (Exception) rollback.getCause(); } } if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME) { throw new JBossTransactionRolledbackLocalException(e); } else { throw new JBossTransactionRolledbackException(e); } }
// in src/main/java/org/jboss/ejb/plugins/TxInterceptorCMT.java
protected void checkTransactionStatus(Transaction tx, InvocationType type) throws TransactionRolledbackException { if (exceptionRollback) { if (log.isTraceEnabled()) log.trace("No exception from ejb, checking transaction status: " + tx); int status = Status.STATUS_UNKNOWN; try { status = tx.getStatus(); } catch (Throwable t) { log.debug("Ignored error trying to retrieve transaction status", t); } if (status != Status.STATUS_ACTIVE) { Exception e = new Exception("Transaction cannot be committed (probably transaction timeout): " + tx); throwJBossException(e, type); } } }
2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
2
            
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
0
unknown (Lib) TransactionRolledbackLocalException 3
            
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
protected Object invokeNext(Invocation invocation, boolean inheritedTx) throws Exception { InvocationType type = invocation.getType(); try { if (type == InvocationType.REMOTE || type == InvocationType.LOCAL || type == InvocationType.SERVICE_ENDPOINT) { // register the Timer with the transaction if (ejbTimeout.equals(invocation.getMethod())) registerTimer(invocation); return getNext().invoke(invocation); } else { return getNext().invokeHome(invocation); } } catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invokeHome(Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(null, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCALHOME); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
public Object invoke(Object id, Method m, Object[] args) throws Exception { // Set the right context classloader ClassLoader oldCl = TCLAction.UTIL.getContextClassLoader(); boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) { TCLAction.UTIL.setContextClassLoader(container.getClassLoader()); } container.pushENC(); SecurityActions sa = SecurityActions.UTIL.getSecurityActions(); try { LocalEJBInvocation invocation = new LocalEJBInvocation(id, m, args, getTransaction(), sa.getPrincipal(), sa.getCredential()); invocation.setType(InvocationType.LOCAL); return container.invoke(invocation); } catch(AccessException ae) { log.trace(ae); throw new AccessLocalException(ae.getMessage(), ae); } catch(NoSuchObjectException nsoe) { throw new NoSuchObjectLocalException(nsoe.getMessage(), nsoe); } catch(TransactionRequiredException tre) { throw new TransactionRequiredLocalException(tre.getMessage()); } catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); } finally { container.popENC(); if(setCl) { TCLAction.UTIL.setContextClassLoader(oldCl); } } }
3
            
// in src/main/java/org/jboss/ejb/plugins/AbstractTxInterceptor.java
catch (Throwable e) { // if this is an ApplicationException, just rethrow it if (e instanceof Exception && !(e instanceof RuntimeException || e instanceof RemoteException)) { throw (Exception) e; } // attempt to rollback the transaction Transaction tx = invocation.getTransaction(); if (tx == null) { // Look for a hanging active user transaction that we should mark rollback try { tx = tm.getTransaction(); if (TxUtils.isActive(tx) == false) tx = null; } catch (Exception ex) { log.warn("Unable to determine transaction context", ex); } } if (tx != null) { try { tx.setRollbackOnly(); } catch (SystemException ex) { log.error("SystemException while setting transaction " + "for rollback only", ex); } catch (IllegalStateException ex) { log.error("IllegalStateException while setting transaction " + "for rollback only", ex); } } // is this a local invocation boolean isLocal = type == InvocationType.LOCAL || type == InvocationType.LOCALHOME; // if this transaction was NOT inherited from the caller we simply // rethrow the exception, and LogInterceptor will handle // all exception conversions. if (!inheritedTx) { if (e instanceof Exception) { throw (Exception) e; } if (e instanceof Error) { throw (Error) e; } // we have some funky throwable, wrap it if (isLocal) { String msg = formatException("Unexpected Throwable", e); throw new EJBException(msg); } else { ServerException ex = new ServerException("Unexpected Throwable"); ex.detail = e; throw ex; } } // to be nice we coerce the execption to an interface friendly type // before wrapping it with a transaction rolled back exception Throwable cause; if (e instanceof NoSuchEntityException) { NoSuchEntityException nsee = (NoSuchEntityException) e; if (isLocal) { cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException()); } else { cause = new NoSuchObjectException(nsee.getMessage()); // set the detil of the exception ((NoSuchObjectException) cause).detail = nsee.getCausedByException(); } } else { if (isLocal) { // local transaction rolled back exception can only wrap // an exception so we create an EJBException for the cause if (e instanceof Exception) { cause = e; } else if (e instanceof Error) { String msg = formatException("Unexpected Error", e); cause = new EJBException(msg); } else { String msg = formatException("Unexpected Throwable", e); cause = new EJBException(msg); } } else { // remote transaction rolled back exception can wrap // any throwable so we are ok cause = e; } } // We inherited tx: Tell caller we marked for rollback only. if (isLocal) { if (cause instanceof TransactionRolledbackLocalException) { throw (TransactionRolledbackLocalException) cause; } else { throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception) cause); } } else { if (cause instanceof TransactionRolledbackException) { throw (TransactionRolledbackException) cause; } else { TransactionRolledbackException ex = new TransactionRolledbackException(cause.getMessage()); ex.detail = cause; throw ex; } } }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
// in src/main/java/org/jboss/ejb/plugins/local/BaseLocalProxyFactory.java
catch(TransactionRolledbackException trbe) { throw new TransactionRolledbackLocalException(trbe.getMessage(), trbe); }
0 0 0 0
unknown (Lib) URISyntaxException 0 0 0 1
            
// in src/main/java/org/jboss/web/deployers/ServletContainerInitializerDeployer.java
catch (URISyntaxException e) { DeploymentException.rethrowAsDeploymentException("Deployment error processing SCI for JAR: " + jarURL, e); }
0 0
unknown (Lib) UnavailableException 1
            
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException { trace = log.isTraceEnabled(); if (getState() != STARTED && getState() != STARTING) throw new UnavailableException("The container is not started"); HashMap context = new HashMap(); context.put(MessageEndpointInterceptor.MESSAGE_ENDPOINT_FACTORY, this); context.put(MessageEndpointInterceptor.MESSAGE_ENDPOINT_XARESOURCE, resource); String ejbName = container.getBeanMetaData().getContainerObjectNameJndiName(); if (trace) log.trace("createEndpoint " + this + " xaResource=" + resource); MessageEndpoint endpoint = (MessageEndpoint) proxyFactory.createProxy ( ejbName + "@" + nextProxyId.incrementAndGet(), container.getServiceName(), InvokerInterceptor.getLocal(), null, null, interceptors, container.getClassLoader(), interfaces, context ); if (trace) log.trace("Created endpoint " + endpoint + " from " + this); return endpoint; }
0 1
            
// in src/main/java/org/jboss/ejb/plugins/inflow/JBossMessageEndpointFactory.java
public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException { trace = log.isTraceEnabled(); if (getState() != STARTED && getState() != STARTING) throw new UnavailableException("The container is not started"); HashMap context = new HashMap(); context.put(MessageEndpointInterceptor.MESSAGE_ENDPOINT_FACTORY, this); context.put(MessageEndpointInterceptor.MESSAGE_ENDPOINT_XARESOURCE, resource); String ejbName = container.getBeanMetaData().getContainerObjectNameJndiName(); if (trace) log.trace("createEndpoint " + this + " xaResource=" + resource); MessageEndpoint endpoint = (MessageEndpoint) proxyFactory.createProxy ( ejbName + "@" + nextProxyId.incrementAndGet(), container.getServiceName(), InvokerInterceptor.getLocal(), null, null, interceptors, container.getClassLoader(), interfaces, context ); if (trace) log.trace("Created endpoint " + endpoint + " from " + this); return endpoint; }
0 0 0
unknown (Lib) UndeclaredThrowableException 9
            
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeMarshalled(Invocation invocation) throws Exception { MarshalledInvocation mi = new MarshalledInvocation(invocation); MarshalledValue copy = new MarshalledValue(mi); Invocation invocationCopy = (Invocation) copy.get(); // copy the Tx Transaction tx = invocation.getTransaction(); invocationCopy.setTransaction(tx); try { Object rtnValue = localInvoker.invoke(invocationCopy); MarshalledValue mv = new MarshalledValue(rtnValue); return mv.get(); } catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); } }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
protected Object invokeLocalMarshalled(Invocation invocation) throws Exception { IMarshalledValue value = createMarshalledValueForCallByValue(invocation.getArguments()); MarshalledInvocation invocationCopy = createInvocationCopy(invocation, value); // copy the Tx Transaction tx = invocation.getTransaction(); invocationCopy.setTransaction(tx); try { Object rtnValue = localInvoker.invoke(invocationCopy); IMarshalledValue mv = createMarshalledValueForCallByValue(rtnValue); return mv.get(); } catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); } }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
public Object invoke(Invocation invocation) throws Exception { try { // Make sure we have the correct classloader before unmarshalling ClassLoader oldCL = SecurityActions.getContextClassLoader(); ClassLoader newCL = null; // Get the MBean this operation applies to ObjectName objectName = (ObjectName) invocation.getValue("JMX_OBJECT_NAME"); if (objectName != null) { newCL = server.getClassLoaderFor(objectName); } if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(newCL); //JBAS-6449: Cache the incoming security context to be retained on exit SecurityContext previousSecurityContext = SecurityActions.getSecurityContext(); try { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the MBeanServer method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Principal principal = invocation.getPrincipal(); Object credential = invocation.getCredential(); Object value = null; SecurityContext sc = SecurityActions.createSecurityContext(SecurityConstants.DEFAULT_APPLICATION_POLICY); SecurityActions.setSecurityContext(sc); // Associate the method SecurityActions.pushSubjectContext(principal, credential, null); try { if( addNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; NotificationFilter filter = (NotificationFilter) args[2]; Object handback = args[3]; addNotificationListener(name, listener, filter, handback); } else if( removeNotificationListeners.contains(method) ) { ObjectName name = (ObjectName) args[0]; RMINotificationListener listener = (RMINotificationListener) args[1]; removeNotificationListener(name, listener); } else { String name = method.getName(); Class[] paramTypes = method.getParameterTypes(); Method mbeanServerMethod = MBeanServer.class.getMethod(name, paramTypes); value = mbeanServerMethod.invoke(server, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; } finally { // Restore the input security context SecurityActions.popSubjectContext(); if(previousSecurityContext != null) SecurityActions.setSecurityContext(previousSecurityContext); else SecurityActions.clearSecurityContext(); // Restore the input class loader if (newCL != null && newCL != oldCL) SecurityActions.setContextClassLoader(oldCL); } } catch (Throwable t) { throw new InvokerAdaptorException(t); } }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
private void checkAuthorization(Principal caller, String objname, String opname) throws Exception { // Get the active Subject Subject subject = SecurityActions.getActiveSubject(); if( subject == null ) throw new SecurityException("No active Subject found, add th AuthenticationInterceptor"); //We will try to use the authorizing class try { Object[] args = {caller, subject, objname, opname}; authorize.invoke(authenticator, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); } }
// in src/main/java/org/jboss/naming/NamingService.java
public Object invoke(Invocation invocation) throws Exception { Naming theServer = namingMain.getNamingInstance(); // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the Naming method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Object value = null; try { value = method.invoke(theServer, args); } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
public Object invoke(Invocation invocation) throws Exception { // Set the method hash to Method mapping if (invocation instanceof MarshalledInvocation) { MarshalledInvocation mi = (MarshalledInvocation) invocation; mi.setMethodMap(marshalledInvocationMapping); } // Invoke the method via reflection Method method = invocation.getMethod(); Object[] args = invocation.getArguments(); Object value = null; try { if( UserTransactionSessionFactory.class.isAssignableFrom(method.getDeclaringClass()) ) { // Just return the UserTransactionSession proxy as its stateless value = txProxy; } else if( method.getName().equals("begin") ) { // Begin a new transaction Integer timeout = (Integer) args[0]; UserTransactionSession session = UserTransactionSessionImpl.getInstance(); value = session.begin(timeout.intValue()); } else if( method.getName().equals("destroy")) { /* We do nothing as the tx will timeout and the tx map is shared across all sessions as we have no association with the txs a given client has started. */ } else { UserTransactionSession session = UserTransactionSessionImpl.getInstance(); value = method.invoke(session, args); } } catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); } return value; }
// in src/main/java/org/jboss/ejb/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { try { return (Subject) AccessController.doPrivileged(exAction); } catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); } }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { try { return (Subject) AccessController.doPrivileged(exAction); } catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); } }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
public Subject getContextSubject() throws PolicyContextException { try { return (Subject) AccessController.doPrivileged(exAction); } catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); } }
9
            
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { MarshalledValue mv = new MarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/invocation/InvokerInterceptor.java
catch(Throwable t) { IMarshalledValue mv = SerializationStreamFactory.getManagerInstance().createdMarshalledValue(t); Throwable t2 = (Throwable) mv.get(); if( t2 instanceof Exception ) throw (Exception) t2; else throw new UndeclaredThrowableException(t2); }
// in src/main/java/org/jboss/jmx/connector/invoker/InvokerAdaptorService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/jmx/connector/invoker/AuthorizationInterceptor.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t); }
// in src/main/java/org/jboss/naming/NamingService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/tm/usertx/server/ClientUserTransactionService.java
catch(InvocationTargetException e) { Throwable t = e.getTargetException(); if( t instanceof Exception ) throw (Exception) t; else throw new UndeclaredThrowableException(t, method.toString()); }
// in src/main/java/org/jboss/ejb/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/SecurityActions.java
catch(PrivilegedActionException e) { Exception ex = e.getException(); if( ex instanceof PolicyContextException ) throw (PolicyContextException) ex; else throw new UndeclaredThrowableException(ex); }
0 1
            
// in src/main/java/org/jboss/Shutdown.java
catch(UndeclaredThrowableException e) { System.out.println("getUndeclaredThrowable: "+e.getUndeclaredThrowable()); throw e.getUndeclaredThrowable(); }
1
            
// in src/main/java/org/jboss/Shutdown.java
catch(UndeclaredThrowableException e) { System.out.println("getUndeclaredThrowable: "+e.getUndeclaredThrowable()); throw e.getUndeclaredThrowable(); }
0
unknown (Lib) UnknownHostException 0 0 6
            
// in src/main/java/org/jboss/invocation/http/server/HttpInvoker.java
protected void checkInvokerURL() throws UnknownHostException { if( invokerURL == null ) { InetAddress addr = InetAddress.getLocalHost(); // First check for a global bind address String host = ServerConfigUtil.getSpecificBindAddress(); if( host == null ) { host = useHostName ? addr.getHostName() : addr.getHostAddress(); } String url = invokerURLPrefix + ServerConfigUtil.fixHostnameForURL(host) + invokerURLSuffix; setInvokerURL(url); } }
// in src/main/java/org/jboss/invocation/http/server/HttpProxyFactory.java
protected void checkInvokerURL() throws UnknownHostException { if( invokerURL == null ) { // First check for a global bind address String host = ServerConfigUtil.getSpecificBindAddress(); if( host == null ) { InetAddress addr = InetAddress.getLocalHost(); host = useHostName ? addr.getHostName() : addr.getHostAddress(); } // JBAS-8540 String url = invokerURLPrefix + ServerConfigUtil.fixHostnameForURL(host) + invokerURLSuffix; setInvokerURL(url); } }
// in src/main/java/org/jboss/naming/NamingService.java
public void setBindAddress(String host) throws UnknownHostException { namingMain.setBindAddress(host); }
// in src/main/java/org/jboss/naming/NamingService.java
public void setRmiBindAddress(String host) throws UnknownHostException { namingMain.setRmiBindAddress(host); }
// in src/main/java/org/jboss/web/WebService.java
public void setBindAddress(String address) throws UnknownHostException { InetAddress bindAddress = toInetAddress(address); server.setBindAddress(bindAddress); }
// in src/main/java/org/jboss/web/WebService.java
private InetAddress toInetAddress(String host) throws UnknownHostException { if (host == null || host.length() == 0) return null; else return InetAddress.getByName(host); }
2
            
// in src/main/java/org/jboss/config/ServerConfigUtil.java
catch (UnknownHostException ignored) { }
// in src/main/java/org/jboss/config/ServerConfigUtil.java
catch (UnknownHostException ignored) { }
0 0
runtime (Domain) UnknownPathException
public final class UnknownPathException extends RuntimeException {
   private final String reason;
   private final String path;
   private final String fieldName;
   private final int errorLine;
   private final int errorColumn;
   
   public UnknownPathException(
         String reason,
         String path,
         String fieldName,
         int errorLine,
         int errorColumn) {

      super(reason + ": at line " + errorLine + ", "+
            "column " + errorColumn + ".  " +
            "Encountered: \"" + fieldName + "\"" +
            ((path==null) ? "" : " after: \"" + path + "\"") );

      this.reason = reason;
      this.path = path;
      this.fieldName = fieldName;
      this.errorLine = errorLine;
      this.errorColumn = errorColumn;
   }
   public String getReason() {
      return reason;
   }
   public String getCurrentPath() {
      return path;
   }
   public String getFieldName() {
      return fieldName;
   }
   public int getErrorLine() {
      return errorLine;
   }
   public int getErrorColumn() {
      return errorColumn;
   }
}
0 0 0 0 0 0
unknown (Lib) UnreachableStatementException 11
            
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Handle handle) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public void removeHome(Object primaryKey) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } try { return mi.performCall(StatelessSessionContainer.this, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatelessSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // wire the transaction on the context, this is how the instance remember the tx EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); // Get method and instance to invoke upon Method miMethod = mi.getMethod(); Map map = getBeanMapping(); Method m = (Method) map.get(miMethod); // The Invocation might contain the actual bean method // e.g. For an invocation based on a JSR-181 @WebMethod annotation if (m == null && map.values().contains(miMethod)) { m = miMethod; } if (m == null) { String msg = "Invalid invocation, check your deployment packaging, method=" + miMethod; throw new EJBException(msg); } //If we have a method that needs to be done by the container (EJBObject methods) if (m.getDeclaringClass().equals(StatelessSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { try { return mi.performCall(StatelessSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else // we have a method that needs to be done by a bean instance { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public void removeLocalHome(Invocation mi) throws RemoteException, RemoveException { throw new UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invokeHome(Invocation mi) throws Exception { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("HOMEMETHOD coming in "); log.trace("" + mi.getMethod()); log.trace("HOMEMETHOD coming in hashcode" + mi.getMethod().hashCode()); log.trace("HOMEMETHOD coming in classloader" + mi.getMethod().getDeclaringClass().getClassLoader().hashCode()); log.trace("CONTAINS " + getHomeMapping().containsKey(mi.getMethod())); } Method miMethod = mi.getMethod(); Method m = (Method) getHomeMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // Invoke and handle exceptions if (trace) { log.trace("HOMEMETHOD m " + m); java.util.Iterator iterator = getHomeMapping().keySet().iterator(); while (iterator.hasNext()) { Method me = (Method) iterator.next(); if (me.getName().endsWith("create")) { log.trace(me.toString()); log.trace("" + me.hashCode()); log.trace("" + me.getDeclaringClass().getClassLoader().hashCode()); log.trace("equals " + me.equals(mi.getMethod()) + " " + mi.getMethod().equals(me)); } } } try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) getBeanMapping().get(miMethod); if (m == null) { String msg = "Invalid invocation, check your deployment packaging" + ", method=" + miMethod; throw new EJBException(msg); } // wire the transaction on the context, this is how the instance remember the tx // Unlike Entity beans we can't do that in the previous interceptors (ordering) EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if (ctx.getTransaction() == null) ctx.setTransaction(mi.getTransaction()); else if(ejbObjectRemove.equals(miMethod) || ejbLocalObjectRemove.equals(miMethod)) { throw new RemoveException("An attempt to remove a session " + "object while the object is in a transaction " + "(EJB2.1, 7.6.4 Restrictions for Transactions): ejb-name=" + metaData.getEjbName() + ", method=" + mi.getMethod() + ", tx=" + ctx.getTransaction()); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(StatefulSessionContainer.class) || m.getDeclaringClass().equals(SessionContainer.class)) { // Invoke and handle exceptions try { return mi.performCall(StatefulSessionContainer.this, m, new Object[]{mi}); } catch (Exception e) { rethrow(e); } } else { // Invoke and handle exceptions try { Object bean = ctx.getInstance(); return mi.performCall(bean, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/MessageDrivenContainer.java
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); // wire the transaction on the context, // this is how the instance remember the tx if (ctx.getTransaction() == null) { ctx.setTransaction(mi.getTransaction()); } // Get method and instance to invoke upon Method m = (Method) beanMapping.get(mi.getMethod()); if( m == null ) { // This is a configuration error that should have been caught earlier String msg = MessageDrivenContainer.this.getBeanMetaData().getEjbName() + " Invalid invocation, check your deployment packaging, interfaces, method=" + mi.getMethod(); throw new EJBException(msg); } // we have a method that needs to be done by a bean instance try { messageCount++; return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invokeHome(Invocation mi) throws Exception { // Invoke and handle exceptions Method miMethod = mi.getMethod(); Method m = (Method) homeMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } if (m.getDeclaringClass().equals(EntityContainer.class)) { try { return mi.performCall(EntityContainer.this, m, new Object[] { mi }); } catch (Exception e) { rethrow(e); } } else // Home method { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); try { AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_EJB_HOME); return mi.performCall(ctx.getInstance(), m, mi.getArguments()); } catch (Exception e) { rethrow(e); } finally{ AllowedOperationsAssociation.popInMethodFlag(); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/ejb/EntityContainer.java
public Object invoke(Invocation mi) throws Exception { // Get method Method miMethod = mi.getMethod(); Method m = (Method) beanMapping.get(miMethod); if( m == null ) { String msg = "Invalid invocation, check your deployment packaging" +", method="+miMethod; throw new EJBException(msg); } // Select instance to invoke (container or bean) if (m.getDeclaringClass().equals(EntityContainer.class)) { // Invoke container try { return mi.performCall(EntityContainer.this, m, new Object[]{ mi }); } catch (Exception e) { rethrow(e); } } else { // Invoke bean instance try { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); Object instance = ctx.getInstance(); return mi.performCall(instance, m, mi.getArguments()); } catch (Exception e) { rethrow(e); } } // We will never get this far, but the compiler does not know that throw new org.jboss.util.UnreachableStatementException(); }
// in src/main/java/org/jboss/proxy/compiler/Utility.java
public static Type getType(Class clazz) { if (clazz.isPrimitive()) { if (clazz.equals(Boolean.TYPE) ) { return Type.BOOLEAN; } else if (clazz.equals(Byte.TYPE) ) { return Type.BYTE; } else if (clazz.equals(Character.TYPE) ) { return Type.CHAR; } else if (clazz.equals(Double.TYPE) ) { return Type.DOUBLE; } else if (clazz.equals(Float.TYPE) ) { return Type.FLOAT; } else if (clazz.equals(Integer.TYPE) ) { return Type.INT; } else if (clazz.equals(Long.TYPE) ) { return Type.LONG; } else if (clazz.equals(Short.TYPE) ) { return Type.SHORT; } else if (clazz.equals(Void.TYPE) ) { return Type.VOID; } // should never get here throw new UnreachableStatementException(); } // if we get this far it is not a primitive String name = clazz.getName(); if (clazz.isArray()) { return Type.getType(name); } return new ObjectType(name); }
0 0 0 0 0
runtime (Lib) UnsupportedOperationException 64
            
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(long duration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createSingleActionTimer(Date expiration, TimerConfig timerConfig) throws IllegalArgumentException, IllegalStateException, EJBException { throw new UnsupportedOperationException("createSingleActionTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule) { throw new UnsupportedOperationException("createCalendarTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, TimerConfig timerConfig) { throw new UnsupportedOperationException("createCalendarTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createCalendarTimer(ScheduleExpression schedule, Serializable info) { throw new UnsupportedOperationException("createCalendarTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createIntervalTimer(Date initialExpiration, long intervalDuration, TimerConfig timerConfig) { throw new UnsupportedOperationException("createIntervalTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerServiceImpl.java
public Timer createIntervalTimer(long initialDuration, long intervalDuration, TimerConfig timerConfig) { throw new UnsupportedOperationException("createIntervalTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public ScheduleExpression getSchedule() { throw new UnsupportedOperationException("getSchedule: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public boolean isCalendarTimer() { throw new UnsupportedOperationException("isCalendarTimer: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/txtimer/TimerImpl.java
public boolean isPersistent() { throw new UnsupportedOperationException("isPersistent: NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatelessSessionEnterpriseContext.java
public boolean wasCancelCalled() { throw new UnsupportedOperationException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/StatefulSessionContainer.java
public long getPassivatedCount() { if (! (instanceCache instanceof StatefulSessionInstanceCache)) throw new UnsupportedOperationException(); return ((StatefulSessionInstanceCache)instanceCache).getPassivatedCount(); }
// in src/main/java/org/jboss/ejb/Container.java
protected InstancePool getInstancePool() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/StatefulSessionEnterpriseContext.java
public boolean wasCancelCalled() { throw new UnsupportedOperationException("NOT IMPLEMENTED"); }
// in src/main/java/org/jboss/ejb/EnterpriseContext.java
public Map<String, Object> getContextData() { // TODO: implement throw new UnsupportedOperationException("Not yet implemented"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public void resetPersistenceContext(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public int setInstanceParameters(PreparedStatement ps, int parameterIndex, EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public Object getInstanceValue(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public void setInstanceValue(EntityEnterpriseContext ctx, Object value) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public int loadInstanceResults(ResultSet rs, int parameterIndex, EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public boolean isDirty(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public void setClean(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public boolean isReadOnly() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public boolean isReadTimedOut(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMPFieldBridge2.java
public boolean isLoaded(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public String getTableName() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public JDBCType getJDBCType() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean isPrimaryKeyMember() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean isReadOnly() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean isReadTimedOut(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public boolean isLoaded(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void resetPersistenceContext(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public int setInstanceParameters(PreparedStatement ps, int parameterIndex, EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public Object getInstanceValue(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void setInstanceValue(EntityEnterpriseContext ctx, Object value) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public int loadInstanceResults(ResultSet rs, int parameterIndex, EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public int loadArgumentResults(ResultSet rs, int parameterIndex, Object[] argumentRef) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCCMRFieldBridge2.java
public void setClean(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc2/bridge/JDBCEntityBridge2.java
public boolean[] getLoadGroupMask(String eagerLoadGroupName) { // todo throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/EJBQLToSQL92Compiler.java
public Object visit(ASTIdentifier node, Object data) { throw new UnsupportedOperationException("Must not visit ASTIdentifier noe."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCUtil.java
public static Object getParameter(Logger log, CallableStatement cs, int index, int jdbcType, Class destination) throws SQLException { Object value = null; switch(jdbcType) { // // Large types // case Types.CLOB: case Types.LONGVARCHAR: case Types.BLOB: case Types.LONGVARBINARY: throw new UnsupportedOperationException(); // // Small binary types // case Types.BINARY: case Types.VARBINARY: { byte[] bytes = cs.getBytes(index); if(!cs.wasNull()) { if(destination == byte[].class) value = bytes; else value = convertToObject(bytes); } if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Binary, value=" + value); } } break; // // Specialist types that the // driver should handle // case Types.JAVA_OBJECT: case Types.STRUCT: case Types.ARRAY: case Types.OTHER: { value = cs.getObject(index); if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Object, value=" + value); } } break; // // Non-binary types // default: Method method = (Method)csTypes.get(destination.getName()); if(method != null) { try { value = method.invoke(cs, new Object[]{new Integer(index)}); if(cs.wasNull()) { value = null; } if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Simple, value=" + value); } } catch(IllegalAccessException e) { // Whatever, I guess non-binary will not work for this field. } catch(InvocationTargetException e) { // Whatever, I guess non-binary will not work for this field. } } else { value = cs.getObject(index); if(log.isTraceEnabled()) { log.trace("Get result: index=" + index + ", javaType=" + destination.getName() + ", Object, value=" + value); } } } return coerceToJavaType(value, destination); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public InputStream getBinaryStream(long pos, long length) throws SQLException { throw new UnsupportedOperationException("Unimplemented JDK6 method"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public OutputStream setBinaryStream(long pos) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public int setBytes(long pos, byte[] bytes) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public int setBytes(long pos, byte[] bytes, int offset, int length) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/ByteArrayBlob.java
public void truncate(long length) throws SQLException { throw new UnsupportedOperationException("ByteArrayBlob is immutable"); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
public Object visit(ASTLimitOffset node, Object data) { int child = 0; if(node.hasOffset) { Node offsetNode = node.jjtGetChild(child++); if(offsetNode instanceof ASTParameter) { ASTParameter param = (ASTParameter) offsetNode; Class parameterType = getParameterType(param.number); if(int.class != parameterType && Integer.class != parameterType) { throw new UnsupportedOperationException("OFFSET parameter must be an int"); } offsetParam = param.number; } else { ASTExactNumericLiteral param = (ASTExactNumericLiteral) offsetNode; offsetValue = (int) param.value; } } if(node.hasLimit) { Node limitNode = node.jjtGetChild(child); if(limitNode instanceof ASTParameter) { ASTParameter param = (ASTParameter) limitNode; Class parameterType = getParameterType(param.number); if(int.class != parameterType && Integer.class != parameterType) { throw new UnsupportedOperationException("LIMIT parameter must be an int"); } limitParam = param.number; } else { ASTExactNumericLiteral param = (ASTExactNumericLiteral) limitNode; limitValue = (int) param.value; } } return data; }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void remove() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCEntityBridge.java
public void removeAll() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public void setClean(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Object getColumnValue(int index, Object value) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public Object setColumnValue(int index, Object value, Object columnValue) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public boolean hasMapper() { throw new UnsupportedOperationException("hasMapper is not implemented."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public boolean isSearchable() { throw new UnsupportedOperationException("isSearchable is not implemented."); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public JDBCResultSetReader[] getResultSetReaders() { // foreign key fields has their result set readers throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public JDBCParameterSetter[] getParameterSetter() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMRFieldBridge.java
public RelationData getRelationData() { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCAbstractCMRFieldBridge.java
public Object getPrimaryKeyValue(Object o) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/plugins/cmp/jdbc/bridge/JDBCCMP1xFieldBridge.java
public Object getLockedValue(EntityEnterpriseContext ctx) { throw new UnsupportedOperationException("Optimistic locking is not supported in CMP1.1."); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/ejb/GlobalTxEntityMap.java
public void invokeEjbStore(Thread thread, EntityEnterpriseContext instance) { throw new UnsupportedOperationException(); }
// in src/main/java/org/jboss/proxy/ejb/ProxyFactory.java
public boolean isIdentical(Container container, Invocation mi) { throw new UnsupportedOperationException("TODO provide a default implementation"); }
0 0 0 0 0
unknown (Lib) XAException 0 0 12
            
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public Xid[] recover(int flag) throws XAException { log.debug("Recover " + providerName); XAResource xaResource = getDelegate(); try { return xaResource.recover(flag); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public void commit(Xid xid, boolean onePhase) throws XAException { log.debug("Commit " + providerName + " xid " + " onePhase=" + onePhase); XAResource xaResource = getDelegate(); try { xaResource.commit(xid, onePhase); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public void rollback(Xid xid) throws XAException { log.debug("Rollback " + providerName + " xid "); XAResource xaResource = getDelegate(); try { xaResource.rollback(xid); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public void forget(Xid xid) throws XAException { log.debug("Forget " + providerName + " xid "); XAResource xaResource = getDelegate(); try { xaResource.forget(xid); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public boolean isSameRM(XAResource xaRes) throws XAException { if (xaRes instanceof XAResourceWrapper) xaRes = ((XAResourceWrapper) xaRes).getDelegate(); XAResource xaResource = getDelegate(); try { return xaResource.isSameRM(xaRes); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public int prepare(Xid xid) throws XAException { XAResource xaResource = getDelegate(); try { return xaResource.prepare(xid); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public void start(Xid xid, int flags) throws XAException { XAResource xaResource = getDelegate(); try { xaResource.start(xid, flags); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public void end(Xid xid, int flags) throws XAException { XAResource xaResource = getDelegate(); try { xaResource.end(xid, flags); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public int getTransactionTimeout() throws XAException { XAResource xaResource = getDelegate(); try { return xaResource.getTransactionTimeout(); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public boolean setTransactionTimeout(int seconds) throws XAException { XAResource xaResource = getDelegate(); try { return xaResource.setTransactionTimeout(seconds); } catch (XAException e) { throw check(e); } }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
public XAResource getDelegate() throws XAException { XAResource result = null; Exception error = null; try { result = connect(); } catch (Exception e) { error = e; } if (result == null) { XAException xae = new XAException("Error trying to connect to provider " + providerName); xae.errorCode = XAException.XAER_RMERR; if (error != null) xae.initCause(error); log.debug("Cannot get delegate XAResource", xae); throw xae; } return result; }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
protected XAException check(XAException e) throws XAException { if (e.errorCode == XAException.XAER_RMERR || e.errorCode == XAException.XAER_RMFAIL) { log.debug("Fatal error in provider " + providerName, e); close(); } throw e; }
10
            
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
10
            
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
// in src/main/java/org/jboss/jms/recovery/XAResourceWrapper.java
catch (XAException e) { throw check(e); }
0

Miscellanous Metrics

nF = Number of Finally 256
nF = Number of Try-Finally (without catch) 150
Number of Methods with Finally (nMF) 227 / 6251 (3.6%)
Number of Finally with a Continue 0
Number of Finally with a Return 0
Number of Finally with a Throw 7
Number of Finally with a Break 4
Number of different exception types thrown 55
Number of Domain exception types thrown 6
Number of different exception types caught 65
Number of Domain exception types caught 6
Number of exception declarations in signatures 1889
Number of different exceptions types declared in method signatures 58
Number of library exceptions types declared in method signatures 56
Number of Domain exceptions types declared in method signatures 2
Number of Catch with a continue 3
Number of Catch with a return 48
Number of Catch with a Break 1
nbIf = Number of If 5647
nbFor = Number of For 755
Number of Method with an if 1994 / 6251
Number of Methods with a for 495 / 6251
Number of Method starting with a try 121 / 6251 (1.9%)
Number of Expressions 63536
Number of Expressions in try 13061 (20.6%)