Eclipse Tycho: Compile error when using the java.xml.bind module? - eclipse

I think the problem is the same as described in this blog post but I get this for Java 10: I have an Eclipse RCP application that uses Java 10 features but also JAXB classes. In Eclipse, I have to add the java.xml.bind module to the build path configuration of my project (as described here) to let the compile errors go away.
However, when building the product with Tycho 1.2.0 I get the following error, exactly for the class that uses JAXB:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.2.0:compile (default-compile) on project epd-editor: Compilation failure: Compilation failure:
[ERROR] ...app\src\app\editors\XmlPage.java:
[ERROR] package app.editors;
[ERROR] ^
[ERROR] Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.BinaryModuleBinding.create(BinaryModuleBinding.java:64)
[ERROR] java.lang.NullPointerException
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.BinaryModuleBinding.create(BinaryModuleBinding.java:64)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getModuleFromAnswer(LookupEnvironment.java:427)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForTypeFromModules(LookupEnvironment.java:367)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:228)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:105)
Is there a way to configure the Tycho compiler plugin so that it can see modules like java.xml.bind or is there another reason for this error?
Thanks.

Java EE modules are deprecated for removal and not resolved by default and will be removed in Java 11.
The best way to handle this is to use a third-party dependency, but as you observe JDT trips over its own feet when that is done. I opened an issue and it was fixed some time ago, but it's not easy to find an artifact that contains the change and works on Java 10. The first artifact I know of comes from Eclipse Photon I20180531-0700.
Execute the following in Eclipse's plugins folder (#people from the future: you may have to update the version):
mvn install:install-file \
-Dfile=org.eclipse.jdt.core_3.14.0.v20180528-0519.jar \
-DgroupId=org.eclipse.tycho \
-DartifactId=org.eclipse.jdt.core \
-Dversion=3.14.0.v20180528-0519 \
-Dpackaging=jar
You can then use it as follows as dependencies for Maven's compiler plugin:
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-jdt</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<!-- unreleased version that was pulled from Eclipse Photon I20180531-0700
contains the fix and compiles Java 10 -->
<version>3.14.0.v20180528-0519</version>
</dependency>
The problem is also described on java9.wtf with a demo project on GitHub. (I forgot to push, so it's only online for about five minutes now. 😒)

There are three ways you can include modules from the java.se.ee aggregator module, which is not included for compile or runtime in JDK 10. (As of JDK 11, these modules will be removed from the JDK).
The simplest is to use the command line option, --add-modules java.xml.bind. This will use the version that is still included in the JDK.
Find a JAXB implementation jar. Maven central is a good place to go for this, there is also a reference implementation for JSR 222 (JAXB), which is part of the Java Web Services Developer Pack (http://www.oracle.com/technetwork/java/webservicespack-jsp-140788.html) but this is waaaay old and may not be the best choice. You can add where you've downloaded the jar to the upgrade module path using --upgrade-module-path {path}
An alternative to 2 is to simply put the jar containing JAXB on the classpath.
I'm not familiar with Tycho but you would need to figure out how to use one of these methods with its configuration.

Related

Building Eclipse plugin with Tycho from mirrored P2 Repository in Nexus

After endless reading and testing out different things, I now have to ask my specific question.
A few information about my project:
I would like to build a Eclipse plugin with Maven to integrate it in our CI/CD process.
We're using Eclipse-2019-06.
I'm in a separate developing network where I only have access to the internet via proxy.
A Nexus is running which is mirroring all the needed Maven repositories (Central and so).
Because of the proxy problem I installed the P2 Nexus plugin and bridge to add the Eclipse P2 repository https://download.eclipse.org/releases/2019-06/201906191000/ in our Nexus to mirror it locally. So the Nexus repository points now from the official P2 download site to the local http://nexus:8081/nexus/content/repositories/eclipse-repository address.
The first thing I tried then, was to add the update site http://nexus:8081/nexus/content/repositories/eclipse-repository to the running Eclipse installation to access all the plugins and so on. This works fine!
So now I'm trying to build the official Eclipse Plugin Tycho demo itp01 from https://github.com/eclipse/tycho-demo.
And here comes the problem: I changed the repositories section in the official pom.xml to
<repositories>
<repository>
<id>eclipse-repo</id>
<layout>p2</layout>
<url>http://nexus:8081/nexus/content/repositories/eclipse-repository</url>
</repository>
</repositories>here
When I now try to build the itp01 project I get the so often seen error:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: tycho.demo.itp01 1.0.0.qualifier
[ERROR] Missing requirement: tycho.demo.itp01 1.0.0.qualifier requires 'osgi.bundle; org.eclipse.core.runtime 3.15.300' but it could not be found
[ERROR]
[ERROR] See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.
[ERROR] Cannot resolve dependencies of MavenProject: tycho.demo.itp01:tycho.demo.itp01:1.0.0-SNAPSHOT # /home/frto100/git/org.eclipse.tycho-demo/itp01/tycho.demo.itp01/pom.xml: See log for details -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MavenExecutionException
It looks like it's not possible for Tycho to read the artifacts from the P2 repository in Nexus.
Secondhand I'm not sure if Tycho even evaluates the given repository URL. Is it possible to check if Tycho is really using the correct URL?
Can somebody maybe give me a hint where the problem could be? Or maybe somebody already solved this problem.
Thanks so much!
If you are using Maven 3.6.1 (which is embedded in Eclipse 2019-06 and 2019-09), you probably ran into the following issue:
Maven issue MNG-6642: Tycho-based modules do not build with 3.6.1 (works with 3.6.0)
Using a different Maven version than 3.6.1 should solve the issue.

Liquibase resource found in both Maven target and Maven repository

I have Eclipse Maven GWT project and I added flowable-form-engine dependency that uses Liquibase. Liquibase is searching for changelog file org/flowable/form/db/liquibase/flowable-form-db-changelog.xml but finds two!
org.flowable.common.engine.api.FlowableException: Error initialising form data schema
at org.flowable.form.engine.impl.db.FormDbSchemaManager.initSchema(FormDbSchemaManager.java:58)
at org.flowable.form.engine.impl.cmd.SchemaOperationsFormEngineBuild.execute(SchemaOperationsFormEngineBuild.java:29)
at org.flowable.form.engine.impl.cmd.SchemaOperationsFormEngineBuild.execute(SchemaOperationsFormEngineBuild.java:24)
at org.flowable.common.engine.impl.interceptor.DefaultCommandInvoker.execute(DefaultCommandInvoker.java:10)
at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:71)
at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
at org.flowable.form.engine.impl.FormEngineImpl.<init>(FormEngineImpl.java:45)
at org.flowable.form.engine.FormEngineConfiguration.buildFormEngine(FormEngineConfiguration.java:172)
at org.flowable.form.engine.configurator.FormEngineConfigurator.initFormEngine(FormEngineConfigurator.java:83)
at org.flowable.form.engine.configurator.FormEngineConfigurator.configure(FormEngineConfigurator.java:63)
at org.flowable.common.engine.impl.AbstractEngineConfiguration.configuratorsAfterInit(AbstractEngineConfiguration.java:859)
at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:985)
at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:887)
at sk.dominanz.coarui.server.services.WorkflowServiceAdditional.<clinit>(WorkflowServiceAdditional.java:64)
... 33 more
Caused by: liquibase.exception.ChangeLogParseException: Error Reading Migration File: Found 2 files that match org/flowable/form/db/liquibase/flowable-form-db-changelog.xml
at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:118)
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:15)
at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:217)
at liquibase.Liquibase.update(Liquibase.java:190)
at liquibase.Liquibase.update(Liquibase.java:179)
at liquibase.Liquibase.update(Liquibase.java:175)
at liquibase.Liquibase.update(Liquibase.java:168)
at org.flowable.form.engine.impl.db.FormDbSchemaManager.initSchema(FormDbSchemaManager.java:52)
... 48 more
Caused by: java.io.IOException: Found 2 files that match org/flowable/form/db/liquibase/flowable-form-db-changelog.xml
at liquibase.util.StreamUtil.singleInputStream(StreamUtil.java:206)
at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:71)
... 55 more
So I debugged it and it finds one resource from target directory:
jar:file:/C:/work/git/coarui/target/Main-1.0-SNAPSHOT/WEB-INF/lib/flowable-form-engine-6.4.0.jar!/org/flowable/form/db/liquibase/flowable-form-db-changelog.xml
and other resource from maven repository:
jar:file:/C:/Users/Piro/.m2/repository/org/flowable/flowable-form-engine/6.4.0/flowable-form-engine-6.4.0.jar!/org/flowable/form/db/liquibase/flowable-form-db-changelog.xml
Is there a way to ignore one of them, or is my build path or dependency definition wrong?
My build path contains:
src/main/java sources
src/test/java sources
JRE System library
Maven dependencies (in C:/Users/Piro/.m2/repository...)
JUnit4
Looking at source code resources are read classLoader.getResources(path); where class loader is jetty class loader JettyLauncher$WebAppContextWithReload$WebAppClassLoaderExtension.
In my run/debug configuration I have classpath similar to build path plus GWT library gwt-dev-2.8.1.jar - C:\Users\Piro\.m2\repository\com\google\gwt\gwt-dev\2.8.1
In pom.xml dependency is defined as:
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-form-engine-configurator</artifactId>
<version>${flowableVersion}</version>
</dependency>
Maven GWT plugin groupId=net.ltgt.gwt.maven, artifactId=gwt-maven-plugin has configuration parameter classpathScope but I tested <classpathScope>compile+runtime</classpathScope>, <classpathScope>compile</classpathScope> and <classpathScope>runtime</classpathScope> and the same error occurs.
Searching the internet I found similar posts on flowable forum (1, 2) but no solution is provided.
This generally happens when you mix client and server code in the same Maven module, and given how GWT works there's no (easy) around that, besides splitting your code in separate client and server (and possibly shared) Maven modules.
You can have a look at https://github.com/tbroyer/gwt-maven-archetypes for examples (disclaimer: I'm the author, but also a member of GWT's Steering Committee)
it seems that for some reason your .m2 is in the classpath. If it really makes sense to you then you can try to use <scope>provided</scope> in a pom where you declare dependency to flowable-form-engine-configurator. However you may decide to exclude .m2 from classpath which is better I think.

Linking JSF libraries from JBoss in Maven

I have a very simple web project in Eclipse that uses JSF and runs with a JBoss 4.2.3. I have 'Mavenized' the project and a pom.xml is generated. The pom.xml is empty with no dependencies, but I can install this maven project and I see my web page when I run the JBoss from eclipse. All fine till here.
Now I need to extend the logic of the java code and I need to add a new artifact generated from another project, and here is where my problem starts. When I add a dependency to this new artifact and I try the make a 'install' I am getting this error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project MyTest: Compilation failure: Compilation
failure:
[ERROR]
/home/daniel/workspace/valais/voba-switch/src/ch/steria/scada/sw/web/controller/SwitchController.java:[7,24]
package javax.faces.model does not exist
[ERROR]
/home/daniel/workspace/valais/voba-switch/src/ch/steria/scada/sw/web/controller/SwitchController.java:[45,13]
cannot find symbol
[ERROR] symbol : class SelectItem
I see the libraries missing are in the jboss-web.deployer directory of the JBoss. How can I link this libraries in the pom.xml or how can I get the right ones from the jboss maven repository for my jboss vesion?
Thanks,
Dani.
I just had to set the artifacts from JBoss as 'provided'.

"Cannot be resolved to a type" after upgrading to GWT 2.7. and trying to compile a multi-project module

I´ve been having trouble getting the Super-Dev-Mode to work with GWT 2.7. and GXT 3.1.x The classical Dev-Mode starts without trouble, but the Super-Dev-Mode and GWT-compile the project won`t work.
I am currently working with Eclipse 4.4.2 with Java 1.7_2 on Windows.
So let´s pretend we have 2 GWT/GXT projects (no Maven) with GWT 2.6 and GXT 3.1.x (Projects are backuped on a repository).
One is called A and the other project is called B. Project A has many packages and no entrypoint (to just work as a library/framework), just an abstract entrypoint every other project has to extend. The other one is called B and inherits from A, the entrypoint extends the entrypoint of A.
When starting the project under GWT 2.6 in classical Dev-Mode the project works fine. When upgrading to GWT 2.7. it will work fine with the classical Dev-Mode, an even in Super-Dev-Mode the Codeserver starts to run, but when compiling the module i get an error that some code seems not to live under a package 'client' so i migrated it into a own package and added the sourcepath to the A.gwt.xml.
After fixing this error and starting the Super-Dev-Mode again (and when trying to GWT-compile) I get errors like this:
Ignored 15 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Finding entry point classes
Tracing compile failure path for type 'com.example.b.client.B'
[ERROR] Errors in 'file:/C:/Workspace/ProjectB/src/com/example/b/client/B.java'
[ERROR] com.example.a.client.A cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/view/ExampleLayout.java'
[ERROR] com.example.a.view.ILayout cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/client/service/ExampleServiceAsync.java'
[ERROR] com.example.a.model.Examplemodel cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/model/OtherExampleModel.java'
[ERROR] com.example.a.hibernate.model.ComOtherExampleModel cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectB/src/com/example/b/client/service/OtherExampleServiceAsync.java'
[ERROR] com.example.a.model.NewExampleModel cannot be resolved to a type
...
(and many more)
Project A is included in the buildpath of the project B, when creating a custom run configuration where the project is added to "user entries" and adding source folders to "user" entries wont work. For the custom run configuration i used something like the following arguments:
"-src src/ -src ${workspace_loc:ProjectA} com.example.b.B"
And even:
"-src src/ -src ${workspace_loc:ProjectA} com.example.b.B com.example.a.A"
I widely searched for solutions and even tried to set up the workspace again, checkout the projects from the repository again, organize imports and even adding every package to the buildpath of A.
I also tried to add this to the .gwt.xml files didn´t work:
<add-linker name="xsiframe"/>
How can I solve the "cannot be resolved to a type" error?
I would really appreciate every form of help to get this problem done! Thanks!
One possible problem could be your version of GXT. If you are using GXT 3.1.1 (which was the latest GPL-release), then you can not use GWT 2.7.0.
Take a look at the version table:
GXT versions
As you can see, Sencha GXT 3.1.1 does not support GWT 2.7.0. The first GXT release which will support GWT 2.7.0 is GXT 3.1.2.

"Plugin not found for prefix" error in Eclipse

In Eclipse I imported a maven-based project which uses maven jetty plugin. If I run mvn jetty:run from command line, everything works fine. If I add a run configuration in Eclipse and try to run it, I get the error message:
[ERROR] No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/eugene/.m2/repository), central (http://repo1.maven.org/maven2)] -> [Help 1]
In the Eclipe run configuration, I use:
Base directory: ${project_loc}
Goal: jetty:run
Maven Runtime: External
I read the [Help1] page. I don't have pluginGroup settings in maven configuration files, but I have the jetty plugin mentioned in pom.xml, so I guess everything should be fine (especially because everything works in command-line). I tried to "Run as > Maven clean" in Eclipse before executing the jetty run configuration, but it didn't help. Project compiles and passes all tests, only jetty:run does not work in Eclipse.
Please help, I'm an Eclipse & Maven newbie. Thanks in advance.
It does not work for me from command-line either.
Can you check if it works after adding the following in settings.xml as documented?
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>
Also note that there are two different versions of the plugin - the older maven jetty plugin and the newer jetty maven plugin.
I met this problem too, an easier way to solve this is to edit your pom.xml, add following plugin:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.6.8.v20121106</version>
</plugin>
...
</plugins>
</build>
...
</project>
Note:
jetty-maven-plugin is used for jetty version 7 and above, if you want jetty version 6, you should use maven-jetty-plugin
for the version, you may want to have a look at here and here for your desired version's full name.
I apologize for wasting your time. Now I looked through maven warnings which appeared in Eclipse console after I ran the run configuration. I noticed
[WARNING] Failed to retrieve plugin descriptor for Plugin [org.mortbay.jetty:maven-jetty-plugin]: null
so it became obvious why it couldn't recognize jetty: prefix. Couple of lines above I saw a bunch of warnings about missing plugin versions. So I added a version specification for the jetty plugin (<version> entry in pom.xml) and it solved the problem. I forgot a common rule that if something breaks the first thing to check is warnings you get.
I've got this issue in eclipse after importing an appengine project.
The target:
mvn appengine:devserver
The error:
[ERROR] No plugin found for prefix 'appengine' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/averasko/.m2/repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
The problem was in the incorrect base directory in the eclipse run configuration. When maven does not see a pom.xml file and is asked to run some non-standard target if fails like this as it don't know anything about the plugin that defines the target.
The solution is to correct the base directory to wherever your pom.xml file resides.
if you following this tutorial:
http://tapestry.apache.org/creating-the-skeleton-application.html
don't forget to follow this one crucial instruction:
Change into the newly created directory, and execute the command: