oracle11g+tomcat 安装war包出错:IO 错误: The Network Adapter could not establish the connection

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle11g+tomcat 安装war包出错:IO 错误: The Network Adapter could not establish the connection相关的知识,希望对你有一定的参考价值。

在笔记本上搭建了oracle11g+tomcat,安装一个war包,报一下错误:
Trace: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (IO 错误: The Network Adapter could not establish the connection)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:359)
org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:275)
org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:344)
org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:272)
org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
com.shineyo.cmwiki.filter.LogMDCFilter.doFilter(LogMDCFilter.java:38)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

连接数据库失败,你拿个其他工具连一下试试,比如sqldeveloper。如果确定数据库启动了,那么查一下防火墙,用户名密码追问

工具是可以连接的,说明,1521端口可以访问。
oracle相关服务都是启动状态。
用户名跟密码是正确的。
防火墙未开启。

追答

连接字符串是怎么配的?TNSListener确定打开了吗?
拿The Network Adapter could not establish the connection这句去百度一下,很多原因会导致这个现象的发生,你得挨个试

参考技术A 你是WIN7系统吧?访问权限没开追问

是win7
继续,怎么开启?

Linux Tomcat8无法解压war包

在使用公司的linux服务器的时候,将项目打成war包丢到tomcat8容器下的时候,启动运行tomcat总是无法解压war包,导致编译出错。但是将项目解压好直接放在tomcat容器的webapps目录下可以直接运行。初步想法就是tomcat不能正常解压war包。

查看tomcat的server.xml配置文件

<?xml version='1.0' encoding='utf-8'?> 
<Server port="8005" shutdown="SHUTDOWN"> 
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> 
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
 
  <GlobalNamingResources> 
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources> 
  <Service name="Catalina"> 
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               maxHttpHeaderSize="24576"
               maxThreads="500"
               acceptCount="600"
               maxConnections="2000"
               enableLookups="false"
               URIEncoding="utf-8"
               disableUploadTimeout="true"
               compression="on" 
               compressionMinSize="2048" 
               compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" 
               redirectPort="8443" /> 
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 
    <Engine name="Catalina" defaultHost="localhost"> 
      <Realm className="org.apache.catalina.realm.LockOutRealm"> 
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm> 
      <Host name="localhost"  appBase="webapps"
            unpackWARs="false" autoDeploy="false"> 
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="tomcat_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>

其中影响war包自动解压的代码就是

 <Host name="localhost" appBase="webapps" unpackWARs="false" autoDeploy="false"> 
  • appBase=“xxx/xxx” 表示项目的路径,有的默认为null,有的默认为webapps,是tomcat容器存放项目的目录
  • unpackWARs=“true” 表示是否自动解压war包,true为自动解压
  • autoDeploy=“true” 表示是否在不重启下自动解压war包,true为自动解压

只要把unpackWARs和autoDeploy的属性改成true并重启tomcat就可以实现tomcat自动解压war包。

参考文章

Linux下 解决Tomcat8不自动解压war包

以上是关于oracle11g+tomcat 安装war包出错:IO 错误: The Network Adapter could not establish the connection的主要内容,如果未能解决你的问题,请参考以下文章

Tomcat war包部署

Linux Tomcat8无法解压war包

Linux Tomcat8无法解压war包

tomcat部署时war包解压慢

如何部署war包到tomcat

tomcat修改war包路径