Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packages accessible from more than one module due to GWT SDK from Eclipse plugin #504

Open
RemiFermentin opened this issue Dec 3, 2024 · 4 comments

Comments

@RemiFermentin
Copy link

I have an error on some package since I try to move from java 8 to java 17.

In fact, i compile good through my gradle commands (so I build correctly the project)... But i still have many errors on Eclipse.
I have some errors like:
The package javax.xml.parsers is accessible from more than one module: , java.xml

The main Reason of that this is because on gwt-dev.jar that is included in the GWT SDK from the eclipse plugin. It contains it.

Of course the GWT SDK is in the classpath for the project... and then, I have this error... (as it goes through a conflict)

I am pretty sure somebody ran into this at some point, but i didn't have any clues at the moment.

The easiest solution would be to trick my "gwt-dev.jar" to remove the unnecessary classes but that's not a suitable way to do in the long run...
(like doing:
zip -d gwt-dev.jar "org/w3c/" "org/xml/" "javax/xml/" "netscape/javascript/"
)

If it is possible to exclude during runTime the "xerces" group from the gwt-dev.jar, that would be great, but as it is inside the "SDK" I cannot manipulate as I would like to. (it is not installed through a "normal" Gradle implmentation).

I have some gradle command to "install the SDK" automatically through gradle task (I use "org.wisepersist.gwt" version "1.1.19"):

eclipse {
	project {
		natures 'com.gwtplugins.gwt.eclipse.core.gwtNature'
		buildCommand 'com.gwtplugins.gwt.eclipse.core.gwtProjectValidator'
		buildCommand 'com.gwtplugins.gdt.eclipse.core.webAppProjectValidator'
	}
	classpath {
		containers 'com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER'
	}
	synchronizationTasks gwtpluginsGdtCorePrefs
}
task gwtpluginsGdtCorePrefs() {
	doLast {
		// Create GWT eclipse settings
		delete("${project.projectDir}/.settings/com.gwtplugins.gdt.eclipse.core.prefs")
		File corePrefs = file("${project.projectDir}/.settings/com.gwtplugins.gdt.eclipse.core.prefs")
		corePrefs.getParentFile().mkdirs()
		if (corePrefs.exists()) {
			logger.warn("GWT core preferences already exist and will not be overridden. Use task 'cleanEclipse' first.")
		} else {
			corePrefs.write('eclipse.preferences.version=1\n')
			corePrefs.append('jarsExcludedFromWebInfLib=\n')
			corePrefs.append('warSrcDir=\n')
			corePrefs.append('warSrcDirIsOutput=true\n')
		}
	}
}

Here is the symptom of the issue:
image

If I ending up removing the SDK. Of course, I don't have the compile issue BUT I have the error :
The project 'webapp' does not have any GWT SDKs on its build path.
image

I saw it could be related to: #414 but i am not sure.

I try to summarize the best what I put on: gwtproject/gwt#10051 initially.

But indeed , this is a Eclipse Plugin issue and not a GWT issue per say.

@niloc132
Copy link
Member

niloc132 commented Dec 3, 2024

Can you describe your project setup - what other projects besides webapp exist in your eclipse workspace, and what purpose do they serve, what classpath do they have?

@RemiFermentin
Copy link
Author

Other Project Setups are Server Dependencies outside GWT Those are for specific features. The Webapp is kind of a big Monolith that we are trying to split over time. Only the WebApp is using GWT and have the SDK.

We are using Gradle to setup the whole projects and sub projects as well for our build mecanism.

We are setting up eclipse for coding and to deploy locally on the tomcat the application (Webapp) and debugging/testing live the changes. GWT dev mode also help in this area as we don't need to restart the server after each changes on client side.

Hope that's helpful.

@RemiFermentin
Copy link
Author

So to go back to the beginning:

For now, I modified my "SDK" I downloaded from the official website. I edited gwt-dev.jar and I removed the files that ARE Giving conflict with the JRE itself due to the dependency from net.sourceforge.htmlunit:htmlunit

image

zip -d gwt-dev.jar "org/w3c/" "org/xml/" "javax/xml/" "netscape/javascript/"

Hope we will find something better as this is not a best practice for sure.

@CrushaKRool
Copy link

We are having similar problems, albeit with the classpath due to us not using the module path. We also use Gradle, and like you, we have modified the gwt-dev.jar from the downloaded SDK due to the conflicts.

The conflicts usually mean that an outdated version of a specific class is loaded from the gwt-dev.jar instead of the newer version from the Gradle classpath, which then ultimately leads to NoSuchMethodErrors when other code is trying to call methods that only exist in the newer definition of that class.

In our case the conflicts are the "org.apache.tomcat.*" package, which clashes with a newer version of an embedded Tomcat that we boot up to deploy GWT during local development.
We had similar issues when using a newer version of an embedded Jetty instead of the Jetty bundled with GWT for its local dev mode. And another frequent source of such clashes is the outdated version of Apache Commons Lang3.

These issues only manifest when running the application (or even just unit tests) locally within Eclipse. Everything is fine when running things standalone via Gradle, since it does not include the gwt-dev dependency that we get via the SDK Container.

So far, removing the package from the JAR does not seem to have any negative effect on running GWT. Which makes me wonder which of the included packages are actually needed for whatever work the GWT SDK needs to do when it's being used in Eclipse. E.g. is there actually a need for HtmlUnit when all we do with the SDK is compile GWT for use in the SuperDevMode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants