Page 1 of 1

Rest API in Broadleaf Demo - NullPointerException

Posted: Mon Mar 17, 2014 1:43 pm
by gowthamgutha
I am trying to access this url for my autocomplete in the search box..

http://localhost:8080/api/v1/catalog/search/products?q=sauce

But, I am getting the following error..
It seems here that the

Code: Select all

@Resource(name = "blExploitProtectionService")
protected ExploitProtectionService exploitProtectionService;


exploitProtectionService is null


Code: Select all

HTTP ERROR 500

Problem accessing /api/v1/catalog/search/products. Reason:

    Server Error

Caused by:

java.lang.NullPointerException
   at org.broadleafcommerce.core.web.api.endpoint.catalog.CatalogEndpoint.findProductsByQuery(CatalogEndpoint.java:190)
   at com.mycompany.api.endpoint.catalog.CatalogEndpoint.findProductsByQuery(CatalogEndpoint.java:75)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


My web.xml is as follows

Code: Select all

    <servlet>
       <servlet-name>RESTApiServlet</servlet-name>
       <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>com.mycompany.api.endpoint</param-value>
        </init-param>
   </servlet>

   <servlet-mapping>
       <servlet-name>RESTApiServlet</servlet-name>
       <url-pattern>/api/v1/*</url-pattern>
   </servlet-mapping>


Next, my applicationContext.xml is

Code: Select all

<context:component-scan base-package="org.broadleafcommerce.core.web.api"/>


and applicationContext-security.xml is

Code: Select all

<!-- Set up Spring security for the RESTful API -->
<sec:http pattern="/api/**" create-session="stateless">
    <sec:http-basic />
    <sec:custom-filter ref="blRestCustomerStateFilter" after="REMEMBER_ME_FILTER"/>
</sec:http>

<!-- Used for REST api calls.   This just takes in the passed in customerId and uses it to establish the customer. -->
<!-- Additional considerations MUST be made for implementations that are allowing external access to APIs. -->
<bean id="blRestCustomerStateFilter" class="org.broadleafcommerce.profile.web.core.security.RestApiCustomerStateFilter"/>

Re: Rest API in Broadleaf Demo - NullPointerException

Posted: Sun Mar 23, 2014 7:42 pm
by phillipuniverse
This might be an issue in Broadleaf; you should be able to access that bean. Can you open an issue at https://github.com/BroadleafCommerce/BroadleafCommerce?