Package org.glassfish.deployment.common

Examples of org.glassfish.deployment.common.DeploymentException


        try {
            InputStream is = openByteCodeStream(mainClassResourceName);
            AppClientDeployerHelper.copyStream(is, os);
            is.close();
        } catch (Exception e) {
            throw new DeploymentException(e);
        }

    }
View Full Code Here


                        application.getRegistrationName());
            }

        } catch (GeneratorException e) {
            _logger.warning(e.getMessage());
            throw new DeploymentException(e);

        } catch (Throwable e) {
            String eType = e.getClass().getName();
            String appName = application.getRegistrationName();
            String exMsg = e.getMessage();

            String msg = null;
            if (bundle == null) {
                // Application or compilation error
                msg = I18NHelper.getMessage(messages,
                    "cmpc.cmp_app_error", eType, appName, exMsg);
            } else {
                String bundleName = bundle.getModuleDescriptor().getArchiveUri();
                if (beanName == null) {
                    // Module processing error
                    msg = I18NHelper.getMessage(messages,
                        "cmpc.cmp_module_error",
                        new Object[] {eType, appName, bundleName, exMsg});
                } else {
                    // CMP bean generation error
                    msg = I18NHelper.getMessage(messages,
                        "cmpc.cmp_bean_error",
                        new Object[] {eType, beanName, appName, bundleName, exMsg});
                }
            }

            _logger.log(Logger.SEVERE, msg, e);

            throw new DeploymentException(msg);
        }

        if (generatorExceptionMsg != null) {
            // We already logged each separate part.
            throw new DeploymentException(generatorExceptionMsg.toString());
        }
    }
View Full Code Here

      try {
    initCMRFieldStuff();
      } catch ( Exception ex ) {
                DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                    new Object[] {ex.toString()});
    throw new DeploymentException(ex);
      }
  }
  return cmrFieldInfo;
    }
View Full Code Here

  CMRFieldInfo[] cmrf = this.getCMRFieldInfo();
  for ( int i=0; i<cmrf.length; i++ ) {
      if ( cmrf[i].name.equals(fieldName) )
    return cmrf[i];
  }
  throw new DeploymentException("CMRFieldInfo not found for field "+fieldName);
    }
View Full Code Here

      pkeyStuffInitialized = true;
  }
  catch ( Exception ex ) {
            DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                new Object[] {ex.toString()});
            throw new DeploymentException(ex);
  }
    }
View Full Code Here

    {
  if ( stateClass == null ) {
      stateClass = getPersistentClass();
      if ( parentDesc.isEJB20() ) {
    if( !Modifier.isAbstract(stateClass.getModifiers()) ) {
              throw new DeploymentException("2.x CMP bean class "
                        + stateClass.getName() + " must be decleared abstract "
                        + "or cmp-version for the corresponding bean must be set to 1.x.");
                }
          String stateClassName = parentDesc.getStateImplClassName();
          stateClass = getClass(stateClassName);
View Full Code Here

    private Class getClass(String className)
    {           
  try {
      return getEjbBundleDescriptor().getClassLoader().loadClass(className);
  } catch ( Exception ex ) {
      throw new DeploymentException(ex);
  }
    }
View Full Code Here

      initializeFieldInfo();
  for ( int i=0; i<persFieldInfo.length; i++ ) {
      if ( persFieldInfo[i].name.equals(fieldName) )
    return persFieldInfo[i];
  }
  throw new DeploymentException("PersistentFieldInfo not found for field "+fieldName);
    }
View Full Code Here

      initializeFieldInfo();
  for ( int i=0; i<pkeyFieldInfo.length; i++ ) {
      if ( pkeyFieldInfo[i].name.equals(fieldName) )
    return pkeyFieldInfo[i];
  }
  throw new DeploymentException("PersistentFieldInfo not found for pkey field "+fieldName);
    }
View Full Code Here

  if ( !pkeyStuffInitialized )
      initPkeyInfo();

  int cmpFieldCount = cmpFields.size();
        if (cmpFieldCount==0) {
            throw new DeploymentException("No cmp field defined for CMP EJB " + parentDesc.getName());
        }

  int fkeyCount = 0;
  if ( fkeyFields != null )
      fkeyCount = fkeyFields.length;

  persFieldInfo = new PersistentFieldInfo[cmpFieldCount + fkeyCount];
  // Add CMP fields
  int fcount = 0;
  Iterator itr = cmpFields.iterator();
  while ( itr.hasNext() ) {
      persFieldInfo[fcount] = new PersistentFieldInfo();
      persFieldInfo[fcount].name =((FieldDescriptor)itr.next()).getName();
      fcount++;
  }
  // Add foreign key fields
  if ( fkeyFields != null ) {
      for ( int i=0; i<fkeyFields.length; i++ ) {
    persFieldInfo[fcount] = fkeyFields[i];
    fcount++;
      }
  }

  // sort persFieldInfo in alphabetical order
        for ( int i=persFieldInfo.length-1; i>0; i-- ) {
            for ( int j=0; j<i; j++ ) {
                if ( persFieldInfo[j].name.compareTo(persFieldInfo[j+1].name)
                  > 0 ) {
                    PersistentFieldInfo tmp = persFieldInfo[j];
                    persFieldInfo[j] = persFieldInfo[j+1];
                    persFieldInfo[j+1] = tmp;
                }
            }
        }

        // Initialize pkeyFieldInfo[] and persNoPkeyFieldInfo[]
  // They contain the same PersistentFieldInfo objects as persFieldInfo.
        pkeyFieldInfo = new PersistentFieldInfo[pkeyFields.size()];
  if ( pkeyFieldSpecified ) {

            // check if PK class has public non-persistent fields
            StringBuffer nonPersFieldsInPK = new StringBuffer();
            for ( Iterator it=pkeyFields.iterator(); it.hasNext(); ) {
                FieldDescriptor fd = (FieldDescriptor)it.next();
                boolean isPersistent = false;
                for ( int i=0; i<persFieldInfo.length; i++ ) {
                    if ( fd.getName().equals(persFieldInfo[i].name) ) {
                        isPersistent = true;
                        break;
                    }
                }
                if ( !isPersistent ) {
                    // if not the first non-persistent field
                    if ( nonPersFieldsInPK.length() != 0 ) {
                        nonPersFieldsInPK.append(", ");
                    }
                    nonPersFieldsInPK.append(fd.getName());
                }
            }
            if ( nonPersFieldsInPK.length() != 0 ) {
                throw new DeploymentException(localStrings.getLocalString(
                "enterprise.deployment.pkhasnopersistentfields",
                "CMP bean [{0}], primary key class [{1}] has " +
                "public non-persistent field(s) [{2}].",
                new Object[] {getParentDescriptor().getName(),
                primaryKeyClassName,
                nonPersFieldsInPK.toString()}));
            }

      persNoPkeyFieldInfo = new PersistentFieldInfo[persFieldInfo.length -
                pkeyFieldInfo.length];
      int pkeyCount = 0;
      int noPkeyCount = 0;
      for ( int i=0; i<persFieldInfo.length; i++ ) {
    boolean isPkey = false;
    for ( Iterator it=pkeyFields.iterator(); it.hasNext(); ) {
        FieldDescriptor fd = (FieldDescriptor)it.next();
        if ( fd.getName().equals(persFieldInfo[i].name) ) {
      isPkey = true;
      break;
        }
    }
    if ( isPkey )
        pkeyFieldInfo[pkeyCount++] = persFieldInfo[i];
    else
        persNoPkeyFieldInfo[noPkeyCount++] = persFieldInfo[i];
      }
  }

  if ( pkeyIsOneField  && pkeyFieldSpecified) {
      // Initialize pkey field type. This is needed for
      // beans with no pkey field (i.e. PM-generated pkey)
      // because they wont have get/set for the pkey in the bean class
      // so the getCMPFieldType() below will bomb if type is not set.
      // Note: pkeyFieldInfo and persFieldInfo arrays share the same
      // PersistentFieldInfo objects.
      pkeyFieldInfo[0].type = getPrimaryKeyClass();
  }

  // Initialize Java types in persFieldInfo
  for ( int i=0; i<persFieldInfo.length; i++ ) {
      // fill type for CMP fields if not there
      // (fkey types will already be filled)
      if ( persFieldInfo[i].type == null )
          persFieldInfo[i].type = getCMPFieldType(persFieldInfo[i].name);
        }

        // When called from Deploytool, the bean class is abstract,
        // and doesnt have the CMP fields: they will be in the generated
        // code after deployment. So all the java.lang.reflect.Field
  // values in PersistentFieldInfo can only be initialized at runtime.
  try {
      if ( persistentClass != null
     && !Modifier.isAbstract(persistentClass.getModifiers()) ) {
    for ( int i=0; i<persFieldInfo.length; i++ ) {
        persFieldInfo[i].field = getField(getStateClass(),
                  persFieldInfo[i].name);
    }
      }

      // Initialize pkeyClassPkeyFields
      if ( !pkeyIsOneField && primaryKeyClass != null
                 && !Modifier.isAbstract(primaryKeyClass.getModifiers()) ) {
    pkeyClassPkeyFields = new Field[pkeyFieldInfo.length];
    for ( int i=0; i<pkeyFieldInfo.length; i++ ) {
        pkeyClassPkeyFields[i] = primaryKeyClass.getField(
              pkeyFieldInfo[i].name);
    }
      }
  } catch ( NoSuchFieldException ex ) {
            if(DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {           
                DOLUtils.getDefaultLogger().log(Level.FINE, ex.toString(), ex);
            }
      throw new DeploymentException(ex);
  }

        fieldInfoInitialized = true;
    }
View Full Code Here

TOP

Related Classes of org.glassfish.deployment.common.DeploymentException

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