Author: jlaskowski Date: Wed Aug 6 04:35:20 2008 New Revision: 683230 URL: http://svn.apache.org/viewvc?rev=683230&view=rev Log: Web app gets deployed yet a browser does not open up as Run project properties are empty and ${url.client} error message shows up. More work needed to deploy a webapp with no troubles Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java?rev=683230&r1=683229&r2=683230&view=diff ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java (original) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoDeploymentManager.java Wed Aug 6 04:35:20 2008 @@ -36,6 +36,7 @@ import javax.enterprise.deploy.spi.factories.DeploymentFactory; import javax.enterprise.deploy.spi.status.ProgressObject; import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; +import org.openide.util.Exceptions; /** * The DeploymentManager object provides the core set of functions a J2EE platform must provide for J2EE application deployment. @@ -66,25 +67,31 @@ serverDir = GeronimoPluginProperties.getInstance().getInstallLocation(); } - URLClassLoader loader = GeronimoPluginUtils.getGeronimoClassLoader(serverDir); - ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(loader); - openWrappedDeploymentFactory(); - } finally { - Thread.currentThread().setContextClassLoader(oldCL); + if (!connected) { + URLClassLoader loader = GeronimoPluginUtils.getGeronimoClassLoader(serverDir); + ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(loader); + openWrappedDeploymentFactory(); + } finally { + Thread.currentThread().setContextClassLoader(oldCL); + } } } private void openWrappedDeploymentFactory() throws DeploymentManagerCreationException { assert df != null : "Wrapped deployment factory must not be null"; - LOGGER.log(Level.FINE, "Creating" + (connected ? "" : " disconnected") + " deployment manager"); - if (connected) { - dm = df.getDeploymentManager(this.uri, this.username, this.password); - } else { - dm = df.getDisconnectedDeploymentManager(this.uri); + LOGGER.log(Level.FINE, "About to create" + (connected ? "" : " disconnected") + " deployment manager"); + if (dm == null) { + LOGGER.log(Level.FINE, "Creating" + (connected ? "" : " disconnected") + " deployment manager"); + if (connected) { + // FIXME: A hack to handle jmx geronimo dm to contact the server when jmx url is in used (inVM is temporarily the default) + dm = df.getDeploymentManager(GeronimoDeploymentFactory.URI_PREFIX + ":" + "jmx", this.username, this.password); + } else { + dm = df.getDisconnectedDeploymentManager(this.uri); + } + LOGGER.log(Level.FINE, (connected ? "" : "Disconnected ") + "deployment manager created " + this.dm); } - LOGGER.log(Level.FINE, (connected ? "" : "Disconnected ") + "deployment manager created " + this.dm); } public InstanceProperties getInstanceProperties() { @@ -95,6 +102,12 @@ } public Target[] getTargets() throws IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } Target[] targets = null; if (dm != null) { targets = dm.getTargets(); @@ -103,22 +116,52 @@ } public TargetModuleID[] getRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.getRunningModules(moduleType, target); } public TargetModuleID[] getNonRunningModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.getNonRunningModules(moduleType, target); } public TargetModuleID[] getAvailableModules(ModuleType moduleType, Target[] target) throws TargetException, IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.getAvailableModules(moduleType, target); } public DeploymentConfiguration createConfiguration(DeployableObject deployableObject) throws InvalidModuleException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return new GeronimoConfiguration(deployableObject); } public ProgressObject distribute(Target[] target, File file, File file2) throws IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } String serverDir = GeronimoPluginUtils.getInstanceProperties(uri).getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR); if (serverDir == null) { serverDir = GeronimoPluginProperties.getInstance().getInstallLocation(); @@ -135,6 +178,12 @@ @SuppressWarnings("deprecation") public ProgressObject distribute(Target[] target, InputStream is, InputStream is2) throws IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } String serverDir = GeronimoPluginUtils.getInstanceProperties(uri).getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR); if (serverDir == null) { serverDir = GeronimoPluginProperties.getInstance().getInstallLocation(); @@ -150,6 +199,12 @@ } public ProgressObject distribute(Target[] target, ModuleType moduleType, InputStream is, InputStream is2) throws IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } String serverDir = GeronimoPluginUtils.getInstanceProperties(uri).getProperty(GeronimoPluginProperties.PROPERTY_SERVER_DIR); if (serverDir == null) { serverDir = GeronimoPluginProperties.getInstance().getInstallLocation(); @@ -165,26 +220,62 @@ } public ProgressObject start(TargetModuleID[] targetModuleId) throws IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.start(targetModuleId); } public ProgressObject stop(TargetModuleID[] targetModuleId) throws IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.stop(targetModuleId); } public ProgressObject undeploy(TargetModuleID[] targetModuleId) throws IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.undeploy(targetModuleId); } public boolean isRedeploySupported() { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.isRedeploySupported(); } public ProgressObject redeploy(TargetModuleID[] targetModuleId, File file, File file2) throws UnsupportedOperationException, IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.redeploy(targetModuleId, file, file2); } public ProgressObject redeploy(TargetModuleID[] targetModuleId, InputStream is, InputStream is2) throws UnsupportedOperationException, IllegalStateException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.redeploy(targetModuleId, is, is2); } @@ -195,34 +286,82 @@ } public Locale getDefaultLocale() { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.getDefaultLocale(); } public Locale getCurrentLocale() { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.getCurrentLocale(); } public void setLocale(Locale locale) throws UnsupportedOperationException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } dm.setLocale(locale); } public Locale[] getSupportedLocales() { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.getSupportedLocales(); } public boolean isLocaleSupported(Locale locale) { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.isLocaleSupported(locale); } public DConfigBeanVersionType getDConfigBeanVersion() { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.getDConfigBeanVersion(); } public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType dConfigBeanVersionType) { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } return dm.isDConfigBeanVersionSupported(dConfigBeanVersionType); } public void setDConfigBeanVersion(DConfigBeanVersionType dConfigBeanVersionType) throws DConfigBeanVersionUnsupportedException { + try { + openWrappedDeploymentFactory(); + } catch (DeploymentManagerCreationException ex) { + Exceptions.printStackTrace(ex); + throw new IllegalStateException(ex); + } dm.setDConfigBeanVersion(dConfigBeanVersionType); } } Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java?rev=683230&r1=683229&r2=683230&view=diff ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java (original) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoPluginUtils.java Wed Aug 6 04:35:20 2008 @@ -29,8 +29,6 @@ import java.security.Permissions; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -54,7 +52,7 @@ */ public class GeronimoPluginUtils { - private static final Logger logger = Logger.getLogger(GeronimoPluginUtils.class.getName()); + private static final Logger LOGGER = Logger.getLogger(GeronimoPluginUtils.class.getName()); private static final String DEPLOYER_JAR_PATH = "/bin/deployer.jar"; private static final String SERVER_JAR_PATH = "/bin/server.jar"; private static final String DEPLOY_JSR88_PARTIAL_JAR_PATH = "/repository/org/apache/geronimo/modules/geronimo-deploy-jsr88/"; @@ -121,7 +119,7 @@ // it must not happen // it's thrown only when instance with same url is already registered, but it's just been checked String msg = NbBundle.getMessage(GeronimoPluginUtils.class, "MSG_ExceptionThrownButShouldHaveNot", ice.getClass().getName(), ice.getLocalizedMessage()); - logger.log(Level.WARNING, msg, ice); + LOGGER.log(Level.WARNING, msg, ice); } } return instanceProperties; @@ -186,74 +184,15 @@ URLClassLoader loader = null; try { List urlList = new ArrayList(); - { - File[] libs = new File(serverRoot + "/lib").listFiles(); - for (File lib : libs) { - urlList.add(lib.toURI().toURL()); - System.out.println(">> lib=" + lib.toURI().toURL()); - } - } - urlList.add(new File(serverRoot + DEPLOYER_JAR_PATH).toURI().toURL()); - urlList.add(new File(serverRoot + SERVER_JAR_PATH).toURI().toURL()); - - String version = computeGeronimoVersion(serverRoot); - - System.out.println("version=" + version); - - // FIXME: Remove the static, hardcoded paths - // FIXME: Use regular expression to find correct file names - final String geronimo_deploy_config_jar = "/repository/org/apache/geronimo/modules/geronimo-deploy-config/" + version + "/geronimo-deploy-config-" + version + ".jar"; - urlList.add(new File(serverRoot + geronimo_deploy_config_jar).toURI().toURL()); - final String geronimo_system_jar = "/repository/org/apache/geronimo/modules/geronimo-system/" + version + "/geronimo-system-" + version + ".jar"; - urlList.add(new File(serverRoot + geronimo_system_jar).toURI().toURL()); - final String geronimo_javaee_deployment_spec_jar = "/repository/org/apache/geronimo/specs/geronimo-javaee-deployment_1.1MR3_spec/1.0/geronimo-javaee-deployment_1.1MR3_spec-1.0.jar"; - urlList.add(new File(serverRoot + geronimo_javaee_deployment_spec_jar).toURI().toURL()); - final String openejb_jar = "/repository/org/apache/openejb/openejb-client/3.0.0-SNAPSHOT/openejb-client-3.0.0-SNAPSHOT.jar"; - urlList.add(new File(serverRoot + openejb_jar).toURI().toURL()); - final String ejb_spec_jar = "/repository/org/apache/geronimo/specs/geronimo-ejb_3.0_spec/1.0/geronimo-ejb_3.0_spec-1.0.jar"; - urlList.add(new File(serverRoot + ejb_spec_jar).toURI().toURL()); - File deployJsr88Jar = new File(serverRoot + DEPLOY_JSR88_PARTIAL_JAR_PATH + version + File.separator + "geronimo-deploy-jsr88-" + version + ".jar"); - if (deployJsr88Jar.exists()) { - urlList.add(deployJsr88Jar.toURI().toURL()); - } - - urlList.clear(); - - File[] libs = new File(serverRoot + "/lib").listFiles(); - for (File lib : libs) { - if (lib.getName().contains("commons-logging")) { - continue; - } - urlList.add(lib.toURI().toURL()); - System.out.println(">> lib=" + lib.toURI().toURL()); - } - urlList.add(new File(serverRoot + "/repository/commons-jexl/commons-jexl/1.1/commons-jexl-1.1.jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/repository/org/apache/geronimo/framework/geronimo-deploy-jsr88/" + version + "/geronimo-deploy-jsr88-" + version + ".jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/repository/org/apache/geronimo/framework/geronimo-deploy-config/" + version + "/geronimo-deploy-config-" + version + ".jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/repository/org/apache/geronimo/framework/geronimo-plugin/" + version + "/geronimo-plugin-" + version + ".jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/repository/org/apache/geronimo/framework/geronimo-system/" + version + "/geronimo-system-" + version + ".jar").toURI().toURL()); - //urlList.add(new File(serverRoot + "/repository/org/apache/geronimo/specs/geronimo-javaee-deployment_1.1MR3_spec/1.0/geronimo-javaee-deployment_1.1MR3_spec-1.0.jar").toURI().toURL()); - System.out.println("urlList.size=" + urlList.size()); - urlList.remove(new File(serverRoot + "/lib/log4j-1.2.14.jar").toURI().toURL()); - urlList.remove(new File(serverRoot + "/lib/commons-logging-1.0.4.jar").toURI().toURL()); - urlList.remove(new File(serverRoot + "/lib/xpp3-1.1.3.4.O.jar").toURI().toURL()); - urlList.remove(new File(serverRoot + "/lib/xstream-1.2.2.jar").toURI().toURL()); - System.out.println("urlList.size=" + urlList.size()); - for (URL url : urlList) { - System.out.println("file=" + url); - } - - urlList.clear(); - - urlList.add(new File(serverRoot + "/lib/geronimo-deploy-jsr88-bootstrapper-2.1.1.jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/lib/geronimo-kernel-2.1.1.jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/lib/asm-2.2.3.jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/lib/asm-commons-2.2.3.jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/lib/cglib-nodep-2.1_3.jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/lib/log4j-1.2.14.jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/lib/xpp3-1.1.3.4.O.jar").toURI().toURL()); - urlList.add(new File(serverRoot + "/lib/xstream-1.2.2.jar").toURI().toURL()); +// urlList.add(new File(serverRoot + "/lib/geronimo-deploy-jsr88-bootstrapper-2.1.1.jar").toURI().toURL()); +// urlList.add(new File(serverRoot + "/lib/geronimo-kernel-2.1.1.jar").toURI().toURL()); +// urlList.add(new File(serverRoot + "/lib/asm-2.2.3.jar").toURI().toURL()); +// urlList.add(new File(serverRoot + "/lib/asm-commons-2.2.3.jar").toURI().toURL()); +// urlList.add(new File(serverRoot + "/lib/cglib-nodep-2.1_3.jar").toURI().toURL()); +// urlList.add(new File(serverRoot + "/lib/log4j-1.2.14.jar").toURI().toURL()); +// urlList.add(new File(serverRoot + "/lib/xpp3-1.1.3.4.O.jar").toURI().toURL()); +// urlList.add(new File(serverRoot + "/lib/xstream-1.2.2.jar").toURI().toURL()); // // org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. // urlList.add(new File(serverRoot + "/lib/commons-logging-1.0.4.jar").toURI().toURL()); // Class-Path causes troubles due to commons-logging @@ -263,12 +202,12 @@ // urlList.add(new File(serverRoot + "/lib/cglib-nodep-2.1_3.jar").toURI().toURL()); // urlList.add(new File(serverRoot + "/lib/geronimo-transformer-2.1.1.jar").toURI().toURL()); - //System.setProperty("Xorg.apache.geronimo.gbean.NoProxy", "false"); + System.setProperty("Xorg.apache.geronimo.gbean.NoProxy", "false"); loader = new GeronimoClassLoader(urlList.toArray(new URL[urlList.size()]), GeronimoDeploymentFactory.class.getClassLoader()); - System.out.println(Arrays.asList(loader.getURLs())); + LOGGER.log(Level.FINE, "GeronimoClassLoader.getURLs()=" + Arrays.asList(loader.getURLs())); } catch (Exception e) { - logger.log(Level.WARNING, e.getLocalizedMessage(), e); + LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); } return loader; } @@ -385,5 +324,20 @@ p.add(new AllPermission()); return p; } + + @Override + public URL getResource(String name) { + // FIXME: A hack to shut down the PCL logger while log4j conf files are loaded from the default (unnamed) package + final String pclName = "org.netbeans.ProxyClassLoader"; + Level oldLevel = Logger.getLogger(pclName).getLevel(); + try { + if ("log4j.xml".equals(name) || "log4j.properties".equals(name)) { + Logger.getLogger(pclName).setLevel(java.util.logging.Level.OFF); + } + return super.getResource(name); + } finally { + Logger.getLogger(pclName).setLevel(oldLevel); + } + } } } Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java?rev=683230&r1=683229&r2=683230&view=diff ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java (original) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/GeronimoStartServer.java Wed Aug 6 04:35:20 2008 @@ -100,12 +100,12 @@ return false; } - public boolean needsStartForTargetList() { - return false; - } - public boolean needsStartForAdminConfig() { - return false; + return true; + } + + public boolean needsStartForTargetList() { + return true; } // FIXME: It should check out more enterprise services than kernel alone @@ -262,7 +262,7 @@ return null; } // FIXME: User should decide what params are to be used - String args = "-c \"geronimo/start-server\""; + String args = "-c \"geronimo/start-server -v -v\""; return new NbProcessDescriptor(scriptName, args); } Modified: geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties URL: http://svn.apache.org/viewvc/geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties?rev=683230&r1=683229&r2=683230&view=diff ============================================================================== --- geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties (original) +++ geronimo/sandbox/geronimo-netbeans-plugin/src/org/apache/geronimo/netbeans/wizard/Bundle.properties Wed Aug 6 04:35:20 2008 @@ -23,6 +23,6 @@ ACSD_locationBrowseButton=Browse for the server location ACSD_locationField=Server Location DIRECTORIES_FILTER_NAME=Directories -ERR_InvalidServerLocation=The entered installation directory is not a valid Geronimo 2.0 directory +ERR_InvalidServerLocation=The entered installation directory is not a valid Geronimo 2.1 directory MSG_SpecifyInstallationFolder=Specify the installation folder (Geronimo Home) and login details