I can't for the life of me create a MongoDB document in Java with values that aren't Strings. I've tried using the "put" and "append" method, both return an error similar to the one below.
BasicDBObject doc = new BasicDBObject();
doc.put("foo", "bar"); // this works
doc.put("ugh", 5); // this doesn't
doc.put("plz", 7L); // nor does this
// [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project league: Compilation failure
// [ERROR] /home/calvin/league/src/main/java/gg/bram/league/App.java:[60,19] error: no suitable method found for put(String,int)
// Relevant bit: "error: no suitable method found for put(String,int)"
Output of java -version:
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.1) (7u65-2.5.1-5~deb7u1)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
Using mongo-java-driver 2.12.4, proof in pom.xml file:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.12.4</version>
</dependency>
This is killing me, I'm doing nothing different from all the tutorials/docs I can find online, please help!!
Thanks
EDIT: My entire pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gg.bram.league</groupId>
<artifactId>league</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>league</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.12.4</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>gg.bram.league.App</mainClass>
<classpathMavenRepositoryLayout>true</classpathMavenRepositoryLayout>
<classpathPrefix>/home/calvin/.m2/repository/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
You have your source and target set in the wrong place; they should be on maven-compiler-plugin.
Related
I've been trying to run some simple code from the first lesson of R for Data Science using Renjin in Eclipse. The reason I'm using Renjin is because I'm eventually going to develop this into a Java data analysis program. Here is the link to the R for Data Science lesson I'm following: https://r4ds.had.co.nz/data-visualisation.html
I got all my dependencies in the pom.xml file of my Maven project, and when I test my pom.xml file, it builds successfully. Here's my pom.xml just in case:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Tests</groupId>
<artifactId>Test1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Test1</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.renjin</groupId>
<artifactId>renjin-script-engine</artifactId>
<version>3.5-beta76</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>ggplot2</artifactId>
<version>3.2.0-b8</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>dplyr</artifactId>
<version>0.8.2-b6</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>feather</artifactId>
<version>0.3.1-b9</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>hms</artifactId>
<version>0.4.2-b18</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>stringr</artifactId>
<version>1.4.0-b6</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>lubridate</artifactId>
<version>1.7.4-b4</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>forcats</artifactId>
<version>0.3.0-b9</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>haven</artifactId>
<version>2.0.0-b1</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>httr</artifactId>
<version>1.4.0-b1</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>jsonlite</artifactId>
<version>1.6-b1</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>readxl</artifactId>
<version>1.3.1-b11</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>rvest</artifactId>
<version>0.3.2-b115</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>xml2</artifactId>
<version>1.2-renjin-8</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>modelr</artifactId>
<version>0.1.1-b31</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>broom</artifactId>
<version>0.4.4-b1</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>tidyr</artifactId>
<version>0.8.0-b1</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>readr</artifactId>
<version>1.3.1-b3</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>purrr</artifactId>
<version>0.3.2-b11</version>
</dependency>
<dependency>
<groupId>org.renjin.cran</groupId>
<artifactId>tibble</artifactId>
<version>2.1.3-b9</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<repositories>
<repository>
<id>bedatadriven</id>
<name>bedatadriven public repo</name>
<url>https://nexus.bedatadriven.com/content/groups/public/</url>
</repository>
</repositories>
</project>
However, when I try to run my App.java program with the R for Data Science code, it gives me loads of errors. Here is my App.java:
package Tests.Test1;
import javax.script.*;
import org.renjin.script.*;
import java.awt.*;
import javax.swing.*;
// ... add additional imports here ...
public class App {
public static void main(String[] args) throws Exception {
// create a script engine manager:
RenjinScriptEngineFactory factory = new RenjinScriptEngineFactory();
// create a Renjin engine:
ScriptEngine engine = factory.getScriptEngine();
// ... put your Java code here ...
engine.eval("library(dplyr)");
engine.eval("library(ggplot2)");
engine.eval("library(tidyr)");
engine.eval("library(readr)");
engine.eval("library(purrr)");
engine.eval("library(tibble)");
engine.eval("?mpg");
engine.eval("ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy))");
}
}
And here's the long list of errors I'm getting:
EEK! colSums.computeMeans() called through getElementAsDouble()
EEK! colSums.computeMeans() called through getElementAsDouble()
EEK! colSums.computeMeans() called through getElementAsDouble()
EEK! colSums.computeMeans() called through getElementAsDouble()
org.renjin.eval.EvalException: Exception initializing compiled GNU R library class org.renjin.cran.dplyr.dplyr
at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:141)
at org.renjin.primitives.packaging.Namespace.loadDynamicLibrary(Namespace.java:383)
at org.renjin.primitives.packaging.Namespace.importDynamicLibrary(Namespace.java:296)
at org.renjin.primitives.packaging.Namespace.initImports(Namespace.java:274)
at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:175)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:143)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
at org.renjin.primitives.packaging.Packages.library(Packages.java:39)
at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java:68)
at org.renjin.primitives.R$primitive$library.applyPromised(R$primitive$library.java:33)
at org.renjin.sexp.BuiltinFunction.apply(BuiltinFunction.java:100)
at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:46)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:39)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.sexp.Closure.applyPromised(Closure.java:200)
at org.renjin.sexp.Closure.apply(Closure.java:133)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.sexp.ExpressionVector.eval(ExpressionVector.java:85)
at org.renjin.eval.Context.evaluate(Context.java:280)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:174)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:133)
at Tests.Test1.App.main(App.java:19)
Caused by: java.lang.ArithmeticException: / by zero
at java.base/java.lang.Integer.remainderUnsigned(Integer.java:1564)
at org.renjin.cran.dplyr.hybrid__._ZN5boost9unordered6detail12prime_policyIjE9to_bucketEjj(hybrid.cpp)
at org.renjin.cran.dplyr.hybrid__._ZNK5boost9unordered6detail5tableINS1_3mapISaISt4pairIKP7SEXPRECN5dplyr6hybrid15hybrid_functionEEES6_SA_NS_4hashIS6_EESt8equal_toIS6_EEEE14hash_to_bucketEj(hybrid.cpp)
at org.renjin.cran.dplyr.hybrid__._ZNK5boost9unordered6detail5tableINS1_3mapISaISt4pairIKP7SEXPRECN5dplyr6hybrid15hybrid_functionEEES6_SA_NS_4hashIS6_EESt8equal_toIS6_EEEE14find_node_implIS6_SG_EEPNS1_8ptr_nodeISB_EEjRKT_RKT0_(hybrid.cpp)
at org.renjin.cran.dplyr.hybrid__._ZNK5boost9unordered6detail5tableINS1_3mapISaISt4pairIKP7SEXPRECN5dplyr6hybrid15hybrid_functionEEES6_SA_NS_4hashIS6_EESt8equal_toIS6_EEEE9find_nodeEjRS7_(hybrid.cpp)
at org.renjin.cran.dplyr.hybrid__._ZN5boost9unordered6detail5tableINS1_3mapISaISt4pairIKP7SEXPRECN5dplyr6hybrid15hybrid_functionEEES6_SA_NS_4hashIS6_EESt8equal_toIS6_EEEE14emplace_uniqueINS1_13emplace_args1ISB_EEEES4_INS0_15iterator_detail8iteratorINS1_8ptr_nodeISB_EEEEbERS7_RKT_(hybrid.cpp)
at org.renjin.cran.dplyr.hybrid__._ZN5boost9unordered13unordered_mapIP7SEXPRECN5dplyr6hybrid15hybrid_functionENS_4hashIS3_EESt8equal_toIS3_ESaISt4pairIKS3_S6_EEE7emplaceISD_EESB_INS0_15iterator_detail8iteratorINS0_6detail8ptr_nodeISD_EEEEbERKT_(hybrid.cpp)
at org.renjin.cran.dplyr.hybrid__._ZN5boost9unordered13unordered_mapIP7SEXPRECN5dplyr6hybrid15hybrid_functionENS_4hashIS3_EESt8equal_toIS3_ESaISt4pairIKS3_S6_EEE6insertERKSD_(hybrid.cpp)
at org.renjin.cran.dplyr.hybrid__._ZN5dplyr6hybrid11hybrid_initEP7SEXPRECS2_S2_NS0_9hybrid_idE(hybrid.cpp)
at org.renjin.cran.dplyr.hybrid__._ZN5dplyr6hybrid4initEv(hybrid.cpp)
at org.renjin.cran.dplyr.hybrid__._Z22init_hybrid_inline_mapP8_DllInfo(hybrid.cpp)
at org.renjin.cran.dplyr.RcppExports__.R_init_dplyr(RcppExports.cpp)
at org.renjin.cran.dplyr.dplyr.R_init_dplyr(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:137)
... 22 more
org.renjin.eval.EvalException: Exception initializing compiled GNU R library class org.renjin.cran.tidyr.tidyr
at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:141)
at org.renjin.primitives.packaging.Namespace.loadDynamicLibrary(Namespace.java:383)
at org.renjin.primitives.packaging.Namespace.importDynamicLibrary(Namespace.java:296)
at org.renjin.primitives.packaging.Namespace.initImports(Namespace.java:274)
at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:175)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:143)
at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
at org.renjin.primitives.packaging.Packages.library(Packages.java:39)
at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java:68)
at org.renjin.primitives.R$primitive$library.applyPromised(R$primitive$library.java:33)
at org.renjin.sexp.BuiltinFunction.apply(BuiltinFunction.java:100)
at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:46)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:39)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.sexp.Closure.applyPromised(Closure.java:200)
at org.renjin.sexp.Closure.apply(Closure.java:133)
at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
at org.renjin.sexp.ExpressionVector.eval(ExpressionVector.java:85)
at org.renjin.eval.Context.evaluate(Context.java:280)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:174)
at org.renjin.script.RenjinScriptEngine.eval(RenjinScriptEngine.java:133)
at Tests.Test1.App.main(App.java:21)
Caused by: java.lang.NoSuchFieldError: _ZTVN10__cxxabiv120__si_class_type_infoE
at org.renjin.cran.tidyr.RcppExports__._ZTIN4Rcpp9exceptionE$$clinit(RcppExports.cpp)
at org.renjin.cran.tidyr.RcppExports__.<clinit>(RcppExports.cpp)
at org.renjin.cran.tidyr.tidyr.R_init_tidyr(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:137)
... 22 more
I'm not quite sure how to get the code to work. If you have any ideas on how to fix this, I'd love to hear them. Please keep in mind that I am a beginner though, and I may need things in simpler/more thorough terms. If you need any more information, let me know, and I'll respond as soon as possible. Any and all help is appreciated. Thank you.
A)Summarize the problem
There are three methods to define compiler version in pom maven.
I did not mention maven.compiler release , plugin and version it works (means maven build success)then how it is picking the compiler version and i did not mention version
For The things ihave tried please refer section b
1)
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<verbose>true</verbose>
</configuration>
</plugin>
<maven.compiler.release> 8</maven.compiler.release>
B) What i have tried
I remove both maven.compiler release and plugin it works then how it is picking the compiler version
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.flowing.retail</groupId>
<artifactId>flowing-retail-kafka-shipping</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.boot.version>2.2.5.RELEASE</spring.boot.version>
<spring-cloud-stream.version>Horsham.RELEASE</spring-cloud-stream.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-dependencies</artifactId>
<version>${spring-cloud-stream.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-kafka</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- required to add JSR310 time formats for Jackson to ObjectMapper -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>io.flowing.retail.shipping.ShippingApplication</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I define invalid maven.compiler.release. It then also works
4.0.0
io.flowing.retail
flowing-retail-kafka-shipping
0.0.1-SNAPSHOT
<maven.compiler.release>108</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring.boot.version>2.2.5.RELEASE</spring.boot.version>
<spring-cloud-stream.version>Horsham.RELEASE</spring-cloud-stream.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-dependencies</artifactId>
<version>${spring-cloud-stream.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-kafka</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- required to add JSR310 time formats for Jackson to ObjectMapper -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>io.flowing.retail.shipping.ShippingApplication</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
[Let me first clarify the expression "picking the compiler version" you use in your question. The compiler you use is configured through the compilerId and compilerVersion options and it's usually the compiler of the JDK you installed. We are talking about setting the compatibility options of your compiler.]
The properties you mention are used to provide the -source, -target and --release arguments to the javac compiler (or equivalent if you use another compiler).
Since --release was introduced in Java 9, which one applies depends on the JDK used to run maven. If you provide the --release argument:
on JDK 9 and higher, maven will ignore the -source and -target parameters,
on JDK 8 and lower, the compilation will fail miserably.
The maven-compiler-plugin specifies three ways to provide these parameters:
in the <configuration> section of a <plugin> tag. This one overrides the others,
as a property in your pom.xml. This one applies if you didn't specify the parameter in a <configuration> section,
if you didn't specify any of the above, a default for -source and -target applies (--release does not have a default).
You can find the defaults in the maven-compiler-plugin.jar (resource META-INF/maven/plugin.xml):
<configuration>
...
<release implementation="java.lang.String">${maven.compiler.release}</release>
...
<source implementation="java.lang.String" default-value="1.6">${maven.compiler.source}</source>
...
<target implementation="java.lang.String" default-value="1.6">${maven.compiler.target}</target>
</configuration>
So, since you are using version 3.8.1 of the plugin, if you don't specify anything at all, Java 6 applies.
TL;DR: if you use Java 9 and higher, your configuration options will apply in the order 3., 2., 1.
Edit: If your compiler supports it, between setting the -source/-target and --release options, I would always choose the latter. With the --release option, you won't have issues like this one. What happened there is: the source syntax was compatible with Java 8 (-source 1.8), the classes could be read by a JVM 8 (-target 1.8), but a method changed signature (in a backward, but not forward compatible way) between Java 8 and 11 and the library would not work with JRE 8.
I'm trying to learn OSGI and figured I would build a simple rest application using Spark Servlet.
https://mvnrepository.com/artifact/com.sparkjava/spark-core/1.0
Within my maven build plugin, I embed Spark-Core. However, after I build and run the bundle, it tells me there is a wiring package problem. So I add the package import, rinse and repeat. I'll get a different wiring package problem, so then I add the dependency, etc.
This seems like a long tedious process to add one package after another. What's the correct way to do this?
POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>osgi-demo</artifactId>
<groupId>com.osgi-hacking</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>bundle</packaging>
<artifactId>osgiclient</artifactId>
<dependencies>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-servlet</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Bundle-Name>
CUSTOM :: GREETER CLIENT :: BUNDLE
</Bundle-Name>
<Bundle-Version>
9.4.8.v20171121
</Bundle-Version>
<Bundle-Activator>
com.osgi.client.Activator
</Bundle-Activator>
<Embed-Dependency>
spark-core
</Embed-Dependency>
<Import-Package>
*
</Import-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
The spark core jar is already a bundle.
So there is no need to embed it. Simply install it as well as its dependendencies (which is mainly jetty) in OSGi.
For your own bundle. Simply remove all inside . The defaults of the maven bundle plugin will produce what you need.
It will detect the packages you need and write Import-Package statements for them. When you then have spark-core installed as a bundle it should work fine.
I'm trying to work with Hive UDF's and UDAF's and so far, I've managed quite well in doing so using maven from the command line on a VM that has essentially been set up quite well by someone very knowledgable. I'm new to Java (projects, not so much the language) but I can at least see what my current issue is. What I don't know is why it's happening and how to fix it.
So...
my problem is that for whatever reason, when running
mvn install
the compiler can't find any classes past
/org/apache/hadoop/hive/ql/exec
It can find all classes in the 'exec' folder, but nothing in any subfolders nested in 'exec'. I don't understand why this is the case. Here is my POM file.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.matthewrathbone.example.RawMapreduce</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<modelVersion>4.0.0</modelVersion>
<groupId>com.matthewrathbone.example</groupId>
<artifactId>hive-extensions</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>hive-extensions</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.0.0-mr1-cdh4.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>0.10.0-cdh4.3.1</version>
<scope>provided</scope>
</dependency>
<!-- TEST DEPENDENCIES -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-test</artifactId>
<version>2.0.0-mr1-cdh4.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
</repositories>
</project>
An example of one of the many errors I get is in the title. 'vector' is a folder located in /org/apache/hadoop/hive/ql/exec.
As far as I can tell, the hive-exec.jar file is listed as a dependency in my POM file, so I'm not really sure why the compiler is having trouble locating all the classes contained within it (it can find some, as mentioned previously).
Essentially what I'm trying to do is incorporate one of the built-in UDAF's as my own temporary function, so that I can bypass Hive's restrictions on sub-querying inside the 'SELECT' statement.
So, to be more specific, I made some adjustments and eventually narrowed it down to compiler was looking for class VectorizedUDAFs which as it turns out, my version of hive-exec .jar does not have.... go figure. Thus, it couldn't find it because it actually did not exist...
Management wants me to migrate a project that uses BIRT 2.1.2/Java 4/IBM WebSphere 5/Windows 2003 to Linux/Apache/Tomcat. I've chosen Tomcat 8, Java 8, and BIRT 4.5, to maximize the time before we again fall off the trailing edge.
I'm stuck on a failing test case that just initializes BIRT, with this code:
public static void init( String engineHome, String Birt_Resource_Path)
throws BirtException
{
if (!initialized) {
initialized = true;
DesignConfig config = new DesignConfig();
// config.setBIRTHome( engineHome);
Platform.startup( config);
IDesignEngineFactory factory =
(IDesignEngineFactory) Platform.createFactoryObject(
IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY);
if (factory == null) {
log.warn("Failed to construct DesignEngineFactory");
initialized = false;
} else {
birtEngine = factory.createDesignEngine(config);
birtResourcePath = Birt_Resource_Path;
}
log.info("DesignEngineService initialized! " + engineHome);
}
}
My test case calls this code, and later tests if the engine is initialized and fails then.
I read the notes about changes in BIRT 3.7 meaning I don't have to call config.setBIRTHome( engineHome), so I commented out that line.
The call to Platform.createFactoryObject(...) is still returning null, so I get the log message "Failed to construct DesignEngineFactory" and my test case fails.
I am using Eclipse Mars, and Maven for build and dependencies. My pom.xml is
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lxnx.sysman.webstar</groupId>
<artifactId>reportService</artifactId>
<packaging>war</packaging>
<version>2.0-DEVELOPMENT</version>
<name>Report Service</name>
<url>http://myproject.mycompany.com/ReportService</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<birt-version>4.5.0a</birt-version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>${birt-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>opennms</groupId>
<artifactId>opennms-joesnmp</artifactId>
<version>20031201-173122</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>struts</groupId>
<artifactId>struts</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>com.mycompany.myproject</groupId>
<artifactId>ReportServiceImpl</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<additionalClasspathElements>
<additionalClasspathElement>c:\mycompany\app\myproject\bin\jars\sqljdbc42.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
<finalName>ReportService</finalName>
</build>
</project>
It looks like all the BIRT jars are in the Maven Dependencies library; at least org.eclipse.birt.runtime-4.5.0a.jar is there along with a hundred others.
What else do I need to do?