Package com.sun.enterprise.config

Examples of com.sun.enterprise.config.ConfigException


     * @param cold java.io.File that is backup/offline (source).
    */
    private void copyFile(File fromFile, File toFile) throws ConfigException
    {
        if(!fromFile.exists())
                throw new ConfigException(Localizer.getValue(ExceptionType.FROM_NOT_EXIST, fromFile.getPath()));

        if(fromFile.isDirectory())
                throw new ConfigException(Localizer.getValue(ExceptionType.FROM_IS_DIR, fromFile.getPath()));

        /** WBN March 14, 2002
         * There is a very strange problem -- Windows will sometimes return 0 for
         * the length of a file that is NOT zero-length.  I tested and proved beyond
         * any doubt that length() is *wrong*.
         * This is probably a JVM bug.  So I've commented-out the following code.
        if(cold.length() <= 0)
        {
                throw new ConfigException(err + coldErr + "is zero length");
        }
        */

        if(toFile.isDirectory())
                throw new ConfigException(Localizer.getValue(ExceptionType.TO_IS_DIR, toFile.getPath()));

        if(toFile.exists() && !toFile.canWrite())
                throw new ConfigException(Localizer.getValue(ExceptionType.TO_READ_ONLY, toFile.getPath()));

        try
        {
                FileUtils.copy(fromFile, toFile);
        }
        catch(Exception e)
        {
      Object[] objs = new Object[] { fromFile.getPath(), toFile.getPath(), e.toString() };
            throw new ConfigException(Localizer.getValue(ExceptionType.FAILED_COPY, objs), e);
        }
    }
View Full Code Here


   
    public String getLocation(String appId) throws ConfigException {
        J2eeApplication app = (J2eeApplication) getJ2eeApplication(appId);
        InstanceEnvironment instEnv;
        if ((instEnv = getInstanceEnvironment()) == null) {
            throw new ConfigException("instEnv was null");
        }
        PropertyResolver resolver = new PropertyResolver(super.configContext,
                instEnv.getName());
        String appLocation;
        if ((appLocation = app.getLocation()) == null) {
            throw new ConfigException("appLocation was null");
        };
        String resolvedPath = resolver.resolve(appLocation);
        return resolvedPath;
       
    }
View Full Code Here

                                                            moduleRoot , appID, parentClassLoader,
                                                            application.getModuleType());
            application.setClassLoader(cl);
        } catch (Exception confEx) {
            _logger.log(Level.SEVERE,"loader.error_while_loading_app_desc", confEx);
            throw new ConfigException(confEx);
        }

        Application fullyLoadedApp = getAppDescriptor(application);
       
        // If needed, write out the new app into the serialized descriptor file.
View Full Code Here

     */
    public Application getAppDescriptor(Application application)
            throws ConfigException {

        if (application == null) {
            throw new ConfigException("Application object should not be null");
        }

        ClassLoader cl = application.getClassLoader();

        // We need to use a temp CL until we are done with validate().
        // See https://glassfish.dev.java.net/issues/show_bug.cgi?id=223
        // for details.
        if (cl instanceof InstrumentableClassLoader) {
            ClassLoader tcl = InstrumentableClassLoader.class.cast(cl).copy();
            application.setClassLoader(tcl);
            // set it in all the bundles as well,
            for (BundleDescriptor bd : (Collection<BundleDescriptor>)
                    application.getBundleDescriptors()) {
                bd.setClassLoader(tcl);
            }
        }
        String appId = application.getRegistrationName();
       
        // we need to load this puppy, save it in the cache...
        try {
            String appDir = getLocation(appId);
            FileArchive in = openDDArchive(appId, appDir);

            ApplicationArchivist archivist = new ApplicationArchivist();
            archivist.setClassLoader(application.getClassLoader());
            archivist.readModulesDescriptors(application, in);
            archivist.readRuntimeDeploymentDescriptor(in, application);
            if(!isSystemAdmin(appId) && !isSystem(appId)) {
                // we need to read persistence descriptors separately
                // because they are read from appDir as oppsed to xmlDir.
                readPersistenceDeploymentDescriptors(appDir, application);
            }
            archivist.setDescriptor(application);

            // use temp CL that is set in the application. For details,
            // see https://glassfish.dev.java.net/issues/show_bug.cgi?id=223
            archivist.validate(application.getClassLoader());
           
            application.setGeneratedXMLDirectory(getGeneratedXMLLocation(appId));
           
            if (!application.getWebServiceDescriptors().isEmpty()) {
                ModuleContentLinker visitor = new ModuleContentLinker(in);
                application.visit((com.sun.enterprise.deployment.util.ApplicationVisitor) visitor);
            }

            // Now that validate() is called, we can set the actual CL.
            // See https://glassfish.dev.java.net/issues/show_bug.cgi?id=223
            // for details.
            application.setClassLoader(cl);
            // set it in all the bundles as well,
            for (BundleDescriptor bd : (Collection<BundleDescriptor>)
                    application.getBundleDescriptors()) {
                bd.setClassLoader(cl);
            }
            registerDescriptor(appId, application);

            return application;
        } catch (ConfigException ce) {
            throw ce;
        } catch (Throwable t) {
      throw new ConfigException(
                Localizer.getValue(ExceptionType.FAIL_DD_LOAD, appId), t);
        }
    }
View Full Code Here

        J2eeApplication app = (J2eeApplication)
            ((Applications)this.configBean).getJ2eeApplicationByName(appId);

        if(app == null)
      throw new ConfigException(
                Localizer.getValue(ExceptionType.APP_NOT_EXIST));
        return app;
       
    }
View Full Code Here

            }
            else
            {
                if(!(roots instanceof String[]))
                {
                    throw new ConfigException(_strMgr.getString("configRootsPropertyIsNotStringArray",
                        ((J2eeApplication)appBean).getName()));    
                }
            }
               
            return (String[])roots;
View Full Code Here

     public static String[] getAppContextRoots(ConfigContext ctx, String appName) throws ConfigException, IASDeploymentException
    {
        ConfigBean appBean = ApplicationHelper.findApplication(ctx, appName);
        if(appBean==null)
        {
            throw new ConfigException(_strMgr.getString("applicationElementIsNotFoundForName", appName));
        }
        return getAppContextRoots(appBean);
    }
View Full Code Here

                        boolean bForceToSetActualValue) throws ConfigException, IASDeploymentException
    {
        ConfigBean appBean = ApplicationHelper.findApplication(ctx, appName);
        if(appBean==null)
        {
            throw new ConfigException(_strMgr.getString("applicationElementIsNotFoundForName", appName));
        }
        resetAppContextRoots(appBean, bForceToSetActualValue);
    }
View Full Code Here

        throws ConfigException, IASDeploymentException
    {
        ConfigBean appBean = ApplicationHelper.findApplication(ctx, appId);
        if(appBean==null)
        {
            throw new ConfigException(_strMgr.getString("applicationElementIsNotFoundForName", appId));
        }
       
        //get context roots for testing element
        String[] ctxRoots = getAppContextRoots(appBean);
        if(ctxRoots==null || ctxRoots.length<=0)
          return null;

        //create target by name
        final Target target = TargetBuilder.INSTANCE.createTarget(
            new TargetType[]{TargetType.CLUSTER, TargetType.SERVER, TargetType.DAS}, targetName, ctx);           
       
        //get apprefs for target
        ApplicationRef[] refs = null;
        if (target.getType() == TargetType.CLUSTER ||
            target.getType() == TargetType.STANDALONE_CLUSTER)
        {
            refs = ClusterHelper.getApplicationReferences(ctx, targetName);
        }
        else
        {
            refs = ServerHelper.getApplicationReferences(ctx, targetName);
        }
           
        if(refs==null)
            return null;
       
        for(int i=0; i<refs.length; i++)
        {
            if(isVSListsIntersected(refs[i].getVirtualServers(), virtualServerList))
            {
                ConfigBean appBeanToCompare = ApplicationHelper.findApplication(ctx, refs[i].getRef());
                if(appBeanToCompare==null)
                {
                    throw new ConfigException(_strMgr.getString("applicationElementIsNotFoundForName", refs[i].getRef()));
                }  
                if(((Object)appBeanToCompare)!=((Object)appBean))
                {
                    String commonElement = (String)getFirstCommonElement(getAppContextRoots(appBeanToCompare), ctxRoots);
                    if(commonElement!=null)
View Full Code Here

        //Resources rbeans = ServerBeansFactory.getServerBean(ctx).getResources();
        Resources rbeans = ServerBeansFactory.getDomainBean(ctx).getResources();

        if (rbeans == null) {
      String msg = localStrings.getString("resourceManager.resource_not_found");
                throw new ConfigException(msg); //XXX
        }
        return rbeans;
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.config.ConfigException

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.