8

我正在尝试从 WSO2 Carbon 3.0.0 升级到 Carbon 4.0.3。使用 Carbon 3.0.0,在安装了必要的特性之后,我可以编写可以调用外部 Java 库的 JavaScript Mashup 服务——而且由于 WSO2 carbon 使用 Rhino,我可以使用 importPackage。我无法在 Carbon 4.0.3 上获得相同的功能。

我遵循的程序是:

  1. 下载并解压 WSO2 Carbon 4.0.3
  2. 启动碳
  3. 导航到“功能管理”页面
  4. 添加 4.0.3 Carbon p2 存储库 ( http://dist.wso2.org/p2/carbon/releases/4.0.3/ )
  5. 搜索并安装“应用服务器”功能
  6. 重启碳
  7. 部署我的测试 Mashup 服务
  8. 使用“tryit”工具执行我的测试 Mashup 服务的 echo 操作。

我的测试混搭服务(TestMashup.js):

this.serviceName = "TestMashup";

echo.inputTypes = "#raw";
echo.outputType = "#raw";
function echo(parameter) {
    var javaDate = new Packages.java.util.Date();
    var response = "<echo><value>" + parameter.toXMLString() + "</value><timestamp>" + javaDate.getTime() + "</timestamp></echo>";

    return new XML(response);
}

我已将此 Mashup 服务安装到 CARBON_HOME/repository/deployment/server/jsservices/admin/

当我在 Carbon 3.0.0 上运行此操作时,我得到以下响应:

<echo>
  <value>
    <r>test</r>
  </value>
  <timestamp>1360699125311</timestamp>
</echo>

当我尝试在 Carbon 4.0.3 上运行此操作时,我得到以下堆栈跟踪:

[2013-02-12 14:46:32,511] ERROR {org.jaggeryjs.scriptengine.engine.RhinoEngine} -  org.mozilla.javascript.EcmaError: ReferenceError: "Packages" is not defined.(//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js#6)
[2013-02-12 14:46:32,512] ERROR {org.jaggeryjs.scriptengine.engine.RhinoEngine} -  org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "Packages" is not defined. (//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js#6)
[2013-02-12 14:46:32,512] ERROR {org.apache.axis2.receivers.AbstractMessageReceiver} -  org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "Packages" is not defined. (//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js#6)
org.apache.axis2.AxisFault: org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "Packages" is not defined.(//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js#6)
        at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
        at org.wso2.carbon.mashup.javascript.messagereceiver.JavaScriptEngine.call(JavaScriptEngine.java:176)
        at org.wso2.carbon.mashup.javascript.messagereceiver.JavaScriptEngine.call(JavaScriptEngine.java:208)
        at org.wso2.carbon.mashup.javascript.messagereceiver.JavaScriptReceiver.invokeBusinessLogic(JavaScriptReceiver.java:185)
        at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
        at org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:231)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.eclipse.equinox.http.helper.FilterServletAdaptor$FilterChainImpl.doFilter(FilterServletAdaptor.java:56)
        at org.wso2.carbon.mashup.jsservices.custom.ui.CustomUIServletFilter.doFilter(CustomUIServletFilter.java:233)
        at org.eclipse.equinox.http.helper.FilterServletAdaptor.service(FilterServletAdaptor.java:37)
        at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
        at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
        at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:172)
        at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
        at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: org.jaggeryjs.scriptengine.exceptions.ScriptException: org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "Packages" is not defined. (//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js#6)
        at org.jaggeryjs.scriptengine.engine.RhinoEngine.execFunc(RhinoEngine.java:383)
        at org.jaggeryjs.scriptengine.engine.RhinoEngine.call(RhinoEngine.java:251)
        at org.wso2.carbon.mashup.javascript.messagereceiver.JavaScriptEngine.call(JavaScriptEngine.java:169)
        ... 40 more
Caused by: org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "Packages" is not defined. (//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js#6)
        at org.jaggeryjs.scriptengine.engine.RhinoEngine.execFunc(RhinoEngine.java:401)
        at org.jaggeryjs.scriptengine.engine.RhinoEngine.execFunc(RhinoEngine.java:380)
        ... 42 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "Packages" is not defined. (//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js#6)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)
        at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3620)
        at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1652)
        at org.jaggeryjs.rhino.c0._c1(//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js:6)
        at org.jaggeryjs.rhino.c0.call(//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
        at org.jaggeryjs.rhino.c0.call(//C:\WSO2CA~1\WSO2CA~1.3\bin\..\repository\deployment\server\jsservices\admin\TestMashup.js)
        at org.jaggeryjs.scriptengine.engine.RhinoEngine.execFunc(RhinoEngine.java:398)
        ... 43 more

如何解决此问题,以便我可以继续使用我的 JavaScript Mashup 服务中的 Java 库?

4

2 回答 2

1

允许此功能工作的代码已被禁用。

我花了一些时间查看 carbon SVN 存储库,发现message-receivermashup 组件的修改方式阻止了 JavaScript Mashup 服务使用ImporterTopLevel上下文创建。这在 中直接可见org.wso2.carbon.mashup.javascript.messagereceiver.JavaScriptEngine,其中以前的版本扩展ImporterTopLevel但较新的版本没有。为了将来参考,此更改是针对修订版 129254 提交的。

我已经能够将ImporterTopLevel3.2.2 中的代码合并到 4.0.3 版本中messagereceiver来解决这个问题。

于 2013-02-28T19:11:34.840 回答
-1

将所需功能安装到 Carbon 服务器时,请查看控制台中是否打印了任何错误。可能存在一些依赖性问题。安装功能后,使用命令启动 WSO2 AS,./wso2server.sh -DosgiConsole并使用ss命令和comp命令查看是否有任何未解决的 OSGi 依赖项。如果有,请尝试将所需的包放入 repository/components/dropins 并重新启动服务器。

而且我不确定是否仅安装应用程序服务器功能会满足您的 Mashup 要求。因此,在该存储库中查看是否有任何可用的 Mashup Server 相关功能。如果是这样,也安装它们。在您的服务器中,主机对象“Packages”似乎有一些问题。

当您由于依赖问题而无法安装某些功能时,您可以尝试将所需的捆绑包放在 dropins 目录中。如果这也失败了,您可能必须检查与该组件相关的代码并将其反向移植到您的服务器版本。

于 2013-02-24T16:49:08.417 回答