How to Migrate a web project running on resin server to tomcat

2k Views Asked by At

I have a web project which is already running on resin but I want to deploy the whole project in tomcat server (i.e., I want to migrate the server)

I think only web.xml should be changed so I tried following changes

I have web.xml in resin as

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:resin="urn:java:com.caucho.resin"
         xmlns:gemini="urn:java:com.techempower.gemini">
  <multipart-form enable="true" upload-max="50M" />

  <!-- These lines will force assets to be served be resin -->
  <servlet-mapping url-pattern="/css/*" servlet-name="resin-file" />
  <servlet-mapping url-pattern="/js/*" servlet-name="resin-file" />
  <servlet-mapping url-pattern="/images/*" servlet-name="resin-file" />
  <servlet-mapping url-pattern="/html/*" servlet-name="resin-file" />
  <servlet-mapping url-pattern="favicon.ico" servlet-name="resin-file" />

  <servlet-mapping url-pattern="/content/*" servlet-name="resin-file" />

  <!-- Assets located in "/static/" are files that should be cached forever, by
       convention. -->
  <servlet-mapping url-pattern="/static/*" servlet-name="resin-file" />
  <resin:Forward regexp="^/static/([\d|-]+)/(css|js|images|html)/(.*)$" target="/$2/$3">
    <gemini:filter.ExpiresFilter>
      <expirationDelta>31556926000</expirationDelta>
    </gemini:filter.ExpiresFilter>
  </resin:Forward>

  <!-- Disallow Resin 4 from compiling PHP or JSP pages directly. -->
  <mime-mapping extension=".php" mime-type="text/plain" />
  <mime-mapping extension=".jsp" mime-type="text/plain" />
  <mime-mapping extension=".jspf" mime-type="text/plain" />
  <mime-mapping extension=".jspx" mime-type="text/plain" />
  <servlet-mapping url-pattern="*.php" servlet-name="resin-file" />
  <servlet-mapping url-pattern="*.jsp" servlet-name="resin-file" />
  <servlet-mapping url-pattern="*.jspf" servlet-name="resin-file" />
  <servlet-mapping url-pattern="*.jspx" servlet-name="resin-file" />
  <servlet-mapping url-pattern="/WEB-INF/*.jsp" servlet-name="resin-jsp" />
  <servlet-mapping url-pattern="/WEB-INF/*.jspf" servlet-name="resin-jsp" />
  <servlet-mapping url-pattern="/WEB-INF/*.jspx" servlet-name="resin-jspx" />

  <!-- Disallow URL rewriting for sessions.-->
  <session-config enable-url-rewriting="false" />

  <!-- Use UTF-8 for everything. -->
  <character-encoding>UTF-8</character-encoding>

  <!-- Uncomment and modify the directives below to enable network
       configuration, wherein each application instance contacts the
       cluster master to receive its configuration. -->


  <!-- Enable GZIP compression. -->
  <filter filter-name="gzip" filter-class="com.caucho.filters.GzipFilter">
    <init>
      <use-vary>true</use-vary>
    </init>
  </filter>
  <filter-mapping url-pattern='*' filter-name="gzip" />


    <listener>
        <display-name>Cron Job Scheduler Manager</display-name>
        <listener-class>com.leonardo.email.CronJobHandler</listener-class>
    </listener>

    <servlet>
        <servlet-name>PrintActionItems</servlet-name>
        <servlet-class>com.leonardo.PrintActionItems</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>PrintActionItems</servlet-name>
        <url-pattern>/PrintActionItems</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>DeleteActionItemFile</servlet-name>
        <servlet-class>com.leonardo.DeleteActionItemFile</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>DeleteActionItemFile</servlet-name>
        <url-pattern>/DeleteActionItemFile</url-pattern>
    </servlet-mapping>


</web-app>

I want to change this web.xml according to Tomcat

I changed it as below:

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:resin="urn:java:com.caucho.resin"
         xmlns:gemini="urn:java:com.techempower.gemini">
  <multipart-form enable="true" upload-max="50M" />

 <servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>/css/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>/js/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>/html/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>/images/*</url-pattern>
</servlet-mapping>


  <servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>/static/*</url-pattern>
</servlet-mapping>


<servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>*.php</url-pattern>
</servlet-mapping>
 <servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>*.jsp</url-pattern>
</servlet-mapping>
 <servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>*.jspf</url-pattern>
</servlet-mapping>
 <servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>*.jspx</url-pattern>
</servlet-mapping>
 <servlet-mapping>
  <servlet-name>default</servlet-name><url-pattern>/WEB-INF/*</url-pattern>
</servlet-mapping>


  <!-- Disallow URL rewriting for sessions.-->
  <session-config enable-url-rewriting="false" />

  <!-- Use UTF-8 for everything. -->
  <character-encoding>UTF-8</character-encoding>


  <!-- Enable GZIP compression. -->
  <filter filter-name="gzip" filter-class="com.caucho.filters.GzipFilter">
    <init>
      <use-vary>true</use-vary>
    </init>
  </filter>

    <listener>
        <display-name>Cron Job Scheduler Manager</display-name>
        <listener-class>com.leonardo.email.CronJobHandler</listener-class>
    </listener>

    <servlet>
        <servlet-name>PrintActionItems</servlet-name>
        <servlet-class>com.leonardo.PrintActionItems</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>PrintActionItems</servlet-name>
        <url-pattern>/PrintActionItems</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>DeleteActionItemFile</servlet-name>
        <servlet-class>com.leonardo.DeleteActionItemFile</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>DeleteActionItemFile</servlet-name>
        <url-pattern>/DeleteActionItemFile</url-pattern>
    </servlet-mapping>

</web-app>

But, while running tomcat it gives following errors

org.apache.tomcat.util.modeler.Registry registerComponent
SEVERE: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/,
J2EEApplication=none,J2EEServer=none
org.apache.catalina.startup.HostConfig deployDirectory
SEVERE: Error deploying web application directory ROOT
java.lang.NullPointerException

Is this a right way to migrate to tomcat server?
If so only web.xml must be changed? then what should be contain in web.xml of tomcat?

Please advice Thanks

1

There are 1 best solutions below

2
On

In Tomcat there is a web.xml in the conf directory, but you don't need to change it, if you are only deploying an application. By default the conf/web.xml is already setup to execute JSP / servlets.

Most web applications follow the Servlet JSR and can run on any Java container like Jetty, Resin or Tomcat etc, you don't need to modify the project.

If you place a WAR file or your project in the webapps directory it gets deployed at startup. You can use ROOT, but I use separate paths for my applications. The URL would then look like http://localhost:8080/mywebapp/