ITeye博客

2013 年文章归档

共 31 篇文章

java.lang.IllegalStateException: The request associated with the AsyncContext ha

在使用Servlet3.0的异步特性时,免不了会遇到下面这个异常 java.lang.IllegalStateException: The request associated with the AsyncContext has already completed processing. at org.apache.catalina.core.AsyncContextImpl.check(AsyncContextImpl.java:521) at org.apache.catalina.core.AsyncContextImpl.getResponse(AsyncContextImpl.ja…

2013-12-27 11:09 · 常见问题

The display name was defined in multiple fragments with different values includi

在使用Servlet3.0的新特性中关于WebFragment的特性,即将一些功能打包到jar包中,在web-fragment.xml中声明一些Servlet、Filter,如果使用annotation,此处基本不需要什么配置就可以。 将各个功能的jar加到某个Web应用中,该Web应用就具有了jar包中声明的这些功能。 但在使用Eclipse开发的时候,比如新创建了两个Web Fragment Project,并将其加到某个Web应用中,此时部署到Web容器中会产生如下异常信息 The display name was defined in multiple fragments with …

2013-12-06 11:13 · 常见问题

java.lang.IllegalStateException: Not supported.at org.apache.catalina.connector.

在使用Servlet3.0的异步特性的时候,经常会遇到如下异步,表示不支持异步特性。 在Tomcat中的异常是: java.lang.IllegalStateException: Not supported. at org.apache.catalina.connector.Request.startAsync(Request.java:1673) 在Jetty中是: java.lang.IllegalStateException: !asyncSupported at org.eclipse.jetty.server.Request.startAsync(Request.java:1982…

2013-12-04 14:30 · 常见问题

java中出现的ConcurrentModificationException产生原因,解决方式及其它

JAVA开发中有时会出现ConcurrentModificationException,该异常是由于在遍历Collection的时候做了删除或者增加的操作,此时原来统计的size和新的size并不一致,产生了该异常。下面是stackOverflow上的解释: Here's why: As it is says in the Javadoc: The iterators returned by this class's iterator and listIterator methods are fail-fast: if the list is structurally modified at…

2013-08-23 14:55 · 常见问题

windows中有用的查找端口占用的命令

在windows中可以使用如下命令,查看端口昌被哪个程序占用。 C:\Users\ho>netstat -aon | findstr "8080" TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 7528 TCP [::]:8080 [::]:0 LISTENING 7528 C:\Users\ho>tasklist | findstr "7528" java.exe 7528 Console 1 205,960 K

2013-07-19 15:43 · 常见问题

ClientCommunicatorAdmin restart/Checker-run 等异常的处理

在做JMX相关的开发过程中,下面这个异常一个会遇到: 2013-7-11 15:58:05 ClientCommunicatorAdmin restart 警告: Failed to restart: java.io.IOException: Failed to get a RMI stub: javax.naming.ServiceUnavailableException [root exception is java.rmi.connectexception: connection refused to host: 10.10.4.18; nested exception is: jav…

2013-07-15 19:32 · 常见问题

jmx的ObjectName中key对应的value的获取

之前开发中用到JMX的地方,如果需要根据ObjectName中某个特定值进行判断,都是把ObjectName执行toString()后,再截取字符串,今天发现原来ObjectName中有个方法 /** * Obtains the value associated with a key in a key property. * * @param property The property whose value is to be obtained. * * @return The value of the property, or null if there is no such * prop…

2013-07-11 14:12

Apache启动异常:apache service unable to open logs

当启动Apache时,如果弹出窗口提示 unable to open logs ,在windows的事件日志是说明 The Apache service named reported the following error: >>> Unable to open logs . 这种情况是本地有程序和Apache的端口冲突,导致Apache启动异常。常见的是Apache的80端口被占用。 解决方式:更改端口 以下信息转自StackOverFlow: The following error usually means that some other program is listening on…

2013-07-04 15:09 · 常见问题

VBox异常退出后,不能启动问题的解决办法

今天把VBox中的进程强制停止后,启动VBox的时候,Ubuntu出错,不能启动,菜单中只有刷新,什么都不能操作了,出错信息大概如下: Runtime error opening 'xxx/xxx/xx.vbox' for reading: -102 (File not Found)..... 不知道怎么去解决了,网上的解决方式是在linux系统下的,后来找到个国外的网站查到了方法,其实只需要把Vobx下虚拟机的vbox文件重命名就可以了。异常关机后,vbox文件被重命令为xxx.vbox-temp,只要把-temp去掉,再次打开VBox,虚拟机就可以正常使用了。

2013-06-26 15:01 · 常见问题

JConsole背后

最近做监控相关的事情,要把本地的所有JAVA应用管理起来,但这些应用的JDK1.4的,有1.5的,1.6的,而且在JDK1.5之前的应用提供的MBeanServer并不是PlatformMBeanServer,这就导致监控时获取堆的信息,线程,Runtime等一些属性的时候没法获取。本打算改造运行在JDK1.4上跑的应用,使其使用PlatFormMBeanServer,但JDK1.4好像并没有提供获取PlatFormMBeanServer的方式,大致想到了以下几个思路: 1.升级JDK,但可能会影响原来应用,因为JDK1.4的时候一些语法像enum这些都还不是关键字。 2.如果可以升级JDK…

2013-06-19 17:27 · 开源软件和算法

JAXB annotation说明及其使用

最近学习REST,,由于jersey的demo中用到了JAXB,就顺便了解了一下。 JAXB的概念一类的就不记录了。 其常用的annotation有如下几个: @XmlType @XmlElement @XmlRootElement @XmlAttribute @XmlAccessorType @XmlAccessorOrder @XmlTransient @XmlJavaTypeAdapter 其中 @XmlType @XmlRootElement @XmlAccessorType @XmlAccessorOrder 用在类之上。 对于一个类,可以使用@XmlAccessorType(Xm…

2013-06-14 14:59 · JEE相关

InetAddress.getLocalHost().getHostAddress()获取的IP不正确

今天把在Windows下运行很正常的程序拿到Linux下测试,却出现了问题,经过检查发现是InetAddress.getLocalHost().getHostAddress() 取本地IP地址时出现了问题。因为期望得到的IP是222.xxx.xxx.xx,但实际打印出来的IP地址却是127.0.0.1。 查看 /etc/hosts 文件,里面有一条本机名和 222.xxx.xxx.xx这个 IP 对应的记录。把它注释掉,然后修改本机的主机名,又在 hosts 文件中加入主机名和222. xx.xx.xx的对应,问题解决了。 通过问题的解决方法,我们可以发现InetAddress.getLoc…

2013-06-09 17:43 · 常见问题

设置rmi引用的fullGC(DGC)的执行频率

经常在应用服务器的启动脚本中看到这样的配置: -Dsun.rmi.dgc.client.gcInterval=3600000 该配置的作用是 One of the most commonly encountered uses of explicit garbage collection occurs with RMI's distributed garbage collection (DGC). Applications using RMI refer to objects in other virtual machines. Garbage cannot be collected in t…

2013-06-09 10:52

获取JVM的所有可选参数

使用如下命令可以列出所有java可选的参数 java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version "-XX:+UnlockExperimentalVMOptions". 也可以,和-XX:+UnlockDiagnosticVMOptions会列出几个不同的参数

2013-05-30 17:54 · 常见问题

获取当前用户所有java进程及jps命令的实现

我们在开发中经常会遇到这样的问题,需要把本地运行的所有某个Java应用找出来,以便于执行某种操作。所以,常见的想法是在不同的平台采用不同的实现方式: 在windows下使用netstat,linux下使用ps -ef。相对来说linux下更方便,因为ps -ef可以把详细的jvm参数和文件路径也列出来,更方便程序操作。当然,如果你使用过java的jps工具的话,感觉会更方便。 jps的usage: usage: jps [-help] jps [-q] [-mlvv] [<hostid>] Definitions: <hostid>: <hostname>[:<port>] 只需要在命令行中…

2013-05-21 17:24 · JEE相关

在windows中获取某个进程的具体执行路径

经常遇到要处理某类问题,知道某个具体进程,但是却不知道真正的执行路径的情况。也许有人会说,在windows下打开任务管理器就可以看到了。但是如果是程序中需要获取呢? 今天google发现一篇文章写的不错,在windows下要获取具体的路径可以使用powershell 例如我们要查看chrome的执行路径,可以在cmd中这样写: powershell "get-process chrome | select-object path" 这们就会把chrome的完整路径列出来。在linux下很容易就不说了。 ps:出处:http://frankgilroy.com/2012/03/06/getti…

2013-05-20 17:55 · 常见问题

java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is

今天在学RMI的时候遇到了这个问题: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: 后来是通过在class同一个目录启动start rmiregistry来解决的。 另外,这篇文章介绍的比较全面,可以参考: http://blog.163.com/hero_213/blog/static/39891214200931822122599/

2013-05-08 17:49 · 常见问题

java中的toString()和(String)obj的区别

java中的toString()和(String)obj的区别 “转”这个术语,其实是不确切的,或者说是不科学的。 一个对象一经建立,其类型已经确定,所谓的“强转”不过是强行改变你看待它的方式。所以,英文中类型“转换”叫做Type Casting或者Class Casting,使用cast以说明改变的是其外在。 SQL Server有一个用来转型的函数叫做cast,后来提供了另一个函数叫做convert,二者略有不同,相差很小,官方推荐用convert,其实就是因为这两个函数实际上改换了数据的内在类型,所以用convert表述更为精准。 理解了我这段话,你就知道toString和强“转”之间…

2013-04-22 18:07 · 常见问题

Struts2 Dispatcher initialization failed No mapping found for dependency default

在struts2的使用时如果发现以下异常信息, 严重: Dispatcher initialization failed com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyException: No mapping found for dependency [type=com.opensymphony.xwork2.ObjectFactory, name='default'] in public void com.o…

2013-04-10 16:41 · 常见问题

Struts2的devMode

今天在debug Struts2的源码的时候发现,当在struts.xml中配置了devMode为true时,源码中会把设置以下几项: if ("true".equalsIgnoreCase(props.getProperty(StrutsConstants.STRUTS_DEVMODE))) { props.setProperty(StrutsConstants.STRUTS_I18N_RELOAD, "true"); props.setProperty(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true"); props.setP…

2013-04-10 16:30 · 开源软件和算法