This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 89969
Collapse All | Expand All

(-)src/org/netbeans/modules/j2ee/jboss4/Bundle.properties (-1 / +1 lines)
Lines 18-24 Link Here
18
#
18
#
19
19
20
20
21
SERVER_NAME=JBoss Application Server 4
21
SERVER_NAME=JBoss Application Server
22
LBL_JBossFactoryVersion=Deployment Factory for JBoss 4 plugin 
22
LBL_JBossFactoryVersion=Deployment Factory for JBoss 4 plugin 
23
23
24
MSG_DEPLOYING=Deploying {0}
24
MSG_DEPLOYING=Deploying {0}
(-)src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java (-18 / +46 lines)
Lines 30-38 Link Here
30
import java.security.CodeSource;
30
import java.security.CodeSource;
31
import java.security.PermissionCollection;
31
import java.security.PermissionCollection;
32
import java.security.Permissions;
32
import java.security.Permissions;
33
import java.util.ArrayList;
33
import java.util.Collections;
34
import java.util.Collections;
34
import java.util.Enumeration;
35
import java.util.Enumeration;
35
import java.util.HashSet;
36
import java.util.HashSet;
37
import java.util.List;
36
import java.util.Set;
38
import java.util.Set;
37
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
39
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
38
import org.openide.ErrorManager;
40
import org.openide.ErrorManager;
Lines 99-118 Link Here
99
101
100
    public static URLClassLoader getJBClassLoader(String serverRoot, String domainRoot){
102
    public static URLClassLoader getJBClassLoader(String serverRoot, String domainRoot){
101
        try {
103
        try {
102
            // dom4j.jar library for JBoss Application Server 4.0.4 and lower
104
            // dom4j.jar library for JBoss Application Server 4.0.4 and lower and JBoss Application Server 5.0
103
            File dom404 = new File(serverRoot + "/lib/dom4j.jar");
105
            File dom404 = new File(serverRoot + "/lib/dom4j.jar"); // NOI18N
104
106
105
            // dom4j.jar library for JBoss Application Server 4.0.5
107
            // dom4j.jar library for JBoss Application Server 4.0.5
106
            File dom405 = new File(domainRoot + "/lib/dom4j.jar");
108
            File dom405 = new File(domainRoot + "/lib/dom4j.jar"); // NOI18N
107
109
108
            URL urls[] = new URL[]{
110
            // jboss-common-client.jar JBoss Application Server 4.x
109
                    new File(serverRoot + "/client/jbossall-client.jar").toURI().toURL(),      //NOI18N
111
            File client40 = new File(serverRoot + "/client/jboss-common-client.jar"); // NOI18N
110
                    new File(serverRoot + "/client/jboss-common-client.jar").toURI().toURL(),  //NOI18N
112
111
                    new File(serverRoot + "/client/jboss-deployment.jar").toURI().toURL(),     //NOI18N
113
            // jboss-client.jar JBoss Application Server 5.0
112
                    new File(serverRoot + "/client/jnp-client.jar").toURI().toURL(),           //NOI18N
114
            File client50 = new File(serverRoot + "/client/jboss-client.jar"); // NOI18N
113
                    (dom404.exists()) ? (dom404.toURI().toURL()) : (dom405.toURI().toURL())    //NOI18N
115
114
            };
116
            // jboss-common-core.jar for JBoss Application Server 5.0
115
            URLClassLoader loader = new JBClassLoader(urls, JBDeploymentFactory.class.getClassLoader());
117
            File core50 = new File(serverRoot + "/client/jboss-common-core.jar"); // NOI18N
118
119
            // jboss-logging-spi.jar for JBoss Application Server 5.0
120
            File logging50 = new File(serverRoot + "/client/jboss-logging-spi.jar"); // NOI18N
121
122
            List<URL> urlList = new ArrayList<URL>();
123
            
124
            urlList.add(new File(serverRoot + "/client/jbossall-client.jar").toURI().toURL());      //NOI18N
125
            urlList.add(new File(serverRoot + "/client/jboss-deployment.jar").toURI().toURL());     //NOI18N
126
            urlList.add(new File(serverRoot + "/client/jnp-client.jar").toURI().toURL());           //NOI18N
127
            urlList.add((dom404.exists()) ? (dom404.toURI().toURL()) : (dom405.toURI().toURL()));   //NOI18N
128
129
            if(client40.exists())
130
                urlList.add(client40.toURI().toURL());
131
132
            if(client50.exists())
133
                urlList.add(client50.toURI().toURL());
134
135
            if(core50.exists())
136
                urlList.add(core50.toURI().toURL());
137
138
            if(logging50.exists())
139
                urlList.add(logging50.toURI().toURL());
140
            
141
            URLClassLoader loader = new JBClassLoader(urlList.toArray(new URL[] {}), JBDeploymentFactory.class.getClassLoader());
116
            return loader;
142
            return loader;
117
        } catch (Exception e) {
143
        } catch (Exception e) {
118
            ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e);
144
            ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e);
Lines 231-243 Link Here
231
            String serverLocation = getDefaultInstallLocation();
257
            String serverLocation = getDefaultInstallLocation();
232
            String domainLocation = serverLocation + File.separator + "server" + File.separator + "default"; // NOI18N
258
            String domainLocation = serverLocation + File.separator + "server" + File.separator + "default"; // NOI18N
233
            setRemovability(serverInstanceDir, domainLocation);
259
            setRemovability(serverInstanceDir, domainLocation);
234
            if (JBPluginUtils.isGoodJBServerLocation(new File(serverLocation))) {
260
            if (JBPluginUtils.isGoodJBServerLocation4x(new File(serverLocation))    &&
235
                if (JBPluginUtils.isGoodJBInstanceLocation(new File(domainLocation))) {
261
                JBPluginUtils.isGoodJBInstanceLocation4x(new File(domainLocation))  ||
236
                    if (!isAlreadyRegistered(serverInstanceDir, domainLocation)) {
262
                JBPluginUtils.isGoodJBServerLocation5x(new File(serverLocation))    &&
237
                        String host = "localhost"; // NOI18N
263
                JBPluginUtils.isGoodJBInstanceLocation5x(new File(domainLocation)))
238
                        String port = JBPluginUtils.getHTTPConnectorPort(domainLocation); // NOI18N
264
            {
239
                        register(serverInstanceDir, serverLocation, domainLocation, host, port);
265
                if (!isAlreadyRegistered(serverInstanceDir, domainLocation)) {
240
                    }
266
                    String host = "localhost"; // NOI18N
267
                    String port = JBPluginUtils.getHTTPConnectorPort(domainLocation); // NOI18N
268
                    register(serverInstanceDir, serverLocation, domainLocation, host, port);
241
                }
269
                }
242
            }
270
            }
243
        }
271
        }
(-)src/org/netbeans/modules/j2ee/jboss4/JBDeploymentManager.java (-9 / +17 lines)
Lines 42-47 Link Here
42
import javax.enterprise.deploy.spi.exceptions.InvalidModuleException;
42
import javax.enterprise.deploy.spi.exceptions.InvalidModuleException;
43
import javax.enterprise.deploy.spi.exceptions.TargetException;
43
import javax.enterprise.deploy.spi.exceptions.TargetException;
44
import javax.enterprise.deploy.spi.status.ProgressObject;
44
import javax.enterprise.deploy.spi.status.ProgressObject;
45
import javax.management.MBeanServerConnection;
45
import javax.naming.Context;
46
import javax.naming.Context;
46
import javax.naming.InitialContext;
47
import javax.naming.InitialContext;
47
import org.netbeans.modules.j2ee.jboss4.config.CarDeploymentConfiguration;
48
import org.netbeans.modules.j2ee.jboss4.config.CarDeploymentConfiguration;
Lines 58-64 Link Here
58
    
59
    
59
    private DeploymentManager dm;
60
    private DeploymentManager dm;
60
    private String realUri;
61
    private String realUri;
61
    private Object rmiServer;
62
    private MBeanServerConnection rmiServer;
62
    
63
    
63
    private int debuggingPort = 8787;
64
    private int debuggingPort = 8787;
64
    
65
    
Lines 109-115 Link Here
109
        return instanceProperties;
110
        return instanceProperties;
110
    }
111
    }
111
    
112
    
112
    public synchronized Object getRMIServer() {
113
    public synchronized MBeanServerConnection getRMIServer() {
113
        if(rmiServer == null) {
114
        if(rmiServer == null) {
114
            try {
115
            try {
115
                InstanceProperties ip = this.getInstanceProperties();
116
                InstanceProperties ip = this.getInstanceProperties();
Lines 121-140 Link Here
121
                Hashtable env = new Hashtable();
122
                Hashtable env = new Hashtable();
122
                
123
                
123
                // Sets the jboss naming environment
124
                // Sets the jboss naming environment
124
                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory");
125
                env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.NamingContextFactory");
125
                env.put(Context.PROVIDER_URL, "jnp://localhost:"+JBPluginUtils.getJnpPort(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR)));
126
                env.put(Context.PROVIDER_URL, "jnp://localhost:"+JBPluginUtils.getJnpPort(ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR)));
126
                env.put(Context.SECURITY_PRINCIPAL, props.getUsername());
127
                env.put(Context.SECURITY_CREDENTIALS, props.getPassword());
128
                env.put(Context.OBJECT_FACTORIES, "org.jboss.naming");
127
                env.put(Context.OBJECT_FACTORIES, "org.jboss.naming");
129
                env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
128
                env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
130
                env.put("jnp.disableDiscovery", Boolean.TRUE);
129
                env.put("jnp.disableDiscovery", Boolean.TRUE);
131
                
130
                
132
                // set the java.security.auth.login.config system property needed by InitialContext 
133
                final String JAVA_SEC_AUTH_LOGIN_CONF = "java.security.auth.login.config"; // NOI18N
131
                final String JAVA_SEC_AUTH_LOGIN_CONF = "java.security.auth.login.config"; // NOI18N
134
                String oldAuthConf = System.getProperty(JAVA_SEC_AUTH_LOGIN_CONF);
132
                String oldAuthConf = System.getProperty(JAVA_SEC_AUTH_LOGIN_CONF);
135
                System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, props.getRootDir() + "/client/auth.conf"); // NOI18N
133
                
134
                File securityConf = new File(props.getRootDir(), "/client/auth.conf");
135
                if (securityConf.exists()) {
136
                    env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory");
137
                    env.put(Context.SECURITY_PRINCIPAL, props.getUsername());
138
                    env.put(Context.SECURITY_CREDENTIALS, props.getPassword());
139
                    System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, securityConf.getAbsolutePath()); // NOI18N
140
                }
141
                
136
                // Gets naming context
142
                // Gets naming context
137
                InitialContext ctx = new InitialContext(env);
143
                InitialContext ctx = new InitialContext(env);
144
145
                //restore java.security.auth.login.config system property 
138
                if (oldAuthConf != null) {
146
                if (oldAuthConf != null) {
139
                    System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, oldAuthConf);
147
                    System.setProperty(JAVA_SEC_AUTH_LOGIN_CONF, oldAuthConf);
140
                } else {
148
                } else {
Lines 142-148 Link Here
142
                }
150
                }
143
                
151
                
144
                // Lookup RMI Adaptor
152
                // Lookup RMI Adaptor
145
                rmiServer = ctx.lookup("/jmx/invoker/RMIAdaptor");
153
                rmiServer = (MBeanServerConnection)ctx.lookup("/jmx/invoker/RMIAdaptor");
146
            } catch (NameNotFoundException ex) {
154
            } catch (NameNotFoundException ex) {
147
            } catch (NamingException ex) {} // Nothing to do
155
            } catch (NamingException ex) {} // Nothing to do
148
        }
156
        }
Lines 150-156 Link Here
150
        return rmiServer;
158
        return rmiServer;
151
    }
159
    }
152
    
160
    
153
    public synchronized Object refreshRMIServer() {
161
    public synchronized MBeanServerConnection refreshRMIServer() {
154
        rmiServer = null;
162
        rmiServer = null;
155
        return getRMIServer();
163
        return getRMIServer();
156
    }
164
    }
(-)src/org/netbeans/modules/j2ee/jboss4/ide/JBJ2eePlatformFactory.java (-5 / +8 lines)
Lines 61-67 Link Here
61
        assert JBDeploymentManager.class.isAssignableFrom(dm.getClass()) : this + " cannot create platform for unknown deployment manager:" + dm;
61
        assert JBDeploymentManager.class.isAssignableFrom(dm.getClass()) : this + " cannot create platform for unknown deployment manager:" + dm;
62
        // Ensure that for each server instance will be always used the same instance of the J2eePlatformImpl
62
        // Ensure that for each server instance will be always used the same instance of the J2eePlatformImpl
63
        JBDeploymentManager manager  = (JBDeploymentManager) dm;
63
        JBDeploymentManager manager  = (JBDeploymentManager) dm;
64
        InstanceProperties ip = ((JBDeploymentManager) manager).getInstanceProperties();
64
        InstanceProperties ip = manager.getInstanceProperties();
65
        if (ip == null) {
65
        if (ip == null) {
66
            throw new RuntimeException("Cannot create J2eePlatformImpl instance for " + manager.getUrl()); // NOI18N
66
            throw new RuntimeException("Cannot create J2eePlatformImpl instance for " + manager.getUrl()); // NOI18N
67
        }
67
        }
Lines 101-107 Link Here
101
        }
101
        }
102
102
103
        public Set getSupportedSpecVersions() {
103
        public Set getSupportedSpecVersions() {
104
            if (properties.isJavaEE5()) {
104
            if (properties.supportsJavaEE5ejb3() && properties.supportsJavaEE5web()) {
105
                return SPEC_VERSIONS_5;
105
                return SPEC_VERSIONS_5;
106
            } else {
106
            } else {
107
                return SPEC_VERSIONS;
107
                return SPEC_VERSIONS;
Lines 109-122 Link Here
109
        }
109
        }
110
110
111
        public Set<String> getSupportedSpecVersions(Object moduleType) {
111
        public Set<String> getSupportedSpecVersions(Object moduleType) {
112
            // JavaEE5 web and app client modules are not supported
112
            // JavaEE5 app client is not supported for JBoss 5.x
113
            if (properties.isJavaEE5() && !(J2eeModule.WAR.equals(moduleType) || J2eeModule.CLIENT.equals(moduleType))) {
113
            if (properties.supportsJavaEE5ejb3() && properties.supportsJavaEE5web() && !J2eeModule.CLIENT.equals(moduleType)) {
114
                return SPEC_VERSIONS_5;
115
            }
116
            // JavaEE5 web and app client modules are not supported for JBoss 4.x
117
            if (properties.supportsJavaEE5ejb3() && !(J2eeModule.WAR.equals(moduleType) || J2eeModule.CLIENT.equals(moduleType))) {
114
                return SPEC_VERSIONS_5;
118
                return SPEC_VERSIONS_5;
115
            } else {
119
            } else {
116
                return SPEC_VERSIONS;
120
                return SPEC_VERSIONS;
117
            }
121
            }
118
        }
122
        }
119
120
123
121
        public Set getSupportedModuleTypes() {
124
        public Set getSupportedModuleTypes() {
122
            return MODULE_TYPES;
125
            return MODULE_TYPES;
(-)src/org/netbeans/modules/j2ee/jboss4/ide/JBLogWriter.java (-6 / +11 lines)
Lines 181-203 Link Here
181
             */
181
             */
182
            private void checkStartProgress(String line) {
182
            private void checkStartProgress(String line) {
183
183
184
                if (line.indexOf("Starting JBoss (MX MicroKernel)") > -1) {
184
                if (line.indexOf("Starting JBoss (MX MicroKernel)") > -1 || // JBoss 4.x message // NOI18N
185
                    line.indexOf("Starting JBoss (Microcontainer)") > -1)   // JBoss 5.0 message // NOI18N
186
                {
185
                    if (VERBOSE) {
187
                    if (VERBOSE) {
186
                        System.out.println("STARTING message fired");            
188
                        System.out.println("STARTING message fired"); // NOI18N
187
                    }
189
                    }
188
                    fireStartProgressEvent(StateType.RUNNING, createProgressMessage("MSG_START_SERVER_IN_PROGRESS"));
190
                    fireStartProgressEvent(StateType.RUNNING, createProgressMessage("MSG_START_SERVER_IN_PROGRESS")); // NOI18N
189
                }
191
                }
190
                else 
192
                else 
191
                if (line.indexOf("JBoss (MX MicroKernel)") > -1 && line.indexOf("Started in") > -1) {//NOI18N
193
                if ((line.indexOf("JBoss (MX MicroKernel)") > -1 ||     // JBoss 4.x message    // NOI18N
194
                     line.indexOf("JBoss (Microcontainer)") > -1) &&    // JBoss 5.0 message    // NOI18N
195
                     line.indexOf("Started in") > -1)                                           // NOI18N
196
                {
192
                    if (VERBOSE) {
197
                    if (VERBOSE) {
193
                        System.out.println("STARTED message fired");            
198
                        System.out.println("STARTED message fired"); // NOI18N
194
                    }
199
                    }
195
                    checkStartProgress = false;
200
                    checkStartProgress = false;
196
                    actionStatus = JBStartServer.ACTION_STATUS.SUCCESS;
201
                    actionStatus = JBStartServer.ACTION_STATUS.SUCCESS;
197
                    notifyStartupThread();
202
                    notifyStartupThread();
198
                }
203
                }
199
                else 
204
                else 
200
                if (line.indexOf("Shutdown complete") > -1) {
205
                if (line.indexOf("Shutdown complete") > -1) { // NOI18N
201
                    checkStartProgress = false;
206
                    checkStartProgress = false;
202
                    actionStatus = JBStartServer.ACTION_STATUS.FAILURE;
207
                    actionStatus = JBStartServer.ACTION_STATUS.FAILURE;
203
                    notifyStartupThread();
208
                    notifyStartupThread();
(-)src/org/netbeans/modules/j2ee/jboss4/ide/JBStartServer.java (-2 / +2 lines)
Lines 203-210 Link Here
203
                    result = false;
203
                    result = false;
204
                }
204
                }
205
                
205
                
206
                Object serverName = Util.getMBeanParameter(dm, "ServerName", "jboss.system:type=ServerConfig", String.class);
206
                Object serverName = Util.getMBeanParameter(dm, "ServerName", "jboss.system:type=ServerConfig");
207
                Object serverHome = Util.getMBeanParameter(dm, "ServerHomeDir", "jboss.system:type=ServerConfig", String.class);
207
                Object serverHome = Util.getMBeanParameter(dm, "ServerHomeDir", "jboss.system:type=ServerConfig");
208
                
208
                
209
                if(serverName == null || serverHome == null) {
209
                if(serverName == null || serverHome == null) {
210
                    result = false;
210
                    result = false;
(-)src/org/netbeans/modules/j2ee/jboss4/ide/ui/AddServerLocationPanel.java (-7 / +9 lines)
Lines 80-95 Link Here
80
    public boolean isValid() {
80
    public boolean isValid() {
81
        String locationStr = ((AddServerLocationVisualPanel)getComponent()).getInstallLocation();
81
        String locationStr = ((AddServerLocationVisualPanel)getComponent()).getInstallLocation();
82
        File location = new File(locationStr);
82
        File location = new File(locationStr);
83
        if (!JBPluginUtils.isGoodJBServerLocation(location)) {
83
        if (!JBPluginUtils.isGoodJBServerLocation4x(location) &&
84
            !JBPluginUtils.isGoodJBServerLocation5x(location)) 
85
        {
84
            wizard.putProperty(PROP_ERROR_MESSAGE,  NbBundle.getMessage(AddServerLocationPanel.class, "MSG_InvalidServerLocation")); // NOI18N
86
            wizard.putProperty(PROP_ERROR_MESSAGE,  NbBundle.getMessage(AddServerLocationPanel.class, "MSG_InvalidServerLocation")); // NOI18N
85
            return false;
87
            return false;
86
        } else {
87
            wizard.putProperty(PROP_ERROR_MESSAGE, null);
88
            JBPluginProperties.getInstance().setInstallLocation(((AddServerLocationVisualPanel)getComponent()).getInstallLocation());
89
            JBPluginProperties.getInstance().saveProperties();
90
            instantiatingIterator.setInstallLocation(locationStr);
91
            return true;
92
        }
88
        }
89
        
90
        wizard.putProperty(PROP_ERROR_MESSAGE, null);
91
        JBPluginProperties.getInstance().setInstallLocation(((AddServerLocationVisualPanel)getComponent()).getInstallLocation());
92
        JBPluginProperties.getInstance().saveProperties();
93
        instantiatingIterator.setInstallLocation(locationStr);
94
        return true;
93
    }
95
    }
94
96
95
    public void removeChangeListener(ChangeListener l) {
97
    public void removeChangeListener(ChangeListener l) {
(-)src/org/netbeans/modules/j2ee/jboss4/ide/ui/AddServerPropertiesPanel.java (-1 / +3 lines)
Lines 58-64 Link Here
58
        if(panel.isLocalServer()){
58
        if(panel.isLocalServer()){
59
            // wrong domain path
59
            // wrong domain path
60
            String path = panel.getDomainPath();
60
            String path = panel.getDomainPath();
61
            if (!JBPluginUtils.isGoodJBInstanceLocation(new File(path))){
61
            if (!JBPluginUtils.isGoodJBInstanceLocation4x(new File(path)) &&
62
                !JBPluginUtils.isGoodJBInstanceLocation5x(new File(path))) 
63
            {
62
                wizard.putProperty(PROP_ERROR_MESSAGE,NbBundle.getMessage(AddServerPropertiesPanel.class, "MSG_WrongDomainPath"));
64
                wizard.putProperty(PROP_ERROR_MESSAGE,NbBundle.getMessage(AddServerPropertiesPanel.class, "MSG_WrongDomainPath"));
63
                return false;
65
                return false;
64
            }
66
            }
(-)src/org/netbeans/modules/j2ee/jboss4/ide/ui/Bundle.properties (-1 / +1 lines)
Lines 31-37 Link Here
31
31
32
LBL_BrowseButton=Br&owse...
32
LBL_BrowseButton=Br&owse...
33
33
34
MSG_InvalidServerLocation=Provide a valid JBoss Application Server 4 Installation Location
34
MSG_InvalidServerLocation=Provide a valid JBoss Application Server 4 or 5 Installation Location
35
35
36
LBL_ChooserName=Choose JBoss Server's Installation Location
36
LBL_ChooserName=Choose JBoss Server's Installation Location
37
37
(-)src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBPluginProperties.java (-1 / +3 lines)
Lines 143-149 Link Here
143
    
143
    
144
    public boolean isCurrentServerLocationValid(){
144
    public boolean isCurrentServerLocationValid(){
145
        if (getInstallLocation()!=null)
145
        if (getInstallLocation()!=null)
146
            return (JBPluginUtils.isGoodJBServerLocation(new File(getInstallLocation())));
146
            return 
147
                JBPluginUtils.isGoodJBServerLocation4x(new File(getInstallLocation())) || 
148
                JBPluginUtils.isGoodJBServerLocation5x(new File(getInstallLocation()));
147
        else
149
        else
148
            return false;
150
            return false;
149
    }
151
    }
(-)src/org/netbeans/modules/j2ee/jboss4/ide/ui/JBPluginUtils.java (-30 / +86 lines)
Lines 24-33 Link Here
24
import java.io.IOException;
24
import java.io.IOException;
25
import java.io.InputStream;
25
import java.io.InputStream;
26
import java.net.ServerSocket;
26
import java.net.ServerSocket;
27
import java.util.Collection;
28
import java.util.Hashtable;
27
import java.util.Hashtable;
29
import java.util.Iterator;
28
import java.util.Iterator;
29
import java.util.LinkedList;
30
import java.util.List;
30
import javax.xml.parsers.DocumentBuilderFactory;
31
import javax.xml.parsers.DocumentBuilderFactory;
32
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
31
import org.openide.ErrorManager;
33
import org.openide.ErrorManager;
32
import org.w3c.dom.Document;
34
import org.w3c.dom.Document;
33
import org.w3c.dom.Element;
35
import org.w3c.dom.Element;
Lines 54-60 Link Here
54
        Hashtable result = new Hashtable();
56
        Hashtable result = new Hashtable();
55
        //  String domainListFile = File.separator+"common"+File.separator+"nodemanager"+File.separator+"nodemanager.domains";  // NOI18N
57
        //  String domainListFile = File.separator+"common"+File.separator+"nodemanager"+File.separator+"nodemanager.domains";  // NOI18N
56
        
58
        
57
        if (isGoodJBServerLocation(new File(serverLocation))){
59
        if (isGoodJBServerLocation4x(new File(serverLocation)) || 
60
            isGoodJBServerLocation5x(new File(serverLocation)))
61
        {
58
           File file = new File(serverLocation + File.separator + "server");  // NOI18N
62
           File file = new File(serverLocation + File.separator + "server");  // NOI18N
59
            
63
            
60
            String[] files = file.list(new FilenameFilter(){
64
            String[] files = file.list(new FilenameFilter(){
Lines 67-73 Link Here
67
            for(int i =0; i<files.length; i++){
71
            for(int i =0; i<files.length; i++){
68
                String path = file.getAbsolutePath() + File.separator + files[i];
72
                String path = file.getAbsolutePath() + File.separator + files[i];
69
                
73
                
70
                if (isGoodJBInstanceLocation(new File(path))){
74
                if (isGoodJBInstanceLocation4x(new File(path)) || 
75
                    isGoodJBInstanceLocation5x(new File(path)))
76
                {
71
                    result.put(files[i], path);
77
                    result.put(files[i], path);
72
                }
78
                }
73
            }
79
            }
Lines 76-134 Link Here
76
    }
82
    }
77
    
83
    
78
    
84
    
79
    //--------------- checking for possible server directory -------------
85
    //--------------- checking for possible domain directory -------------
80
    private static Collection serverFileColl = new java.util.ArrayList();
86
    private static List<String> domainRequirements4x = new LinkedList<String>();
87
    static {
88
        domainRequirements4x.add("conf");                               // NOI18N
89
        domainRequirements4x.add("deploy");                             // NOI18N
90
        domainRequirements4x.add("lib");                                // NOI18N
91
        domainRequirements4x.add("conf/jboss-service.xml");             // NOI18N
92
        domainRequirements4x.add("lib/jboss-j2ee.jar");                 // NOI18N
93
        domainRequirements4x.add("lib/jboss.jar");                      // NOI18N
94
        domainRequirements4x.add("lib/jbosssx.jar");                    // NOI18N
95
        domainRequirements4x.add("lib/jboss-transaction.jar");          // NOI18N
96
        domainRequirements4x.add("lib/jmx-adaptor-plugin.jar");         // NOI18N
97
        domainRequirements4x.add("lib/jnpserver.jar");                  // NOI18N
98
        domainRequirements4x.add("lib/log4j.jar");                      // NOI18N
99
        domainRequirements4x.add("lib/xmlentitymgr.jar");               // NOI18N
100
        domainRequirements4x.add("deploy/jmx-invoker-service.xml");     // NOI18N
101
    }
102
    
103
    private static List<String> domainRequirements5x = new LinkedList<String>();
104
81
    static {
105
    static {
82
        serverFileColl.add("conf");              // NOI18N
106
        domainRequirements5x.add("conf");                               // NOI18N
83
        serverFileColl.add("deploy");               // NOI18N
107
        domainRequirements5x.add("deploy");                             // NOI18N
84
        serverFileColl.add("lib");    // NOI18N
108
        domainRequirements5x.add("lib");                                // NOI18N
85
        serverFileColl.add("conf/jboss-service.xml");      // NOI18N
109
        domainRequirements5x.add("conf/jboss-service.xml");             // NOI18N
86
        serverFileColl.add("lib/jboss-j2ee.jar");   // NOI18N
110
        domainRequirements5x.add("lib/jboss-j2ee.jar");                 // NOI18N
87
        serverFileColl.add("lib/jboss.jar");   // NOI18N
111
        domainRequirements5x.add("lib/jboss.jar");                      // NOI18N
88
        serverFileColl.add("lib/jbosssx.jar");   // NOI18N
112
        domainRequirements5x.add("lib/jbosssx.jar");                    // NOI18N
89
        serverFileColl.add("lib/jboss-transaction.jar");   // NOI18N
113
        domainRequirements5x.add("lib/jboss-transaction.jar");          // NOI18N
90
        serverFileColl.add("lib/jmx-adaptor-plugin.jar");   // NOI18N
114
        domainRequirements5x.add("lib/jmx-adaptor-plugin.jar");         // NOI18N
91
        serverFileColl.add("lib/jnpserver.jar");   // NOI18N
115
        domainRequirements5x.add("lib/jnpserver.jar");                  // NOI18N
92
        serverFileColl.add("lib/log4j.jar");   // NOI18N
116
        domainRequirements5x.add("lib/log4j.jar");                      // NOI18N
93
        serverFileColl.add("lib/xmlentitymgr.jar");   // NOI18N
117
        domainRequirements5x.add("deploy/jmx-invoker-service.xml");     // NOI18N
94
        serverFileColl.add("deploy/jmx-invoker-service.xml");   // NOI18N
95
    }
118
    }
96
    
119
    
97
    public static boolean isGoodJBInstanceLocation(File candidate){
120
    private static boolean isGoodJBInstanceLocation(File candidate, List<String> requirements){
98
        if (null == candidate ||
121
        if (null == candidate ||
99
                !candidate.exists() ||
122
                !candidate.exists() ||
100
                !candidate.canRead() ||
123
                !candidate.canRead() ||
101
                !candidate.isDirectory()  ||
124
                !candidate.isDirectory()  ||
102
                !hasRequiredChildren(candidate, serverFileColl)) {
125
                !hasRequiredChildren(candidate, requirements)) {
103
            return false;
126
            return false;
104
        }
127
        }
105
        return true;
128
        return true;
106
    }
129
    }
107
    
130
    
131
    public static boolean isGoodJBInstanceLocation4x(File candidate){
132
        return isGoodJBInstanceLocation(candidate, domainRequirements4x);
133
    }
134
    
135
    public static boolean isGoodJBInstanceLocation5x(File candidate){
136
        return isGoodJBInstanceLocation(candidate, domainRequirements5x);
137
    }
138
    
108
    //--------------- checking for possible server directory -------------
139
    //--------------- checking for possible server directory -------------
109
    private static Collection fileColl = new java.util.ArrayList();
140
    private static List<String> serverRequirements4x = new LinkedList<String>();
110
    
141
    
111
    static {
142
    static {
112
        fileColl.add("bin");        // NOI18N
143
        serverRequirements4x.add("bin");                        // NOI18N
113
        fileColl.add("client");       // NOI18N
144
        serverRequirements4x.add("client");                     // NOI18N
114
        fileColl.add("lib");     // NOI18N
145
        serverRequirements4x.add("lib");                        // NOI18N
115
        fileColl.add("server");    // NOI18N
146
        serverRequirements4x.add("server");                     // NOI18N
116
        fileColl.add("lib/jboss-common.jar"); // NOI18N
147
        serverRequirements4x.add("lib/jboss-common.jar");       // NOI18N
117
        fileColl.add("lib/endorsed/resolver.jar"); // NOI18N
148
        serverRequirements4x.add("lib/endorsed/resolver.jar");  // NOI18N
118
    }  
149
    }  
119
    
150
    
120
    public static boolean isGoodJBServerLocation(File candidate){
151
    private static List<String> serverRequirements5x = new LinkedList<String>();
152
    
153
    static {
154
        serverRequirements5x.add("bin");                        // NOI18N
155
        serverRequirements5x.add("client");                     // NOI18N
156
        serverRequirements5x.add("lib");                        // NOI18N
157
        serverRequirements5x.add("server");                     // NOI18N
158
        serverRequirements5x.add("lib/jboss-common-core.jar");  // NOI18N
159
        serverRequirements5x.add("lib/endorsed/resolver.jar");  // NOI18N
160
    }  
161
    
162
    private static boolean isGoodJBServerLocation(File candidate, List<String> requirements){
121
        if (null == candidate ||
163
        if (null == candidate ||
122
                !candidate.exists() ||
164
                !candidate.exists() ||
123
                !candidate.canRead() ||
165
                !candidate.canRead() ||
124
                !candidate.isDirectory()  ||
166
                !candidate.isDirectory()  ||
125
                !hasRequiredChildren(candidate, fileColl)) {
167
                !hasRequiredChildren(candidate, requirements)) {
126
            return false;
168
            return false;
127
        }
169
        }
128
        return true;
170
        return true;
129
    }
171
    }
130
    
172
    
131
    private static boolean hasRequiredChildren(File candidate, Collection requiredChildren) {
173
    public static boolean isGoodJBServerLocation4x(File candidate){
174
        return isGoodJBServerLocation(candidate, serverRequirements4x);
175
    }
176
    
177
    public static boolean isGoodJBServerLocation4x(JBDeploymentManager dm){
178
        String installDir = dm.getInstanceProperties().getProperty(JBPluginProperties.PROPERTY_ROOT_DIR);
179
        return isGoodJBServerLocation4x(new File(installDir));
180
    }
181
    
182
    public static boolean isGoodJBServerLocation5x(File candidate){
183
        return isGoodJBServerLocation(candidate, serverRequirements5x);
184
    }
185
    
186
    private static boolean hasRequiredChildren(File candidate, List<String> requiredChildren) {
132
        if (null == candidate)
187
        if (null == candidate)
133
            return false;
188
            return false;
134
        String[] children = candidate.list();
189
        String[] children = candidate.list();
Lines 146-151 Link Here
146
        return true;
201
        return true;
147
    }
202
    }
148
    
203
    
204
    //--------------------------------------------------------------------
149
  
205
  
150
    /**
206
    /**
151
     *
207
     *
(-)src/org/netbeans/modules/j2ee/jboss4/nodes/JBEarApplicationsChildren.java (-4 / +13 lines)
Lines 19-32 Link Here
19
19
20
package org.netbeans.modules.j2ee.jboss4.nodes;
20
package org.netbeans.modules.j2ee.jboss4.nodes;
21
21
22
import java.lang.reflect.InvocationTargetException;
23
import java.util.Iterator;
22
import java.util.Iterator;
24
import java.util.Set;
23
import java.util.Set;
25
import java.util.Vector;
24
import java.util.Vector;
26
import javax.management.MalformedObjectNameException;
27
import javax.management.ObjectInstance;
25
import javax.management.ObjectInstance;
28
import javax.management.ObjectName;
26
import javax.management.ObjectName;
29
import javax.management.QueryExp;
27
import javax.management.QueryExp;
28
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
29
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
30
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
30
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
31
import org.openide.ErrorManager;
31
import org.openide.ErrorManager;
32
import org.openide.nodes.Children;
32
import org.openide.nodes.Children;
Lines 44-49 Link Here
44
    
44
    
45
    private Lookup lookup;
45
    private Lookup lookup;
46
    private Boolean remoteManagementSupported = null;
46
    private Boolean remoteManagementSupported = null;
47
    private Boolean isJB4x = null;
47
    
48
    
48
    JBEarApplicationsChildren(Lookup lookup) {
49
    JBEarApplicationsChildren(Lookup lookup) {
49
        this.lookup = lookup;
50
        this.lookup = lookup;
Lines 60-66 Link Here
60
                    // Query to the jboss4 server
61
                    // Query to the jboss4 server
61
                    ObjectName searchPattern;
62
                    ObjectName searchPattern;
62
                    String propertyName;
63
                    String propertyName;
63
                    if (isRemoteManagementSupported()) {
64
                    if (isRemoteManagementSupported() && isJB4x()) {
64
                        searchPattern = new ObjectName("jboss.management.local:j2eeType=J2EEApplication,*"); // NOI18N
65
                        searchPattern = new ObjectName("jboss.management.local:j2eeType=J2EEApplication,*"); // NOI18N
65
                        propertyName = "name"; // NOI18N
66
                        propertyName = "name"; // NOI18N
66
                    }
67
                    }
Lines 79-85 Link Here
79
                            ObjectName elem = ((ObjectInstance) it.next()).getObjectName();
80
                            ObjectName elem = ((ObjectInstance) it.next()).getObjectName();
80
                            String name = elem.getKeyProperty(propertyName);
81
                            String name = elem.getKeyProperty(propertyName);
81
82
82
                            if (isRemoteManagementSupported()) {
83
                            if (isRemoteManagementSupported() && isJB4x) {
83
                                if (name.endsWith(".sar")) { // NOI18N
84
                                if (name.endsWith(".sar")) { // NOI18N
84
                                    continue;
85
                                    continue;
85
                                }
86
                                }
Lines 128-133 Link Here
128
            remoteManagementSupported = Util.isRemoteManagementSupported(lookup);
129
            remoteManagementSupported = Util.isRemoteManagementSupported(lookup);
129
        }
130
        }
130
        return remoteManagementSupported;
131
        return remoteManagementSupported;
132
    }
133
 
134
    private boolean isJB4x() {
135
        if (isJB4x == null) {
136
            JBDeploymentManager dm = (JBDeploymentManager)lookup.lookup(JBDeploymentManager.class);
137
            isJB4x = JBPluginUtils.isGoodJBServerLocation4x(dm);
138
        }
139
        return isJB4x;
131
    }
140
    }
132
    
141
    
133
}
142
}
(-)src/org/netbeans/modules/j2ee/jboss4/nodes/JBEarModulesChildren.java (-1 / +1 lines)
Lines 74-80 Link Here
74
                            else if(elem.getKeyProperty("j2eeType").equals("WebModule")) {
74
                            else if(elem.getKeyProperty("j2eeType").equals("WebModule")) {
75
                                String url = "http://"+dm.getHost()+":"+dm.getPort();
75
                                String url = "http://"+dm.getHost()+":"+dm.getPort();
76
                                String context = Util.getWebContextRoot((String)Util.getMBeanParameter(dm, "jbossWebDeploymentDescriptor",
76
                                String context = Util.getWebContextRoot((String)Util.getMBeanParameter(dm, "jbossWebDeploymentDescriptor",
77
                                        elem.getCanonicalName(), String.class));
77
                                        elem.getCanonicalName()));
78
                                keys.add(new JBWebModuleNode(name, lookup, (context == null) ? null : url+context));
78
                                keys.add(new JBWebModuleNode(name, lookup, (context == null) ? null : url+context));
79
                            }
79
                            }
80
                        } catch (Exception ex) {
80
                        } catch (Exception ex) {
(-)src/org/netbeans/modules/j2ee/jboss4/nodes/JBEjbModulesChildren.java (-1 / +21 lines)
Lines 26-31 Link Here
26
import javax.management.ObjectInstance;
26
import javax.management.ObjectInstance;
27
import javax.management.ObjectName;
27
import javax.management.ObjectName;
28
import javax.management.QueryExp;
28
import javax.management.QueryExp;
29
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
30
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
29
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
31
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
30
import org.openide.ErrorManager;
32
import org.openide.ErrorManager;
31
import org.openide.nodes.Children;
33
import org.openide.nodes.Children;
Lines 42-47 Link Here
42
public class JBEjbModulesChildren extends Children.Keys implements Refreshable {
44
public class JBEjbModulesChildren extends Children.Keys implements Refreshable {
43
    
45
    
44
    private Lookup lookup;
46
    private Lookup lookup;
47
    private Boolean remoteManagementSupported = null;
48
    private Boolean isJB4x = null;
45
    
49
    
46
    public JBEjbModulesChildren(Lookup lookup) {
50
    public JBEjbModulesChildren(Lookup lookup) {
47
        this.lookup = lookup;
51
        this.lookup = lookup;
Lines 68-74 Link Here
68
        try {
72
        try {
69
            String propertyName;
73
            String propertyName;
70
            Object searchPattern;
74
            Object searchPattern;
71
            if (Util.isRemoteManagementSupported(lookup)) {
75
            if (isRemoteManagementSupported() && isJB4x()) {
72
                propertyName = "name"; // NOI18N
76
                propertyName = "name"; // NOI18N
73
                searchPattern = new ObjectName("jboss.management.local:j2eeType=EJBModule,J2EEApplication=null,*"); // NOI18N
77
                searchPattern = new ObjectName("jboss.management.local:j2eeType=EJBModule,J2EEApplication=null,*"); // NOI18N
74
            }
78
            }
Lines 134-137 Link Here
134
        
138
        
135
        return null;
139
        return null;
136
    }
140
    }
141
    
142
    private boolean isRemoteManagementSupported() {
143
        if (remoteManagementSupported == null) {
144
            remoteManagementSupported = Util.isRemoteManagementSupported(lookup);
145
        }
146
        return remoteManagementSupported;
147
    }
148
149
    private boolean isJB4x() {
150
        if (isJB4x == null) {
151
            JBDeploymentManager dm = (JBDeploymentManager)lookup.lookup(JBDeploymentManager.class);
152
            isJB4x = JBPluginUtils.isGoodJBServerLocation4x(dm);
153
        }
154
        return isJB4x;
155
    }
156
    
137
}
157
}
(-)src/org/netbeans/modules/j2ee/jboss4/nodes/JBWebApplicationsChildren.java (-9 / +24 lines)
Lines 19-24 Link Here
19
19
20
package org.netbeans.modules.j2ee.jboss4.nodes;
20
package org.netbeans.modules.j2ee.jboss4.nodes;
21
21
22
import java.io.File;
22
import java.util.Iterator;
23
import java.util.Iterator;
23
import java.util.Set;
24
import java.util.Set;
24
import java.util.Vector;
25
import java.util.Vector;
Lines 26-31 Link Here
26
import javax.management.ObjectName;
27
import javax.management.ObjectName;
27
import javax.management.QueryExp;
28
import javax.management.QueryExp;
28
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
29
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
30
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
31
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
29
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
32
import org.netbeans.modules.j2ee.jboss4.nodes.actions.Refreshable;
30
import org.openide.ErrorManager;
33
import org.openide.ErrorManager;
31
import org.openide.nodes.Children;
34
import org.openide.nodes.Children;
Lines 43-48 Link Here
43
    
46
    
44
    private Lookup lookup;
47
    private Lookup lookup;
45
    private Boolean remoteManagementSupported = null;
48
    private Boolean remoteManagementSupported = null;
49
    private Boolean isJB4x = null;
46
    
50
    
47
    public JBWebApplicationsChildren(Lookup lookup) {
51
    public JBWebApplicationsChildren(Lookup lookup) {
48
        this.lookup = lookup;
52
        this.lookup = lookup;
Lines 53-65 Link Here
53
        
57
        
54
        RequestProcessor.getDefault().post(new Runnable() {
58
        RequestProcessor.getDefault().post(new Runnable() {
55
            Vector keys = new Vector();
59
            Vector keys = new Vector();
56
            JBDeploymentManager dm = (JBDeploymentManager)lookup.lookup(JBDeploymentManager.class);
57
            
60
            
58
            public void run() {
61
            public void run() {
59
                try {
62
                try {
60
                    // Query to the jboss4 server
63
                    // Query to the jboss server
61
                    ObjectName searchPattern;
64
                    ObjectName searchPattern;
62
                    if (isRemoteManagementSupported()) {
65
                    if (isRemoteManagementSupported() && isJB4x()) {
63
                        searchPattern = new ObjectName("jboss.management.local:j2eeType=WebModule,J2EEApplication=null,*"); // NOI18N
66
                        searchPattern = new ObjectName("jboss.management.local:j2eeType=WebModule,J2EEApplication=null,*"); // NOI18N
64
                    }
67
                    }
65
                    else {
68
                    else {
Lines 71-76 Link Here
71
                    
74
                    
72
                    Iterator it = managedObj.iterator();
75
                    Iterator it = managedObj.iterator();
73
                    
76
                    
77
                    JBDeploymentManager dm = (JBDeploymentManager)lookup.lookup(JBDeploymentManager.class);
78
                    
74
                    // Query results processing
79
                    // Query results processing
75
                    while(it.hasNext()) {
80
                    while(it.hasNext()) {
76
                        try {
81
                        try {
Lines 78-102 Link Here
78
                            String name = elem.getKeyProperty("name");
83
                            String name = elem.getKeyProperty("name");
79
                            String url = "http://" + dm.getHost() + ":" + dm.getPort();
84
                            String url = "http://" + dm.getHost() + ":" + dm.getPort();
80
                            String context = "";
85
                            String context = "";
81
                            if (isRemoteManagementSupported()) {
86
                            if (isRemoteManagementSupported() && isJB4x()) {
82
                                if("jmx-console.war".equals(name)) { // Excluding it. It's system package
87
                                if("jmx-console.war".equals(name)) { // Excluding it. It's system package
83
                                    continue;
88
                                    continue;
84
                                }
89
                                }
85
                                String descr = (String)Util.getMBeanParameter(dm, "jbossWebDeploymentDescriptor", elem.getCanonicalName(), String.class); // NOI18N
90
                                String descr = (String)Util.getMBeanParameter(dm, "jbossWebDeploymentDescriptor", elem.getCanonicalName()); // NOI18N
86
                                context = Util.getWebContextRoot(descr);
91
                                context = Util.getWebContextRoot(descr);
87
                            }
92
                            }
88
                            else {
93
                            else {
89
                                if (name.startsWith("//localhost/")) { // NOI18N
94
                                if (name.startsWith("//localhost/")) { // NOI18N
90
                                    name = name.substring("//localhost/".length()); // NOI18N
95
                                    name = name.substring("//localhost/".length()); // NOI18N
91
                                }
96
                                }
92
                                if("".equals(name) || "jmx-console".equals(name) || "jbossws".equals(name)) { // Excluding it. It's system package
97
                                // excluding system packages
98
                                if("".equals(name) || "jmx-console".equals(name) || "jbossws".equals(name) ||
99
                                   "web-console".equals(name) || "invoker".equals(name)) {
93
                                    continue;
100
                                    continue;
94
                                }
101
                                }
95
                                name +=  ".war"; // NOI18N
102
                                name +=  ".war"; // NOI18N
96
103
97
                                context = (String)Util.getMBeanParameter(dm, "path", elem.getCanonicalName(), String.class); // NOI18N
104
                                context = (String)Util.getMBeanParameter(dm, "path", elem.getCanonicalName()); // NOI18N
98
                            }
105
                            }
99
                            keys.add(new JBWebModuleNode(name, lookup, url + context));                        
106
                            keys.add(new JBWebModuleNode(name, lookup, (context == null ? null : url + context)));                        
100
                        } catch (Exception ex) {
107
                        } catch (Exception ex) {
101
                            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
108
                            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
102
                        }
109
                        }
Lines 136-140 Link Here
136
        }
143
        }
137
        return remoteManagementSupported;
144
        return remoteManagementSupported;
138
    }
145
    }
139
    
146
147
    private boolean isJB4x() {
148
        if (isJB4x == null) {
149
            JBDeploymentManager dm = (JBDeploymentManager)lookup.lookup(JBDeploymentManager.class);
150
            isJB4x = JBPluginUtils.isGoodJBServerLocation4x(dm);
151
        }
152
        return isJB4x;
153
    }
154
140
}
155
}
(-)src/org/netbeans/modules/j2ee/jboss4/nodes/JBWebModuleNode.java (-2 / +6 lines)
Lines 24-29 Link Here
24
import javax.swing.Action;
24
import javax.swing.Action;
25
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
25
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport;
26
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport.ServerIcon;
26
import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport.ServerIcon;
27
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
28
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginUtils;
27
import org.netbeans.modules.j2ee.jboss4.nodes.actions.OpenURLAction;
29
import org.netbeans.modules.j2ee.jboss4.nodes.actions.OpenURLAction;
28
import org.netbeans.modules.j2ee.jboss4.nodes.actions.OpenURLActionCookie;
30
import org.netbeans.modules.j2ee.jboss4.nodes.actions.OpenURLActionCookie;
29
import org.netbeans.modules.j2ee.jboss4.nodes.actions.UndeployModuleAction;
31
import org.netbeans.modules.j2ee.jboss4.nodes.actions.UndeployModuleAction;
Lines 40-51 Link Here
40
public class JBWebModuleNode extends AbstractNode {
42
public class JBWebModuleNode extends AbstractNode {
41
43
42
    final boolean isRemoteManagementSupported;
44
    final boolean isRemoteManagementSupported;
45
    final boolean isJB4x;
43
46
44
    public JBWebModuleNode(String fileName, Lookup lookup, String url) {
47
    public JBWebModuleNode(String fileName, Lookup lookup, String url) {
45
        super(new JBServletsChildren(fileName, lookup));
48
        super(new JBServletsChildren(fileName, lookup));
46
        setDisplayName(fileName.substring(0, fileName.indexOf('.')));
49
        setDisplayName(fileName.substring(0, fileName.indexOf('.')));
47
        isRemoteManagementSupported = Util.isRemoteManagementSupported(lookup);
50
        isRemoteManagementSupported = Util.isRemoteManagementSupported(lookup);
48
        if (isRemoteManagementSupported) {
51
        isJB4x = JBPluginUtils.isGoodJBServerLocation4x((JBDeploymentManager)lookup.lookup(JBDeploymentManager.class));
52
        if (isRemoteManagementSupported && isJB4x) {
49
            // we cannot find out the .war name w/o the management support, thus we cannot enable the Undeploy action
53
            // we cannot find out the .war name w/o the management support, thus we cannot enable the Undeploy action
50
            getCookieSet().add(new UndeployModuleCookieImpl(fileName, ModuleType.WAR, lookup));
54
            getCookieSet().add(new UndeployModuleCookieImpl(fileName, ModuleType.WAR, lookup));
51
        }
55
        }
Lines 61-67 Link Here
61
            };
65
            };
62
        }
66
        }
63
        else {
67
        else {
64
            if (isRemoteManagementSupported) {
68
            if (isRemoteManagementSupported && isJB4x) {
65
                return new SystemAction[] {
69
                return new SystemAction[] {
66
                    SystemAction.get(OpenURLAction.class),
70
                    SystemAction.get(OpenURLAction.class),
67
                    SystemAction.get(UndeployModuleAction.class)
71
                    SystemAction.get(UndeployModuleAction.class)
(-)src/org/netbeans/modules/j2ee/jboss4/nodes/Util.java (-40 / +29 lines)
Lines 22-40 Link Here
22
import java.io.ByteArrayInputStream;
22
import java.io.ByteArrayInputStream;
23
import java.io.IOException;
23
import java.io.IOException;
24
import java.lang.reflect.InvocationTargetException;
24
import java.lang.reflect.InvocationTargetException;
25
import java.lang.reflect.Method;
26
import java.net.URLClassLoader;
27
import java.util.Set;
25
import java.util.Set;
28
import javax.enterprise.deploy.shared.ModuleType;
26
import javax.enterprise.deploy.shared.ModuleType;
27
import javax.management.AttributeNotFoundException;
28
import javax.management.InstanceNotFoundException;
29
import javax.management.MBeanException;
30
import javax.management.MBeanServerConnection;
29
import javax.management.MalformedObjectNameException;
31
import javax.management.MalformedObjectNameException;
30
import javax.management.ObjectName;
32
import javax.management.ObjectName;
31
import javax.management.QueryExp;
33
import javax.management.QueryExp;
34
import javax.management.ReflectionException;
32
import javax.xml.parsers.DocumentBuilderFactory;
35
import javax.xml.parsers.DocumentBuilderFactory;
33
import javax.xml.parsers.ParserConfigurationException;
36
import javax.xml.parsers.ParserConfigurationException;
34
import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
35
import org.netbeans.modules.j2ee.jboss4.JBDeploymentFactory;
36
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
37
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager;
37
import org.netbeans.modules.j2ee.jboss4.ide.ui.JBPluginProperties;
38
import org.openide.ErrorManager;
38
import org.openide.ErrorManager;
39
import org.openide.nodes.AbstractNode;
39
import org.openide.nodes.AbstractNode;
40
import org.openide.nodes.Children;
40
import org.openide.nodes.Children;
Lines 55-68 Link Here
55
    /**
55
    /**
56
     * Lookup a JBoss4 RMI Adaptor
56
     * Lookup a JBoss4 RMI Adaptor
57
     */
57
     */
58
    public static Object getRMIServer(Lookup lookup) {
58
    public static MBeanServerConnection getRMIServer(Lookup lookup) {
59
        return getRMIServer((JBDeploymentManager)lookup.lookup(JBDeploymentManager.class));
59
        return getRMIServer((JBDeploymentManager)lookup.lookup(JBDeploymentManager.class));
60
    }
60
    }
61
    
61
    
62
    /**
62
    /**
63
     * Lookup a JBoss4 RMI Adaptor
63
     * Lookup a JBoss4 RMI Adaptor
64
     */
64
     */
65
    public static Object getRMIServer(JBDeploymentManager manager) {
65
    public static MBeanServerConnection getRMIServer(JBDeploymentManager manager) {
66
        return manager.getRMIServer();
66
        return manager.getRMIServer();
67
    }
67
    }
68
    
68
    
Lines 172-214 Link Here
172
     *
172
     *
173
     * @return MBean attribute
173
     * @return MBean attribute
174
     */
174
     */
175
    public static Object getMBeanParameter(JBDeploymentManager dm, String name, String targetObject, Class paramClass) {
175
    public static Object getMBeanParameter(JBDeploymentManager dm, String name, String targetObject) {
176
        ClassLoader oldLoader = null;
176
        MBeanServerConnection server = dm.refreshRMIServer();
177
        InstanceProperties ip = dm.getInstanceProperties();
177
        try {
178
        
178
            return server.getAttribute(new ObjectName(targetObject), name);            
179
        try{
179
        } catch (InstanceNotFoundException ex) {
180
            oldLoader = Thread.currentThread().getContextClassLoader();
180
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
181
            URLClassLoader loader = JBDeploymentFactory.getJBClassLoader(ip.getProperty(JBPluginProperties.PROPERTY_ROOT_DIR), 
181
        } catch (AttributeNotFoundException ex) {
182
                    ip.getProperty(JBPluginProperties.PROPERTY_SERVER_DIR));
182
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
183
          
183
        } catch (MalformedObjectNameException ex) {
184
            Thread.currentThread().setContextClassLoader(loader);
184
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
185
            
186
            Object srv = dm.refreshRMIServer();
187
            
188
            Class objectName = loader.loadClass("javax.management.ObjectName"); // NOI18N
189
            Method getInstance = objectName.getMethod("getInstance", new Class[] {String.class} );          // NOI18N
190
            Object target = getInstance.invoke(null, new Object[]{targetObject});       // NOI18N
191
            Class[] params = new Class[]{loader.loadClass("javax.management.ObjectName"), paramClass};    // NOI18N
192
            Method getAttribute = srv.getClass().getMethod("getAttribute", params);                 // NOI18N
193
            return getAttribute.invoke(srv, new Object[]{target, name});       // NOI18N
194
            
195
        } catch (NullPointerException ex) {
185
        } catch (NullPointerException ex) {
196
            // It's normal behaviour when the server is off
186
            // it's normal behaviour when the server is not running
197
            return null;
187
        } catch (IllegalArgumentException ex) {
198
        } catch (IllegalAccessException ex) {
188
            // it's normal behaviour when the server is not running
189
        } catch (ReflectionException ex) {
199
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
190
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
200
        } catch (ClassNotFoundException ex) {
191
        } catch (MBeanException ex) {
201
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
192
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
202
        } catch (NoSuchMethodException ex) {
193
        } catch (IOException ex) {
203
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
194
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
204
        } catch (InvocationTargetException ex) {
195
        }            
205
            // It's normal behaviour when the server is off
206
            return null;
207
        } finally{
208
            if (oldLoader != null) {
209
                Thread.currentThread().setContextClassLoader(oldLoader);
210
            }
211
        }
212
        
196
        
213
        return null;
197
        return null;
214
    }
198
    }
Lines 219-224 Link Here
219
     * @return context-root of web application
203
     * @return context-root of web application
220
     */
204
     */
221
    public static String getWebContextRoot(String dd) {
205
    public static String getWebContextRoot(String dd) {
206
        
207
        if (dd == null) {
208
            return null;
209
        }
210
        
222
        Document doc = null;
211
        Document doc = null;
223
        
212
        
224
        try {
213
        try {
(-)src/org/netbeans/modules/j2ee/jboss4/resources/Bundle.properties (-3 / +3 lines)
Lines 17-23 Link Here
17
# Microsystems, Inc. All Rights Reserved.
17
# Microsystems, Inc. All Rights Reserved.
18
#
18
#
19
19
20
OpenIDE-Module-Name=JBoss Application Server 4.0
20
OpenIDE-Module-Name=JBoss Application Server
21
OpenIDE-Module-Display-Category=Java EE
21
OpenIDE-Module-Display-Category=Java EE
22
OpenIDE-Module-Short-Description=Plugin for JBoss Application Server 4.0
22
OpenIDE-Module-Short-Description=Plugin for JBoss Application Server
23
OpenIDE-Module-Long-Description=The plugin enables J2EE development modules to configure and deploy J2EE components on JBoss Application Server 4.0.
23
OpenIDE-Module-Long-Description=The plugin enables J2EE development modules to configure and deploy J2EE components on JBoss Application Server.
(-)src/org/netbeans/modules/j2ee/jboss4/util/JBProperties.java (-10 / +39 lines)
Lines 39-45 Link Here
39
import org.openide.ErrorManager;
39
import org.openide.ErrorManager;
40
import org.openide.filesystems.FileUtil;
40
import org.openide.filesystems.FileUtil;
41
import org.openide.modules.InstalledFileLocator;
41
import org.openide.modules.InstalledFileLocator;
42
import org.openide.util.Enumerations;
43
42
44
/**
43
/**
45
 * Helper class that makes it easier to access and set JBoss instance properties.
44
 * Helper class that makes it easier to access and set JBoss instance properties.
Lines 83-90 Link Here
83
        ip = manager.getInstanceProperties();
82
        ip = manager.getInstanceProperties();
84
    }
83
    }
85
    
84
    
86
    public boolean isJavaEE5() {
85
    public boolean supportsJavaEE5ejb3() {
87
        return new File(getServerDir(), "deploy/ejb3.deployer").exists(); // NOI18N
86
        return new File(getServerDir(), "deploy/ejb3.deployer").exists() || // JBoss 4 // NOI18N
87
               new File(getServerDir(), "deployers/ejb3.deployer").exists(); // JBoss 5 // NOI18N
88
    }
89
90
    public boolean supportsJavaEE5web() {
91
        return new File(getServerDir(), "deployers/jbossweb.deployer").exists(); // JBoss 5 // NOI18N
88
    }
92
    }
89
    
93
    
90
    public File getServerDir() {
94
    public File getServerDir() {
Lines 139-155 Link Here
139
            File rootDir = getRootDir();
143
            File rootDir = getRootDir();
140
            File serverDir = getServerDir();
144
            File serverDir = getServerDir();
141
            list.add(fileToUrl(new File(rootDir, "client/jboss-j2ee.jar")));  // NOI18N
145
            list.add(fileToUrl(new File(rootDir, "client/jboss-j2ee.jar")));  // NOI18N
142
            if (isJavaEE5()) {
146
143
                File wsClientLib = new File(rootDir, "client/jbossws-client.jar"); // NOI18N
147
            File wsClientLib = new File(rootDir, "client/jbossws-client.jar"); // NOI18N
144
                if (wsClientLib.exists()) {
148
            if (wsClientLib.exists()) {
145
                    list.add(fileToUrl(wsClientLib));
149
                list.add(fileToUrl(wsClientLib));
146
                }
147
            }
150
            }
151
148
            addFiles(new File(rootDir, "lib"), list); //NOI18N
152
            addFiles(new File(rootDir, "lib"), list); //NOI18N
149
            addFiles(new File(serverDir, "/lib"), list); //NOI18N
153
            addFiles(new File(serverDir, "/lib"), list); //NOI18N
150
            if (isJavaEE5()) {
154
            if (supportsJavaEE5ejb3()) {
151
                addFiles(new File(serverDir, "/deploy/ejb3.deployer/"), list); // NOI18N
155
                File ejb3deployer = new File(serverDir, "/deploy/ejb3.deployer/");  // NOI18N
156
                if (ejb3deployer.exists()) {
157
                    addFiles(ejb3deployer, list);
158
                }
159
                else
160
                if ((ejb3deployer = new File(serverDir, "/deployers/ejb3.deployer/")).exists()) {        // NOI18N
161
                    addFiles(ejb3deployer, list);
162
                }
152
            }
163
            }
164
            
153
            File jsfAPI = new File(serverDir, "/deploy/jbossweb-tomcat55.sar/jsf-libs/myfaces-api.jar"); // NOI18N
165
            File jsfAPI = new File(serverDir, "/deploy/jbossweb-tomcat55.sar/jsf-libs/myfaces-api.jar"); // NOI18N
154
            if (jsfAPI.exists()) {
166
            if (jsfAPI.exists()) {
155
                try {
167
                try {
Lines 158-165 Link Here
158
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
170
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
159
                }
171
                }
160
            }
172
            }
173
            else 
174
            if ((jsfAPI = new File(serverDir, "/deployers/jbossweb.deployer/jsf-libs/jsf-api.jar")).exists()) { // NOI18N 
175
                try {
176
                    list.add(fileToUrl(jsfAPI));
177
                } catch (MalformedURLException e) {
178
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
179
                }
180
            }
181
            
161
            File jsfIMPL = new File(serverDir, "/deploy/jbossweb-tomcat55.sar/jsf-libs/myfaces-impl.jar"); // NOI18N
182
            File jsfIMPL = new File(serverDir, "/deploy/jbossweb-tomcat55.sar/jsf-libs/myfaces-impl.jar"); // NOI18N
162
            if (jsfIMPL.exists()) {
183
            if (jsfIMPL.exists()) {
184
                try {
185
                    list.add(fileToUrl(jsfIMPL));
186
                } catch (MalformedURLException e) {
187
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
188
                }
189
            }
190
            else
191
            if ((jsfIMPL = new File(serverDir, "/deployers/jbossweb.deployer/jsf-libs/jsf-impl.jar")).exists()) { // NOI18N
163
                try {
192
                try {
164
                    list.add(fileToUrl(jsfIMPL));
193
                    list.add(fileToUrl(jsfIMPL));
165
                } catch (MalformedURLException e) {
194
                } catch (MalformedURLException e) {
(-)test/qa-functional/src/org/netbeans/modules/j2ee/jboss4/test/JBoss4TestSuite.java (-1 / +1 lines)
Lines 55-61 Link Here
55
 */
55
 */
56
public class JBoss4TestSuite extends NbTestCase {
56
public class JBoss4TestSuite extends NbTestCase {
57
    
57
    
58
    private static final String DISPLAY_NAME = "JBoss Application Server 4";
58
    private static final String DISPLAY_NAME = "JBoss Application Server";
59
    private static final String EJB_PROJECT_NAME = "JBoss4EjbTest";
59
    private static final String EJB_PROJECT_NAME = "JBoss4EjbTest";
60
    private static final String WEB_PROJECT_NAME = "JBoss4WebTest";
60
    private static final String WEB_PROJECT_NAME = "JBoss4WebTest";
61
    private static final String EJB_PROJECT_PATH = System.getProperty("xtest.tmpdir") + File.separator + EJB_PROJECT_NAME;
61
    private static final String EJB_PROJECT_PATH = System.getProperty("xtest.tmpdir") + File.separator + EJB_PROJECT_NAME;
(-)test/qa-functional/src/org/netbeans/test/j2ee/jboss4/JBossValidation.java (-3 / +3 lines)
Lines 100-106 Link Here
100
        Node node = new Node(new RuntimeTabOperator().getRootNode(),Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.Bundle", "SERVER_REGISTRY_NODE"));
100
        Node node = new Node(new RuntimeTabOperator().getRootNode(),Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.Bundle", "SERVER_REGISTRY_NODE"));
101
        node.performPopupActionNoBlock(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle", "LBL_Add_Server_Instance"));
101
        node.performPopupActionNoBlock(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle", "LBL_Add_Server_Instance"));
102
        NbDialogOperator dialog = new NbDialogOperator(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.wizard.Bundle", "LBL_ASIW_Title"));
102
        NbDialogOperator dialog = new NbDialogOperator(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.wizard.Bundle", "LBL_ASIW_Title"));
103
        new JComboBoxOperator(dialog).selectItem("JBoss Application Server 4");
103
        new JComboBoxOperator(dialog).selectItem("JBoss Application Server");
104
        new JButtonOperator(dialog,Bundle.getStringTrimmed("org.openide.Bundle", "CTL_NEXT")).push();
104
        new JButtonOperator(dialog,Bundle.getStringTrimmed("org.openide.Bundle", "CTL_NEXT")).push();
105
        new JTextFieldOperator(dialog).setText("");
105
        new JTextFieldOperator(dialog).setText("");
106
        new JTextFieldOperator(dialog).typeText(path);
106
        new JTextFieldOperator(dialog).typeText(path);
Lines 134-140 Link Here
134
        Node serverNode = new Node(runtimeTab.getRootNode(), Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.Bundle", "SERVER_REGISTRY_NODE")
134
        Node serverNode = new Node(runtimeTab.getRootNode(), Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.Bundle", "SERVER_REGISTRY_NODE")
135
                                   +"|JBoss");        
135
                                   +"|JBoss");        
136
        serverNode.performPopupAction(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.Bundle", "LBL_Stop"));
136
        serverNode.performPopupAction(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.Bundle", "LBL_Stop"));
137
        org.netbeans.test.j2ee.lib.ProgressOperator.waitFinished("Stopping JBoss Application Server 4.0",300000);
137
        org.netbeans.test.j2ee.lib.ProgressOperator.waitFinished("Stopping JBoss Application Server",300000);
138
        new org.netbeans.jemmy.EventTool().waitNoEvent(2000);
138
        new org.netbeans.jemmy.EventTool().waitNoEvent(2000);
139
    }
139
    }
140
    
140
    
Lines 234-240 Link Here
234
                                   +"|JBoss");
234
                                   +"|JBoss");
235
                
235
                
236
        serverNode.performPopupAction(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.Bundle", "LBL_Start"));
236
        serverNode.performPopupAction(Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.Bundle", "LBL_Start"));
237
        org.netbeans.test.j2ee.lib.ProgressOperator.waitFinished("Starting JBoss Application Server 4.0",300000);
237
        org.netbeans.test.j2ee.lib.ProgressOperator.waitFinished("Starting JBoss Application Server",300000);
238
        new org.netbeans.jemmy.EventTool().waitNoEvent(2000);
238
        new org.netbeans.jemmy.EventTool().waitNoEvent(2000);
239
    }
239
    }
240
    
240
    

Return to bug 89969