JDK 11 with JAXB and JAXWS works with Eclipse but not IntelliJ - eclipse

I am converting an application that uses JAXB and JAX-WS from JDK 8 to JDK 11. The code runs when I use Eclipse IDE but exactly the same code fails with IntelliJ IDEA
I have created a Maven project using both Eclipse and IntelliJ IDEA. The problems of finding a working combination of Maven resources has been described in another question. JDK 11 with JAXB and JAXWS problems
The code builds without error in both environments. I have tried creating the IntelliJ IDEA project as a Maven project as well as a standard IDEA project
part of pom.xl
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.0</version>
</dependency>
<!-- JAXWS for Java 11 -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.1</version>
</dependency>
module-info.java
module org.openfx.gustfx {
requires javafx.controls;
requires javafx.fxml;
requires transitive javafx.graphics;
requires java.xml.bind;
requires java.xml.ws;
requires javax.jws;
opens com.agile.ws.schema.common.v1.jaxws to javafx.fxml;
opens org.openfx.gustfx to javafx.fxml;
exports org.openfx.gustfx;
}
When the code is run from Eclipse, there are no errors.
Running the same code from IntelliJ IDE results in this error
java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl
Searching through the jar files confirms that ProviderImpl.class is now located in com.sun.ws.spi not in com.sun.xml.internal.ws.spi This does not cause a problem with eclipse but IDEA reports the ClassNotFoundException
Therefore, my question "How does eclipse resolve this problem while IntelliJ does not ?"

With help from Roman Shevchenko at IntelliJ, I have solved this problem using the following pom.xml
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
and module-info.java
requires java.xml.ws;
requires java.xml.bind;
requires javax.jws;

Related

Cannot resolve symbol 'owasp', import error in intellij

I want to use ESAPI in my project and have added following dependency in the pom.xml
pom.xml with dependency:
<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.5.0.0</version>
</dependency>
But when I import org.owasp.esapi.* intellij give me warning as shown in image.
I want to use ESAPI logger to prevent CRLF injection possibilities in log statements.
My current project uses slf4j.Logger
I am very new to this ESAPI and OWASP and have never used it and have tried from here
https://github.com/ESAPI/esapi-java-legacy/wiki/Using-ESAPI-with-SLF4J#configuring-esapi-to-use-slf4j
Please tell me if im doing something wrong and how to correctly use ESAPI in project.
Hmm. What JDK are you using with IntelliJ? Java 8 or later is required as of 2.4.0.0. That's the only thing that I can think of that would cause this behavior. Looks okay otherwise. Did you check if the esapi-2.5.0.0.jar got pulled down? Because it's either not finding that or it's not compatible with the Java version that your IntelliJ IDE is using.
Well i found that I was adding this dependency in <dependencyManagement> tag instead of <dependencies> tag, that's why it wasn't downloading from the repository.
Previous:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.5.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
after fix:
<dependencies>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.5.0.0</version>
</dependency>
</dependencies>
Whats the difference in <dependencies> and <dependencyManagement> please refer this Differences between dependencyManagement and dependencies in Maven

Module java.xml.bind not found

I am new with javafx and eclipse . I installed eclipse then javafx from the eclipse market . I generated an fxml code with scene builder but I can not execute it . I m really blocked and couldnt find any soltution
I added --add-modules java.xml.bind as an argument in run configuration , but no chance
Error occurred during initialization of boot layer
java.lang.module.FindException: Module java.xml.bind not found
This has been removed from the JDK with version 11+. You have to explicitly add some external dependencies to your project.
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.1</version>
<scope>runtime</scope>
</dependency>
And remove the --add-modules directive.

Scala package throws java.lang.UnsupportedClassVersionError

Our java application has dependencies on Spark, which is written in Scala. Build tool is Maven, and am running from within Eclipse. The JDK_HOME used to compile the application on the command line using Maven, and the JRE used to run within Eclipse, are both 1.7.0_15.
The Maven POM contains the following:
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
...
<configuration>
<scalaVersion>1.10.5</scalaVersion>
<args>
<arg>-target:jvm-1.7</arg>
</args>
</configuration>
</plugin>
I understand that Spark is built using Scala 2.10
The maven dependencies include the following:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-hadoop</artifactId>
<version>2.1.0.Beta4</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-spark_2.10</artifactId>
<version>2.1.0.Beta4</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-xml</artifactId>
<version>2.11.0-M4</version>
</dependency>
<dependency>
<groupId>org.scala-lang.modules</groupId>
<artifactId>scala-parser-combinators_2.12.0-M2</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.10</artifactId>
<version>1.3.0</version>
</dependency
>
At runtime, the folowing exception is thrown:
Exception in thread "main" java.lang.UnsupportedClassVersionError: scala/util/parsing/combinator/PackratParsers : Unsupported major.minor version 52.0
I cannot find a 2.10.* version of the scala-parser-combinators jar.
Can anyone assist with the solution?
Thanks!
The scala-parser-combinators_2.12.0-M2 module is part of the Scala 2.12 distribution.
2.12 is targeted for Java 8 - bytecode major version 52, hence the error.
Your best bet is to either use an older Spark distribution or switch to Java 8 (Java 7 is at End-Of-Life since April 2015).
EDIT (addressing question edit): you cannot find an older version of the scala-parser-combinators library, because it was isolated to a stand-alone module at some point after 2.10. You can attempt to simply exclude this dependency in your POM, but there's no guarantee your chosen Spark version will be compatible with this older library version.

Maven generates old and unwanted RichFaces jars

I have a JSF 2.0 project and when I run 'mvn package' from eclipse (right click on the pom file and run) I get the war file with older versions of the richfaces jars along with the latest jars as shown in the image below.
pom.xml:
<properties>
<org.richfaces.bom.version>4.3.4.Final</org.richfaces.bom.version>
</properties>
<dependencies>
<!-- Mojarra implementation of JSF spec 2.2 -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-bom</artifactId>
<version>${org.richfaces.bom.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-components-ui</artifactId>
<version>${org.richfaces.bom.version}</version>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
<version>${org.richfaces.bom.version}</version>
</dependency>
</dependencies>
How can I fix this? Any help would be appreciated.
Suggest you to install maven outside of eclipse and try to run 'mvn package' from command line and see if you encounter the same problem in this way as well.
You may also create a 'New Launch Configuration' in eclipse for running mvn package from inside eclipse. To do this, right click on the pom.xml file > Run as > Run configuration ...
Hit 'New launch configuration'. This will take care of any mis-configuration you might have done inadvertently in your earlier launch configuration.

Scala JPA in netbeans

I am learning Java EE 6 but wants my Entities in scala and am also using netbeans. I created a scala class library but I cannot use javax.persistence._ even if I add the eclipselink library I can't import it. NB: I've tried eclipse but always having problems especially with glassfish thus I want to use netbeans and have java web project depend on the scala class library. I also like vim and netbeans have a perfect plugin for that. Not dishing eclipse but I am always suffering when I tried to use eclipse with Java EE 6 compared to netbeans.
You can use Maven to configure your dependencies for JavaEE and your specific JPA provider, for example:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>toplink.essentials</groupId>
<artifactId>toplink-essentials</artifactId>
<version>2.1-60f</version>
</dependency>
Notes:
To use javax.persistence classes, you need javax.persistence dependency.
Im using Java EE 7 but in your case, change "7.0" to "6.0"
Toplink is my JPA provider (you can use EclipseLink, Hibernate, ...), for example:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.6.0</version>
</dependency>
Or another provider at this link:
JPA provider