Encrypt a Java application with Cloud KMS example - google-cloud-kms

https://codelabs.developers.google.com/codelabs/cloud-bookshelf-java-cloud-kms/index.html#0
I'm getting following error after downloading additional Bookshelf app files ( Step 7)
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.3.8.v20160314:run-exploded (default-cli) on project bookshelf-3: Execution default-cli of goal org.eclipse.jetty:jetty-maven-plugin:9.3.8.v20160314:run-exploded failed: An API incompatibility was encountered while executing org.eclipse.jetty:jetty-maven-plugin:9.3.8.v20160314:run-exploded: java.lang.NoSuchMethodError: com.google.cloud.ServiceOptions.(Ljava/lang/Class;Ljava/lang/Class;Lcom/google/cloud/ServiceOptions$Builder;Lcom/google/cloud/ServiceDefaults;)
https://codelabs.developers.google.com/codelabs/cloud-bookshelf-java-cloud-kms/index.html#0

like Tim mentioned, you're getting this error because that codelab is currently instructing users to download an older version of the KMS library (v1beta1). You can see this in the pom.xml file in the GCS bucket downloaded, for the google-api-services-cloudkms artifact, whose version is v1beta1-rev1-1.22.0.
To fix the issue, edit the pom.xml file in the bucket to point to the current v1 version, you can find the current version here: https://mvnrepository.com/artifact/com.google.apis/google-api-services-cloudkms. At the time I'm writing this, its v1-rev41-1.23.0.
Current:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudkms</artifactId>
<version>v1beta1-rev1-1.22.0</version>
</dependency>
Fix
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudkms</artifactId>
<version>v1-rev41-1.23.0</version>
</dependency>
You're also going to need to resolve all of the v1beta1 references inside src/main/java/com/example/getstarted/util/CloudKeyManagementServiceHelper.java
For more information and guides on how to use Google Cloud KMS Java, I'd suggest looking at our java samples.
Thanks

Related

maven-connector-java, module not found

Successfully I did my first JDBC program using MariaDB, Maven, Java-11.
Now I have to access MySQL and just exchanged the MariaDB dependency by
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
I figured out, that com.mysql.jdbc and com.mysql.cj and other modules are hosted in the mysql-connector-java-8.0.28.jar.
Hence, in module-info.java I exchanged
requires org.mariadb.jdbc;
by
requires com.mysql.jdbc;
I also tried
requires com.mysql.cj;
but still, the maven-compiler-plugin:3.9.0 complains
module not found
What did I miss, here?
khmarbaise has put me on the right track: I almost forgot that there are legacy jar files around not prepared for easy integration into JPMS. To include the jar file mysql-connector-java-8.0.28.jar, which comes without a module-info.class, I had to enter
requires java.sql;
requires mysql.connector.java;
to my module-info.java.
The module name mysql.connector.java is derived from the name of its jar file by omitting the version info and substituting the dashes by dots.

Cannot resolve type problems with eclipse

It seems that I got the wires crossed & ask you to point me the right direction.
I have a problem with the Eclipse IDE for Enterprise Java Developers (version: 2019-06 (4.12.0), build id: 20190614-1200). There is a code part where I get the error message MysqlDataSource cannot be resolved to a type. Searching the Web, I found out that this class is included in the download of mysql-connector-java JAR 8.0.14 with all dependencies. I added it over the 'Fix project setup…', where I added the JAR file to the libraries of the Java Build Path.
Unfortunately, the error message does not vanish. Can you see what I am doing wrong?
Edit 1:
With the hint from another Website, I found out that the hibernate JAR included was the source files JAR. So, I corrected it the hibernate-entitymanager JAR, clicked "Clean…" under "Project", but to no avail: the EntityManager is still unlocatable. (Well, after several tries, the first error message to resolve is no more with MySQL.)
As I learned from somebody on another Web site, the following lines have to be added to the pom.xml file:
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.2.Final</version>
</dependency>
or
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>

Unable to Configure CAS Database Authentication

Following this tutorial I am unable to configure database configuration.
Using the cas-overlay, I've added settings to the cas.properties file, but when I run the project it fails to authenticate.
I don't think the settings are loading completely, because my cas.authn.jdbc.query[0].passwordEncoder.type=BCRYPT setting doesn't take.
I'm coming to this pretty green, so I feel like there is a gap in the documentation.
I figured out my problem. It wasn't necessarily the cas.properties file was wrong. I was actually missing a dependency that imports JDBC support.
Their documentation kind of reads like it is supported, but makes an assumption the reader knows to add the dependency.
Added this to my overlay pom.xml
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-jdbc</artifactId>
<version>${cas.version}</version>
</dependency>

How to configure Hudson base distribution?

I am a total newbie to the Hudson administration, so my question is very 101:
I downloaded hudson-3.0.0.war, which is said to be just the Hudson Core without any plugins included, and deployed it on my Apache Tomcat 7.0 server.
So Hudson as a web app is up, I can browse it, manage plugins via UI and so on.
But when I try to create my very first job as Build a free-style software project, I get the following exception:
HTTP Status 500 - java.lang.NoClassDefFoundError: org/eclipse/hudson/utils/tasks/MetaProject
type Exception report
message java.lang.NoClassDefFoundError: org/eclipse/hudson/utils/tasks/MetaProject
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/eclipse/hudson/utils/tasks/MetaProject
I assume that a certain plugin is missing (although I would expect that even the base distribution included such a basic task, but never mind...).
I cannot figure out which plugin I have to install in order to enable the job creation between all available plugins.
I am really hoping to any assistance with this issue, which I shall appreciate very much.
It looks like you are missing a dependency. Add to the pom.xml the dependency:
<dependency>
    <groupId>org.eclipse.hudson</groupId>
    <artifactId>hudson-plugin-utils</artifactId>
    <version>3.0.1</version>
</dependency>

Help: org.apache.hadoop.hbase.MasterNotRunningException 12.34.56.78:60000

I am writting a small Java application to connect to a HBase node. The ZooKeeper connection is successful, but later, I systematically get the following error (I have changed my IP address of course):
org.apache.hadoop.hbase.MasterNotRunningException 12.34.56.78:60000
Does anyone know what is happening and how to solve this issue?
Thanks!
Ok, solved that issue. Before someone commits suicide... -> the problem is caused by a mismatch between the HBase.jar versions available in the central maven repository (currently 0.90.xx) and those used by Cloudera's CDH3 installation package (0.89.xx).
The main issue is that Cloudera compiles its own Hbase.jar and these are not available from the central repository. But, Cloudera makes them available from:
<repositories>
<repository>
<id>cloudera</id>
<url>https://repository.cloudera.com/content/groups/public/</url>
</repository>
</repositories>
To find the HBase version you need for your application, open http://your.node.ip.address:60010. For CDH3Beta3, it is 0.89.20100924-28. Then, add it in your pom.xml as a dependency:
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase</artifactId>
<version>0.89.20100924-28</version>
</dependency>
Et voila!