将WebSphere App移植到运行Java 6的TOMCAT 7
我们只是想看看是否可以做到这一点。我们不使用EJB。该应用程序已有10年历史,并连接到Oracle数据库(11g)。我们一直在添加并修改它,因为它正在大量使用。它一直在Websphere 6.1下运行,并且有几个JAX-RPC Web服务。我让它在WebSphere 8.5上运行但成本不变,我们决定尝试使用TOMCAT 7和JUNO。
我没有与Tomcat广泛合作,因为这是一家IBM商店。更多的应用程序似乎正在使用Tomcat,所以我更愿意学习。我安装了Eclipse - Juno,在我的工作区中,我在创建一个新的动态Web项目后引入了应用程序文件。我们的应用程序部署为EAR文件,但在这里我将它部署为WAR文件。构建时出现了许多警告和错误。
我安装了TOMCAT并使用我在网上找到的部署并正确运行的小型webServices应用程序教程对其进行了测试。我把服务器带进了我的项目 通过查找jar文件并将其移入WEB / lib或Tomcat lib目录,可以快速解决大多数编译错误。例如,ojdbc6.jar文件位于Tomcat lib中。
我现在不打算进行最佳配置,我们只是想看看能否让它发挥作用。这就是为什么我将com.ibm.ws.runtime.jar移动到应用程序的WEB-INF库中以清除大多数编译错误。我们绝对不希望使用它,但如果我们让它运行,我们将进一步尝试删除它并重新生成Web服务。我很快就得到了一个干净的编译。
我确实让Data Source Explorer将数据库连接识别为一边,但我在启动应用程序时遇到了麻烦。这就是我所做的 在我的应用程序web.xml文件的顶部,我添加了一个Oracle数据库条目,如下所示:
<?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>.........
我想知道我是否应该重新生成这个jsut移植到应用程序的文件?它显示了web-app version =“2.5”,尽管Tomcat 7可以与3.0一起工作。我相信。
在Tomcat的context.xml文件中,我添加了:
...<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>
到目前为止,我没有对server.xml文件进行任何更改。在tomcat-Users.xml中,我将自己添加为manager-gui。我们不希望任何其他应用程序在服务器上运行,但我们的应用程序。 我不知道是否要向GlobalNamingResources部分添加任何东西是值得尝试的,尽管有些文件似乎暗示了这一点。
当我第一次启动服务器的时候,我得到了一个xml解析错误,我没有追踪到这个错误,但现在的情况是错误没有出现。 我现在得到一个'启动组件失败'(见下文)'引起:java.lang.IllegalArgumentException:无效的服务/ Au 在servlet映射中的thorizer'等等。
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
如果有人能提出建议我会很感激。如果你想看到更多,请让我清楚地知道你想看到的是什么。我们希望它在没有上下文的情况下运行,但也就是说 在这一点上是次要的。如果我错过了一些明显的东西,我道歉。提前谢谢。
答案 0 :(得分:0)
根据规范,像这样的网址格式必须以/
开头。将您的web.xml更改为:
<url-pattern>/services/Authorizer</url-pattern>
答案 1 :(得分:0)
警告:找不到与“上下文/资源”匹配的规则。
这是一个严重的问题!请注意,context.xml
的内容区分大小写!