Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:38:29+00:00 2026-06-09T08:38:29+00:00

I am attempting to deploy Jersey 1.13 and Struts 2 inside the same WAR

  • 0

I am attempting to deploy Jersey 1.13 and Struts 2 inside the same WAR file on Glassfish.

I am using a very old version of Glassfish and unfortunately am stuck on this version (Version = Sun Java System Application Server 9.1_02)

The Struts 2 configuration is as per the documentation. THe problem is the filter will intercept all urls and attempt to handle them via the Struts 2 configuration. My question is how do you deploy Jersey (or any servlet) inside the same war as a Struts 2 application?

Below is the web.xml file that I am using.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<servlet>
    <servlet-name>JerseyServletAdaptor</servlet-name>
    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.example.portal.api</param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>JerseyServletAdaptor</servlet-name>
    <url-pattern>/helloworld</url-pattern>
</servlet-mapping>
<listener>
    <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>

<context-param>
    <param-name>org.apache.tiles.impl.BasicTilesConatiner.DEFINITIONS_CONFIG</param-name>
    <param-value>tiles.xml</param-value>
</context-param>

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>com.example.portal.web.actions.WLSessionFilterDispatcher</filter-class>
</filter>

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

<welcome-file-list>
    <welcome-file>/jsp/index.html</welcome-file>
</welcome-file-list>

</web-app>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:38:31+00:00Added an answer on June 9, 2026 at 8:38 am

    I was able to resolve this as follows:

    In web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    
    <servlet>
        <servlet-name>JerseyServletAdaptor</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>com.example.portal.api</param-value>
        </init-param>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>JerseyServletAdaptor</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>
    
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>com.example.portal.web.actions.WLSessionFilterDispatcher</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    </web-app>
    

    In struts.xml I added this under the element

    <constant name="struts.action.excludePattern" value="/api/.*" />
    

    The URL is still sent to the struts framework first but is ignored due to the above excludePattern. This then allows my servlet mapping to handle the URL and pass it into the Jersey framework.

    This approach does mean you have to prefix your Jersey URLs with api (or what ever you define) e.g.

    http://<domain-name>/api/resource/id

    This works until you add security into the mix. The problem comes from wanting to use FORM based authentication for Struts and Basic Authentication for Jersey. Unfortunately web.xml only allows you to define a single login-config for an application which meant I was stuck using either FORM based authentication or Basic Authentication for both Struts and Jersey.

    Given this I decided to deploy the Jersey application in it’s own WAR which means I didn’t end up using the above solution in the end. The good news is that if you don’t want to use different authentication methods (or any authentication) the above approach does work for deploying Jersey and Struts 2 in the same WAR.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to deploy to a war file in Tomcat 7. It's giving me
I am attempting to deploy my webapp using maven to an embedded tomcat server.
I'm very new to rails and attempting to deploy some changes to my production
I am using Capistrano to deploy a ruby on rails project. I am attempting
I am attempting to deploy a RoR app using Passenger onto my DreamHost hosting
I have a Django app we're attempting to deploy to a Tomcat server, using
I am attempting to deploy my first alpha version of a system online for
I am attempting to deploy a Java application from Eclipse (Version: Indigo Release, Build
I'm attempting to deploy ODP.Net with my application using the Oracle Instaclient. While reading
I built an app using Django 1.3 and am now attempting to deploy to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.