1

我正在尝试在 Axis2 服务器上开发具有应用程序范围的服务,当我启动服务时,axis2 服务器不会实例化上下文层次结构。

有人可以帮助我理解为什么 Axis2 服务器没有启动上下文?

这里是类的代码:

package xxx;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.service.Lifecycle;

import org.apache.log4j.Logger;

public class Transportsessionservice implements Lifecycle {

  private static final Logger log = Logger.getLogger(LoginStrong.class);

  public int loginTablet(String username, String password) throws Exception {

    ServiceContext serviceContext = MessageContext.getCurrentMessageContext().getServiceContext();
    String ip = (String)MessageContext.getCurrentMessageContext().getProperty("REMOTE_ADDR");
    log.info("SERVICE start ["+ip+"]");

    if(serviceContext.getProperty("COUNT") == null) {
      serviceContext.setProperty("COUNT", 1);
    } else {
      int c = (Integer)serviceContext.getProperty("COUNT");
      serviceContext.setProperty("COUNT", c++);
    }
    log.info("COUNT = " + serviceContext.getProperty("COUNT"));
  }

  @Override
  public void init(ServiceContext serviceContext) {
    log.info("init");
  }

  @Override
  public void destroy(ServiceContext serviceContext) {
    log.info("destroy");
  }

}

在我正在使用的 service.xml 文件下方:

<serviceGroup>
<service name="Transportsessionservice" scope="application">
    <Description>This is a sample service to test transport scope</Description>
    <messageReceivers>
        <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
        <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
    </messageReceivers>
    <parameter name="ServiceClass" locked="false">xxx.Transportsessionservice</parameter>
</service>
</serviceGroup>

最后是 apache tomcat 的输出:

23-ott-2012 14.26.19 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files (x86)/Java/jre6/bin/client;C:/Program Files (x86)/Java/jre6/bin;C:/Program Files (x86)/Java/jre6/lib/i386;C:\Program Files (x86)\Java\jre6\bin;C:\app\product\11.2.0\client_1\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Users\margheritti.luigi\Oracle\obiee11g\oraMiddle\Oracle_BI1\products\Essbase\EssbaseServer\bin;C:\Users\margheritti.luigi\Oracle\obiee11g\oraMiddle\Oracle_BI1\bin;C:\Users\margheritti.luigi\Oracle\obiee11g\oraMiddle\Oracle_BI1\opmn\bin;C:\Users\margheritti.luigi\Oracle\obiee11g\oraMiddle\Oracle_BI1\opmn\lib;C:\Users\margheritti.luigi\Oracle\obiee11g\oraMiddle\Oracle_BI1\perl\bin;C:\Program Files (x86)\Borland\StarTeam SDK 11.0\Lib;C:\Program Files (x86)\Borland\StarTeam SDK 11.0\Bin;C:\blp\Api\dde;C:\blp\Api;.
23-ott-2012 14.26.19 org.apache.tomcat.util.digester.SetPropertiesRule begin
AVVERTENZA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:MyBusiness_v2' did not find a matching property.
23-ott-2012 14.26.19 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
23-ott-2012 14.26.19 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 302 ms
23-ott-2012 14.26.19 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
23-ott-2012 14.26.19 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.32
[WARN] Web application uses org.apache.axis2.transport.http.AxisAdminServlet; please update web.xml to use org.apache.axis2.webapp.AxisAdminServlet instead
[INFO] Clustering has been disabled
[INFO] Deploying module: addressing-1.6.1 - file:/C:/Data/Personal/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyBusiness_v2/WEB-INF/modules/addressing-1.6.1.mar
[INFO] Deploying module: metadataExchange-1.6.1 - file:/C:/Data/Personal/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyBusiness_v2/WEB-INF/modules/mex-1.6.1.mar
[INFO] Deploying module: mtompolicy-1.6.1 - file:/C:/Data/Personal/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyBusiness_v2/WEB-INF/modules/mtompolicy-1.6.1.mar
[INFO] Deploying module: ping-1.6.1 - file:/C:/Data/Personal/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyBusiness_v2/WEB-INF/modules/ping-1.6.1.mar
[INFO] Deploying module: script-1.6.1 - file:/C:/Data/Personal/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyBusiness_v2/WEB-INF/modules/scripting-1.6.1.mar
[INFO] Deploying module: soapmonitor-1.6.1 - file:/C:/Data/Personal/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyBusiness_v2/WEB-INF/modules/soapmonitor-1.6.1.mar
[INFO] Deploying Web service: Transportsessionservice - file:/C:/Data/Personal/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyBusiness_v2/WEB-INF/services/Transportsessionservice/
[INFO] Deploying Web service: version.aar - file:/C:/Data/Personal/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/MyBusiness_v2/WEB-INF/services/version.aar
[INFO] init
[WARN] No transportReceiver for org.apache.axis2.transport.http.AxisServletListener found. An instance for HTTP will be configured automatically. Please update your axis2.xml file!
23-ott-2012 14.26.20 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
23-ott-2012 14.26.20 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
23-ott-2012 14.26.20 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/12  config=null
23-ott-2012 14.26.20 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1042 ms

请帮助我找到激活上下文层次结构的解决方案。

4

1 回答 1

0

请更新您的axis2.xml 文件!包括这个

      <parameter name="manageTransportSession" locked="false">true</parameter> 
于 2013-03-28T10:50:02.373 回答