Cannot find XmlRpcServlet.properties file in war when packaged it in ear
------------------------------------------------------------------------

                 Key: XMLRPC-190
                 URL: https://issues.apache.org/jira/browse/XMLRPC-190
             Project: XML-RPC
          Issue Type: Wish
    Affects Versions: 3.1.3
         Environment: linux / windows
            Reporter: zappee
            Priority: Minor
             Fix For: 3.0


Cannot find XmlRpcServlet.properties file in war when packaged it in ear.

Workaround:
-------------------
You have to extend the original org.apache.xmlrpc.webserver.XmlRpcServlet class 
and overwrite newXmlRpcHandlerMapping() method. After it you may use your new 
class file in web.xml instead of the original 
org.apache.xmlrpc.webserver.XmlRpcServlet class.

 
MyXmlRpcServlet.java:
public class MyXmlRpcServlet extends org.apache.xmlrpc.webserver.XmlRpcServlet
{
    @Override
    protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws 
XmlRpcException
    {
        String packageName = 
this.getClass().getPackage().getName().replaceAll("\\.", "/");
        String realPath = "/WEB-INF/classes/" + packageName + 
"/XmlRpcServlet.properties";

        try
        {
            URL url = this.getServletContext().getResource(realPath);
            if (url == null)
            {
                throw new XmlRpcException("Failed to locate resource 
XmlRpcServlet.properties");
            }

            return newPropertyHandlerMapping(url);
        }
        catch (IOException e)
        {
            throw new XmlRpcException("Failed to load resource " + realPath + 
": " + e.getMessage(), e);
        }
    }
}

web.xml:
        <servlet>
            <servlet-name>XmlRpcServlet</servlet-name>
            
<servlet-class>com.remal.xmlrpc.webserver.MyXmlRpcServlet</servlet-class>
            <init-param>
              <param-name>enabledForExtensions</param-name>
              <param-value>true</param-value>
              <description>
                Sets, whether the servlet supports vendor extensions for 
XML-RPC.
              </description>
            </init-param>
        </servlet>
        <servlet-mapping>
            <servlet-name>XmlRpcServlet</servlet-name>
            <url-pattern>/xmlrpc</url-pattern>
        </servlet-mapping>

This solution is working in standalone war and/or war when packaged it in ear.

regards, Arnold Somogyi


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to