WSO2 API Manager /services/… throw a NullPointerEx

2019-08-13 09:41发布

问题:

I have the WSO2 API Manager running on a Windows 2012 R2 server and all dashboard URL's like https://localhost:9443/store,https://localhost:9443/carbon,https://localhost:9443/publisher work fine. But when I configure and deploy (in the carbon.super tenant) the example WeatherAPI web service and try to reach it via the /services/... URL i.e.:

https://localhost:9443/services/weather/1.0.0/*?q=Amsterdam

I get the following error page returned:

> HTTP Status 500 - 
> 
> 
> type Exception report
> 
> message 
> 
> description The server encountered an internal error that prevented it
> from fulfilling this request.
> 
> exception  org.apache.axis2.AxisFault
>   org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
>   org.wso2.carbon.core.transports.CarbonServlet.doGet(CarbonServlet.java:155)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>   org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
>   org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
>   org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>   org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
>   org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)
> 
> 
> 
> root cause  java.lang.NullPointerException
>   org.apache.synapse.rest.RESTUtils.getFullRequestPath(RESTUtils.java:80)
>   org.apache.synapse.rest.API.canProcess(API.java:179)
>   org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:79)
>   org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:64)
>   org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:220)
>   org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:83)
>   org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
>   org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:144)
>   org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:139)
>   org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:837)
>   org.wso2.carbon.core.transports.CarbonServlet.handleRestRequest(CarbonServlet.java:303)
>   org.wso2.carbon.core.transports.CarbonServlet.doGet(CarbonServlet.java:152)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>   org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
>   org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
>   org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>   org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
>   org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)

When I create my own web service in a tenant and deploy it, I get the same error. So I probably misconfigured something, but don't know where to look. All paths below /services/... seem to return this error page. I checked the log files in the [WSO2]/repository/logs directory, but they don't show any errors.

回答1:

You are trying to access the services from the servlet port 9443. Try with the 8280 port . However, the endpoint of the API in APIM does not look like as you mention. Check the example given in the official WSO2 documentation