0
votes

Porting WebSphere App to TOMCAT 7 running Java 6

We are simply trying to see if this can be done. We use no EJB's. The application is 10 years old and connects to an Oracle database (11g). We have been adding to it and modifying it as it is in heavy use. It has been running under Websphere 6.1 and does have several JAX-RPC webservices. I got it to run on WebSphere 8.5 but costs as they are, we decided to try TOMCAT 7 and JUNO.

I have not worked extensively with Tomcat as this is an IBM shop. More apps seem to be using Tomcat so I am more than willing to learn. I installed Eclipse - Juno and in my workspace I brought in the application files after creating a new dynamic web project. Our application was deployed as an EAR file but here I was going to deploy it as a WAR file. There were many warnings and errors on build.

I installed TOMCAT and tested it with a little webServices app tutorial I found online that deployed and ran correctly. I brought the server into my project.
Most compile errors were quickly resolved by finding jar files and moving them in to either the WEB/lib or the Tomcat lib directory. For example the ojdbc6.jar file is in the Tomcat lib.

I am not going for an optimal configuration right now, we are just trying to see if we can get this to work. That is why I moved the com.ibm.ws.runtime.jar into the WEB-INF lib of the application to clear most compilation errors. We definitely do not want to use that going forward but if we get this to run, we will then go further and attempt removal of that and regenration of the web services. I got a clean compile fairly soon.

I did get the Data Source Explorer to recognize the Database Connection as an aside, but I have had trouble getting the app to start-up. Here is what I have done.
At the top of my apps web.xml file I added a entry for the Oracle database as can be seen below:

<?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">
    <display-name>SupplierNetRelease</display-name>
    <resource-ref>
        <description>SupplierNet Oracle Database</description>
        <res-ref-name>jdbc/SupplierNetDataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
    <servlet>
        <display-name>MsgLogin</display-name>
        <servlet-name>MsgLogin</servlet-name>
        <servlet-class>com.alstom.power.suppliernet.servlets.MsgLogin</servlet-class>
    </servlet>.........

I was wondering if I should regenerate this file which was jsut ported over with the app? It is showing web-app version="2.5" although Tomcat 7 works with 3.0 I believe.

In the context.xml file for Tomcat I added:

...<Resource name="SupplierNetDataSource"
        auth="Container"
        type="javax.sql.DataSource"
        username="xxxxxx"
        password="xxxxxx"
        driverClassName="oracle.jdbc.OracleDriver"
        url="jdbc:oracle:thin:@localhost:1521:supnjttx"
        maxActive="10"
        maxIdle="4"/>

</Context>

I made no changes to the server.xml file as of yet. In tomcat-Users.xml I added myself as manager-gui. We do not expect any other application to run on the server but ours. I do not know if adding anything to the GlobalNamingResources section is the thing to try, although some documents seemed to hint at that.

When I first started the server I was getting an xml parsing error which I did not track down but with the way things sit now that error is not appearing. I now get a 'Failed to start component' (see below) 'Caused by: java.lang.IllegalArgumentException: Invalid services/Au thorizer in servlet mapping' amongst others.

INFO: Initializing ProtocolHandler ["http-apr-8080"]
Jun 4, 2013 10:36:56 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Jun 4, 2013 10:36:56 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 633 ms
Jun 4, 2013 10:36:56 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 4, 2013 10:36:56 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.40
Jun 4, 2013 10:36:56 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive D:\apache-tomcat-7\apache-tomcat-7.0.40\
webapps\SupplierNetRelease.war
Jun 4, 2013 10:36:56 AM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'Context/resource'.
Jun 4, 2013 10:37:00 AM org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngin
e[Catalina].StandardHost[localhost].StandardContext[/SupplierNetRelease]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:901)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87
7)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)

        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)

        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:
1654)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> services/Au
thorizer in servlet mapping
        at org.apache.catalina.core.StandardContext.addServletMapping(StandardCo
ntext.java:3223)
        at org.apache.catalina.core.StandardContext.addServletMapping(StandardCo
ntext.java:3198)
        at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1366)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.jav
a:1353)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfi
g.java:878)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi
g.java:369)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:119)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa
se.java:90)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContex
t.java:5269)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 11 more
Jun 4, 2013 10:37:00 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive D:\apache-tomcat-7\apache-tomcat
-7.0.40\webapps\SupplierNetRelease.war
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catal
ina.LifecycleException: Failed to start component [StandardEngine[Catalina].Stan
dardHost[localhost].StandardContext[/SupplierNetRelease]]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:904)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:87
7)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)

        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)

        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:
1654)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Jun 4, 2013 10:37:00 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive D:\apache-tomcat-7\apache-tomcat-7.0.40\
webapps\WebServices.war                  <-------------------------------------- test app I deployed
Jun 4, 2013 10:37:00 AM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'Context/resource'.
Jun 4, 2013 10:37:01 AM com.sun.xml.ws.transport.http.servlet.WSServletDelegate
<init>
INFO: WSSERVLET14: JAX-WS servlet initializing
Jun 4, 2013 10:37:01 AM com.sun.xml.ws.transport.http.servlet.WSServletContextLi
stener contextInitialized
INFO: WSSERVLET12: JAX-WS context listener initializing
Jun 4, 2013 10:37:01 AM com.sun.xml.ws.transport.http.servlet.WSServletContextLi
stener contextInitialized
INFO: WSSERVLET12: JAX-WS context listener initializing
Jun 4, 2013 10:37:01 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7\apache-tomcat-7.0.4
0\webapps\docs
Jun 4, 2013 10:37:01 AM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'Context/resource'.
Jun 4, 2013 10:37:01 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7\apache-tomcat-7.0.4
0\webapps\examples
Jun 4, 2013 10:37:01 AM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'Context/resource'.
Jun 4, 2013 10:37:02 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7\apache-tomcat-7.0.4
0\webapps\host-manager
Jun 4, 2013 10:37:02 AM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'Context/resource'.
Jun 4, 2013 10:37:02 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7\apache-tomcat-7.0.4
0\webapps\manager
Jun 4, 2013 10:37:02 AM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'Context/resource'.
Jun 4, 2013 10:37:03 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7\apache-tomcat-7.0.4
0\webapps\ROOT
Jun 4, 2013 10:37:03 AM org.apache.tomcat.util.digester.Digester endElement
WARNING:   No rules found matching 'Context/resource'.
Jun 4, 2013 10:37:03 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Jun 4, 2013 10:37:03 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Jun 4, 2013 10:37:03 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 6755 ms

If someone can suggest something I would appreciate it. If you want to see more, let me know clearly what it is you want to see. We want this to run with no context but that is secondary at this point. I apologize if I missed something obvious. Thanks in advance.

2
Server Fault may be a better place for this question.Maerlyn

2 Answers

0
votes

Per the specification, a url-pattern like this must begin with a /. Change your web.xml to:

<url-pattern>/services/Authorizer</url-pattern>
0
votes

WARNING: No rules found matching 'Context/resource'.

This is a serious problem! Remember, the contents of context.xml are case-sensitive!