Could not load java.net.BindException异常的解决办法

本文介绍了一个关于MyEclipse环境下重启Tomcat时出现的异常问题及其解决方案。异常表现为二次加载MySQL JDBC驱动导致的问题,通过将驱动文件移至Tomcat的lib目录解决了这一难题。

转载自:http://blog.youkuaiyun.com/a5489888/article/details/6641417


系统配置, MyEclipse6.5+tomcat6.0+MySQL+Struts2症状如下: 在启动 tomcat ,并发布应用后没有问题,但是如果重新发布就出现如下异常:this web application instance has been stopped already. Could not load java.net.BindExceptionthis web application instance has been stopped already. Could not load com.mysql.jdbc 这是由于 MySQL 的 JDBC 驱动放在应用的 WEB-INF\lib 目录下,在重新发布时其加载了两次,故只要将其拷贝到 TOMCAT_HOME%\lib 中即可解决该问题。解决这两个异常可以将 MySQL 的驱动文件从 WEB-INF\lib 文件夹中移动到 %TOMCAT_HOME%\lib 中。

2025-09-16 15:00:23,186 [main] INFO [com.opensymphony.xwork2.spring.SpringObjectFactory] - Setting autowire strategy to name 2025-09-16 15:00:23,186 [main] INFO [org.apache.struts2.spring.StrutsSpringObjectFactory] - ... initialized Struts-Spring integration successfully 九月 16, 2025 3:00:35 下午 org.apache.cxf.transport.servlet.CXFServlet updateContext 信息: Load the bus with application context 九月 16, 2025 3:00:35 下午 org.apache.cxf.transport.servlet.AbstractCXFServlet replaceDestinationFactory 信息: Servlet transport factory already registered 2025-09-16 15:00:35,381 [main] INFO [org.apache.cxf.bus.spring.BusApplicationContext] - Refreshing org.apache.cxf.bus.spring.BusApplicationContext@75803b11: startup date [Tue Sep 16 15:00:35 CST 2025]; parent: Root WebApplicationContext 2025-09-16 15:00:35,392 [main] INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@638fff71: defining beans []; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@346fb908 九月 16, 2025 3:00:35 下午 org.apache.coyote.http11.Http11Protocol init 严重: Error initializing endpoint java.net.BindException: Address already in use: JVM_Bind <null>:8080 at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549) at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:176) at org.apache.catalina.connector.Connector.initialize(Connector.java:1014) at org.apache.catalina.startup.Embedded.start(Embedded.java:830) at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558) at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289) at org.apache.maven.cli.MavenCli.main(MavenCli.java:193) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347) at org.codehaus.classworlds.Launcher.main(Launcher.java:47) Caused by: java.net.BindException: Address already in use: JVM_Bind at java.net.DualStackPlainSocketImpl.bind0(Native Method) at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.<init>(ServerSocket.java:237) at java.net.ServerSocket.<init>(ServerSocket.java:181) at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:50) at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538) ... 28 more [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:06 min [INFO] Finished at: 2025-09-16T15:00:35+08:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:run (default-cli) on project PowerDesk: Could not start Tomcat: Protocol handler initialization failed: java.net.BindException: Address already in use: JVM_Bind <null>:8080 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 已与地址为 ''127.0.0.1:1773',传输: '套接字'' 的目标虚拟机断开连接 进程已结束,退出代码为 1 分析下报错
最新发布
09-17
帮我解释如下日志有什么问题:C:\Users\17362\.jdks\corretto-1.8.0_442\bin\java.exe -Dcatalina.home=C:\Users\17362\tomcat9 -Dcatalina.base=C:\Users\17362\.SmartTomcat\journal\期刊 -Djava.io.tmpdir=C:\Users\17362\.SmartTomcat\journal\期刊\temp -Djava.util.logging.config.file=C:\Users\17362\.SmartTomcat\journal\期刊\conf\logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2024.3.4.1\lib\idea_rt.jar=52038" -Dfile.encoding=UTF-8 -classpath C:\Users\17362\tomcat9\bin\bootstrap.jar;C:\Users\17362\tomcat9\bin\tomcat-juli.jar org.apache.catalina.startup.Bootstrap start 16-Jun-2025 18:42:06.417 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server.服务器版本: Apache Tomcat/9.0.31 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器构建: Feb 5 2020 19:32:12 UTC 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 服务器版本号(:9.0.31.0 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 11 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS.版本: 10.0 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log 架构: amd64 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java 环境变量: C:\Users\17362\.jdks\corretto-1.8.0_442\jre 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM 版本: 1.8.0_442-b06 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM.供应商: Amazon.com Inc. 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\17362\.SmartTomcat\journal\期刊 16-Jun-2025 18:42:06.419 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: C:\Users\17362\tomcat9 16-Jun-2025 18:42:06.422 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Users\17362\tomcat9 16-Jun-2025 18:42:06.422 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\17362\.SmartTomcat\journal\期刊 16-Jun-2025 18:42:06.422 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Users\17362\.SmartTomcat\journal\期刊\temp 16-Jun-2025 18:42:06.422 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\17362\.SmartTomcat\journal\期刊\conf\logging.properties 16-Jun-2025 18:42:06.422 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 16-Jun-2025 18:42:06.423 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2024.3.4.1\lib\idea_rt.jar=52038 16-Jun-2025 18:42:06.423 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dfile.encoding=UTF-8 16-Jun-2025 18:42:06.423 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.7.0]. 16-Jun-2025 18:42:06.423 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 16-Jun-2025 18:42:06.423 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL配置:useAprConnector[false],useOpenSSL[true] 16-Jun-2025 18:42:06.431 信息 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1c 28 May 2019] 16-Jun-2025 18:42:06.641 信息 [main] org.apache.coyote.AbstractProtocol.init 初始化协议处理器 ["http-nio-8080"] 16-Jun-2025 18:42:07.182 严重 [main] org.apache.catalina.util.LifecycleBase.handleSubClassException 初始化组件[Connector[HTTP/1.1-8080]]失败。 org.apache.catalina.LifecycleException: Protocol handler initialization failed at org.apache.catalina.connector.Connector.initInternal(Connector.java:1013) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) at org.apache.catalina.core.StandardService.initInternal(StandardService.java:533) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:1057) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) at org.apache.catalina.startup.Catalina.load(Catalina.java:584) at org.apache.catalina.startup.Catalina.load(Catalina.java:607) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:303) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473) Caused by: java.net.BindException: Address already in use: bind at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:461) at sun.nio.ch.Net.bind(Net.java:453) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:222) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:85) at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:229) at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:212) at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141) at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1154) at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:581) at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:74) at org.apache.catalina.connector.Connector.initInternal(Connector.java:1010) ... 13 more 16-Jun-2025 18:42:07.184 信息 [main] org.apache.catalina.startup.Catalina.load 服务器在[976]毫秒内初始化 16-Jun-2025 18:42:07.210 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina] 16-Jun-2025 18:42:07.210 信息 [main] org.apache.catalina.core.StandardEngine.startInternal 正在启动 Servlet 引擎:[Apache Tomcat/9.0.31] 16-Jun-2025 18:42:07.218 信息 [main] org.apache.catalina.startup.HostConfig.deployDescriptor Deploying deployment descriptor [C:\Users\17362\.SmartTomcat\journal\期刊\conf\Catalina\localhost\BBS.xml] 16-Jun-2025 18:42:07.229 警告 [main] org.apache.catalina.startup.HostConfig.deployDescriptor The path attribute with value [/BBS] in deployment descriptor [C:\Users\17362\.SmartTomcat\journal\期刊\conf\Catalina\localhost\BBS.xml] has been ignored 16-Jun-2025 18:42:09.828 信息 [main] org.apache.jasper.servlet.TldScanner.scanJars 至少有一个JAR被扫描用于TLD但尚未包含TLD。 为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。 在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。 16-Jun-2025 18:42:09.892 信息 [main] org.springframework.web.context.ContextLoader.initWebApplicationContext Root WebApplicationContext: initialization started 16-Jun-2025 18:42:09.980 信息 [main] org.springframework.web.context.support.XmlWebApplicationContext.prepareRefresh Refreshing Root WebApplicationContext: startup date [Mon Jun 16 18:42:09 CST 2025]; root of context hierarchy 16-Jun-2025 18:42:10.057 信息 [main] org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions Loading XML bean definitions from URL [file:/C:/Users/17362/Documents/NetBeansProjects/BBS/build/web/WEB-INF/classes/applicationContext.xml] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. MLog initialization issue: slf4j found no binding or threatened to use its (dangerously silent) NOPLogger. We consider the slf4j library not found. 16-Jun-2025 18:42:11.743 信息 [MLog-Init-Reporter] com.mchange.v2.log.MLog. MLog clients using java 1.4+ standard logging. 16-Jun-2025 18:42:11.814 信息 [main] com.mchange.v2.c3p0.C3P0Registry. Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10] ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console... 16-Jun-2025 18:42:13.302 信息 [main] com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource. Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> rvre4gbbxdysph1ss8stn|6fab250b, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> rvre4gbbxdysph1ss8stn|6fab250b, idleConnectionTestPeriod -> 0, initialPoolSize -> 1, jdbcUrl -> jdbc:mysql://localhost/bbs, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 20, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 40, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
06-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值