Search in sources :

Example 26 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class WebDeployer method runJSPC.

/**
 * This method setups the in/outDir and classpath and invoke
 * JSPCompiler.
 * @param dc - DeploymentContext to get command parameters and
 *             source directory and compile jsp directory.
 * @throws DeploymentException if JSPCompiler is unsuccessful.
 */
void runJSPC(final DeploymentContext dc) throws DeploymentException {
    final WebBundleDescriptorImpl wbd = dc.getModuleMetaData(WebBundleDescriptorImpl.class);
    try {
        final File outDir = dc.getScratchDir(env.kCompileJspDirName);
        final File inDir = dc.getSourceDir();
        StringBuilder classpath = new StringBuilder(super.getCommonClassPath());
        classpath.append(File.pathSeparatorChar);
        classpath.append(ASClassLoaderUtil.getModuleClassPath(sc.getDefaultServices(), wbd.getApplication().getName(), dc.getCommandParameters(DeployCommandParameters.class).libraries));
        classpath.append(File.pathSeparatorChar);
        classpath.append(super.getModuleClassPath(dc));
        JSPCompiler.compile(inDir, outDir, wbd, classpath.toString(), sc);
    } catch (DeploymentException de) {
        String msg = rb.getString(LogFacade.JSPC_FAILED);
        msg = MessageFormat.format(msg, wbd.getApplication().getName());
        logger.log(Level.SEVERE, msg, de);
        throw de;
    }
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) WebBundleDescriptorImpl(org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl) DeploymentException(org.glassfish.deployment.common.DeploymentException) String(java.lang.String) File(java.io.File)

Example 27 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class AppClientDeployer method generateArtifacts.

@Override
protected void generateArtifacts(DeploymentContext dc) throws DeploymentException {
    // should not handle this module
    if (dc.getModuleMetaData(ApplicationClientDescriptor.class) == null) {
        return;
    }
    try {
        final AppClientDeployerHelper helper = createAndSaveHelper(dc, gfClientModuleClassLoader);
        helper.prepareJARs();
        addArtifactsToDownloads(helper, dc);
        addArtifactsToGeneratedFiles(helper, dc);
        recordUserFriendlyContextRoot(helper, dc);
    } catch (Exception ex) {
        throw new DeploymentException(ex);
    }
}
Also used : DeploymentException(org.glassfish.deployment.common.DeploymentException) ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) IOException(java.io.IOException) DeploymentException(org.glassfish.deployment.common.DeploymentException)

Example 28 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class SafeProperties method initializeHome.

/**
 * Called from the ContainerFactory during initialization.
 */
protected void initializeHome() throws Exception {
    if (isWebServiceEndpoint) {
        EjbBundleDescriptorImpl bundle = ejbDescriptor.getEjbBundleDescriptor();
        WebServicesDescriptor webServices = bundle.getWebServices();
        Collection myEndpoints = webServices.getEndpointsImplementedBy(ejbDescriptor);
        // An ejb can only be exposed through 1 web service endpoint
        Iterator iter = myEndpoints.iterator();
        webServiceEndpoint = (com.sun.enterprise.deployment.WebServiceEndpoint) iter.next();
        Class serviceEndpointIntfClass = loader.loadClass(webServiceEndpoint.getServiceEndpointInterface());
        if (!serviceEndpointIntfClass.isInterface()) {
            ServiceInterfaceGenerator generator = new ServiceInterfaceGenerator(loader, ejbClass);
            serviceEndpointIntfClass = EJBUtils.generateSEI(generator, generator.getGeneratedClass(), loader, this.ejbClass);
            if (serviceEndpointIntfClass == null) {
                throw new RuntimeException(localStrings.getLocalString("ejb.error_generating_sei", "Error in generating service endpoint interface class for EJB class {0}", this.ejbClass));
            }
        }
        Class tieClass = null;
        WebServiceInvocationHandler invocationHandler = new WebServiceInvocationHandler(ejbClass, webServiceEndpoint, serviceEndpointIntfClass, ejbContainerUtilImpl, webServiceInvocationInfoMap);
        invocationHandler.setContainer(this);
        Object servant = (Object) Proxy.newProxyInstance(loader, new Class[] { serviceEndpointIntfClass }, invocationHandler);
        // starting in 2.0, there is no more generated Ties
        if (webServiceEndpoint.getTieClassName() != null) {
            tieClass = loader.loadClass(webServiceEndpoint.getTieClassName());
        }
        // Create a facade for container services to be used by web services runtime.
        EjbEndpointFacade endpointFacade = new EjbEndpointFacadeImpl(this, ejbContainerUtilImpl);
        wsejbEndpointRegistry = Globals.getDefaultHabitat().getService(WSEjbEndpointRegistry.class);
        if (wsejbEndpointRegistry != null) {
            wsejbEndpointRegistry.registerEndpoint(webServiceEndpoint, endpointFacade, servant, tieClass);
        } else {
            throw new DeploymentException(localStrings.getLocalString("ejb.no_webservices_module", "EJB-based Webservice endpoint is detected but there is no webservices module installed to handle it"));
        }
    }
    Map<String, Object> intfsForPortableJndi = new HashMap<String, Object>();
    // Root of portable global JNDI name for this bean
    String javaGlobalName = getJavaGlobalJndiNamePrefix();
    if (isRemote) {
        boolean disableNonPortableJndiName = false;
        Boolean disableInDD = ejbDescriptor.getEjbBundleDescriptor().getDisableNonportableJndiNames();
        if (disableInDD != null) {
            // explicitly set in glassfish-ejb-jar.xml
            disableNonPortableJndiName = disableInDD;
        } else {
            String disableInServer = ejbContainerUtilImpl.getEjbContainer().getPropertyValue(RuntimeTagNames.DISABLE_NONPORTABLE_JNDI_NAMES);
            disableNonPortableJndiName = Boolean.valueOf(disableInServer);
        }
        String glassfishSpecificJndiName = null;
        if (!disableNonPortableJndiName) {
            // This is either the default glassfish-specific (non-portable)
            // global JNDI name or the one specified via mappedName(), sun-ejb-jar.xml,
            // etc.
            glassfishSpecificJndiName = ejbDescriptor.getJndiName();
            // clashes.
            if ((glassfishSpecificJndiName != null) && (glassfishSpecificJndiName.equals("") || glassfishSpecificJndiName.equals(javaGlobalName))) {
                glassfishSpecificJndiName = null;
            }
        }
        if (hasRemoteHomeView) {
            this.ejbHomeImpl = instantiateEJBHomeImpl();
            this.ejbHome = ejbHomeImpl.getEJBHome();
            // Since some containers might create multiple EJBObjects for
            // the same ejb, make sure we use the same Proxy class to
            // instantiate all the proxy instances.
            ejbObjectProxyClass = Proxy.getProxyClass(loader, new Class[] { remoteIntf });
            ejbObjectProxyCtor = ejbObjectProxyClass.getConstructor(new Class[] { InvocationHandler.class });
            // 
            // Make sure all Home/Remote interfaces conform to RMI-IIOP
            // rules.  Checking for conformance here keeps the exposed
            // deployment/startup error behavior consistent since when
            // rmic is used during codegen it makes equivalent checks and
            // treats any validation problems as fatal errors.
            // 
            // These same checks will be made when setTarget is called
            // in POARemoteReferenceFactory.preinvoke, but that happens
            // only when the actual invocation is made, so it's better to
            // know at container initialization time if there is a problem.
            // 
            getProtocolManager().validateTargetObjectInterfaces(this.ejbHome);
            // Unlike the Home, each of the concrete containers are
            // responsible for creating the EJBObjects, so just create
            // a dummy EJBObjectImpl for validation purposes.
            EJBObjectImpl dummyEJBObjectImpl = instantiateEJBObjectImpl();
            EJBObject dummyEJBObject = (EJBObject) dummyEJBObjectImpl.getEJBObject();
            getProtocolManager().validateTargetObjectInterfaces(dummyEJBObject);
            // Remotereference factory needs instances of
            // Home and Remote to get repository Ids since it doesn't have
            // stubs and ties.  This must be done before any Home or Remote
            // references are created.
            remoteHomeRefFactory.setRepositoryIds(homeIntf, remoteIntf);
            // get a remote ref for the EJBHome
            ejbHomeStub = (EJBHome) remoteHomeRefFactory.createHomeReference(homeInstanceKey);
            // Add 2.x Home for later portable JNDI name processing.
            intfsForPortableJndi.put(ejbDescriptor.getHomeClassName(), ejbHomeStub);
            // this was the original use of the jndi name.
            if (glassfishSpecificJndiName != null) {
                JndiInfo jndiInfo = JndiInfo.newNonPortableRemote(glassfishSpecificJndiName, ejbHomeStub);
                jndiInfoMap.put(jndiInfo.name, jndiInfo);
            }
        }
        if (hasRemoteBusinessView) {
            this.ejbRemoteBusinessHomeImpl = instantiateEJBRemoteBusinessHomeImpl();
            this.ejbRemoteBusinessHome = ejbRemoteBusinessHomeImpl.getEJBHome();
            // RMI-IIOP validation
            getProtocolManager().validateTargetObjectInterfaces(this.ejbRemoteBusinessHome);
            for (RemoteBusinessIntfInfo next : remoteBusinessIntfInfo.values()) {
                next.proxyClass = Proxy.getProxyClass(loader, new Class[] { next.generatedRemoteIntf });
                next.proxyCtor = next.proxyClass.getConstructor(new Class[] { InvocationHandler.class });
                // Remotereference factory needs instances of
                // Home and Remote to get repository Ids since it
                // doesn't have stubs and ties.  This must be done before
                // any Home or Remote references are created.
                next.referenceFactory.setRepositoryIds(remoteBusinessHomeIntf, next.generatedRemoteIntf);
                // selected, so just do it the first time through the loop.
                if (ejbRemoteBusinessHomeStub == null) {
                    ejbRemoteBusinessHomeStub = (EJBHome) next.referenceFactory.createHomeReference(homeInstanceKey);
                }
            }
            EJBObjectImpl dummyEJBObjectImpl = instantiateRemoteBusinessObjectImpl();
            // Internal jndi name under which remote business home is registered for
            // glassfish-specific remote business JNDI names
            String remoteBusinessHomeJndiName = null;
            if (glassfishSpecificJndiName != null) {
                remoteBusinessHomeJndiName = EJBUtils.getRemote30HomeJndiName(glassfishSpecificJndiName);
            }
            // Convenience location for common case of 3.0 session bean with only
            // 1 remote business interface and no adapted remote home.  Allows a
            // stand-alone client to access 3.0 business interface by using simple
            // jndi name.  Each remote business interface is also always available
            // at <jndi-name>#<business_interface_name>.  This is needed for the
            // case where the bean has an adapted remote home and/or multiple business
            // interfaces.
            String simpleRemoteBusinessJndiName = null;
            if ((glassfishSpecificJndiName != null) && !hasRemoteHomeView && remoteBusinessIntfInfo.size() == 1) {
                simpleRemoteBusinessJndiName = glassfishSpecificJndiName;
            }
            // We need a separate name for the internal generated home object to
            // support the portable global JNDI names for business interfaces.
            // There won't necessarily be a glassfish-specific name specified so
            // it's cleaner to just always use a separate ones.
            String internalHomeJndiNameForPortableRemoteNames = EJBUtils.getRemote30HomeJndiName(javaGlobalName);
            for (RemoteBusinessIntfInfo next : remoteBusinessIntfInfo.values()) {
                java.rmi.Remote dummyEJBObject = dummyEJBObjectImpl.getEJBObject(next.generatedRemoteIntf.getName());
                getProtocolManager().validateTargetObjectInterfaces(dummyEJBObject);
                if (glassfishSpecificJndiName != null) {
                    next.jndiName = EJBUtils.getRemoteEjbJndiName(true, next.remoteBusinessIntf.getName(), glassfishSpecificJndiName);
                    Reference remoteBusRef = new Reference(next.remoteBusinessIntf.getName(), new StringRefAddr("url", remoteBusinessHomeJndiName), "com.sun.ejb.containers.RemoteBusinessObjectFactory", null);
                    // Glassfish-specific JNDI name for fully-qualified 3.0 Remote business interface.
                    JndiInfo jndiInfo = JndiInfo.newNonPortableRemote(next.jndiName, remoteBusRef);
                    jndiInfoMap.put(jndiInfo.name, jndiInfo);
                }
                if (simpleRemoteBusinessJndiName != null) {
                    Reference remoteBusRef = new Reference(next.remoteBusinessIntf.getName(), new StringRefAddr("url", remoteBusinessHomeJndiName), "com.sun.ejb.containers.RemoteBusinessObjectFactory", null);
                    // Glassfish-specific JNDI name for simple 3.0 Remote business interface lookup.
                    // Applicable when the bean exposes only a single Remote 3.x client view.
                    JndiInfo jndiInfo = JndiInfo.newNonPortableRemote(simpleRemoteBusinessJndiName, remoteBusRef);
                    jndiInfoMap.put(jndiInfo.name, jndiInfo);
                }
                Reference remoteBusRef = new Reference(next.remoteBusinessIntf.getName(), new StringRefAddr("url", internalHomeJndiNameForPortableRemoteNames), "com.sun.ejb.containers.RemoteBusinessObjectFactory", null);
                // Always register portable JNDI name for each remote business view
                intfsForPortableJndi.put(next.remoteBusinessIntf.getName(), remoteBusRef);
            }
            if (remoteBusinessHomeJndiName != null) {
                // Glassfish-specific JNDI name for internal generated
                // home object used by container
                JndiInfo jndiInfo = JndiInfo.newNonPortableRemote(remoteBusinessHomeJndiName, ejbRemoteBusinessHomeStub);
                jndiInfo.setInternal(true);
                jndiInfoMap.put(jndiInfo.name, jndiInfo);
            }
            // Always registeer internal name for home in support of portable global
            // remote business JNDI names.
            JndiInfo jndiInfo = JndiInfo.newPortableRemote(internalHomeJndiNameForPortableRemoteNames, ejbRemoteBusinessHomeStub);
            jndiInfo.setInternal(true);
            jndiInfoMap.put(jndiInfo.name, jndiInfo);
            // lookup logic that depends on ejbDescriptor.getJndiName() will work.
            if (glassfishSpecificJndiName == null) {
                ejbDescriptor.setJndiName(javaGlobalName);
            }
        }
    }
    if (isLocal) {
        if (hasLocalHomeView) {
            this.ejbLocalHomeImpl = instantiateEJBLocalHomeImpl();
            this.ejbLocalHome = ejbLocalHomeImpl.getEJBLocalHome();
            // Since some containers might create multiple EJBLocalObjects
            // for the same ejb, make sure we use the same Proxy class to
            // instantiate all the proxy instances.
            Class ejbLocalObjectProxyClass = Proxy.getProxyClass(loader, new Class[] { IndirectlySerializable.class, localIntf });
            ejbLocalObjectProxyCtor = ejbLocalObjectProxyClass.getConstructor(new Class[] { InvocationHandler.class });
            // Portable JNDI name for EJB 2.x LocalHome.  We don't provide a
            // glassfish-specific way of accessing Local EJBs.
            JavaGlobalJndiNamingObjectProxy namingProxy = new JavaGlobalJndiNamingObjectProxy(this, localHomeIntf.getName());
            intfsForPortableJndi.put(localHomeIntf.getName(), namingProxy);
        }
        if (hasLocalBusinessView) {
            ejbLocalBusinessHomeImpl = instantiateEJBLocalBusinessHomeImpl();
            ejbLocalBusinessHome = (GenericEJBLocalHome) ejbLocalBusinessHomeImpl.getEJBLocalHome();
            Class[] proxyInterfaces = new Class[localBusinessIntfs.size() + 1];
            proxyInterfaces[0] = IndirectlySerializable.class;
            int index = 1;
            for (Class next : localBusinessIntfs) {
                proxyInterfaces[index] = next;
                index++;
            }
            Class proxyClass = Proxy.getProxyClass(loader, proxyInterfaces);
            ejbLocalBusinessObjectProxyCtor = proxyClass.getConstructor(new Class[] { InvocationHandler.class });
            for (Class next : localBusinessIntfs) {
                // Portable JNDI name for EJB 3.x Local business interface.
                // We don't provide a glassfish-specific way of accessing Local EJBs.
                JavaGlobalJndiNamingObjectProxy namingProxy = new JavaGlobalJndiNamingObjectProxy(this, next.getName());
                intfsForPortableJndi.put(next.getName(), namingProxy);
            }
        }
        if (hasOptionalLocalBusinessView) {
            EJBLocalHomeImpl obj = instantiateEJBOptionalLocalBusinessHomeImpl();
            ejbOptionalLocalBusinessHomeImpl = (EJBLocalHomeImpl) obj;
            ejbOptionalLocalBusinessHome = (GenericEJBLocalHome) ejbOptionalLocalBusinessHomeImpl.getEJBLocalHome();
            Class[] proxyInterfaces = new Class[2];
            proxyInterfaces[0] = IndirectlySerializable.class;
            String optionalIntfName = EJBUtils.getGeneratedOptionalInterfaceName(ejbClass.getName());
            proxyInterfaces[1] = ejbGeneratedOptionalLocalBusinessIntfClass = optIntfClassLoader.loadClass(optionalIntfName);
            Class proxyClass = Proxy.getProxyClass(loader, proxyInterfaces);
            ejbOptionalLocalBusinessObjectProxyCtor = proxyClass.getConstructor(new Class[] { InvocationHandler.class });
            // Portable JNDI name for no-interface view.
            // We don't provide a glassfish-specific way of accessing the
            // no-interface view of a session bean.
            JavaGlobalJndiNamingObjectProxy namingProxy = new JavaGlobalJndiNamingObjectProxy(this, ejbClass.getName());
            intfsForPortableJndi.put(ejbClass.getName(), namingProxy);
        }
    }
    for (Map.Entry<String, Object> entry : intfsForPortableJndi.entrySet()) {
        String intf = entry.getKey();
        String fullyQualifiedJavaGlobalName = javaGlobalName + "!" + intf;
        Object namingProxy = entry.getValue();
        boolean local = (namingProxy instanceof JavaGlobalJndiNamingObjectProxy);
        if (intfsForPortableJndi.size() == 1) {
            JndiInfo jndiInfo = local ? JndiInfo.newPortableLocal(javaGlobalName, namingProxy) : JndiInfo.newPortableRemote(javaGlobalName, namingProxy);
            jndiInfoMap.put(jndiInfo.name, jndiInfo);
        }
        JndiInfo jndiInfo = local ? JndiInfo.newPortableLocal(fullyQualifiedJavaGlobalName, namingProxy) : JndiInfo.newPortableRemote(fullyQualifiedJavaGlobalName, namingProxy);
        jndiInfoMap.put(jndiInfo.name, jndiInfo);
    }
    for (Map.Entry<String, JndiInfo> entry : jndiInfoMap.entrySet()) {
        JndiInfo jndiInfo = entry.getValue();
        try {
            jndiInfo.publish(this.namingManager);
            if (jndiInfo.internal) {
                publishedInternalGlobalJndiNames.add(jndiInfo.name);
            } else {
                if (jndiInfo.portable) {
                    publishedPortableGlobalJndiNames.add(jndiInfo.name);
                } else {
                    publishedNonPortableGlobalJndiNames.add(jndiInfo.name);
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(localStrings.getLocalString("ejb.error_binding_jndi_name", "Error while binding JNDI name {0} for EJB {1}", jndiInfo.name, this.ejbDescriptor.getName()), e);
        }
    }
    if (!publishedPortableGlobalJndiNames.isEmpty()) {
        _logger.log(Level.INFO, PORTABLE_JNDI_NAMES, new Object[] { this.ejbDescriptor.getName(), publishedPortableGlobalJndiNames });
    }
    if (!publishedNonPortableGlobalJndiNames.isEmpty()) {
        _logger.log(Level.INFO, GLASSFISH_SPECIFIC_JNDI_NAMES, new Object[] { this.ejbDescriptor.getName(), publishedNonPortableGlobalJndiNames });
    }
    if (!publishedInternalGlobalJndiNames.isEmpty()) {
        _logger.log(Level.FINE, "Internal container JNDI names for EJB {0}: {1}", new Object[] { this.ejbDescriptor.getName(), publishedInternalGlobalJndiNames });
    }
    // set EJBMetaData
    setEJBMetaData();
}
Also used : ServiceInterfaceGenerator(com.sun.ejb.codegen.ServiceInterfaceGenerator) HashMap(java.util.HashMap) EjbEndpointFacade(org.glassfish.ejb.api.EjbEndpointFacade) WSEjbEndpointRegistry(org.glassfish.ejb.spi.WSEjbEndpointRegistry) EJBObject(javax.ejb.EJBObject) Iterator(java.util.Iterator) com.sun.enterprise.deployment(com.sun.enterprise.deployment) Reference(javax.naming.Reference) InvocationHandler(java.lang.reflect.InvocationHandler) TransactionRequiredLocalException(javax.ejb.TransactionRequiredLocalException) EJBAccessException(javax.ejb.EJBAccessException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EJBException(javax.ejb.EJBException) DeploymentException(org.glassfish.deployment.common.DeploymentException) AccessException(java.rmi.AccessException) AccessLocalException(javax.ejb.AccessLocalException) TransactionRolledbackLocalException(javax.ejb.TransactionRolledbackLocalException) SystemException(javax.transaction.SystemException) NoSuchEJBException(javax.ejb.NoSuchEJBException) NamingException(javax.naming.NamingException) RemoveException(javax.ejb.RemoveException) EJBTransactionRequiredException(javax.ejb.EJBTransactionRequiredException) EJBTransactionRolledbackException(javax.ejb.EJBTransactionRolledbackException) RemoteException(java.rmi.RemoteException) RollbackException(javax.transaction.RollbackException) FinderException(javax.ejb.FinderException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException) StringRefAddr(javax.naming.StringRefAddr) Collection(java.util.Collection) EJBLocalObject(javax.ejb.EJBLocalObject) EJBObject(javax.ejb.EJBObject) DeploymentException(org.glassfish.deployment.common.DeploymentException) Map(java.util.Map) MethodMap(com.sun.ejb.containers.util.MethodMap) HashMap(java.util.HashMap)

Example 29 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class EventsImpl method send.

@Override
public void send(final Event event, boolean asynchronously) {
    List<EventListener> l = new ArrayList<EventListener>();
    l.addAll(listeners);
    for (final EventListener listener : l) {
        Method m = null;
        try {
            // check if the listener is interested with his event.
            m = listener.getClass().getMethod("event", Event.class);
        } catch (Throwable ex) {
            // We need to catch Throwable, otherwise we can server not to
            // shutdown when the following happens:
            // Assume a bundle which has registered a event listener
            // has been uninstalled without unregistering the listener.
            // listener.getClass() refers to a class of such an uninstalled
            // bundle. If framework has been refreshed, then the
            // classloader can't be used further to load any classes.
            // As a result, an exception like NoClassDefFoundError is thrown
            // from getMethod.
            logger.log(Level.SEVERE, KernelLoggerInfo.exceptionSendEvent, ex);
        }
        if (m != null) {
            RestrictTo fooBar = m.getParameterTypes()[0].getAnnotation(RestrictTo.class);
            if (fooBar != null) {
                EventTypes interested = EventTypes.create(fooBar.value());
                if (!event.is(interested)) {
                    continue;
                }
            }
        }
        if (asynchronously) {
            executor.submit(new Runnable() {

                @Override
                public void run() {
                    try {
                        listener.event(event);
                    } catch (Throwable e) {
                        logger.log(Level.WARNING, KernelLoggerInfo.exceptionDispatchEvent, e);
                    }
                }
            });
        } else {
            try {
                listener.event(event);
            } catch (DeploymentException de) {
                // we re-throw the exception to abort the deployment
                throw de;
            } catch (Throwable e) {
                logger.log(Level.WARNING, KernelLoggerInfo.exceptionDispatchEvent, e);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Event(org.glassfish.api.event.EventListener.Event) RestrictTo(org.glassfish.api.event.RestrictTo) EventTypes(org.glassfish.api.event.EventTypes) DeploymentException(org.glassfish.deployment.common.DeploymentException) EventListener(org.glassfish.api.event.EventListener) Method(java.lang.reflect.Method)

Example 30 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class JSPCompiler method compile.

// //////////////////////////////////////////////////////////////////////////
public static void compile(File inWebDir, File outWebDir, WebBundleDescriptor wbd, String classpath, ServerContext serverContext) throws DeploymentException {
    JspC jspc = new JspC();
    if (classpath != null && classpath.length() > 0) {
        jspc.setClassPath(classpath);
    }
    // START SJSAS 6311155
    String appName = wbd.getApplication().getName();
    // so far, this is not segragated per web bundle, all web-bundles will get the
    // same sysClassPath
    String sysClassPath = ASClassLoaderUtil.getModuleClassPath(serverContext.getDefaultServices(), appName, null);
    jspc.setSystemClassPath(sysClassPath);
    // END SJSAS 6311155
    verify(inWebDir, outWebDir);
    configureJspc(jspc, wbd);
    jspc.setOutputDir(outWebDir.getAbsolutePath());
    jspc.setUriroot(inWebDir.getAbsolutePath());
    jspc.setCompile(true);
    logger.log(Level.INFO, LogFacade.START_MESSAGE);
    try {
        jspc.execute();
    } catch (Exception je) {
        throw new DeploymentException("JSP Compilation Error: " + je, je);
    } finally {
        // bnevins 9-9-03 -- There may be no jsp files in this web-module
        // in such a case the code above will create a useless, and possibly
        // problematic empty directory.	 If the directory is empty -- delete
        // the directory.
        String[] files = outWebDir.list();
        if (files == null || files.length <= 0) {
            if (!outWebDir.delete()) {
                logger.log(Level.FINE, LogFacade.CANNOT_DELETE_FILE, outWebDir);
            }
        }
        logger.log(Level.INFO, LogFacade.FINISH_MESSAGE);
    }
}
Also used : DeploymentException(org.glassfish.deployment.common.DeploymentException) DeploymentException(org.glassfish.deployment.common.DeploymentException) JspC(org.apache.jasper.JspC)

Aggregations

DeploymentException (org.glassfish.deployment.common.DeploymentException)30 IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)8 IOException (java.io.IOException)6 Application (com.sun.enterprise.deployment.Application)4 File (java.io.File)4 ResourceException (javax.resource.ResourceException)4 ResourceConflictException (org.glassfish.resourcebase.resources.api.ResourceConflictException)4 Iterator (java.util.Iterator)3 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)3 Resource (com.sun.enterprise.config.serverbeans.Resource)2 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)2 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)2 ArrayList (java.util.ArrayList)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 OpsParams (org.glassfish.api.deployment.OpsParams)2 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)2 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)2 SAXException (org.xml.sax.SAXException)2 SAXParseException (org.xml.sax.SAXParseException)2 ServiceInterfaceGenerator (com.sun.ejb.codegen.ServiceInterfaceGenerator)1