MINA的第一个例子终于能运行了__2

[url=http://leo.iteye.com/admin/show/34019]MINA的第一个例子终于能运行了__1[/url]

二、
将mina包换成1.0,并引入mina-filter-ssl-1.0.0.jar后再执行,报错[code]java.lang.NoClassDefFoundError: edu/emory/mathcs/backport/java/util/concurrent/Executor[/code]
原来是mina1.0硬引入了别的类文件[code]import edu.emory.mathcs.backport.java.util.concurrent.Executor;[/code]
于是乎我就把整个[url=http://dcl.mathcs.emory.edu/cgi-bin/viewvc.cgi/software/harness2/trunk/util/backport-util-concurrent/src/edu/?pathrev=2594]edu.emory.mathcs.backport.java.util包[/url]给down了下来,并引入工程echoserver(mina1.0中的example)。但是里面的关于assert的代码全部报错,忽略这个错误,执行程序,正确执行,但是后台报错(估计由于那个assert的问题引起的)
[code]
9109 [AnonymousIoService-1] INFO org.apache.mina.example.echoserver.EchoProtocolHandler - [/127.0.0.1:2306] OPENED
java.lang.Error: Unresolved compilation problems:
assert cannot be resolved to a type
Duplicate local variable state
Syntax error on token "!=", = expected
assert cannot be resolved to a type
Syntax error on token "==", = expected

at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.workerDone(ThreadPoolExecutor.java:544)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:679)
at java.lang.Thread.run(Thread.java:534)
11328 [AnonymousIoService-2] INFO org.apache.mina.example.echoserver.EchoProtocolHandler - [/127.0.0.1:2306] RECEIVED: DirectBuffer[pos=0 lim=9 cap=2048: 7A 68 61 6E 67 6C 65 0D 0A]
11328 [AnonymousIoService-2] INFO org.apache.mina.example.echoserver.EchoProtocolHandler - [/127.0.0.1:2306] WRITE: DirectBuffer[pos=0 lim=9 cap=16: 7A 68 61 6E 67 6C 65 0D 0A]
java.lang.Error: Unresolved compilation problems:
assert cannot be resolved to a type
Duplicate local variable state
Syntax error on token "!=", = expected
assert cannot be resolved to a type
Syntax error on token "==", = expected

at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.workerDone(ThreadPoolExecutor.java:544)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:679)
at java.lang.Thread.run(Thread.java:534)
11328 [AnonymousIoService-3] INFO org.apache.mina.example.echoserver.EchoProtocolHandler - [/127.0.0.1:2306] SENT: DirectBuffer[pos=0 lim=9 cap=16: 7A 68 61 6E 67 6C 65 0D 0A]
java.lang.Error: Unresolved compilation problems:
assert cannot be resolved to a type
Duplicate local variable state
Syntax error on token "!=", = expected
assert cannot be resolved to a type
Syntax error on token "==", = expected

at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.workerDone(ThreadPoolExecutor.java:544)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:679)
at java.lang.Thread.run(Thread.java:534)
15797 [AnonymousIoService-4] INFO org.apache.mina.example.echoserver.EchoProtocolHandler - [/127.0.0.1:2306] CLOSED
java.lang.Error: Unresolved compilation problems:
assert cannot be resolved to a type
Duplicate local variable state
Syntax error on token "!=", = expected
assert cannot be resolved to a type
Syntax error on token "==", = expected

at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.workerDone(ThreadPoolExecutor.java:544)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:679)
at java.lang.Thread.run(Thread.java:534)

[/code]
这个问题怎么解决啊??


找到了,解决办法:
JDK1.4版新加入的assertion机制(关键词:assert),由于JDK1.4编译器
预设是兼容1.3,所以要使用assert必须在编译时加上-source 1.4的参数.

C:\>javac -source 1.4 XXX.java
执行时则必须加-ea 或-enableassertions参数启动。

C:\>java -ea XXX
如要在Eclipse中使用assertion机制,请作以下设定:
设定一:(编译设定)
Windows->Preferance->Java->Compiler->Compliance and Classfiles
页面。将..JDK Compliance level->Compiler compliance level调成1.4。

设定二:(执行设定)
Run->Run->(x)=Arguments页面,在VM arguments加入-da参数,按下
Run button便可看到启动assertion后的执行结果。
(Eclipse 2.1.3 release + assertion测试)
<assert判别为false,所以show出AssertionError>

新版(m8+)的eclipse可以设vm arguments
另外提供一种设法,是在eclipse启动时加入vm arguments(跟加大eclipse预设内存大小的方式一样)
这样就不用每次run都得需去设vm arguments
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值