Reputation: 11
I am trying to create an odata service using apache olingo library version 2.0. Following is the content in my web.xml :
<servlet>
<servlet-name>StudentServlet</servlet-name>
<servlet-class>org.apache.olingo.odata2.core.servlet.ODataServlet</servlet-class>
<init-param>
<param-name>org.apache.olingo.odata2.service.factory</param-name>
<param-value>com.opengalaxy.students.MyServiceFactory</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>StudentServlet</servlet-name>
<url-pattern>/Sample/*</url-pattern>
</servlet-mapping>
With the above servlet mapping, when I load URL "localhost:8888/Sample/$metadata", I am getting the following error:
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code />
<message xml:lang="en-US">Could not find an entity set or function import for 'Sample'.</message>
</error>
But, if I change the servlet mapping in the web.xml to root, i.e., to "/*" as:
<servlet-mapping>
<servlet-name>StudentServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
and load URL "localhost:8888/$metadata", it works fine and loads the metadata:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="com.opengalaxy.Students">
<EntityType Name="Student">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
<Property Name="Name" Type="Edm.String" Nullable="false" MaxLength="100" />
</EntityType>
<EntityContainer Name="ODataStudentsEntityContainer" m:IsDefaultEntityContainer="true">
<EntitySet Name="Students" EntityType="com.opengalaxy.Students.Student" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Please help me resolve this issue.
Thanks, Keshav
Upvotes: 1
Views: 801
Reputation: 26
AFAIK this is a bug which should be solved in newer version of Olingo. If it is still there then open an issue: https://issues.apache.org/jira/browse/OLINGO
Upvotes: 0