1
votes
public static void main(String[] args) {
    // TODO Auto-generated method stub
    String[] arguments =
          { "http://services.odata.org/V4/Northwind/Northwind.svc/",
          "src/com" };
    Generator.main(arguments);
}

Output:

    ---------------------------
OData client code generator
---------------------------
step 1 - check parameters
step 2 - check the ouput directory
step 3 - get the metadata descriptor
Starting the internal HTTP client
Get the metadata for http://services.odata.org/V4/Northwind/Northwind.svc/ at http://services.odata.org/V4/Northwind/Northwind.svc/$metadata
Starting the internal HTTP client
step 4 - generate source code
Starting the internal HTTP client
Get the metadata for http://services.odata.org/V4/Northwind/Northwind.svc/ at http://services.odata.org/V4/Northwind/Northwind.svc/$metadata
Starting the internal HTTP client
Stopping the internal HTTP client
Stopping the internal HTTP client
Stopping the internal HTTP client
Stopping the internal HTTP client
Error executing FreeMarker template

FreeMarker template error:
get(importedJavaClasses) failed on instance of org.restlet.ext.odata.internal.edm.EntityType. See cause exception.

The failing instruction (FTL stack trace):
----------
==> #list type.importedJavaClasses?sort a...  [in template "template" at line 29, column 1]
----------

Java stack trace (for programmers):
----------
freemarker.template.TemplateModelException: [... Exception message was already printed; see it above ...]
    at freemarker.ext.beans.BeanModel.get(BeanModel.java:222)
    at freemarker.core.Dot._eval(Dot.java:76)
    at freemarker.core.Expression.eval(Expression.java:111)
    at freemarker.core.SequenceBuiltins$SequenceBuiltIn._eval(SequenceBuiltins.java:94)
    at freemarker.core.Expression.eval(Expression.java:111)
    at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
    at freemarker.core.Environment.visit(Environment.java:265)
    at freemarker.core.MixedContent.accept(MixedContent.java:93)
    at freemarker.core.Environment.visitByHiddingParent(Environment.java:286)
    at freemarker.core.Environment.visitAndTransform(Environment.java:377)
    at freemarker.core.CompressedBlock.accept(CompressedBlock.java:73)
    at freemarker.core.Environment.visit(Environment.java:265)
    at freemarker.core.MixedContent.accept(MixedContent.java:93)
    at freemarker.core.Environment.visit(Environment.java:265)
    at freemarker.core.Environment.process(Environment.java:243)
    at freemarker.template.Template.process(Template.java:277)
    at org.restlet.ext.freemarker.TemplateRepresentation.write(TemplateRepresentation.java:315)
    at org.restlet.representation.CharacterRepresentation.write(CharacterRepresentation.java:67)
    at org.restlet.ext.odata.Generator.generate(Generator.java:283)
    at org.restlet.ext.odata.Generator.main(Generator.java:140)
    at com.MainMethod.main(MainMethod.java:14)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:912)
    at freemarker.ext.beans.BeanModel.invokeThroughDescriptor(BeanModel.java:275)
    at freemarker.ext.beans.BeanModel.get(BeanModel.java:182)
    ... 20 more
Caused by: java.lang.NullPointerException
    at org.restlet.ext.odata.internal.edm.EntityType.getImportedJavaClasses(EntityType.java:121)
    ... 27 more
An error occurred: 
Cannot generate the source code in directory: src\com

Please check that you provide the following parameters:
   - Valid URI for the remote service
   - Valid directory path where to generate the files
   - Valid name for the generated service class (optional)

My libs enter image description here

What can be the problem?

Thanks.

1
Have you tried using "src" instead of "src/com"? The "com" directory is the package, and not the root directory of your project's sources.Chronio
Changed the second string to 'src' , same error. DId you achieved generating your classes?Boldijar Paul

1 Answers

1
votes

I saw that you use an OData v4 service with the restlet OData extension. This extension currently only supports older versions of OData (v2 and v3).

I know that there is a contribution in progress to support this latest version or OData.

I'm almost sure that it's the reason of your problem...

Hope it helps, Thierry