"No such field" Exception when trying to login using Java API
Hello, I have a server running Bonita BPM. So far the platform can be accessed using a browser and with the REST API, however, trying to login using the Java API results in some strange exceptions being thrown. Has anyone had this problem before? Did I maybe forget to set something in a config file somewhere or so?
Bonita BPM vers: 6.3.1 OS: Windows 8.1 Deployed with: JBoss-5.0 Java Version: 1.6
I basically just took this project: https://github.com/bonitasoft/bonita-examples/tree/1.0.x and then: - performed a successful mvn clean install - imported it into eclipse - updated bonita-client.properties with the right http address - and then created a new main class with nothing but the following code:
- LoginAPI loginAPI = TenantAPIAccessor.getLoginAPI();
- APISession apiSession = loginAPI.login("TestUser", "welcome"); // Error occurs here
- ProcessAPI processAPI = TenantAPIAccessor.getProcessAPI(apiSession);
- Exception in thread "main" com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$UnknownFieldException: No such field org.bonitasoft.engine.session.impl.APISessionImpl.tenantName
- ---- Debugging information ----
- field : tenantName
- class : org.bonitasoft.engine.session.impl.APISessionImpl
- required-type : org.bonitasoft.engine.session.impl.APISessionImpl
- converter-type : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
- path : /org.bonitasoft.engine.session.impl.APISessionImpl/tenantName
- line number : 9
- version : null
- at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.determineType(AbstractReflectionConverter.java:453)
- at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:294)
- at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:234)
- at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
- at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
- at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
- at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
- at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
- at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
- at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1052)
- at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1024)
- at com.thoughtworks.xstream.XStream$2.readFromStream(XStream.java:1716)
- at com.thoughtworks.xstream.core.util.CustomObjectInputStream.readObjectOverride(CustomObjectInputStream.java:104)
- at java.io.ObjectInputStream.readObject(Unknown Source)
- at org.bonitasoft.engine.api.HTTPServerAPI.fromXML(HTTPServerAPI.java:244)
- at org.bonitasoft.engine.api.HTTPServerAPI.checkInvokeMethodReturn(HTTPServerAPI.java:146)
- at org.bonitasoft.engine.api.HTTPServerAPI.invokeMethod(HTTPServerAPI.java:132)
- at org.bonitasoft.engine.api.impl.ClientInterceptor.invoke(ClientInterceptor.java:88)
- at com.sun.proxy.$Proxy0.login(Unknown Source)
- at org.bonitasoft.example.App.main(App.java:36)
Hookay, seems like the cause of the error was sitting ~40cm in front of my monitor...
To get it working I did the following: - Edit the POM file to match Bonita version 6.3.1 (The example was still on 6.2.2) - Redo the Maven clean install - Update the bonita-client.properties with the right http address (again)
I figured out what was wrong by going through the documentation step by step and checking to see if everything matches up: http://documentation.bonitasoft.com/create-your-first-project-engine-api...
..."The bonita home used must have the same version as the Bonita BPM Engine" is what tipped me off.
Thanks for sharing the solution. It was really helpful!