0

Apache Gronimo 3.01 を使用していますが、基本認証を使用する Web サービスで大量のメモリ リークが発生しています (認証が使用されていない場合はメモリ リークは発生しません)。

唯一のコードは次のとおりです。

 package org.apache.geronimo.samples.jws;

import javax.annotation.Resource;
import javax.jws.WebService;
import javax.xml.ws.WebServiceContext;

@WebService(serviceName = "Calculator",
            portName="CalculatorPort",
            endpointInterface = "org.apache.geronimo.samples.jws.Calculator",
            targetNamespace = "http://jws.samples.geronimo.apache.org"
            )
public class CalculatorService implements Calculator {

    @Resource
    private WebServiceContext context;

    public int add(int value1, int value2) {
        System.out.println("User Principal: " + context.getUserPrincipal());
        return value1 + value2;
    }
}

package org.apache.geronimo.samples.jws;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

@WebService(name="CalculatorPortType",
            targetNamespace = "http://jws.samples.geronimo.apache.org")
public interface Calculator {

    @WebMethod
    public int add(@WebParam(name = "value1") int value1,
                   @WebParam(name = "value2") int value2);

}

そして、次の XML:

jaxws-calculator/WebContent/WEB-INF/WebContent/web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>jaxws-calculator</display-name>
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Protected</web-resource-name>
      <url-pattern>/*</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
      <role-name>wsusers</role-name>
    </auth-constraint>
  </security-constraint>
  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>LeakyWsSecurityRealm</realm-name>
  </login-config>
  <security-role>
    <role-name>wsusers</role-name>
  </security-role>
  <servlet>
    <display-name>Apache-Axis Servlet</display-name>
    <servlet-name>AxisServlet</servlet-name>
    <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/servlet/AxisServlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>*.jws</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>AxisServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
  <servlet>
    <display-name>Axis Admin Servlet</display-name>
    <servlet-name>AdminServlet</servlet-name>
    <servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
    <load-on-startup>100</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>AdminServlet</servlet-name>
    <url-pattern>/servlet/AdminServlet</url-pattern>
  </servlet-mapping>
</web-app>

jaxws-calculator/WebContent/WEB-INF/WebContent/geronimo-web.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web:web-app xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0" xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:jaspi="http://geronimo.apache.org/xml/ns/geronimo-jaspi" xmlns:log="http://geronimo.apache.org/xml/ns/loginconfig-2.0" xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:pers="http://java.sun.com/xml/ns/persistence" xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1" xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">
    <dep:environment>
        <dep:moduleId>
            <dep:groupId>leaky-ws</dep:groupId>
            <dep:artifactId>jaxws-calculator</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>car</dep:type>
        </dep:moduleId>
    </dep:environment>
    <web:context-root>/jaxws-calculator</web:context-root>
    <web:security-realm-name>LeakyWsSecurityRealm</web:security-realm-name>
</web:web-app>

jaxws-calculatorEAR/EarContent/META-INF/application.xml:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" id="Application_ID" version="6">
  <display-name>jaxws-calculatorEAR</display-name>
  <module>
    <web>
      <web-uri>jaxws-calculator.war</web-uri>
      <context-root>jaxws-calculator</context-root>
    </web>
  </module>
</application>

jaxws-calculatorEAR/EarContent/META-INF/geronimo-application.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<app:application xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0" xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:jaspi="http://geronimo.apache.org/xml/ns/geronimo-jaspi" xmlns:log="http://geronimo.apache.org/xml/ns/loginconfig-2.0" xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:pers="http://java.sun.com/xml/ns/persistence" xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1" xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1" application-name="ws-ivr">
    <dep:environment>
        <dep:moduleId>
            <dep:groupId>leaky-ws</dep:groupId>
            <dep:artifactId>jaxws-calculatorEAR</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>car</dep:type>
        </dep:moduleId>
        <dep:dependencies>
            <dep:dependency>
                <dep:groupId>console.realm</dep:groupId>
                <dep:artifactId>LeakyWsSecurityRealm</dep:artifactId>
            </dep:dependency>
        </dep:dependencies>
    </dep:environment>
    <sec:security>
        <sec:role-mappings>
            <sec:role role-name="wsusers">
                <sec:principal class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal" name="wsusers"/> 
            </sec:role>
        </sec:role-mappings>
    </sec:security>
</app:application>

geronimo のコンソールで、「Properties File Realm」である LeakyWsSecurityRealm という Security Realm をセットアップしました。

問題は、VisualVM を使用して見たように、64K インスタンス「org.apache.geronimo.security.Context」によって参照されるタイプ「java.security.AccessControlContext」(OutOfMemoryError の前に 128K インスタンス) のオブジェクトがリークすることです。

ここで何が問題なのか、誰にも手がかりがありますか?

4

0 に答える 0