The Artima Developer Community
Sponsored Link

Java Buzz Forum
Struts 2.1.x with CXF 2.1.4 issues on URI mappings

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Marc Logemann

Posts: 594
Nickname: loge
Registered: Sep, 2002

Marc Logemann is founder of www.logentis.de a Java consultancy
Struts 2.1.x with CXF 2.1.4 issues on URI mappings Posted: Apr 3, 2009 5:48 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Marc Logemann.
Original Post: Struts 2.1.x with CXF 2.1.4 issues on URI mappings
Feed Title: Logemann Blog
Feed URL: http://feeds.feedburner.com/LogemannBlog
Feed Description: Marc Logemann's thoughts on java and other stuff
Latest Java Buzz Posts
Latest Java Buzz Posts by Marc Logemann
Latest Posts From Logemann Blog

Advertisement
When having this web.xml (aka filter and servlet mappings for both frameworks):

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>


The CXF servlet never gets called on CXF requests like "http://..../services/. Thats because even though Struts2 has no namespace for this nor any action it "handles" this request without passing through the chain.

My quick solutions is to write a custom ActionMapper which modifies the default one a bit. Here the struts.properties for the custom actionMapper.

struts.mapper.class=de.logentis.struts2.CXFStruts2ActionMapper

And here the ActionMapper:


/*
* Copyright (c) 2008 Logentis GmbH. All Rights Reserved.
*
* This software is the proprietary information of Logentis GmbH
* Use is subject to license terms as seen in LICENSE.txt in the
* distribution. Logentis GmbH PROPRIETARY/CONFIDENTIAL.
*
*/
package de.logentis.struts2;

import org.apache.struts2.dispatcher.mapper.DefaultActionMapper;
import org.apache.struts2.dispatcher.mapper.ActionMapping;

import javax.servlet.http.HttpServletRequest;

import com.opensymphony.xwork2.config.ConfigurationManager;

/**
* ActionMapper that excludes all /services/* URLs. A shame that this cant be
* done simpler w/o a custom ActionMapper
*
*/
public class CXFStruts2ActionMapper extends DefaultActionMapper {

@Override
public ActionMapping getMapping(HttpServletRequest request, ConfigurationManager configManager) {
ActionMapping mapping = new ActionMapping();
String uri = getUri(request);
int indexOfSemicolon = uri.indexOf(";");
uri = (indexOfSemicolon > -1) ? uri.substring(0, indexOfSemicolon) : uri;
uri = dropExtension(uri, mapping);

if(uri.matches("/services/.*")) return null;
else return super.getMapping(request, configManager);
}
}


Perhaps i am missing something... but for now thats the best thing i came up with...

Read: Struts 2.1.x with CXF 2.1.4 issues on URI mappings

Topic: Goodbye MSN Encarta. Was Wikipedia too Much? Previous Topic   Next Topic Topic: Adobe and Facebook Join Hands to Build Apps

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use