1.1 --- a/visualweb.insync/src/org/netbeans/modules/visualweb/insync/ModelSet.java Thu Apr 03 14:08:51 2008 -0700
1.2 +++ b/visualweb.insync/src/org/netbeans/modules/visualweb/insync/ModelSet.java Thu Apr 03 17:03:48 2008 -0700
1.3 @@ -63,6 +63,7 @@
1.4 import java.util.Properties;
1.5 import java.util.Set;
1.6
1.7 +import java.util.jar.JarFile;
1.8 import java.util.logging.Level;
1.9 import java.util.logging.LogRecord;
1.10 import java.util.logging.Logger;
1.11 @@ -404,7 +405,8 @@
1.12 }
1.13
1.14
1.15 - private static final String WEBSERVICE_CLIENTS_SUB_DIR = "webservice_clients"; // NOI18N
1.16 + private static final String WEBSERVICE_CLIENTS_SUB_DIR = "webservice_clients"; // NOI18N
1.17 + private static final String EJB_DATA_SUB_DIR = "ejb-sources"; // NOI18N
1.18
1.19 /**
1.20 * Get the per-project class loader for this ModelSet. The class loader may change as project
1.21 @@ -448,7 +450,17 @@
1.22 }
1.23 } catch (IOException e) {
1.24 // not found - ignore
1.25 - }
1.26 + }
1.27 + }
1.28 +
1.29 + // Check if project uses ejbs.
1.30 + boolean hasEjbClients = false;
1.31 + try {
1.32 + FileObject projectLibDir = JsfProjectUtils.getProjectLibraryDirectory(project);
1.33 + FileObject ejbClientsSubDir = projectLibDir.getFileObject(EJB_DATA_SUB_DIR);
1.34 + hasEjbClients = (ejbClientsSubDir != null && hasJarFiles(ejbClientsSubDir));
1.35 + } catch (IOException e) {
1.36 + // not found - ignore
1.37 }
1.38
1.39 //"classpath/packaged" gives us all the jars excluding app server jars in case of maven project
1.40 @@ -460,19 +472,36 @@
1.41 URLClassLoader classPathClassLoader = (URLClassLoader) classPath.getClassLoader(true);
1.42 URL urls[] = classPathClassLoader.getURLs();
1.43 urlSet.addAll(Arrays.asList(urls));
1.44 - //Remove the app server jars from the classpath to improve design time performance
1.45 + //Remove the J2ee Classpath jars from the classpath to improve design time performance
1.46 String[] j2eeJars = JsfProjectUtils.getJ2eeClasspathEntries(project);
1.47 - for (String j2eeJar : j2eeJars) {
1.48 - for (URL url : urls) {
1.49 - URL fileURL = FileUtil.getArchiveFile(url);
1.50 - FileObject fileObj = URLMapper.findFileObject(fileURL != null ? fileURL : url);
1.51 - if (fileObj != null) {
1.52 - File file = FileUtil.toFile(fileObj);
1.53 - if (file != null && j2eeJar.equals(file.getPath())) {
1.54 - urlSet.remove(url);
1.55 - break;
1.56 + List<String> j2eeJarsList = Arrays.asList(j2eeJars);
1.57 + for (URL url : urls) {
1.58 + URL fileURL = FileUtil.getArchiveFile(url);
1.59 + FileObject fileObj = URLMapper.findFileObject(fileURL != null ? fileURL : url);
1.60 + if (fileObj != null) {
1.61 + File file = FileUtil.toFile(fileObj);
1.62 + if (file == null) {
1.63 + continue;
1.64 + }
1.65 + if (hasEjbClients) {
1.66 + if (file.isFile() && file.getName().endsWith(".jar")) {
1.67 + try {
1.68 + JarFile jarFile = new JarFile(file);
1.69 + // Found one of the ejb20 classes - use this jar file
1.70 + if (jarFile.getEntry("javax/ejb/CreateException.class") != null) {
1.71 + // We need to keep this jar in designtime classpath
1.72 + continue;
1.73 + }
1.74 + } catch (IOException e) {
1.75 + // corrupt .jar file
1.76 + }
1.77 }
1.78 }
1.79 + // Is this a URL from J2ee Classpath
1.80 + if (j2eeJarsList.contains(file.getAbsolutePath())) {
1.81 + // Remove it from designtime classpath
1.82 + urlSet.remove(url);
1.83 + }
1.84 }
1.85 }
1.86 }else {