Using BoringSSL With Vertx (ALPN) - java

I am trying to use BoringSSL with Vertx so that I can use ALPN. I am running vertx 3.7.1 and have included the following in my pom.xml-
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>2.0.23.Final</version>
</dependency>
When I run my application I get the following message- "ALPN not available for JDK SSL/TLS engine". If I add <scope>runtime</scope> or <scrope>compile</scope> to the dependency, I will not get this message when I run the application through my IDE.
However, when I build a jar with any of the scopes (or no scope defined) the resulting jar does not contain the boringssl piece. More specifically, there is an io.netty package, but the io.netty.internal.tcnative is missing.
How can I include this package in the final jar I'm building?

Related

Spring, Maven: Correct the classpath of your application

I am trying to create a maven version of the gradle-based treehouse 'unit-testing-a-spring-application' project used in this course. See course code here.
After not being able to build initially, I ended up adding dependency versions specified in the original gradle build file. Maven will build fine, but running the app gives this:
The following method did not exist:
org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)
Ljava/lang/String;
The method's class, org.springframework.data.repository.config.RepositoryConfigurationSource, is
available from the following locations:
jar:file:/C:/Users/home/.m2/repository/org/springframework/data/spring-data-
commons/2.1.6.RELEASE/spring-data-commons-2.1.6.RELEASE.jar!/org/springframework/data/repository/config/RepositoryConfigurationSource.class
It was loaded from the following location:
file:/C:/Users/home/.m2/repository/org/springframework/data/spring-data-commons/2.1.6.RELEASE/spring-
data-commons-2.1.6.RELEASE.jar
Action
Correct the classpath of your application so that it contains a single, compatible version of
org.springframework.data.repository.config.RepositoryConfigurationSource.
Several similar problems are solved here on S.O. by changing the version of some related dependency. I have tried various versions of the following to no avail (I stick normally with spring-boot-starter-parent v2.1.4 cause it works all the time with my projects):
spring-data-commons
spring-boot-starter-parent
I see the needed class below listed in my project Dependencies directory, but what dependency versions will work in this case? How can I solve this otherwise?
org/springframework/data/repository/config/RepositoryConfigurationSource.class
I looked at your code and found some mistakes. Since your project is a spring-boot one, you mustn't add direct spring dependencies in your pom file. Instead try to use spring-boot based dependencies. For instance, instead of having such this dependency:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.9.2.RELEASE</version>
</dependency>
You must have the following one in your pom file.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

How to download files from Gitlab account using java

I am writing one utility job in java to download JSON files from particular URL of Gitlab account and further process them according to requirement. I tried to do same using java-gitlab-api dependency. However, even after including below maven dependency,
I get error as :
Missing artifact org.gitlab:java-gitlab-api:jar:1.1.8-
The import org.gitlab cannot be resolved.
Maven dependency I am using is :
<dependency>
<groupId>org.gitlab</groupId>
<artifactId>java-gitlab-api</artifactId>
<version>1.1.8-SNAPSHOT</version>
</dependency>
I tried to update, clean maven project but nothing worked. Anyone has an idea of how can I rectify issues and download files from gitlab account.
Use appropriate maven java-gitlab-api version(s). There is most recent version is available too.
https://mvnrepository.com/artifact/org.gitlab/java-gitlab-api/1.1.8
https://mvnrepository.com/artifact/org.gitlab/java-gitlab-api
<!-- https://mvnrepository.com/artifact/org.gitlab/java-gitlab-api -->
<dependency>
<groupId>org.gitlab</groupId>
<artifactId>java-gitlab-api</artifactId>
<version>1.1.8</version>
</dependency>

log4j package does not exist

I'm running mvn install, getting below error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile
error: package org.apache.log4j does not exist
In my project hierarchy I have log4j-1.2.15.jar added as a Referenced Libraries..not sure what I'm missing.
Part of POM file with log4j dependency (should I change the version to just say 1.2...or possible remove the scope below?):
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>1.2.15</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>1.2.15</version>
</dependency>
For log4j I only use this libraries:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
At first, it can be related with some your customizations of the environment or with dependencies in your *.pom file (Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin (default-compile) on project: Fatal error compiling: tools.jar not found). You need to check default installed "jre" to a jdk. Also ensure maven instalation and , namely paths: $JAVA_HOME and $M2_HOME
for example the paths adjustments when you have linux:
When I execute the command: echo $JAVA_HOME I will have /usr/lib/jvm/java-9-oracle and appropriate path for maven
For eclipse users this directly resolved this problem. There is no need to re-install anything with maven installed in eclipse oxygen centos 6. Vogella tutorial below says to resolve the dependency by adding the .jar via downloaded index at startup. As identified above answer 1.2.17 is around the same solution that worked for me (1.2.15) You must launch eclipse in a terminal with JAVA_HOME set as mentioned above. Eclipse will handle the rest.
How to use maven in eclipse
Identifies how to download the dependency list. Once you setup your project you open the pom gui and select Dependencies. You search for the above mentioned library select and add it. During initial build, the dependent .jar is downloaded and configured dynamically via the pom.xml state injection, this is why no manual deleting or re-install is necessary.
It is still not managed- To manage the dependency, i.e. add it to the pom, you select the item you just added and click manage and follow the prompts to add it the Dependency Management list. This is an automatic pom addition from the gui - `
<dependency>
<groupId>org.eclipse.ecf</groupId>
<artifactId>org.apache.log4j</artifactId>
<version>1.2.15.v201012070815</version>
</dependency>`
When the Dependency Management list is populated your library will display a (managed:version) tag in orange.
Start smiling, right click pom, run as maven build, the errors should be gone.

How to use spark mllib in web project

I am trying to use spark mllib.jar in web project. I downloaded spark-1.1.0-bin-hadoop2.4 and unzipped. There are some jar found as follows:
datanucleus-api-jdi-3.2.1.jar
datanucleus-core-3.2.2.jar
datanucleus-rdbms-3.2.1.jar
spark-assembly-1.1.0-hadoop2.4.0.jar
spark-examples-1.1.0-hadoop2.4.0.jar
Then I use spark-assembly-1.1.0-hadoop2.4.0.jar to import classification methods. It can be run successfully in java project. However when I add the jar to SomeWebProject/web-inf/lib, it turns out error messages:
validateJarFile ...\web-inf\lib\spark-assembly-1.1.0-hadoop2.4.0.jar jar not loaded. offending class:javax/servlet/servlet.class
I know it because my web project javax.servlet class is duplicated with spark jar. I try to delete spark's javax.servlet. It still not working.
Could you please tell me how to figure it out
and
Can I use other spark jar to run mllib in local mode. This jar is too large and it is about 132 mb and I think some of them are useless. But I cannot find any other available jars. Is this jar the only way to import spark-mllib.jar?
p.s. For some reasons I can not deploy spark in my servers. So I could not use hadoop environments
Thanks very much!!!
If you can use maven then just add these dependencies to your pom.xml:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.11</artifactId>
<version>1.3.0</version>
</dependency>

#XmlElement - OpenJDK using Maven

I recently am trying open JDK, for obvious reasons the SUN libraries are not included as part of the openJDK runtime.
I am wondering what I have to add to my POM file to use mavin to include the SUN libraries.
Currently in my environment I am using the following annotation.
package com.sun.xml.internal.txw2.annotation does not exist
#XmlElement
If this is javax.xml.bind.annotation.XmlElement then you need to add dependencies to either JAXB or java-ee API.
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
</dependency>
Or
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
Both should be available on Maven Central. Note that the API dependencies will let you compile your code, but if you have any unit tests that actually use JAXB you'll also need to declare dependencies on an actual JAXB implementation.
You can try downloading the JAR containing the required classes and importing external dependencies into your project, but it will explode if the project is embedded on a continuous integration server.

Categories