You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Hans Kruse <kr...@hanskruse.eu> on 2017/06/29 15:12:31 UTC

calling an operation on a pojogen generated client fails clientside with a NullPointerException

Hello,

We have an Olingo based service with two operations.
We generated a client  using pojogen.
Both operations fail clientside with a NullPointer Exception.
What is my mistake?

- We have generated a C# client using the OData Client generator for Visual
Studio 2015 and created a complete test suite in C#. All tests work fine
from C#.
We ported a subset of these C# tests to Java. All query related tests work
fine.

The code we wrote:

---
...
@Test
public void getChallenges() {
  final Container ctx = svc.createContext();
  final Operations ops = ctx.operations();
  final
StructuredCollectionInvoker<ActiveAuthenticationChallengeCollection>
invoker = ops.getChallenges(10);// <<-- NullPointer Exception here
  final ActiveAuthenticationChallengeCollection challenges =
invoker.execute();
  assertNotNull(challenges);
  ActiveAuthenticationChallenge[] xs = challenges.toArray(new
ActiveAuthenticationChallenge[0]);
  ActiveAuthenticationChallenge aa = xs[0];
  assertNotNull(aa);
  System.out.println(aa.getSessionId());
}
...
--
Here svc is a Custom Junit testrule that embeds an OData client with the
proper Url and credentials.
Container is  the top level generated which has two operations:
* getChallenges(int count)
* new Session(...)
Ignore the second for now.
I debugged the above code into the Apache OLingo code:
The error occurs in  method:

org.apache.olingo.ext.proxy.commons.OperationInvocationHandler::getUnboundOperation:

...
private Map.Entry<URI, EdmOperation> getUnboundOperation(final Operation
operation, final List<String> parameterNames) {

    final EdmEntityContainer container =
getClient().getCachedEdm().getEntityContainer(targetFQN); //<<= this will
resolve to null, and cause the nullpointer Exception.
    final EdmOperation edmOperation;

    if (operation.type() == OperationType.FUNCTION) {
      edmOperation =
container.getFunctionImport(operation.name()).getUnboundFunction(parameterNames);
// <-- NullPointer Exception here here
    } else {
      edmOperation = container.getActionImport(operation.name
()).getUnboundAction();
    }
...
How and where should I set the container or should I call operations in a
different way?
 Or is this a bug?

 Tested both with 4.3.0 and 4.4.0-SNAPSHOT.

Kind regards,
Hans Kruse




-- 

Hans Kruse

☎: +31683968991

✉  kruse@hanskruse.eu

Disclaimer

E-mail correspondence  is secret only if encrypted.
Digital signatures are only recognized as a signature when using public key
cryptography.
E-mail messages without digital signature are not legally binding and
included disclaimers are not relevant.