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.
Related
I have a Java application which is deployed on Websphere 8.5. It gets a message which I am trying to use it but this is the error I get even though I have the right JMS jars on line getBody()
Code Snippet:
if (arg0 instanceof BytesMessage)
{
byte[] payload = arg0.getBody(byte[].class);
myMessage = new String(payload);
}
Jar Files:
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
Error from Websphere logs:
Caused by: java.lang.NoSuchMethodError: javax/jms/Message.getBody(Ljava/lang/Class;)Ljava/lang/Object; (loaded from file:/opt/was_static/websphere_8.5.5.15.1/appserver/plugins/javax.j2ee.jms.jar by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader#6d5d04f3) called from class com.mycompany.myapplication.sync.mdb.myapplicationSyncOutboundMDB (loaded from file:/opt/was_static/profiles/appsrv01/installedApps/eaodr01Cell01/myapplication-ear-mydomain.com-editionmyapplication-ear-0.9.6.ear/myapplication-ejb-0.9.6.jar by
com.ibm.ws.classloader.CompoundClassLoader#19abf904[app:myapplication-ear-mydomain.com-editionmyapplication-ear-0.9.6]
Local ClassPath:
Parent: com.ibm.ws.classloader.ExtJarClassLoader#890f8480[PF][server:0]
Delegation Mode: PARENT_FIRST)
Websphere CLassloading:
Any ideas why my application, which compiles fine as it sees javax.jms.Message in the code but the Websphere can't find this?
WebSphere Application Server 8.5.5 supports Java EE 6 which includes JMS 1.1, not JMS 2.0 and the getBody(Class) method was added in JMS 2.0 which is Java EE 7 and newer.
If you want to use JMS 2.0 then you need to upgrade to WebSphere Application Server 9.0.
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 have a war and want to deploy it on a websphere application server.
The application server has slf4j, version 1.4.2 installed.
However, my application requires at least version 1.6.1.
Here's the dependency defined in my POM:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
<scope>compile</scope>
</dependency>
I can build the application successfully, but everytime I try to launch it on the websphere server, I get the following error:
DispatcherSer E org.springframework.web.servlet.DispatcherServlet initServletBean Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in ServletContext resource [/WEB-INF/spring/timer-context.xml]: Invocation of init method failed; nested exception is java.lang.LinkageError: org.slf4j.Logger
What do I have to do so that my application uses version 1.6.1, and ignores the already installed version on the server?
Related Question: java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;
I'm on Mac OS X 10.9.2 and sbt 0.13.3-SNAPSHOT (built from the sources), Java 8 and sbt-proguard 0.2.2 plugin.
sbt 0.13.3-SNAPSHOT
[jacek]> sbtVersion
[info] 0.13.3-SNAPSHOT
Java 8
$ /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
project/plugins.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-proguard" % "0.2.2")
When I ran proguard:proguard in sbt shell it blew up with the following exception:
[sbt-updates]> show proguard:proguard
[info] ProGuard, version 4.9
[info] Reading program directory [/Users/jacek/oss/sbt-updates/target/scala-2.10/sbt-0.13/classes] (filtered)
[info] Reading program jar [/Users/jacek/.ivy2/cache/org.scalaz/scalaz-concurrent_2.10/bundles/scalaz-concurrent_2.10-7.1.0-M6.jar] (filtered)
[info] Reading program jar [/Users/jacek/.sbt/boot/scala-2.10.3/lib/scala-library.jar] (filtered)
[info] Reading program jar [/Users/jacek/.ivy2/cache/org.scalaz/scalaz-core_2.10/bundles/scalaz-core_2.10-7.1.0-M6.jar] (filtered)
[info] Reading program jar [/Users/jacek/.ivy2/cache/org.scalaz/scalaz-effect_2.10/bundles/scalaz-effect_2.10-7.1.0-M6.jar] (filtered)
[info] Reading library jar [/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar]
[error] Error: Can't read [/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/rt.jar] (Can't process class [apple/applescript/AppleScriptEngine.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)))
[trace] Stack trace suppressed: run last proguard:proguard for the full output.
[error] (proguard:proguard) Proguard failed with exit code [1]
[error] Total time: 16 s, completed Apr 19, 2014 2:27:56 PM
Why could be the reason for the error?
It appears that ProGuard and hence sbt-proguard don't support Java 8 yet and changing the version of Java used in the script to launch sbt helped.
[sbt-updates]> show proguard:proguard
[info] Compiling 8 Scala sources to /Users/jacek/oss/sbt-updates/target/scala-2.10/sbt-0.13/classes...
[warn] there were 6 feature warning(s); re-run with -feature for details
[warn] one warning found
[info] ProGuard, version 4.9
[info] Reading program directory [/Users/jacek/oss/sbt-updates/target/scala-2.10/sbt-0.13/classes] (filtered)
[info] Reading program jar [/Users/jacek/.ivy2/cache/org.scalaz/scalaz-concurrent_2.10/bundles/scalaz-concurrent_2.10-7.1.0-M6.jar] (filtered)
...
This is with the following version of Java 7:
$ /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
The question is really interesting and i was facing the same problem with the only difference that i added Proguard programmatically by using maven. Consequently, i considered that it will be helpful to post my solution although it is a bit different from the main question. For all those that using maven and faces the same problem, my workaround fix was to update the version of Proguard by using it as runtime inside the plugin, so the working pom.xml looks like this
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.14</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<attach>true</attach>
<appendClassifier>false</appendClassifier>
<addMavenDescriptor>true</addMavenDescriptor>
<injar>${project.build.finalName}-jar-with-dependencies.jar</injar>
<injarNotExistsSkip>true</injarNotExistsSkip>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jce.jar</lib>
<lib>${java.home}/lib/ext/sunjce_provider.jar</lib>
</libs>
<options>
<option>-allowaccessmodification</option>
<option>-optimizationpasses 3</option>
<option>-overloadaggressively</option>
<option>-repackageclasses ''</option>
<option>-dontusemixedcaseclassnames</option>
<option>-dontskipnonpubliclibraryclasses</option>
<option>-flattenpackagehierarch</option>
<option>-dontwarn</option> <!-- added option to ignore com.sun missing classes -->
<option>-keep public class com.StocksNews.App {
public static void main(java.lang.String[]);
}
</option>
</options>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>6.1.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
It's possible to update the version of Proguard that sbt-proguard uses by changing the key proguardVersion in build.sbt to a setting newer than 5.0, e.g.
ProguardKeys.proguardVersion in Proguard := "5.2.1"
See: https://github.com/sbt/sbt-proguard/issues/5
I fixed that by update to latest version of ProGuad from link below
Sourceforge ProGuard page
Add classpath "com.guardsquare:proguard-gradle:7.0.1" in the project level build.gradle to resolve the error. I have solved this issue by adding the same.
I will recommend you to upgrade the Gradle Version to 7.x.x, which will remove ProGuard and you have to migrate to R8, as R8 is backward compatible with your exisiting code ProGuard rules. For Migration please read docs other you will waste alot time in figuring out some feature is not working after migration same happened to me.
I am using hibernate tools with hibernate 3. JDK version is 1.6. However when I run this hibernate tool it by default takes jdk 1.4 as you can see in the code. and because of that I am getting this error.
16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
32 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
32 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
63 [main] INFO org.hibernate.cfg.Configuration - configuring from resource:
C:\Documents and Settings\lakhan\workspace\dpppbuild\dpp_core\build.xml:332: java.lang.UnsupportedClassVersionError: com/pyyyy/pccc/dtt/core/hibernate/DppppProductMatchesPK : Unsupported major.minor version 51.0
Please help me to sort out this issue. I am notable to figure how can i change the target jdk from 1.4 to 1.6. I am using build.xml to execute this hibernate tool.
It's not defaulting to jdk 1.4, it's saying that it's using "JDK 1.4 Timestamp handling".
The major.minor version 51.0 is JDK 7, so you're using a too low version of JDK.
It seems that the application that you are running was built using a newer version of JDK. You need either to use older version of JDK to build your app or you can use newer version of JDK to run your app.
Alternatively you can specify which version of JDK to use during build.
In javac you should you flags source and target:
javac -source 1.4 -target 1.4
If you are building using Ant you should do:
<javac srcdir="${src}"
destdir="${build}"
fork="true"
source="1.4"
target="1.4"
/>
If you are building using Maven you should do:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
</configuration>
</plugin>
</plugins>