[112608]NPE for closed/removed projects
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerBehaviour.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerBehaviour.java
index 898d259..71d6188 100644
--- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerBehaviour.java
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerBehaviour.java
@@ -43,6 +43,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.core.ServerPort;
+import org.eclipse.wst.server.core.internal.DeletedModule;
import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
import org.eclipse.wst.server.core.model.ServerDelegate;
import org.eclipse.wst.server.core.util.SocketUtil;
@@ -54,7 +55,7 @@
*/
public class GenericServerBehaviour extends ServerBehaviourDelegate {
- private static final String ATTR_STOP = "stop-server";
+ private static final String ATTR_STOP = "stop-server"; //$NON-NLS-1$
// the thread used to ping the server to check for startup
protected transient PingThread ping = null;
@@ -74,6 +75,7 @@
public void publishModule(int kind, int deltaKind, IModule[] module,
IProgressMonitor monitor) throws CoreException {
+ checkClosed(module);
if(REMOVED == deltaKind){
removeFromServer(module,monitor);
}
@@ -81,7 +83,7 @@
String publisherId = ServerTypeDefinitionUtil.getPublisherID(module[0], getServerDefinition());
GenericPublisher publisher = PublishManager.getPublisher(publisherId);
if(publisher==null){
- IStatus status = new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,0,"Unable to create publisher",null);
+ IStatus status = new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,0, GenericServerCoreMessages.bind(GenericServerCoreMessages.unableToCreatePublisher,publisherId),null);
throw new CoreException(status);
}
publisher.initialize(module,getServer());
@@ -99,12 +101,23 @@
}
}
+ private void checkClosed(IModule[] module) throws CoreException
+ {
+ for(int i=0;i<module.length;i++)
+ {
+ if(module[i] instanceof DeletedModule)
+ {
+ IStatus status = new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,0, GenericServerCoreMessages.bind(GenericServerCoreMessages.canNotPublishDeletedModule,module[i].getName()),null);
+ throw new CoreException(status);
+ }
+ }
+ }
private void removeFromServer(IModule[] module, IProgressMonitor monitor) throws CoreException
{
String publisherId = ServerTypeDefinitionUtil.getPublisherID(module[0], getServerDefinition());
GenericPublisher publisher = PublishManager.getPublisher(publisherId);
if(publisher==null){
- IStatus status = new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,0,"Unable to create publisher to remove module",null);
+ IStatus status = new Status(IStatus.ERROR,CorePlugin.PLUGIN_ID,0,GenericServerCoreMessages.bind(GenericServerCoreMessages.unableToCreatePublisher,publisherId),null);
throw new CoreException(status);
}
publisher.initialize(module,getServer());
@@ -138,7 +151,7 @@
protected void shutdown(int state) {
GenericServerRuntime runtime = getRuntimeDelegate();
try {
- Trace.trace(Trace.FINEST, "Stopping Server");
+ Trace.trace(Trace.FINEST, "Stopping Server"); //$NON-NLS-1$
if (state != IServer.STATE_STOPPED)
setServerState(IServer.STATE_STOPPING);
String configTypeID = getConfigTypeID();
@@ -165,7 +178,7 @@
// To stop from appearing in history lists
wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
// Set the stop attribute so that we know we are stopping
- wc.setAttribute(ATTR_STOP, "true");
+ wc.setAttribute(ATTR_STOP, "true"); //$NON-NLS-1$
// Setup the launch config for stopping the server
setupStopLaunchConfiguration(runtime, wc);
@@ -174,7 +187,7 @@
wc.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
} catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error stopping Server", e);
+ Trace.trace(Trace.SEVERE, "Error stopping Server", e); //$NON-NLS-1$
}
}
@@ -191,7 +204,7 @@
* @return
*/
protected String getStopLaunchName() {
- return "GenericServerStopper";
+ return "GenericServerStopper"; //$NON-NLS-1$
}
private boolean isRemote(){
@@ -384,7 +397,7 @@
* @param monitor IProgressMonitor
*/
protected void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException {
- if ("true".equals(launch.getLaunchConfiguration().getAttribute(ATTR_STOP, "false")))
+ if ("true".equals(launch.getLaunchConfiguration().getAttribute(ATTR_STOP, "false"))) //$NON-NLS-1$ //$NON-NLS-2$
return;
String host = getServer().getHost();
@@ -402,13 +415,13 @@
// ping server to check for startup
try {
- String url = "http://"+host;
+ String url = "http://"+host; //$NON-NLS-1$
int port = sp.getPort();
if (port != 80)
- url += ":" + port;
+ url += ":" + port; //$NON-NLS-1$
ping = new PingThread(getServer(), url, this);
} catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Can't ping for server startup.");
+ Trace.trace(Trace.SEVERE, "Can't ping for server startup."); //$NON-NLS-1$
}
}
@@ -460,14 +473,14 @@
try {
setServerState(IServer.STATE_STOPPING);
- Trace.trace(Trace.FINEST, "Killing the Server process");
+ Trace.trace(Trace.FINEST, "Killing the Server process"); //$NON-NLS-1$
if (process != null && !process.isTerminated()) {
process.terminate();
}
stopImpl();
} catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error killing the process", e);
+ Trace.trace(Trace.SEVERE, "Error killing the process", e); //$NON-NLS-1$
}
}
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerCoreMessages.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerCoreMessages.java
index 6792cbc..d3f9f7f 100644
--- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerCoreMessages.java
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerCoreMessages.java
@@ -37,9 +37,16 @@
public static String errorStartingExternalDebugging;
public static String invalidPath;
public static String runModeNotSupported;
+ public static String unableToCreatePublisher;
+ public static String canNotPublishDeletedModule;
+ public static String antLauncherMissing;
static{
NLS.initializeMessages(RESOURCE_BUNDLE, GenericServerCoreMessages.class);
}
+
+
+
+
}
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerCoreMessages.properties b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerCoreMessages.properties
index 54bc75a..36e088b 100644
--- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerCoreMessages.properties
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerCoreMessages.properties
@@ -24,4 +24,7 @@
debugPortUnspecified=Debugging port is unspecified
errorStartingExternalDebugging=Error launching remote debugging for external server, changing to non-debugging mode.\nPlease check the debug port setting and ensure that the specified 'start' executable launches the server with debugging enabled
invalidPath = {0} is not valid
-runModeNotSupported= Selected VM does not support this mode
\ No newline at end of file
+runModeNotSupported= Selected VM does not support this mode
+unableToCreatePublisher=Unable to create publisher {0}
+canNotPublishDeletedModule=Can not publish because module {0} is closed or deleted
+antLauncherMissing=Ant launcher is missing or disabled
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerLaunchConfigurationDelegate.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerLaunchConfigurationDelegate.java
index e20e92a..068d31d 100644
--- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServerLaunchConfigurationDelegate.java
@@ -42,7 +42,7 @@
IServer server = ServerUtil.getServer(configuration);
if (server == null) {
- abort("Server does not exist", null,
+ abort(GenericServerCoreMessages.missingServer, null,
IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
GenericServerBehaviour genericServer = (GenericServerBehaviour) server.loadAdapter(ServerBehaviourDelegate.class, null);
@@ -96,7 +96,7 @@
runner.run(runConfig, launch, monitor);
genericServer.setProcess(launch.getProcesses()[0]);
} catch (CoreException e) {
- Trace.trace(Trace.SEVERE,"error lauching generic server",e);
+ Trace.trace(Trace.SEVERE,"error launching generic server",e); //$NON-NLS-1$
genericServer.terminate();
throw e;
}