I'm using the Java-based Keycloak server and attempting to run the demo examples. I'm a bit of a Java hack, so please pardon my naivetΓ©.
I'm getting the error shown below -- any help debugging and solving would be appreciated.
ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-7) Uncaught server error: java.lang.RuntimeException: org.eclipse.aether.collection.DependencyCollectionException: Failed to read artifact descriptor for org.keycloak:photoz-authz-policy:jar:3.4.3.Final
I had some trouble getting M2_HOME set so that keycloak could locate artifacts. I seem to be past that problem and now, but I'm not sure where to go with the above error. I've included some system info below. And if someone's really eager, the dockerfile is available.
I'm running v3.5.3 of maven:
$ mvn --version
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T19:49:05Z)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el7_4.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.9.60-linuxkit-aufs", arch: "amd64", family: "unix"
I ran mvn -U clean install in the project directory, and the artifacts appear to be built correctly:
[jboss#09fea4c663e0 ~]$ ll .m2/repository/org/keycloak/photoz-authz-policy/3.4.3.Final/
total 44
-rw-r--r-- 1 jboss jboss 5169 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.jar
-rw-r--r-- 1 jboss jboss 32 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.jar.md5
-rw-r--r-- 1 jboss jboss 40 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.jar.sha1
-rw-r--r-- 1 jboss jboss 773 Jan 4 09:24 photoz-authz-policy-3.4.3.Final.pom
-rw-r--r-- 1 jboss jboss 32 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.pom.md5
-rw-r--r-- 1 jboss jboss 40 Mar 28 17:16 photoz-authz-policy-3.4.3.Final.pom.sha1
-rw-r--r-- 1 jboss jboss 3859 Mar 28 17:16 photoz-authz-policy-3.4.3.Final-sources.jar
-rw-r--r-- 1 jboss jboss 32 Mar 28 17:16 photoz-authz-policy-3.4.3.Final-sources.jar.md5
-rw-r--r-- 1 jboss jboss 40 Mar 28 17:16 photoz-authz-policy-3.4.3.Final-sources.jar.sha1
-rw-r--r-- 1 jboss jboss 262 Mar 28 17:16 _remote.repositories
And finally, here's the metadata associated with the artifact:
[jboss#09fea4c663e0 ~]$ cat .m2/repository/org/keycloak/photoz-authz-policy/maven-metadata-local.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>org.keycloak</groupId>
<artifactId>photoz-authz-policy</artifactId>
<versioning>
<release>3.4.3.Final</release>
<versions>
<version>3.4.3.Final</version>
</versions>
<lastUpdated>20180328171633</lastUpdated>
</versioning>
</metadata>
Any insight?
I was able to get the examples to run by copying the project files to the server and compiling on the server. That seems strange to me -- a fat WAR seems like it would make more sense. That is, I wouldn't expect to have to have supporting libraries compiled on a the server, but that strategy allowed me to move on. Here are the commands I ran on my wildfly server (Dockerfile commands):
# Build and install keycloak example libraries
WORKDIR /opt/jboss
USER jboss
COPY --chown=jboss:jboss _srv/keycloak-demo-3.4.3.Final ./_srv/keycloak-demo-3.4.3.Final
WORKDIR _srv/keycloak-demo-3.4.3.Final/examples
RUN mvn -U clean install
WORKDIR /opt/jboss
Related
I have added web dependency by editing build.gradle file and adding line below in my Spring Eclipse Java project.
dependencies {
...
implementation 'org.springframework.boot:spring-boot-starter-web'
...
}
But project complains The import org.springframework.web cannot be resolved. How to tell Spring Tool Suite 4 project update this library?
UPD
My whole build.gradle :
plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
id 'war'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '15'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
UPD 2
I have another project that was generated with web module from very beginning. I looked in project properties in both of them and found that current project don't have Web App Libraries :
Current project:
Should I ask gradle somehow update Spring Tool Suite project with required library?
UPD 3 Project file structure:
drwxrwxr-x 8 a a 4096 Oct 4 07:39 .
drwxrwxr-x 6 a a 4096 Oct 4 08:27 ..
drwxrwxr-x 5 a a 4096 Oct 1 08:18 bin
drwxrwxr-x 9 a a 4096 Oct 4 07:39 build
-rw-r--r-- 1 a a 599 Oct 4 05:32 build.gradle
-rw-rw-r-- 1 a a 1102 Oct 1 08:18 .classpath
-rw-r--r-- 1 a a 397 Oct 1 07:54 .gitignore
drwxrwxr-x 7 a a 4096 Oct 1 07:56 .gradle
drwxrwxr-x 3 a a 4096 Oct 1 07:54 gradle
-rwxr-xr-x 1 a a 5766 Oct 1 07:54 gradlew
-rw-r--r-- 1 a a 2763 Oct 1 07:54 gradlew.bat
-rw-r--r-- 1 a a 590 Oct 1 07:54 HELP.md
-rw-rw-r-- 1 a a 741 Oct 1 08:18 .project
drwxrwxr-x 2 a a 4096 Oct 1 08:18 .settings
-rw-r--r-- 1 a a 26 Oct 1 07:54 settings.gradle
drwxrwxr-x 4 a a 4096 Oct 1 07:54 src
did you also add
repositories {
mavenCentral()
}
To your gradle build? The maven import needs to resolved from somewhere, maven central is a good place.
According to Spring you also need to use the spring plugin
plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
At the top of your build gradle
These are my config.ini files, logs, and error I'm receiving. I was able to open and build a basic test yesterday, albeit giving binary error, but I'm receiving these errors again today trying to open eclipse. I have reinstalled java and eclipse multiple times all because of these errors. I'm running ubuntu 18.04, java 1.8.0_181, and eclipse 4.7. Can you help me get my eclipse running please?
configi.ini file...
#This configuration file was written by: org.eclipse.oomph.p2.internal.core.AgentImpl
#Wed Aug 22 19:16:40 PDT 2018
org.eclipse.update.reconcile=false
eclipse.p2.profile=_home_ryan_eclipse_cpp-oxygen_eclipse
osgi.instance.area.default=#user.home/workspace
osgi.framework=file\:/home/ryan/.p2/pool/plugins/org.eclipse.osgi_3.12.100.v20180210-1608.jar
equinox.use.ds=true
eclipse.buildId=4.7.3.M20180330-0640
ds.delayed.keepInstances=true
osgi.bundles=reference\:file\:org.eclipse.equinox.simpleconfigurator_1.2.1.v20180131-1435.jar#1\:start
log...
!SESSION Thu Aug 23 15:58:45 PDT 2018 ------------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2018-08-23 15:58:45.890
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:626)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
org.eclipse.equinox.simpleconfigurator.configUrl=file\:org.eclipse.equinox.simpleconfigurator/bundles.info
eclipse.product=org.eclipse.platform.ide
osgi.splashPath=file\:/home/ryan/.p2/pool/plugins/org.eclipse.platform_4.7.3.v20180330-0640
osgi.framework.extensions=reference\:file\:org.eclipse.osgi.compatibility.state_1.1.0.v20170516-1513.jar
eclipse.application=org.eclipse.ui.ide.workbench
eclipse.p2.data.area=file\:/home/ryan/.p2/osgi.bundles.defaultStartLevel=4
error when opening eclipse...
An error has occurred. See the log file
/home/ryan/.eclipse/org.eclipse.platform_3.8_155965261/configuration/1535066792371.log
I know this question has been asked many times before, but none of the answers has solved my problem thus far.
I am trying to compile a maven project.
The compiled class files must be in the 1.7 format.
But for some reason, it seems to be encountering a JDK class (javax/tools/DiagnosticListener) that has been compiled with version 1.8.
Here is the error I am getting ...
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-compiler-plugin:3.3:compile: java.lang.UnsupportedClassVersionError: javax/tools/DiagnosticListener : Unsupported major.minor version 52.0
I believe that I've configured the compiler correctly in the pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
JAVA_HOME is set correctly ...
π >echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
π >java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
π >javac -version
javac 1.7.0_80\
π >mvn --version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
I have physically removed all versions of jdk 1.8 installed ...
π >ls -lF /Library/Java/JavaVirtualMachines
total 0
drwxr-xr-x 3 root wheel 102 Jul 14 2015 1.6.0.jdk/
drwxr-xr-x 3 root wheel 102 Mar 24 2016 jdk1.7.0_80.jdk/
and yet it seems that maven is still trying to use a 1.8 version of the SDK to compile against.
I'm not sure how this is possible or how to fix it.
I am using a spring maven tomcat8 java8 stack. The problem I am facing is that logs are not getting generated on certain machines. I am using slf4j-logback combination for logging. The problem has surfaced when I am trying to move my stack from java7 to java8.
Here is my logback.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="dal"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/log/dal/dal.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>/var/log/dal/dal-%d{yyyy-MM-dd}.log.gz</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<append>true</append>
<encoder>
<pattern>[%d{HH:mm:ss.SSS} %thread %-5level %C:%L] %msg%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%d{HH:mm:ss.SSS} %thread %-5level %C:%L] %msg%n</pattern>
</encoder>
</appender>
<appender name="email-appender" class="ch.qos.logback.classic.net.SMTPAppender">
<to></to>
<from></from>
<subject>API Logs - Error while sending notification</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>[%d{HH:mm:ss.SSS} %thread %-5level %C:%L] %msg%n</pattern>
</layout>
</appender>
<root level="DEBUG">
<appender-ref ref="dal" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
Using this, I expect to get logs at two places, at custom location /var/log/dal/dal.log and in catalina.out
Here are a few relevant details of the server where logs are getting generated:
OS:
apache-tomcat-8.0.15 $ uname -a
Linux azi 3.2.0-74-generic #109-Ubuntu SMP Tue Dec 9 16:45:49 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
MVN:
apache-tomcat-8.0.15 $ mvn -version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-74-generic", arch: "amd64", family: "unix"
Tomcat:
apache-tomcat-8.0.15 $ bin/version.sh
Using CATALINA_BASE: /opt/apache-tomcat-8.0.15
Using CATALINA_HOME: /opt/apache-tomcat-8.0.15
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.0.15/temp
Using JRE_HOME: /usr/lib/jvm/java-8-oracle/
Using CLASSPATH: /opt/apache-tomcat-8.0.15/bin/bootstrap.jar:/opt/apache-tomcat-8.0.15/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.0.15
Server built: Nov 2 2014 19:25:20 UTC
Server number: 8.0.15.0
OS Name: Linux
OS Version: 3.2.0-74-generic
Architecture: amd64
JVM Version: 1.8.0_25-b17
JVM Vendor: Oracle Corporation
JAVA:
apache-tomcat-8.0.15 $ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Permission:
ls -al /var/log/dal/
total 72
drwxrwxrwx 2 root root 4096 Dec 22 19:50 .
drwxrwxrwx 4 root root 4096 Oct 21 09:47 ..
-rw-r--r-- 1 root root 60925 Dec 22 20:38 dal.log
Here are the details for the server where I am not getting any log:
OS:
sysadmin#ip-172-30-0-26:/opt/apache-tomcat-8.0.15$ uname -a
Linux ip-172-30-0-26 3.13.0-29-generic #53-Ubuntu SMP Wed Jun 4 21:00:20 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
MVN:
sysadmin#ip-172-30-0-26:/opt/apache-tomcat-8.0.15$ mvn -version
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T19:21:42+05:30)
Maven home: /opt/apache-maven-3.2.2
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /opt/jdk1.8.0_25-linux-x64/java-linux-x64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-29-generic", arch: "amd64", family: "unix"
Tomcat:
sysadmin#ip-172-30-0-26:/opt/apache-tomcat-8.0.15$ sudo bin/version.sh
Using CATALINA_BASE: /opt/apache-tomcat-8.0.15
Using CATALINA_HOME: /opt/apache-tomcat-8.0.15
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.0.15/temp
Using JRE_HOME: /usr
Using CLASSPATH: /opt/apache-tomcat-8.0.15/bin/bootstrap.jar:/opt/apache-tomcat-8.0.15/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.0.15
Server built: Nov 2 2014 19:25:20 UTC
Server number: 8.0.15.0
OS Name: Linux
OS Version: 3.13.0-29-generic
Architecture: amd64
JVM Version: 1.8.0_25-b17
JVM Vendor: Oracle Corporation
JAVA:
sysadmin#ip-172-30-0-26:/opt/apache-tomcat-8.0.15$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Permission:
sysadmin#ip-172-30-0-26:/opt/apache-tomcat-8.0.15$ ls -al /var/log/dal/
total 8
drwxrwxrwx 2 root root 4096 Dec 22 19:48 .
drwxrwxrwx 4 root root 4096 Dec 22 19:48 ..
Another thing of note can be the fact that when I do System.out.println("msg"), "msg" goes into catalins.out on both servers. And If I change permission of /var/log/dal on the machine logs are getting generated, logs still get generated in catalina.out. So this shouldn't be related to permissions.
I have tried copying war file from one server to another and didn't find any change in behavior. So, this shouldn't be related to maven. Tomcat and Java versions are same. Can this be related to OS?
UPDATE: When I run my application using mvn clean tomcat7:run, I get logs on all servers. So problem seems to be related to tomcat8. I have even tried copying tomcat8 from one server to another. It didn't help.
Please make sure there are no other slf4j bindings on the classpath (e.g., in the tomcat).
This was the case of slf4j identifying multiple bindings in classpath. In such scenarios, slf4j chooses the binding pretty much randomly. In my case, this was happening because slf4j-log4j12 binding was available through solr-core. To remove this, I had to exclude this explicitly:
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<version>${solr.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
After purging and reinstalling eclipse with dpkg (Ubuntu) there is an error throws there:
cat /home/sergiy/.eclipse/org.eclipse.platform_3.7.0_155965261/configuration/1337883707989.log
!SESSION Thu May 24 21:21:48 EEST 2012 -----------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2012-05-24 21:21:48.242
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Here is /usr/lib/eclipse/configuration/config.ini file:
#This configuration file was written by: org.eclipse.equinox.internal.frameworkadmin.equinox.EquinoxFwConfigFileParser
#Wed Apr 04 13:29:31 UTC 2012
org.eclipse.update.reconcile=false
eclipse.p2.profile=PlatformProfile
osgi.instance.area.default=#user.home/workspace
osgi.framework=file\:plugins/org.eclipse.osgi_3.7.2.dist.jar
equinox.use.ds=true
eclipse.buildId=I20110613-1736
osgi.bundles=reference\:file\:org.eclipse.equinox.simpleconfigurator_1.0.200.dist.jar#1\:start
org.eclipse.equinox.simpleconfigurator.configUrl=file\:org.eclipse.equinox.simpleconfigurator/bundles.info
eclipse.product=org.eclipse.platform.ide
osgi.splashPath=platform\:/base/plugins/org.eclipse.platform
osgi.framework.extensions=
osgi.bundles.defaultStartLevel=4
eclipse.p2.data.area=#config.dir/../p2/
eclipse.application=org.eclipse.ui.ide.workbench
osgi.bundlefile.limit=100
How to fix this issue? Thanks in advance!
The first recommendation is to NOT install Eclipse from any Linux package manager or software repository. Instead, just get it from http://www.eclipse.org/downloads/. The builds that linux distro's install are often modified (mangled, some would say).
see https://askubuntu.com/a/695401/407641 for full instructions, ...
Highlights:
Don't sudo apt-get eclipse, that version is old!
Do download and install from http://www.eclipse.org/downloads
Do create a ~/Desktop/eclipse.desktop file. Note, the full path to the Desktop folder will be dependent upon your version of ubuntu.