IntelliJ Compiling error with gRPC - scala

IntelliJ tells this compiling error, when I build a scala project to test gRPC APIs with Gatling.
IntelliJ:
IntelliJ IDEA 2017.3.5 (Community Edition)
Build #IC-173.4674.33, built on March 6, 2018
JRE: 1.8.0_152-release-1024-b15 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Scala Plugin
Version: 2017.3.15
The project depends on another project(API). The latter one uses the following pom file (gRPC).
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.7.0</version>
</dependency>
The code:
val channel = ManagedChannelBuilder
.forAddress("...", 8088)
.usePlaintext(true)
.build() // <---- IntelliJ says "Error:..." here
Error:
Error:(10, 161) value build is not a member of ?0
val channel = ManagedChannelBuilder.forAddress("...", 8088).usePlaintext(true).build()
I cannot see anything wrong with the code. Is it a bug of IntelliJ?
Any help will be appreciated.

That issue was a bug in Scala that was fixed in Scala 2.11 and later. See grpc-java issue 2813 for discussion.

Related

sbt maven compatibility issues

I am facing an issue with sbt here https://github.com/dmlc/xgboost/issues/1858
strangely not even the maven variables are resolved
com.typesafe.akka#akka-actor_${scala.binary.version};2.3.11: not found
maven outputs these warnings during the build:
Expected all dependencies to require Scala version: 2.11.8
[WARNING] com.typesafe.akka:akka-actor_2.11:2.3.11 requires scala version: 2.11.5
[WARNING] Multiple versions of scala libraries detected!
On a mac hard coding the scala version of the akka dependency seems to be a workaround. For windows or ubuntu this workaround does not work.
edit
<scala.binary.version>2.11</scala.binary.version> in https://github.com/dmlc/xgboost/blob/master/jvm-packages/pom.xml
and
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_${scala.binary.version}</artifactId>
<version>2.3.11</version>
<scope>compile</scope>
</dependency>
in https://github.com/dmlc/xgboost/blob/e7fbc8591fa7277ee4c474b7371c48c11b34cbde/jvm-packages/xgboost4j/pom.xml
which I hard coded to
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.3.11</version>
<scope>compile</scope>
</dependency>
The problem is xgboost is using properties from the pom.xml which are defined in a non-default per profile section. SBT does not seem to be able to handle that
see my pull request here https://github.com/dmlc/xgboost/issues/1858

Scala ORM producing incompatible version build errors

We have a working Scala application, using Scala 2.11.5.
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.5</version>
</dependency>
When we introduce SORM, using the following maven dependency:
<dependency>
<groupId>org.sorm-framework</groupId>
<artifactId>sorm</artifactId>
<version>0.3.18</version>
</dependency>
the following two build errors occur:
scala-parser-combinators_2.12.0-M4-1.0.4.jar of xxx build path is cross-compiled with an incompatible version of Scala (2.12.0).
scala-xml_2.12.0-M4-1.0.5.jar of xxx build path is cross-compiled with an incompatible version of Scala (2.12.0).
I have tried using older version of SORM, but similar problems occur. For instance, with version 0.3.8 :
slf4s_2.9.1-1.0.7.jar of xxx build path is cross-compiled with an incompatible version of Scala (2.9.1).
A similar problem exists when using Squeryl for the object relational mapping:
<dependency>
<groupId>org.squeryl</groupId>
<artifactId>squeryl_2.9.3</artifactId>
<version>0.9.5-7</version>
</dependency>
causes the following build error;
squeryl_2.9.3-0.9.5-7.jar of xxx build path is cross-compiled with an incompatible version of Scala (2.9.3).
Does anyone have a solution?
Thanks
You can fix your Squeryl issue by referencing the correct Scala version in your POM.
<dependency>
<groupId>org.squeryl</groupId>
<artifactId>squeryl_2.11</artifactId>
<version>0.9.5-7</version>
</dependency>

javax.xml.bind.JAXBException while generating word document from XHTML in cq5

I am trying to convert HTML> XHTML to word document, using docx4j library. While hitting the servlet I get this exception.
I have converted docx4j jar to OSGi bundle and in my classpath 1.7.0_21 is set.
java.lang.RuntimeException: javax.xml.bind.JAXBException: JAXB: neither Reference Implementation nor Java 6 implementation present?
at org.docx4j.XmlUtils.marshaltoString(XmlUtils.java:546)
at org.docx4j.XmlUtils.marshaltoString(XmlUtils.java:478)
at org.docx4j.openpackaging.parts.WordprocessingML.StyleDefinitionsPart.createVirtualStylesForDocDefaults(StyleDefinitionsPart.java:330)
at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.getStyleTree(MainDocumentPart.java:172)
at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.getStyleTree(MainDocumentPart.java:161)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.stylesToCSS(XHTMLImporterImpl.java:424)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.getRenderer(XHTMLImporterImpl.java:218)
at org.docx4j.convert.in.xhtml.XHTMLImporterImpl.convert(XHTMLImporterImpl.java:620)
It reports JRE 1.7 only:
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
This issue is now resolved, we had to deploy two more bundles( org.apache.servicemix.bundles.ant-1.7.0 and JAXB).
This might help others !
Thanks
I had the very same issue regarding the exception, and what helped me was to introduce following into my pom.xml
<dependency>
<groupId>com.googlecode.jaxb-namespaceprefixmapper-interfaces</groupId>
<artifactId>JAXBNamespacePrefixMapper</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
</dependency>

java.lang.NoClassDefFoundError: scala/reflect/ClassManifest

I am getting an error when trying to run an example on spark. Can anybody please let me know what changes do i need to do to my pom.xml to run programs with spark.
Currently Spark only works with Scala 2.9.3. It does not work with later versions of Scala. I saw the error you describe when I tried to run the SparkPi example with SCALA_HOME pointing to a 2.10.2 installation. When I pointed SCALA_HOME at a 2.9.3 installation instead, things worked for me. Details here.
You should add dependecy for scala-reflect to your maven build:
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>2.10.2</version>
</dependency>
Ran into the same issue using the Scala-Redis 2.9 client (incompatible with Scala 2.10) and including a dependency to scala-reflect does not help. Indeed, scala-reflect is packaged as its own jar but does not include the Class missing which is deprecated since Scala 2.10.0 (see this thread).
The correct answer is to point to an installation of Scala which includes this class (In my case using the Scala-Redis client, the answer of McNeill helped. I pointed to Scala 2.9.3 using SBT and everything worked as expected)
In my case, the error is raised in Kafka's api. I change the dependency from
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.9.2</artifactId>
<version>0.8.1.1</version>
</dependency>
to
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming-kafka_2.10</artifactId>
<version>1.6.1</version>
</dependency>
fixed the problem.

Using Drools on Jetty

I am trying to start up a webapp that uses Drools 5.2.0.M1. I get the following stacktrace on startup:
java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem;
at org.drools.commons.jci.compilers.EclipseJavaCompiler$3.acceptResult(EclipseJavaCompiler.java:336)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335)
at org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:366)
at org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:51)
at org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:366)
at org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:55)
I have the jars in my pom:
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.2.0.M1</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>3.5.1</version>
</dependency>
Why Can't it find CompilationResult.getProblems()?
JDT isn't backwards compatible.
Check the drools-compiler pom (of exactly the version you're using) on which version of ecj it depends and use that version. Or don't declare ecj at all, it's a transitive dependency for drools-compiler anyway.
PS: upgrade to drools 5.2.0.CR1 (or final once it's out)
I had a similar problem. I was having a web-app using Jetty 6. Jetty 6 which apparently bringing in a non-compatible version of JDT. After switching to Jetty 7 the problem was solved.