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>
Related
I am doing a maven build, but it gets an error related to one of the dependencies. If I (and other developers) build this on our local machines or on other linux servers, it builds with no problems. However, on one particular linux server, it gets the following error when building.
mvn clean install DskipTests=true -U
maven Build Error:
[ERROR] Failed to execute goal on project corporateInterface: Could
not resolve dependencies for project
com.travellinck:corporateInterface:war:3.10: Failed to collect
dependencies at
com.github.Cloudmersive:Cloudmersive.APIClient.Java:jar:v3.62: Failed
to read artifact descriptor for
com.github.Cloudmersive:Cloudmersive.APIClient.Java:jar:v3.62: Could
not transfer artifact
com.github.Cloudmersive:Cloudmersive.APIClient.Java:pom:v3.62 from/to
jitpack.io (https://jitpack.io): Transfer failed for
https://jitpack.io/com/github/Cloudmersive/Cloudmersive.APIClient.Java/v3.62/Cloudmersive.APIClient.Java-v3.62.pom:
java.lang.RuntimeException: Unexpected error:
java.security.InvalidAlgorithmParameterException: the trustAnchors
parameter must be non-empty -> [Help 1] [ERROR]
So I think there must be something different on this server that is causing the dependency error. Any ideas please?
I see it gets a java.security.InvalidAlgorithmParameterException, so this suggests that there is probably some restriction configured on the server that is preventing the dependency being downloaded to the server.
More info:
pom.xml
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v3.62</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>
Maven version on linux server with the error:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven
home: /home/jboss/.sdkman/candidates/maven/current Java version:
1.7.0_95, vendor: Oracle Corporation, runtime: /usr/java/java-7-openjdk-amd64/jre Default locale: en_US, platform
encoding: ANSI_X3.4-1968 OS name: "linux", version:
"3.10.0-1160.15.2.el7.x86_64", arch: "amd64", family: "unix"
Maven version of linux server that has no error:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven
home: /opt/apache-maven-3.6.3 Java version: 1.7.0_161, vendor: Oracle
Corporation, runtime:
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968 OS name:
"linux", version: "3.10.0-957.21.3.el7.x86_64", arch: "amd64", family:
"unix"
Maven version on localhost that has no error:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5;
2015-11-10T18:41:47+02:00) Maven home:
/Users/richardmarais/Development/java/Maven/apache-maven-3.3.9 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_GB, platform encoding: UTF-8 OS name: "mac os x",
version: "10.16", arch: "x86_64", family: "mac"
I fixed this issue. The problem was the Java version. I temporally build with Java 8 (to download the Cloudmersive api), then switched back to Java 7. Build is successful.
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
I am trying to build a maven project. Following are specifications of system and maven version:
Apache Maven 3.5.0,
Java version: 1.8.0_121, vendor: Oracle,
Corporation Default locale: en_IN, platform encoding: Cp1252,
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
on running mvn install command I am getting following error.
[WARNING] Could not transfer metadata
com.googlecode.wicket-jquery-ui:wicket-kendo-ui:8.0.0-SNAPSHOT/maven-metadata.xml
from/to sonatype-snapshots
(http://oss.sonatype.org/content/repositories/snapshots/): Error
transferring file: Server returned HTTP response code: 407 for URL:
http://oss.sonatype.org/content/repositories/snapshots/com/googlecode/wicket-jquery-ui/wicket-kendo-ui/8.0.0-SNAPSHOT/maven-metadata.xml
from
http://oss.sonatype.org/content/repositories/snapshots/com/googlecode/wicket-jquery-ui/wicket-kendo-ui/8.0.0-SNAPSHOT/maven-metadata.xml
with proxyInfo ProxyInfo{host='', userName='null', port=,
type='http', nonProxyHosts='null'}
I am working behind proxy so I have added following mapping in settings.xml which is inside %MAVEN_HOME%\conf:
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>username</username>
<password>password</password>
<host>proxyhost</host>
<port>proxyport</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
even after adding username and password in settings.xml it is considering username as null and throwing 407 authentication error. Its causing problem to build the project. Please help to resolve this.
Update:
variables:
MAVEN_HOME=D:\Apache\Maven\apache-maven-3.5.0
M2_HOME=D:\Apache\Maven\apache-maven-3.5.0
Complete mvn -version :
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426;
2017-04-04T01:09:06+05:30) Maven home:
D:\Apache\Maven\apache-maven-3.5.0\bin.. Java version: 1.8.0_121,
vendor: Oracle Corporation Java home: C:\Program
Files\Java\jdk1.8.0_121\jre Default locale: en_IN, platform encoding:
Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64",
family:"windows"
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.
During development I use tomcat plugging for maven: tomcat7-maven-plugin version 2.2
When I deploy war file to the remote host, tomcat throws errors. Here is the version of tomcat on the remote server:
root#vido:/var/lib/tomcat7/webapps# sh /usr/share/tomcat7/bin/version.sh
Using CATALINA_BASE: /var/lib/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using CATALINA_TMPDIR: /var/lib/tomcat7/temp
Using JRE_HOME: /usr/lib/jvm/java-7-oracle
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.26
Server built: Apr 1 2013 08:32:04
Server number: 7.0.26.0
OS Name: Linux
OS Version: 3.8.0-29-generic
Architecture: amd64
JVM Version: 1.7.0_55-b13
JVM Vendor: Oracle Corporation
Here is java version:
root#vido:/var/lib/tomcat7/webapps# java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
Here is a part of pom.xml file:
<!-- web sockets -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- servlets -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
Here are exceptions:
DEBUG [pool-2-thread-1] (AnnotationAttributesReadingVisitor.java:186) - Failed to class-load type while reading annotation metadata. This is a non-fatal error, but certain annotation metadata may be unavailable.
java.lang.ClassNotFoundException: javax.websocket.server.ServerEndpoint
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(AnnotationAttributesReadingVisitor.java:182)
at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1788)
DEBUG [pool-2-thread-1] (DefaultListableBeanFactory.java:404) - Ignoring bean class loading failure for bean 'getDataHandler'
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.vm.controllers.GetDataHandler] for bean with name 'getDataHandler' defined in file [/var/lib/tomcat7/webapps/videomessenger/WEB-INF/classes/com/vm/controllers/GetDataHandler.class]: problem with class file or dependent class; nested exception is java.lang.UnsupportedClassVersionError: com/vm/controllers/GetDataHandler : Unsupported major.minor version 51.0 (unable to load class com.vm.controllers.GetDataHandler)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1330)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)
There are more errors but all of them of described type above.
solved by installing tomcat v 7.0.53
I guess you are building a web app based on the JEE 7 specs, I can see the WebSocket api, While your dependency is for the JEE 6. Add the correct dependency for JEE 7 and the error will be removed. The error is due to its not able to find the class. Due to dependency mismatch its showing a version mismatch error too.