Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

WebsphereDeploymentTool for Ant

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* author:Todd Chambery
* email:tchambery@hotmail.com
*
* WesphereDeploymentTool borrows _very_ heavily from the WeblogicDeploymentTool.
*
* It is designed to work with WebSphere 4.0 EJBDeploy class.
*
* In order to use this class with Ant 1.4, the optional.jar must be updated with
* this compiled class, as well as Ejbjar.class modified to recognize this nested
* element (add the following method):
*
*
* public WebsphereDeploymentTool createWebsphere() {
* WebsphereDeploymentTool tool = new WebsphereDeploymentTool();
* tool.setTask(this);
* deploymentTools.add(tool);
* return tool;
* }
*
* The EJBDeploy tool has what I believe is a bug: it builds a classpath so large
* that, at least on WinNT, critical classes fall off the end off the end of the
* classpath. A temporary solution is to place all necessary jars into the
* <drive>:\Websphere\AppServer\java\jre\lib\ext directory. For my particular project,
* I had to add
*j2ee.jar
*ejbcontainer.jar
*cscpi.jar
*ras.jar
*utils.jar
*xalan.jar
*xerces.jar
* in addition to the project internal jars. It also should be mentioned that you _must_
* use an IBM jre (or better yet, the Websphere-installed jre). Not doing so will
* result in weird errors from missing or different implementations of common classes.
*
* The GenericDeploymentTool, of which this class is a subclass, adds a manifest in a
* way that I believe is incorrect. If an absolute path to a manifest file is not
* specified as an attribute to the <ejbjar> task, the GDT will insert the Ant default.
* This may be fine for most cases, but in my project, each jar had a specific
* manifest which contained the classpath for that jar. I have to manually remove
* and update each jar with a new manifest until the Ant people correct me or
* address this issue.
*/
package org.apache.tools.ant.taskdefs.optional.ejb;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.Path;
import org.xml.sax.InputSource;
public class WebsphereDeploymentTool extends GenericDeploymentTool {
public static final String PUBLICID_EJB11 =
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
public static final String PUBLICID_EJB20 =
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN";
protected static final String WAS_EXT_DD = "ibm-ejb-jar-ext.xmi";
protected static final String WAS_BND_DD = "ibm-ejb-jar-bnd.xmi";
protected static final String MANIFEST = "MANIFEST.MF";

protected static final String EJBDEPLOY_WAS40 = "com.ibm.etools.ejbdeploy.EJBDeploy";
/** Instance variable that stores the suffix for the weblogic jarfile. */
private String jarSuffix = ".jar";
/** Instance variable that stores the location of the ejb 1.1 DTD file. */
private String ejb11DTD = null;

/** determines whether to only generate the deployment code (not run RMIC or Javac). */
private boolean codegen = true;

/** The name of the database to create */
private String dbname = null;

/** The name of the database schema to create */
private String dbschema = null;

/** The name of the database vendor type, must be one of the following:
SQL92 SQL99 DB2UDBWIN_V71 DB2UDBOS390_V6 DB2UDBAS400_V4R5
ORACLE_V8 INFORMIX_V92 SYBASE_V1192 MSSQLSERVER_V7 MYSQL_V323 */
private String dbvendor = null;
/** determines whether to keep the contents of the working directory. */
private boolean keep = false;

/** determines whether to halt for compilation or validation errors */
private boolean ignoreErrors = true;

/** stores the fully qualified classname of the websphere deploytool */
private String ejbDeployClass = null;
/** determines whether to only output errors, suppress informational messages */
private boolean quiet = true;
/** determines whether to disable the validation steps */
private boolean novalidate = true;
/** determines whether to disable warning and informational messages */
private boolean nowarn = true;
/** determines whether to disable informational messages */
private boolean noinform = true;
/** Set additional options to use for RMIC */
private String rmic = null;
/** determines whether to use the WebSphere 3.5 compatible mapping rules */
private boolean compat35 = false;
/** determines whether to enable internal tracing */
private boolean trace = false;
private String additionalArgs = "";

private boolean keepGeneric = false;
private boolean alwaysRebuild = false;
/** The classpath to the weblogic classes. */
private Path wasClasspath = null;

/**
* Get the classpath to the websphere classpaths
*/
public Path createWasClasspath() {
if (wasClasspath == null) {
wasClasspath = new Path(getTask().getProject());
}
return wasClasspath.createPath();
}
/**
* Set the rebuild flag to false to only update changes in the
* jar rather than rerunning ejbc
*/
public void setRebuild(boolean rebuild) {
this.alwaysRebuild = rebuild;
}
/**
* Setter used to store the suffix for the generated weblogic jar file.
* @param inString the string to use as the suffix.
*/
public void setSuffix(String inString) {
this.jarSuffix = inString;
}
/**
* sets some additional args to send to EJBDeploy
*/
public void setArgs(String args) {
this.additionalArgs = args;
}
/**
* Setter used to store the location of the Sun's Generic EJB DTD.
* This can be a file on the system or a resource on the classpath.
* @param inString the string to use as the DTD location.
*/
public void setEJBdtd(String inString) {
this.ejb11DTD = inString;
}
protected void registerKnownDTDs(DescriptorHandler handler) {
// register all the known DTDs
/*
handler.registerDTD(PUBLICID_EJB11, DEFAULT_WL51_EJB11_DTD_LOCATION);
handler.registerDTD(PUBLICID_EJB11, DEFAULT_WL60_EJB11_DTD_LOCATION);
*/
handler.registerDTD(PUBLICID_EJB11, ejb11DTD);
//handler.registerDTD(PUBLICID_EJB20, DEFAULT_WL60_EJB20_DTD_LOCATION);
}
protected DescriptorHandler getWebsphereDescriptorHandler(final File srcDir) {
DescriptorHandler handler = new DescriptorHandler(getTask(), srcDir) {
protected void processElement() {
if (currentElement.equals("type-storage")) {
// Get the filename of vendor specific descriptor
String fileNameWithMETA = currentText;
//trim the META_INF\ off of the file name
String fileName =
fileNameWithMETA.substring(META_DIR.length(), fileNameWithMETA.length());
File descriptorFile = new File(srcDir, fileName);
ejbFiles.put(fileNameWithMETA, descriptorFile);
}
}
};
/*
handler.registerDTD(PUBLICID_WEBLOGIC_EJB510, DEFAULT_WL51_DTD_LOCATION);
handler.registerDTD(PUBLICID_WEBLOGIC_EJB510, DEFAULT_WL60_51_DTD_LOCATION);
handler.registerDTD(PUBLICID_WEBLOGIC_EJB600, DEFAULT_WL60_DTD_LOCATION);
handler.registerDTD(PUBLICID_WEBLOGIC_EJB510, weblogicDTD);
handler.registerDTD(PUBLICID_WEBLOGIC_EJB600, weblogicDTD);
*/
for (Iterator i = getConfig().dtdLocations.iterator(); i.hasNext() {
EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation) i.next();
handler.registerDTD(dtdLocation.getPublicId(), dtdLocation.getLocation());
}
return handler;
}
/**
* Add any vendor specific files which should be included in the
* EJB Jar.websphereDD
*/
protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) {
File websphereExtDD = new File(getConfig().descriptorDir, ddPrefix + WAS_EXT_DD);
File websphereBndDD = new File(getConfig().descriptorDir, ddPrefix + WAS_BND_DD);
File manifest = new File(getConfig().descriptorDir, ddPrefix + MANIFEST);
if (websphereExtDD.exists()) {
ejbFiles.put(META_DIR + WAS_EXT_DD,
websphereExtDD);
}
else {
log("Unable to locate WebSphere EJB jar extensions descriptor. It was expected to be in " +
websphereExtDD.getPath(), Project.MSG_WARN);
return;
}

if (websphereBndDD.exists()) {
ejbFiles.put(META_DIR + WAS_BND_DD,
websphereBndDD);
}
else {
log("Unable to locate WebSphere EJB jar bindings descriptor. It was expected to be in " +
websphereBndDD.getPath(), Project.MSG_WARN);
return;
}

if (manifest.exists()) {
ejbFiles.put(META_DIR + MANIFEST,
manifest);
}
else {
log("Unable to locate MANIFEST.MF. It was expected to be in " +
manifest.getPath(), Project.MSG_WARN);
return;
}


// now that we have the websphere descriptor, we parse the file
// to find other descriptors needed to deploy the bean.
// this could be the weblogic-cmp-rdbms.xml or any other O/R
// mapping tool descriptors.
try
{
File ejbDescriptor = (File)ejbFiles.get(META_DIR + EJB_DD);
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setValidating(true);
SAXParser saxParser = saxParserFactory.newSAXParser();
DescriptorHandler handler = getWebsphereDescriptorHandler(ejbDescriptor.getParentFile());
saxParser.parse(new InputSource
(new FileInputStream
(websphereExtDD)),
handler);

Hashtable ht = handler.getFiles();
Enumeration e = ht.keys();
while(e.hasMoreElements()){
String key = (String)e.nextElement();
ejbFiles.put(key, ht.get(key));
}
saxParser.parse(new InputSource
(new FileInputStream
(websphereBndDD)),
handler);

ht = handler.getFiles();
e = ht.keys();
while(e.hasMoreElements()){
String key = (String)e.nextElement();

ejbFiles.put(key, ht.get(key));
}
// adding MANIFEST.MF to the generic jar
ht = handler.getFiles();
e = ht.keys();
while(e.hasMoreElements()){
String key = (String)e.nextElement();
ejbFiles.put(key, ht.get(key));
}
}
catch(Exception e)
{
String msg = "Exception while adding Vendor specific files: " + e.toString();
throw new BuildException(msg, e);
}

}
/**
* Get the vendor specific name of the Jar that will be output. The modification date
* of this jar will be checked against the dependent bean classes.
*/
File getVendorOutputJarFile(String baseName) {
return new File(getDestDir(), baseName + jarSuffix);
}
/**
* Helper method invoked by execute() for each WebLogic jar to be built.
* Encapsulates the logic of constructing a java task for calling
* com.ibm.etools.ejbdeploy.EJBDeploy and executing it.
* @param sourceJar java.io.File representing the source (EJB1.1) jarfile.
* @param destJar java.io.File representing the destination, WebLogic
* jarfile.
*/
private void buildWebsphereJar(File sourceJar, File destJar, String publicId) {
org.apache.tools.ant.taskdefs.Java javaTask = null;
String ejbDeployClassName = ejbDeployClass;
try {
javaTask = (Java) getTask().getProject().createTask("java");
javaTask.setTaskName("EJBDeploy");
if (ejbDeployClassName == null) {
/*// try to determine it from publicId
if (PUBLICID_EJB11.equals(publicId)) {
ejbDeployClassName = COMPILER_EJB11;
} else if (PUBLICID_EJB20.equals(publicId)) {
ejbDeployClassName = COMPILER_EJB20;
} else {
log(
"Unrecognized publicId " + publicId + " - using EJB 1.1 compiler",
Project.MSG_WARN);
ejbDeployClassName = COMPILER_EJB11;
}
*/
ejbDeployClassName = WebsphereDeploymentTool.EJBDEPLOY_WAS40;
}

javaTask.setClassname(ejbDeployClassName);
javaTask.createArg().setLine(additionalArgs);

setEJBDeployArgs(javaTask);
javaTask.createArg().setValue(sourceJar.getPath());
javaTask.createArg().setValue(getDestDir().getPath());
javaTask.createArg().setValue(destJar.getPath());
// should be settable from the buildfile
javaTask.createJvmarg().setValue("-Dwebsphere.lib.dir=\"F:/WebSphere/AppServer/lib\"");
javaTask.createJvmarg().setValue("-Xmx512M");

Path classpath = wasClasspath;
if (classpath == null) {
classpath = getCombinedClasspath();
}
javaTask.setFork(true);
if (classpath != null) {
javaTask.setClasspath(classpath);
}
log(
"Calling " + ejbDeployClassName + " for " + sourceJar.toString(),
Project.MSG_VERBOSE);
if (javaTask.executeJava() != 0) {
throw new BuildException("EJBDeploy reported an error");
}
} catch (Exception e) {
// Have to catch this because of the semantics of calling main()
String msg =
"Exception while calling " + ejbDeployClassName + ". Details: " + e.toString();
throw new BuildException(msg, e);
}
}
/**
* Helper method invoked by buildWebsphereJar(...). Assembles the command
* line arguments passed to the EJBDeploy task..
* @param javaTask org.apache.tools.ant.taskdefs.Java represents the java
* task that gets the command line args.
*/
protected void setEJBDeployArgs(Java javaTask) {
if(compat35 == true) {
javaTask.createArg().setValue("-35");
}
if(ignoreErrors == true) {
javaTask.createArg().setValue("-ignoreErrors");
}
if(keep == true) {
javaTask.createArg().setValue("-keep");
}
if(noinform == true) {
javaTask.createArg().setValue("-noInform");
}
if(novalidate == true) {
javaTask.createArg().setValue("-noValidate");
}
if(nowarn == true) {
javaTask.createArg().setValue("-noWarn");
}
if(quiet == true) {
javaTask.createArg().setValue("-quiet");
}
if(trace == true) {
javaTask.createArg().setValue("-trace");
}
if(dbname != null) {
javaTask.createArg().setValue("-dbname " + dbname);
}
if(dbschema != null) {
javaTask.createArg().setValue("-dbschema " + dbschema);
}
if(dbvendor != null) {
javaTask.createArg().setValue("-dbvendor " + dbvendor);
}
if(rmic != null) {
javaTask.createArg().setValue("-rmic \"" + rmic + "\"");
}
if(dbvendor != null) {
javaTask.createArg().setValue("-dbvendor " + dbvendor);
}
}
/**
* Method used to encapsulate the writing of the JAR file. Iterates over the
* filenames/java.io.Files in the Hashtable stored on the instance variable
* ejbFiles.
*/
protected void writeJar(
String baseName,
File jarFile,
Hashtable files,
String publicId)
throws BuildException {
// need to create a generic jar first.
File genericJarFile = super.getVendorOutputJarFile(baseName);
super.writeJar(baseName, genericJarFile, files, publicId);
if (alwaysRebuild || isRebuildRequired(genericJarFile, jarFile)) {
buildWebsphereJar(genericJarFile, jarFile, publicId);
}
if (!keepGeneric) {
log("deleting generic jar " + genericJarFile.toString(), Project.MSG_VERBOSE);
genericJarFile.delete();
}
}
/**
* Called to validate that the tool parameters have been configured.
*
*/
public void validateConfigured() throws BuildException {
super.validateConfigured();
}
/**
* Helper method to check to see if a weblogic EBJ1.1 jar needs to be rebuilt using
* EJBDeploy. Called from writeJar it sees if the "Bean" classes are the only thing that needs
* to be updated and either updates the Jar with the Bean classfile or returns true,
* saying that the whole weblogic jar needs to be regened with ejbc. This allows faster
* build times for working developers.
*

* The way weblogic ejbc works is it creates wrappers for the publicly defined methods as
* they are exposed in the remote interface. If the actual bean changes without changing the
* the method signatures then only the bean classfile needs to be updated and the rest of the
* weblogic jar file can remain the same. If the Interfaces, ie. the method signatures change
* or if the xml deployment dicriptors changed, the whole jar needs to be rebuilt with ejbc.
* This is not strictly true for the xml files. If the JNDI name changes then the jar doesnt
* have to be rebuild, but if the resources references change then it does. At this point the
* weblogic jar gets rebuilt if the xml files change at all.
*
* @param genericJarFile java.io.File The generic jar file.
* @param weblogicJarFile java.io.File The weblogic jar file to check to see if it needs to be rebuilt.
*/
protected boolean isRebuildRequired(
File genericJarFile,
File weblogicJarFile) {
boolean rebuild = false;
JarFile genericJar = null;
JarFile wasJar = null;
File newWASJarFile = null;
JarOutputStream newJarStream = null;
try {
log(
"Checking if weblogic Jar needs to be rebuilt for jar "
+ weblogicJarFile.getName(),
Project.MSG_VERBOSE);
// Only go forward if the generic and the weblogic file both exist
if (genericJarFile.exists()
&& genericJarFile.isFile()
&& weblogicJarFile.exists()
&& weblogicJarFile.isFile()) {
//open jar files
genericJar = new JarFile(genericJarFile);
wasJar = new JarFile(weblogicJarFile);
Hashtable genericEntries = new Hashtable();
Hashtable wlEntries = new Hashtable();
Hashtable replaceEntries = new Hashtable();
//get the list of generic jar entries
for (Enumeration e = genericJar.entries(); e.hasMoreElements() {
JarEntry je = (JarEntry) e.nextElement();
genericEntries.put(je.getName().replace('\\', '/'), je);
}
//get the list of weblogic jar entries
for (Enumeration e = wasJar.entries(); e.hasMoreElements() {
JarEntry je = (JarEntry) e.nextElement();
wlEntries.put(je.getName(), je);
}
//Cycle Through generic and make sure its in weblogic
ClassLoader genericLoader = getClassLoaderFromJar(genericJarFile);
for (Enumeration e = genericEntries.keys(); e.hasMoreElements() {
String filepath = (String) e.nextElement();
if (wlEntries.containsKey(filepath)) // File name/path match
{
// Check files see if same
JarEntry genericEntry = (JarEntry) genericEntries.get(filepath);
JarEntry wlEntry = (JarEntry) wlEntries.get(filepath);
if ((genericEntry.getCrc() != wlEntry.getCrc())
|| // Crc's Match
(genericEntry.getSize() != wlEntry.getSize())) // Size Match
{
if (genericEntry.getName().endsWith(".class")) {
//File are different see if its an object or an interface
String classname = genericEntry.getName().replace(File.separatorChar, '.');
classname = classname.substring(0, classname.lastIndexOf(".class"));
Class genclass = genericLoader.loadClass(classname);
if (genclass.isInterface()) {
//Interface changed rebuild jar.
log("Interface " + genclass.getName() + " has changed", Project.MSG_VERBOSE);
rebuild = true;
break;
} else {
//Object class Changed update it.
replaceEntries.put(filepath, genericEntry);
}
} else {
// is it the manifest. If so ignore it
if (!genericEntry.getName().equals("META-INF/MANIFEST.MF")) {
//File other then class changed rebuild
log(
"Non class file " + genericEntry.getName() + " has changed",
Project.MSG_VERBOSE);
rebuild = true;
break;
}
}
}
} else // a file doesnt exist rebuild
{
log("File " + filepath + " not present in weblogic jar", Project.MSG_VERBOSE);
rebuild = true;
break;
}
}
if (!rebuild) {
log("No rebuild needed - updating jar", Project.MSG_VERBOSE);
newWASJarFile = new File(weblogicJarFile.getAbsolutePath() + ".temp");
if (newWASJarFile.exists()) {
newWASJarFile.delete();
}
newJarStream = new JarOutputStream(new FileOutputStream(newWASJarFile));
newJarStream.setLevel(0);
//Copy files from old weblogic jar
for (Enumeration e = wlEntries.elements(); e.hasMoreElements() {
byte[] buffer = new byte[1024];
int bytesRead;
InputStream is;
JarEntry je = (JarEntry) e.nextElement();
if (je.getCompressedSize() == -1 || je.getCompressedSize() == je.getSize()) {
newJarStream.setLevel(0);
} else {
newJarStream.setLevel(9);
}
// Update with changed Bean class
if (replaceEntries.containsKey(je.getName())) {
log(
"Updating Bean class from generic Jar " + je.getName(),
Project.MSG_VERBOSE);
// Use the entry from the generic jar
je = (JarEntry) replaceEntries.get(je.getName());
is = genericJar.getInputStream(je);
} else //use fle from original weblogic jar
{
is = wasJar.getInputStream(je);
}
newJarStream.putNextEntry(new JarEntry(je.getName()));
while ((bytesRead = is.read(buffer)) != -1) {
newJarStream.write(buffer, 0, bytesRead);
}
is.close();
}
} else {
log(
"Weblogic Jar rebuild needed due to changed interface or XML",
Project.MSG_VERBOSE);
}
} else {
rebuild = true;
}
} catch (ClassNotFoundException cnfe) {
String cnfmsg =
"ClassNotFoundException while processing ejb-jar file"
+ ". Details: "
+ cnfe.getMessage();
throw new BuildException(cnfmsg, cnfe);
} catch (IOException ioe) {
String msg =
"IOException while processing ejb-jar file " + ". Details: " + ioe.getMessage();
throw new BuildException(msg, ioe);
} finally {
// need to close files and perhaps rename output
if (genericJar != null) {
try {
genericJar.close();
} catch (IOException closeException) {
}
}
if (wasJar != null) {
try {
wasJar.close();
} catch (IOException closeException) {
}
}
if (newJarStream != null) {
try {
newJarStream.close();
} catch (IOException closeException) {
}
weblogicJarFile.delete();
newWASJarFile.renameTo(weblogicJarFile);
if (!weblogicJarFile.exists()) {
rebuild = true;
}
}
}
return rebuild;
}
/**
* Helper method invoked by isRebuildRequired to get a ClassLoader for
* a Jar File passed to it.
*
* @param classjar java.io.File representing jar file to get classes from.
*/
protected ClassLoader getClassLoaderFromJar(File classjar) throws IOException {
Path lookupPath = new Path(getTask().getProject());
lookupPath.setLocation(classjar);
Path classpath = getCombinedClasspath();
if (classpath != null) {
lookupPath.append(classpath);
}
return new AntClassLoader(getTask().getProject(), lookupPath);
}
/**
* Gets the ejbDeployClass.
* @return Returns a String
*/
public String getEjbDeployClass() {
return ejbDeployClass;
}
/**
* Sets the ejbDeployClass.
* @param ejbDeployClass The ejbDeployClass to set
*/
public void setEjbDeployClass(String ejbDeployClass) {
this.ejbDeployClass = ejbDeployClass;
}
/**
* Setter used to store the value of keepGeneric
* @param inValue a string, either 'true' or 'false'.
*/
public void setKeepgeneric(boolean inValue) {
this.keepGeneric = inValue;
}

/**
* Gets the wasClasspath.
* @return Returns a Path
*/
public Path getWasClasspath() {
return wasClasspath;
}
/**
* Sets the wasClasspath.
* @param wasClasspath The wasClasspath to set
*/
public void setWasClasspath(Path wasClasspath) {
this.wasClasspath = wasClasspath;
}
/**
* Sets the codegen.
* @param codegen The codegen to set
*/
public void setCodegen(boolean codegen) {
this.codegen = codegen;
}
/**
* Sets the compat35.
* @param compat35 The compat35 to set
*/
public void setCompat35(boolean compat35) {
this.compat35 = compat35;
}
/**
* Sets the dbname.
* @param dbname The dbname to set
*/
public void setDbname(String dbname) {
this.dbname = dbname;
}
/**
* Sets the dbschema.
* @param dbschema The dbschema to set
*/
public void setDbschema(String dbschema) {
this.dbschema = dbschema;
}
/**
* Sets the dbvendor.
* @param dbvendor The dbvendor to set
*/
public void setDbvendor(String dbvendor) {
this.dbvendor = dbvendor;
}
/**
* Sets the ignoreErrors.
* @param ignoreErrors The ignoreErrors to set
*/
public void setIgnoreErrors(boolean ignoreErrors) {
this.ignoreErrors = ignoreErrors;
}
/**
* Sets the keep.
* @param keep The keep to set
*/
public void setKeep(boolean keep) {
this.keep = keep;
}
/**
* Sets the noinform.
* @param noinform The noinform to set
*/
public void setNoinform(boolean noinform) {
this.noinform = noinform;
}
/**
* Sets the novalidate.
* @param novalidate The novalidate to set
*/
public void setNovalidate(boolean novalidate) {
this.novalidate = novalidate;
}
/**
* Sets the nowarn.
* @param nowarn The nowarn to set
*/
public void setNowarn(boolean nowarn) {
this.nowarn = nowarn;
}
/**
* Sets the quiet.
* @param quiet The quiet to set
*/
public void setQuiet(boolean quiet) {
this.quiet = quiet;
}
/**
* Sets the rmic.
* @param rmic The rmic to set
*/
public void setRmic(String rmic) {
this.rmic = rmic;
}
/**
* Sets the trace.
* @param trace The trace to set
*/
public void setTrace(boolean trace) {
this.trace = trace;
}
/**
* Sets the alwaysRebuild.
* @param alwaysRebuild The alwaysRebuild to set
*/
public void setAlwaysRebuild(boolean alwaysRebuild) {
this.alwaysRebuild = alwaysRebuild;
}
}
 
Todd Chambery
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I apologize for posting the whole code for this, but JavaRanch has been the most useful place for finding solutions, and hopefully nobody will have to redo my effort as a result of it being posted here.
 
Todd Chambery
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a reply from the Ant people. There's a WebsphereDeploymentTool in the CVS repository. I've used it briefly, and it works, though I still can't get it to use my manifests (you can only specify either a single absolute-path manifest for all ejb jars, or else use the useless default).
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found that there is an undocumented "manifest" parameter for the ANT ejb task. So you can set this to your exsisting MANIFEST file.
 
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!