ja-sig (cas)项目移植到linux(centos6)发生java.net.UnknownHostException: cloud: 未知的名称或服务

时间:2022-03-16 00:38:02

今天把win7下的cas项目移植到linux服务器

没想到报了这个错

java.net.UnknownHostException: cloud: 未知的名称或服务
具体如下:

root cause

java.net.UnknownHostException: cloud: cloud: 未知的名称或服务
	java.net.InetAddress.getLocalHost(InetAddress.java:1473)
	org.springframework.webflow.util.RandomGuid.<clinit>(RandomGuid.java:106)
	org.springframework.webflow.util.RandomGuidUidGenerator.generateUid(RandomGuidUidGenerator.java:48)
	org.springframework.webflow.conversation.impl.SessionBindingConversationManager.beginConversation(SessionBindingConversationManager.java:113)
	org.springframework.webflow.execution.repository.support.AbstractConversationFlowExecutionRepository.generateKey(AbstractConversationFlowExecutionRepository.java:95)
	org.springframework.webflow.executor.FlowExecutorImpl.launch(FlowExecutorImpl.java:190)
	org.springframework.webflow.executor.support.FlowRequestHandler.handleFlowRequest(FlowRequestHandler.java:125)
	org.springframework.webflow.executor.mvc.FlowController.handleRequestInternal(FlowController.java:165)
	org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
	org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	org.jasig.cas.web.init.SafeDispatcherServlet.service(SafeDispatcherServlet.java:115)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	org.inspektr.common.web.ClientInfoThreadLocalFilter.doFilterInternal(ClientInfoThreadLocalFilter.java:48)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
一开始以为是cas中涉及到spring的某些包到了linux版本不对应.比如
org.springframework.webflow.util.RandomGuid
报错中的这些类啊.

到后面仔细研究这句错误

java.net.UnknownHostException: cloud: cloud: 未知的名称或服务

应该是主机名未找到,

虽然不知道cas这个框架哪部分会用到获取主机名,不过找到问题关键就好办了

找到位于/etc/hosts这个文件

cloud是我的主机名,把它与127.0.0.1绑定好就行了.