首先说明一下,来来回回折腾两天,把遇到的问题进行总结。
1、首先到github上下载,这个是分支地址,找到自己想要的版本:https://github.com/apache/incubator-dubbo/releases
我这里版本为incubator-dubbo-dubbo-2.5.4
解压文件之后先进到根目录先安装dubbo依赖,如果没有安装dubbo到时候安装dubbo-admin的时候就会报错,进到目录使用mvn package
等待出现success
提示信息,则说明依赖安装成功,此时可以到你本地的mvn仓库上能看到dubbo-2.5.4-SNAPSHOT.jar
。
目录是在你自己的本地mvn仓库上E:\Program Files\ApacheMaven3.5\MavenRepository\com\alibaba\dubbo\2.5.4-SNAPSHOT
参考自己的目录。
首先进到dubbo-admin模块目录下。
然后百度出一条命令开心的打包mvn package -Dmaven.test.skip=true
。
此时非常开心,终于打包成功。
接下就把打包好的dubbo-admin-2.5.4-SNAPSHOT.war
复制到tomcat的webapps目录下,当然名字太长我这里直接改成dubbo-admin.war
。
此时可以启动tomcat。在tomcat的bin目录下找到startup.bat
,双击运行启动,注意windows下是找到startup.bat
,linux下是startup.sh
。
启动完成后到浏览器输入localhost:8080/dubbo-admin
。
然后百度找dubbo-admin启动404的相关文章,结果还是没有什么用。然后看到tomcat的启动日志文件,结果如下。
16-Oct-2018 10:02:44.155 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\dubbo-admin.war]
16-Oct-2018 10:02:54.888 信息 [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO: configuring "log4j" using file:/E:/InstallPackage/KFPackage/apache-tomcat-8.5.31/webapps/dubbo-admin/WEB-INF/log4j.xml
- with property localAddress = 192.168.100.100
- with property localHost = DESKTOP-1DFSV5L
- with property loggingCharset = UTF-8
- with property loggingLevel = INFO
- with property loggingRoot = C:\Users\Kyrie\logs
INFO context.ContextLoader - Root WebApplicationContext: initialization started
INFO support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Oct 16 10:02:55 CST 2018]; root of context hierarchy
INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:515)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4792)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5256)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
... 25 more
16-Oct-2018 10:02:55.573 严重 [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
16-Oct-2018 10:02:55.584 严重 [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/dubbo-admin] startup failed due to previous errors
INFO support.XmlWebApplicationContext - Closing Root WebApplicationContext: startup date [Tue Oct 16 10:02:55 CST 2018]; root of context hierarchy
WARN support.XmlWebApplicationContext - Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Tue Oct 16 10:02:55 CST 2018]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:427)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:999)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:583)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4839)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
16-Oct-2018 10:02:55.656 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\dubbo-admin.war] has finished in [11,500] ms
16-Oct-2018 10:02:55.661 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\docs]
16-Oct-2018 10:02:55.745 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\docs] has finished in [83] ms
16-Oct-2018 10:02:55.752 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\examples]
16-Oct-2018 10:02:57.497 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\examples] has finished in [1,745] ms
16-Oct-2018 10:02:57.498 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\host-manager]
16-Oct-2018 10:02:57.579 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\host-manager] has finished in [81] ms
16-Oct-2018 10:02:57.580 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\manager]
16-Oct-2018 10:02:57.645 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\manager] has finished in [65] ms
16-Oct-2018 10:02:57.646 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\ROOT]
16-Oct-2018 10:02:57.692 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [E:\InstallPackage\KFPackage\apache-tomcat-8.5.31\webapps\ROOT] has finished in [47] ms
16-Oct-2018 10:02:57.701 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
16-Oct-2018 10:02:57.720 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
16-Oct-2018 10:02:57.729 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 13683 ms
结果发现dubbo-admin并没有启动。出现一个异常,这个异常明显说没有找到一个叫applicationContext.xml的文件,然后完全蒙蔽,别人打包的没问题我打包的居然报错。
ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]
各种百度查找。终于找到一个解决的办法。原来是spring版本太高要换成3.2.9.RELEASE
,然后找到incubator-dubbo-dubbo-2.5.4
下的pom.xml找到spring的版本改成3.2.9.RELEASE
。
附上参考链接:https://my.oschina.net/iioschina/blog/1615086
修改完成之后保存从新打包一份,此时看到dubbo-admin目录下多了一个target文件,可以直接手动删除掉,或者执行命令mvn clean package -Dmaven.test.skip=true
重新打包一份。
此时可以查看一下spring版本是否成功修改,进到lib目录下查看E:\setup\incubator-dubbo-dubbo-2.5.4\dubbo-admin\target\dubbo-admin-2.5.4-SNAPSHOT\WEB-INF\lib
,根据自己目录。
然后又开心的把war包拿丢到webapps下启动tomcat。
看到tomcat启动信息停止一直不动如图
仔细看了一下信息原来是在需要连接zookeeper,然后先关掉tomcat,进到dubbo-admin下的WEB-INF目录下找到dubbo.properties修改zookeeper连接地址。由于我本地没有安装zookeeper,我连接的是阿里云上的zookeeper。
dubbo.registry.address=zookeeper://120.79.135.254:2181
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest
注意:如果是连接阿里云上的zookeeper需要添加安全组规则。开放2181端口才可以,否则会报连接超时错误。这里就不截图了,我这里已经添加好安全级规则。添加安全组规则就不在说明,在本地是没有这个情况的。
此时在次启动tomcat,查看启动日志就没有发现错误,此时访问终于成功了。
默认用户名密码都是root
,登录看到非常完美的dubbo-admin
首页
1、遇到报错需要仔细查看启动日志这些,找对关键字,看是哪个异常报错。
2、本地连接阿里云的服务需要添加对应端口的安全组规则。