WSo2 自定义处理程序:Class 未找到错误
WSo2 custom handler: Class Not Found error
我根据用户指南中的说明编写了自定义身份验证处理程序。
我放置了我的 jar /repository/components/lib 并尝试从管理控制台 -> 服务总线 -> 服务视图将其添加到特定的 API,但收到 class not found 错误日志。
我能够让它工作的唯一方法是 "pushing" 它到 WSO2 的一个部署 jar (org.wso2.carbon.apimgt.gateway_5.0.3.jar).当添加到这个 jar 并重新启动 WSo2 时,我的处理程序工作正常。
但我想这个解决方法不是正确的方法...这是 CLASSPATH 问题还是我在使其工作的过程中遗漏了什么?
进一步检查后,发现我的 JAR 已因某种原因损坏。我重新构建了它,现在可以使用了。
为了社区中尝试此操作的任何人的利益,我将post我所做的步骤(使用 APIM 1.10.0)
1) JAR 文件:
$ cd /home/olahav/wso2/wso2am-1.10.0/repository/components/lib
$ jar tf extensions.jar
...
org/wso2/carbon/test/OferAPIAuthenticationHandler_1.class
2) API 模板:
<handlers xmlns="http://ws.apache.org/ns/synapse">
<handler class="org.wso2.carbon.test.OferAPIAuthenticationHandler_1"/>
#foreach($handler in $handlers)
<handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className">
#if($handler.hasProperties())
#set ($map = $handler.getProperties() )
#foreach($property in $map.entrySet())
<property name="$!property.key" value="$!property.value"/>
#end
#end
</handler>
#end
</handlers>
3) 由于这是模板,需要re-create API。然后检查服务视图(通过 https://localhost:9443/carbon),您可以看到添加到处理程序列表中的处理程序:
<handlers>
<handler class="org.wso2.carbon.test.OferAPIAuthenticationHandler_1"/>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
<property name="apiImplementationType" value="ENDPOINT"/>
</handler>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler">
<property name="id" value="A"/>
<property name="policyKeyResource" value="gov:/apimgt/applicationdata/res-tiers.xml"/>
<property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/>
<property name="policyKeyApplication" value="gov:/apimgt/applicationdata/app-tiers.xml"/>
</handler>
<handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/>
<handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler">
<property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/>
</handler>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
</handlers>
就是这样!
感谢所有帮助过我的人。
我根据用户指南中的说明编写了自定义身份验证处理程序。
我放置了我的 jar /repository/components/lib 并尝试从管理控制台 -> 服务总线 -> 服务视图将其添加到特定的 API,但收到 class not found 错误日志。
我能够让它工作的唯一方法是 "pushing" 它到 WSO2 的一个部署 jar (org.wso2.carbon.apimgt.gateway_5.0.3.jar).当添加到这个 jar 并重新启动 WSo2 时,我的处理程序工作正常。
但我想这个解决方法不是正确的方法...这是 CLASSPATH 问题还是我在使其工作的过程中遗漏了什么?
进一步检查后,发现我的 JAR 已因某种原因损坏。我重新构建了它,现在可以使用了。
为了社区中尝试此操作的任何人的利益,我将post我所做的步骤(使用 APIM 1.10.0)
1) JAR 文件:
$ cd /home/olahav/wso2/wso2am-1.10.0/repository/components/lib
$ jar tf extensions.jar
...
org/wso2/carbon/test/OferAPIAuthenticationHandler_1.class
2) API 模板:
<handlers xmlns="http://ws.apache.org/ns/synapse">
<handler class="org.wso2.carbon.test.OferAPIAuthenticationHandler_1"/>
#foreach($handler in $handlers)
<handler xmlns="http://ws.apache.org/ns/synapse" class="$handler.className">
#if($handler.hasProperties())
#set ($map = $handler.getProperties() )
#foreach($property in $map.entrySet())
<property name="$!property.key" value="$!property.value"/>
#end
#end
</handler>
#end
</handlers>
3) 由于这是模板,需要re-create API。然后检查服务视图(通过 https://localhost:9443/carbon),您可以看到添加到处理程序列表中的处理程序:
<handlers>
<handler class="org.wso2.carbon.test.OferAPIAuthenticationHandler_1"/>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.CORSRequestHandler">
<property name="apiImplementationType" value="ENDPOINT"/>
</handler>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler"/>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.throttling.APIThrottleHandler">
<property name="id" value="A"/>
<property name="policyKeyResource" value="gov:/apimgt/applicationdata/res-tiers.xml"/>
<property name="policyKey" value="gov:/apimgt/applicationdata/tiers.xml"/>
<property name="policyKeyApplication" value="gov:/apimgt/applicationdata/app-tiers.xml"/>
</handler>
<handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageHandler"/>
<handler class="org.wso2.carbon.apimgt.usage.publisher.APIMgtGoogleAnalyticsTrackingHandler">
<property name="configKey" value="gov:/apimgt/statistics/ga-config.xml"/>
</handler>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler"/>
</handlers>
就是这样!
感谢所有帮助过我的人。