This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!

Todd Chambery

Greenhorn
+ Follow
since Dec 13, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Todd Chambery

Also take a look at XMLBuddy
[ April 12, 2004: Message edited by: Thomas Paul ]
I'm going post-crazy here, but I forgot to plug my own plugins :
http://zclipse.org
# CompleteClipse - auto-complete any string
# ExclusionBuilder - exclude particular files/types from compilation
# Insectivore - team task tracking through the eclipse Tasks view
# JScheme Eclipse Plug-in - JScheme highlighting/compilation support for eclipse
# TabNavigator - tab navigation through the code (very cool--have to use it to understand)
# zMail - simple mail client for eclipse
# Zero Effort Feedback - plugin feedback plugin
Todd
I'm going post-crazy here, but I forgot to plug my own plugins:
http://zclipse.org
# CompleteClipse - auto-complete any string
# ExclusionBuilder - exclude particular files/types from compilation
# Insectivore - team task tracking through the eclipse Tasks view
# JScheme Eclipse Plug-in - JScheme highlighting/compilation support for eclipse
# TabNavigator - tab navigation through the code (very cool--have to use it to understand)
# zMail - simple mail client for eclipse
# Zero Effort Feedback - plugin feedback plugin
Presently using Eclipse with >2000 java files + >1000 non-code files. No problems, using Clearcase for source control.
Ctrl+F6 is pretty un-ergonomic, but since 2.1 you can change the keymappings (for just about all actions in the IDE) to whatever suits your fancy.
For Tomcat, check out Sysdeo:
http://www.sysdeo.com/eclipse/tomcatPlugin.html
I posted this on another thread, but can't see how to link it, so here are my core eclipse plugins:
Metrics: http://metrics.sourceforge.net/
Eclipse profiler plugin: http://eclipsecolorer.sourceforge.net/
Call hierarchy and implementors view: http://eclipse-tools.sourceforge.net/
XML Buddy (xml editor): http://www.xmlbuddy.com/
Checkstye (code audit): http://sourceforge.net/projects/eclipse-cs
Omondo (UML): http://www.omondo.com/index.jsp
DbEdit (Database plugin): http://www.geocities.com/uwe_ewald/dbedit.html
Color Editor (JEdit text highlighting for eclipse): http://gstaff.org/colorEditor/

Originally posted by Jonathan MBaker:
I recently had to evaluate Eclipse(www.eclipse.org) and Intellij Idea(www.intellij.com/jetbrains) for my team.(we develop only in Java) I came to prefer Idea...
<snip>
I would really reccomend either of them, but it is best to just download them both and see which one you like.


I haven't seen it mentioned on this thread, and I'm wondering how you evaluated Eclipse against IDEA, so...
It's important to understand that Eclipse out of the box is not (for me) the complete IDE. Eclipse's strength is in its extensibility as a plugin platform, so here's my list of core plugins:
Metrics: http://metrics.sourceforge.net/
Eclipse profiler plugin: http://eclipsecolorer.sourceforge.net/
Call hierarchy and implementors view: http://eclipse-tools.sourceforge.net/
XML Buddy (xml editor): http://www.xmlbuddy.com/
Checkstye (code audit): http://sourceforge.net/projects/eclipse-cs
Omondo (UML): http://www.omondo.com/index.jsp
DbEdit (Database plugin): http://www.geocities.com/uwe_ewald/dbedit.html
Color Editor (JEdit text highlighting for eclipse): http://gstaff.org/colorEditor/

Originally posted by Frank Carver:
I'd like to add my tuppence.
<snip>
A few months ago I finally found two "killer" features that has got me using an IDE.
The first feature is refactoring.
<snip>
The second feature is CVS support.
<snip>


I second this. While I don't share your aversion to IDEs (I'm all in favor of computers relieving me of the drudgery of coding... I did enough emacs/command line in college), Eclipse's refactoring and cvs support are just winning. I used to find cvs a pain, but the integration within the IDE is so seamless, I want to buy the guys who coded it a beer. The merge/compare facility is as intuitive as I've seen, and make commercial products (*cough* Clearcase *cough*) look like a stone axe in comparison.
The refactoring, too, is a marvel, and something I had not seen in another IDE (I've never used IDEA...). And it continues to improve with each milestone release.
It's even politically correct being Open Source, which incidentally makes plugin development infinitely simpler, since if you see something you like in the IDE, just step into the Runtime-Workspace (the plugin development test environment) and see exactly what the Eclipse folks did.
Todd
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).
18 years ago
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.
18 years ago
/*
* 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;
}
}
18 years ago
I'm working with WAS 4.0/Linux, deploying an .ear that works properly on NT and WSAD. Someone else set up the server, and presumably tested the sample apps, but when I deployed the .ear file with the wizard from a remote client console to the localhost node (the Default Server for which was stopped), and ran it, none of the EJB would start. Fine.
I created another node and deployed the sample app to that one, was able to start the server and all sample ejbs started.
Here's my problem: I can't get to the machine through the standard test url, and want to remove the node I created so as to restore WAS to the state it was in before I mucked it up. Unfortunately, I can't remove the node, either from the client java console, or wscp> Node remove /Node:foo/. On the java console, Remove is grayed out, and wscp gives me this:
WSCP0144E: /Node:dev22app/ cannot be removed because it is running; exception was com.ibm.ejs.sm.exception.RunningObjectRemoveException
wscp> Node stop /Node:dev22app/
wscp> Node remove /Node:dev22app/
[01.12.18 19:29:04:378 EST] 2836d506 MasterProxy W WWLM0019: Method getNextClone found no usable proxies in the list. Current exception:
(I can't remove it when it's running, and when I stop it, wscp can't get a handle on the AppServer to do anything.)

Thanks in advance for any help
Todd

18 years ago