[英]WSo2 custom handler: Class Not Found error
我根據用戶指南中的說明編寫了一個自定義身份驗證處理程序。
我放置了jar / repository / components / lib並嘗試從管理控制台->服務總線->服務視圖將其添加到特定的API,但是在日志中收到未找到類的錯誤。
我能夠使其工作的唯一方法是將其“推送”到WSO2的一個部署jar(org.wso2.carbon.apimgt.gateway_5.0.3.jar)的變通方法。 將其添加到此jar並重新啟動WSo2后,我使處理程序正常工作。
但是我猜想這種解決方法不是正確的方法……這是CLASSPATH問題還是我在使其正常運行的過程中缺少的東西?
經過進一步檢查后,發現我的JAR出於某種原因已損壞。 我再次構建它,現在可以使用了。
為了使社區中任何嘗試這樣做的人都能從中受益,我將發布我所做的步驟(使用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)由於這是模板,因此需要重新創建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>
而已!
感謝任何幫助我完成任務的人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.