常见错误与解决方案:html
错误一、服务器重启后,自动中止java
解决办法:通常查看E:\Program Files\Apache Software Foundation\Tomcat 7.0\logs,tomcat安装目录下面的tomcat7-stderr.2014-05-10.txt,通常性错误须要在这里面找,错误以下:mysql
严重: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.startup.Catalina.start(Catalina.java:689)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
后来,装了又重启机器,仍是不行,而后在重装。目标定位在context上面(service.xml里面的加上的一句话)。看看他到底如何影响你的服务器的。其实,这个能够理解为将服务器的启动项的地址改不了,每次都不会从原来的tomcat里面去找,而是从咱们改变的目录底下去找启动文件,而后执行里面的操做。这些操做都是编译完的。web
web.xml文件以下:sql
<?xml version="1.0" encoding="UTF-8"?> <web-app> <servlet> <servlet-name>poi</servlet-name> <servlet-class>zhuxuekui.service.SrvPoi</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>poi</servlet-name> <url-pattern>/poi</url-pattern> </servlet-mapping> </web-app>
千万千万不要写错,也不要多写,以前在servlet里面套servlet太不该该,一句的结尾与结束,确定有其缘由。还有就是假如你以前没错,后来忽然错了,你就不要在搞之前的操做了。错误确定发生在后面,而不是前面。这个必定要注意。我是深受其害。数据库
servlet里面的文件能够从下往上看,首先在手机客户端配置好ip地址+/poi(局域网便可),当程序执行到这一步的时候,服务器自动搜索web.xml中的/poi,而后经过servlet-name,找到servlet中的servlet-name,而后找到包名+类名的类。这个其实就有一对标签。servlet 以及 servlet映射。这个操做其实就是经过http通讯协议,数据协议用的JSON,而后将数据经过tomcat服务器传至mysql数据库。这二者之间的联系经过两个函数:手机客户端的post 与 服务器端的dopost ,并且,每次他俩都是一对同时执行,就如上面我刚刚讲到的同样,假如客户端提交的是post请求,那么服务器端执行SrvPoi类中的dopost(),来处理请求,一一对应。apache
错误二、mysqlworkbench 删掉原来的表后,没法重现再建表。浏览器
解决方案:一、不删,直接修改表名,表里面的字段,而不用删除。tomcat
二、查找与删除要用合适的方案,不要一味的删数据库或者表。这个操做,貌似还须要重启workbench。服务器
错误三、每次执行到下面这步,程序出错。
TransactionManager.callInTransaction(getConnectionSource(), new Callable<Void>() { @Override public Void call() throws Exception { ArrayList<MKPoiInfo> bdPois = res.getAllPoi(); ArrayList<Poi> pois = new ArrayList<Poi>(); for (MKPoiInfo poi : bdPois) { Poi p = new Poi(poi, "测试用户"); create(p); pois.add(p); } sendPoiToServer(pois); return null; } }); 2014/5/10 21:05:36 程序运行到这一步出错。这是啥问题,请教。
在咱们调试错误的时候,学会看日志有时候事半功陪,有些时候纠结不少什么都未必能解决。因此调试时 须要 单步调试(第一个警告栏不用按下)+日志。错误以下:
缘由:col_id须要惟一,重复插入相同的数据会失败。
这里介绍下,为何虚拟机能够与服务器端联系在一块儿,而手机有时候却不行。
主要仍是上面的缘由,因此在手机上调试的时候,必需要卸载再卸载。而后在测试。咱们能够经过捕捉发现错误之所在。
错误四、如何保证数据传输过去。
解决:一、保证防火墙关闭 二、最好在一个局域网下 三、保证手机浏览器与电脑浏览器均可以链接服务器。能够多测测。IP地址必定要对。
截图: