我正在尝试访问此 url 以在搜索框中自动完成。
http://localhost:8080/api/v1/catalog/search/products?q=sauce
但是,我收到以下错误。似乎在这里
@Resource(name = "blExploitProtectionService")
protected ExploitProtectionService exploitProtectionService;
exploitProtectionService 为空
这是错误..
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)
我的web.xml如下
<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>
接下来,我的applicationContext.xml是
<context:component-scan base-package="org.broadleafcommerce.core.web.api"/>
和applicationContext-security.xml是
<!-- 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"/>
如何解决这个问题呢?如何使exploitProtectionService
变量不为空。如何初始化?
提前致谢。