Existing Entity with REST component

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Existing Entity with REST component

Deepak P
Hi,

I am new to OfBiz and started with apache-ofbiz-13.07.03. I have successfully compiled and installed the ofbiz and now trying to implement a REST service to fetch demo data from "Product" entity.

I have created a sample REST service using apache-wink as described  here but inside ecommerce application.

The REST component is working fine but when I failed to access the existing Entity, say, product from REST service.

My Resource file looks like:


@Path("/")
public class RestSearchResource {

        public static final String module = RestSearchResource.class.getName();
        @Context
        HttpHeaders headers;
       
       
       
        @GET
        @Produces("text/plain")
        @Path("{message}")
        public Response sayHello( @PathParam("message") String message ) {

        GenericDispatcherFactory gc = new GenericDispatcherFactory();
               
        Debug.logInfo("Inside SayHello message:" + message, module);
 
        GenericDelegator delegator = (GenericDelegator) DelegatorFactory.getDelegator("default");
    LocalDispatcher dispatcher = gc.createLocalDispatcher("ecommerce",delegator);
        //LocalDispatcher dispatcher = gc.createLocalDispatcher("default",delegator);

      List<GenericValue> productList = null;
    String entityName = "product";
   
    try {
   
          /* try to fetch product records */
    productList = delegator.findList(entityName, null, null, null, null, false);

                /*
         
                        logic to traverse through product list

                */

    Debug.logInfo("Find successful", module);
   
    } catch (GenericEntityException gex) {
    Debug.logError(gex, RestSearchResource.class.getName());
    }
   
        Response.ok("REQUEST *** " + message ).type("text/plain").build();

    }
}


The exception I got is:



GenericDelegator              |E| Failure in findByCondition operation for entity [product]: org.ofbiz.entity.GenericModelException: Could not find definition for entity name product. Rolling back transaction.
     [java] org.ofbiz.entity.GenericModelException: Could not find definition for entity name product
     [java] at org.ofbiz.entity.model.ModelReader.getModelEntity(ModelReader.java:489) ~[ofbiz-entity-test.jar:?]

...
...
..



Is there anything I missed out in the configuration for it? Can somebody kindly help me out with this?

Thanks in advance.


-BR
Deepak
 
Regards,
Deepak
Reply | Threaded
Open this post in threaded view
|

Re: Existing Entity with REST component

masionas
Hi Deepak,

Did you try to put an entity name starting with a capital letter?

I.e.
String entityName = "Product";
Reply | Threaded
Open this post in threaded view
|

Re: Existing Entity with REST component

Deepak P
Thanks @masionas . It worked with String entityName="Product".
Regards,
Deepak