use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.
the class SecurityDeployer method removePolicy.
private void removePolicy(DeploymentContext dc) throws DeploymentException {
OpsParams params = dc.getCommandParameters(OpsParams.class);
if (!params.origin.needsCleanArtifacts()) {
return;
}
String appName = params.name();
// Remove policy files only if managers are not destroyed by cleanup
try {
String[] webcontexts = wsmf.getContextsForApp(appName, false);
if (webcontexts != null) {
for (int i = 0; i < webcontexts.length; i++) {
if (webcontexts[i] != null) {
websecurityProbeProvider.policyDestructionStartedEvent(webcontexts[i]);
SecurityUtil.removePolicy(webcontexts[i]);
websecurityProbeProvider.policyDestructionEndedEvent(webcontexts[i]);
websecurityProbeProvider.policyDestructionEvent(webcontexts[i]);
}
}
}
} catch (IASSecurityException ex) {
String msg = "Error in removing security policy for " + appName;
_logger.log(Level.WARNING, msg, ex);
throw new DeploymentException(msg, ex);
}
// Destroy the managers if present
cleanSecurityContext(appName);
/*
* From V2 but keep commented until need is discovered //remove any remaining policy //This is to address the bug where
* the CONTEXT_ID in //WebSecurityManagerFactory is not properly populated. //We force the sub-modules to be removed in
* this case. //This should not impact undeploy performance on DAS. //This needs to be fixed better later. String
* policyRootDir = System.getProperty( "com.sun.enterprise.jaccprovider.property.repository"); if (policyRootDir !=
* null) { List<String> contextIds = new ArrayList<String>(); File policyDir = new File(policyRootDir + File.separator +
* appName); if (policyDir.exists()) { File[] policies = policyDir.listFiles(); for (int i = 0; i < policies.length;
* i++) { if (policies[i].isDirectory()) { contextIds.add(appName + '/' + policies[i].getName()); } } } else { //we
* tried. give up now. } if (contextIds.size() > 0) { for (String cId : contextIds) { SecurityUtil.removePolicy(cId); }
* } }
*/
}
use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.
the class SecurityDeployer method generateArtifacts.
// creates security policy if needed
@Override
protected void generateArtifacts(DeploymentContext dc) throws DeploymentException {
OpsParams params = dc.getCommandParameters(OpsParams.class);
if (params.origin.isArtifactsPresent()) {
return;
}
String appName = params.name();
try {
Application app = dc.getModuleMetaData(Application.class);
Set<WebBundleDescriptor> webDesc = app.getBundleDescriptors(WebBundleDescriptor.class);
if (webDesc == null) {
return;
}
for (WebBundleDescriptor webBD : webDesc) {
loadPolicy(webBD, false);
}
} catch (Exception se) {
String msg = "Error in generating security policy for " + appName;
throw new DeploymentException(msg, se);
}
}
use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.
the class CMPDeployerImpl method deploy.
/**
* Generates the concrete impls for all CMPs in the application.
*
* @throws DeploymentException if this exception was thrown while generating concrete impls
*/
public void deploy(DeploymentContext ctx) throws DeploymentException {
// deployment descriptor object representation for the archive
Application application = null;
// deployment descriptor object representation for each module
EjbBundleDescriptorImpl bundle = null;
// ejb name
String beanName = null;
// GeneratorException message if any
StringBuffer generatorExceptionMsg = null;
try {
CMPGenerator gen = new JDOCodeGenerator();
// stubs dir for the current deployment (generated/ejb)
// NOI18N
File stubsDir = ctx.getScratchDir("ejb");
application = ctx.getModuleMetaData(Application.class);
if (_logger.isLoggable(Logger.FINE)) {
// NOI18N
_logger.fine(// NOI18N
"cmpc.processing_cmp", application.getRegistrationName());
}
List<File> cmpFiles = new ArrayList<File>();
final ClassLoader jcl = application.getClassLoader();
bundle = ctx.getModuleMetaData(EjbBundleDescriptorImpl.class);
// This gives the dir where application is exploded
String archiveUri = ctx.getSource().getURI().getSchemeSpecificPart();
if (_logger.isLoggable(Logger.FINE)) {
_logger.fine(// NOI18N
"[CMPC] Module Dir name is " + archiveUri);
}
// xml dir for the current deployment (generated/xml)
String generatedXmlsPath = ctx.getScratchDir("xml").getCanonicalPath();
if (_logger.isLoggable(Logger.FINE)) {
_logger.fine(// NOI18N
"[CMPC] Generated XML Dir name is " + generatedXmlsPath);
}
try {
long start = System.currentTimeMillis();
gen.init(bundle, ctx, archiveUri, generatedXmlsPath);
Iterator ejbs = bundle.getEjbs().iterator();
while (ejbs.hasNext()) {
EjbDescriptor desc = (EjbDescriptor) ejbs.next();
beanName = desc.getName();
if (_logger.isLoggable(Logger.FINE)) {
_logger.fine(// NOI18N
"[CMPC] Ejb Class Name: " + desc.getEjbClassName());
}
if (desc instanceof IASEjbCMPEntityDescriptor) {
// generate concrete CMP class implementation
IASEjbCMPEntityDescriptor entd = (IASEjbCMPEntityDescriptor) desc;
if (_logger.isLoggable(Logger.FINE)) {
_logger.fine(// NOI18N
"[CMPC] Home Object Impl name is " + entd.getLocalHomeImplClassName());
}
// The classloader needs to be set else we fail down the road.
ClassLoader ocl = entd.getClassLoader();
entd.setClassLoader(jcl);
try {
gen.generate(entd, stubsDir, stubsDir);
} catch (GeneratorException e) {
String msg = e.getMessage();
_logger.warning(msg);
generatorExceptionMsg = addGeneratorExceptionMessage(msg, generatorExceptionMsg);
} finally {
entd.setClassLoader(ocl);
}
/* WARNING: IASRI 4683195
* JDO Code failed when there was a relationship involved
* because it depends upon the orginal ejbclasname and hence
* this code is shifted to just before the Remote Impl is
* generated.Remote/Home Impl generation depends upon this
* value
*/
}
}
// end while ejbs.hasNext()
beanName = null;
cmpFiles.addAll(gen.cleanup());
long end = System.currentTimeMillis();
_logger.fine("CMP Generation: " + (end - start) + " msec");
} catch (GeneratorException e) {
String msg = e.getMessage();
_logger.warning(msg);
generatorExceptionMsg = addGeneratorExceptionMessage(msg, generatorExceptionMsg);
}
// Used in exception processing
bundle = null;
// Compile the generated classes
if (generatorExceptionMsg == null) {
long start = System.currentTimeMillis();
compileClasses(ctx, cmpFiles, stubsDir);
long end = System.currentTimeMillis();
_logger.fine("Java Compilation: " + (end - start) + " msec");
// Do Java2DB if needed
start = System.currentTimeMillis();
CMPProcessor processor = new CMPProcessor(ctx);
processor.process();
end = System.currentTimeMillis();
_logger.fine("Java2DB processing: " + (end - start) + " msec");
_logger.fine("cmpc.done_processing_cmp", 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());
}
}
use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.
the class Verifier method verify.
public void verify(DeploymentContext context) {
com.sun.enterprise.tools.verifier.VerifierFrameworkContext verifierFrameworkContext = new com.sun.enterprise.tools.verifier.VerifierFrameworkContext();
verifierFrameworkContext.setArchive(context.getSource());
verifierFrameworkContext.setApplication(context.getModuleMetaData(com.sun.enterprise.deployment.Application.class));
verifierFrameworkContext.setJarFileName(context.getSourceDir().getAbsolutePath());
verifierFrameworkContext.setJspOutDir(context.getScratchDir("jsp"));
verifierFrameworkContext.setIsBackend(true);
verifierFrameworkContext.setOutputDirName(env.getDomainRoot().getAbsolutePath() + "/logs/verifier-results");
com.sun.enterprise.tools.verifier.ResultManager rm = verifierFrameworkContext.getResultManager();
try {
init(verifierFrameworkContext);
verify();
} catch (Exception e) {
LogRecord logRecord = new LogRecord(Level.SEVERE, "Could not verify successfully.");
logRecord.setThrown(e);
verifierFrameworkContext.getResultManager().log(logRecord);
}
try {
generateReports();
} catch (IOException ioe) {
context.getLogger().log(Level.WARNING, "Can not generate verifier report: {0}", ioe.getMessage());
}
int failedCount = rm.getFailedCount() + rm.getErrorCount();
if (failedCount != 0) {
((ExtendedDeploymentContext) context).clean();
throw new DeploymentException(smh.getLocalString("deploy.failverifier", "Some verifier tests failed. Aborting deployment"));
}
}
use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.
the class EjbDeployer method createAutomaticPersistentTimersForEJB.
/**
* Start EJB Timer Service and create automatic timers for this EJB in this target
*/
private void createAutomaticPersistentTimersForEJB(EjbDescriptor ejbDescriptor, String target) {
try {
// Start EJB Timer Service if it wasn't started yet. On DAS the first start will create the timer table.
EJBTimerService timerService = EJBTimerService.getEJBTimerService(target);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "EjbDeployer BEAN ID? " + ejbDescriptor.getUniqueId());
_logger.log(Level.FINE, "EjbDeployer TimerService: " + timerService);
}
if (timerService != null) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "EjbDeployer - calling timerService.createSchedules for " + ejbDescriptor.getUniqueId());
}
timerService.createSchedulesOnServer(ejbDescriptor, getOwnerId(target));
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "EjbDeployer Done With BEAN ID: " + ejbDescriptor.getUniqueId());
}
} else {
throw new RuntimeException("EJB Timer Service is not available");
}
} catch (Exception e) {
throw new DeploymentException("Failed to create automatic timers for " + ejbDescriptor.getName(), e);
}
}
Aggregations