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.

Bug 207047 - Java Web project.properties file windows/linux inconsistities
Summary: Java Web project.properties file windows/linux inconsistities
Status: RESOLVED FIXED
Alias: None
Product: serverplugins
Classification: Unclassified
Component: Tomcat (show other bugs)
Version: 7.0.1
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Assignee: Petr Hejl
URL:
Keywords:
: 222424 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-01-09 06:55 UTC by williescholtz
Modified: 2015-03-12 13:49 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
svn commit difference, linux -> windows (28.93 KB, image/png)
2012-01-09 06:55 UTC, williescholtz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description williescholtz 2012-01-09 06:55:16 UTC
Created attachment 114722 [details]
svn commit difference, linux -> windows

The project.properties file for java web applications differs (when saving or editing) on linux/windows machines. Specifically the j2ee.platform.classpath variable. although both versions of the file are correct the classpath ordering is different, this leads to the file being updated in our SVN code repository on every commit from a different operating system.
Comment 1 David Konecny 2012-04-15 21:53:38 UTC
The j2ee.platform.classpath property contains classpath of the application server. Do you use the same version of Tomcat on both platforms? If yes then the problem would be in Tomcat support in NetBeans for not storing classpath in the same order. If you are using different Tomcats then I do not see an easy way to resolve this - during project opening the classpath of server is checked and the path is updated in project properties so that everything is up to date.
Comment 2 David Konecny 2012-04-16 22:42:03 UTC
Feel free to reopen when you have more information to attach. Thx.
Comment 3 giotex 2012-09-25 09:12:04 UTC
(In reply to comment #2)
> Feel free to reopen when you have more information to attach. Thx.

As of 7.2 the defect is still present, and it's quite annoying when developers share project from different platforms.

I've checked the source from zip (201207171143) and made some tests.
IMHO it would resolve applying an explicit sorting to generated classpath in org.netbeans.modules.j2ee.common.project.ui.J2EEProjectProperties, methods toClasspathString(...), lines 512 till end.

Adding method:

private static String sortClasspath(String cp) {
	if (cp != null && cp.trim().length() > 0) {
		StringBuilder classpath = new StringBuilder();
		String[] entries = cp.split(":");
		Arrays.sort(entries);
		for(String path : entries) {
			if (classpath.length() > 0) {
				classpath.append(':'); // NOI18N
			}
            		classpath.append(path);
		}
		return classpath.toString();
	}
	else {
		return cp;
	}
}

and changing the return statements of the 3 toClasspathString(...) methods to

return sortClasspath(classpath.toString());

seems to solve the issue for me.

Sorry for not providing directly a patch, I'm new to netbeans development.
Comment 4 David Konecny 2012-09-25 20:58:40 UTC
Order of JARs in classpath is important and J2EEProjectProperties.toClasspathString(...) cannot change the order because it knows very little of the classpath it was given. Who could sort the list though is the provider of the classpath, that is application server plugin. If sorting helped to solve your problem it must mean that in your team you are using the same server (Tomcat, right?) but for different versions of Tomcat the classpath is different. Passing to Tomcat plugin to fix the classpath.
Comment 5 giotex 2012-09-26 08:49:01 UTC
I used on both platforms the same bundled Tomcat server (7.0.27).
If a team is working on the same project, it's likely to use the same app server.
Btw I agree that it makes more sense that it is the serverplugin which should order the JARs in consistent way.

However, if the order of JARs into classpath is important, then this issue is a double issue, as at the moment in windows and linux, for the same bundled Tomcat server, the order of JARs into the generated classpath is very different.

I did not check the code yet but, from the generated class path, I guess that the JARs are get from a directory search, and while windows returns them ordered by name, linux returns them without explicit order (see the original attached screenshot too).
Comment 6 Petr Hejl 2012-10-08 12:35:27 UTC
Fixed in web-main de04fcc9012e.
Comment 7 Petr Hejl 2012-10-08 12:55:30 UTC
Fixed for JBoss web-main e96418b790d0.
Comment 8 Quality Engineering 2012-10-09 02:05:19 UTC
Integrated into 'main-golden', will be available in build *201210090002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/de04fcc9012e
User: Petr Hejl <phejl@netbeans.org>
Log: #207047 - Java Web project.properties file windows/linux inconsistities
Comment 9 David Konecny 2012-11-21 19:48:29 UTC
*** Bug 222424 has been marked as a duplicate of this bug. ***
Comment 10 Petr Hejl 2013-07-10 06:29:13 UTC
*** Bug 222424 has been marked as a duplicate of this bug. ***
Comment 11 chelsee 2014-01-31 09:23:20 UTC
like gvaleika@netbeans.org said before :

nbproject/project.properties j2ee.platform.classpath property depends on user environment. There is no way to configure its value to make it compatible to other team member's environmnents. It causes a lot of unnecessary version control system trafic.

Easy solution would be to move this setting to nbproject/private/private.properties. Together with j2ee.server.instance, j2ee.server.domain, j2ee.server.home properties.

It works ok if placed there until nbproject/project.properties file is regenerated. Then it is moved back to nbproject/project.properties file.

Problem is mentioned in http://forums.netbeans.org/topic44652.html and http://stackoverflow.com/questions/8957913/netbeans-project-properties-file-different-between-mac-and-windows

Still no workaround found.

I'm using netbeans 7.3
Comment 12 chelsee 2014-01-31 15:28:29 UTC
I also checked with 7.4, still not fixed.
Comment 13 Petr Jiricka 2014-02-03 09:59:32 UTC
Cc'ing also Martin J.
Comment 14 tpapad 2015-01-22 15:35:31 UTC
Bug still exists in NB 8.0.2 (both Windows and Linux)
Comment 15 Petr Hejl 2015-03-12 13:49:45 UTC
I believe the original classpath ordering is fixed. If the server is of the same version there should be no inconsistencies.

If you mean something different please file a new bug.