2

We are working with MobileFirst Platform Studio 7.1, installed on top of Eclipse Luna 4.4.2 (I believe Eclipse comes with its own embedded Java compiler - according to the Workspace properties, the "Compiler Compliance Level" is set to 1.7).

When we build our .adapter file, and then take it apart with unzip and check the version of one of the .class files within with file myadapter.adapter, it shows myadapter.adapter: compiled Java class data, version 51.0, which corresponds to Java Platform 7 (1.7).

However, when we deploy it to our standalone MobileFirst Platform Server, running on top of WAS ND, we get an error, both in the MobileFirst administration console and the WAS SystemOut.log:

[11/3/15 11:56:07:166 UTC] 0000009b StatusMessage E StatusMessage createStatusMessage Preparation to deploy adapter 'MyAdapter' failed.
                         java.lang.Error: The adapter was built with a later version of Java than is used to run the server.
    at com.worklight.adapters.rest.ParentLastClassLoader.defineClass(ParentLastClassLoader.java:274)
    at com.worklight.adapters.rest.ParentLastClassLoader.defineClassFromURL(ParentLastClassLoader.java:233)
    at com.worklight.adapters.rest.ParentLastClassLoader.internalFindClass(ParentLastClassLoader.java:215)
    at com.worklight.adapters.rest.ParentLastClassLoader.loadClass(ParentLastClassLoader.java:128)

The Java level on the server is also 1.7, as shown by java -version:

java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (rhel-2.3.4.1.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

I don't believe this error is correct, unless there is some subtlety in the way JDK levels are validated (perhaps it's looking at the patch level as well?).

How can we fix this error? Is there a way we can force the JDK in Eclipse to be at a particular level?

Update: We've just tried dropping the JDK compliance level in Eclipse to 1.6, we still have the same problem.

Community
  • 1
  • 1
Andrew Ferrier
  • 16,664
  • 13
  • 47
  • 76
  • Are you using OpenJDK locally as well? Or maybe Oracle Hotspot? – Gergely Bacso Nov 03 '15 at 12:11
  • @GergelyBacso I'm confused. Locally to which machine? As I said, I think Eclipse uses an embedded JDK to compile the `.adapter`...? – Andrew Ferrier Nov 03 '15 at 12:15
  • By "locally" I meant the machine on which your Eclipse is installed. Eclipse has several different versions, so it would be good to find out what exactly your classes are built with. – Gergely Bacso Nov 03 '15 at 12:16
  • So we are using Eclipse 4.4.2. As far as I can tell (from examining the class) it's using 1.7.x. It's hard to tell any more precisely than that, unless you know how to tell the embedded Java compiler version inside Eclipse? – Andrew Ferrier Nov 03 '15 at 12:41
  • How do you build your adapter? If it's something like Ant, then it will *not* use Eclipse's Java Compiler settings. – Ordous Nov 03 '15 at 13:19

1 Answers1

0

OK, mystery solved. It turns out I was wrong; although there was a Java 1.7 JDK on the server, the WAS ND server in question was actually using Java 1.6. Once we changed the JDK compliance level in the project (as per my first link in the question), the .adapter was successfully deployed.

Andrew Ferrier
  • 16,664
  • 13
  • 47
  • 76