在我的webapp中,我创建了一个ExecutorService使用固定大小的ThreadPool的服务.我ExecutorService在整个应用程序生命周期中重复使用它.
private static ExecutorService pool = Executors.newFixedThreadPool(8);
Run Code Online (Sandbox Code Playgroud)
所有都在Tomcat中运行,它在向下发出错误时给出了以下错误:
appears to have started a thread named [pool-1-thread-1] but has failed to stop it. This is very likely to create a memory leak.
Run Code Online (Sandbox Code Playgroud)
我确实意识到我需要在关闭tomcat之前关闭ExecutorService.Soms SO线程已经谈到了这一点,但我找不到一个干净的方法来处理这个问题.
我是否应该ShutdownHook在线程和执行程序的正常关闭中使用@ Tim-bender ?或者我应该使用CachedThreadPool吗?
我正在尝试使用Enum中的所有可用值初始化泛型类.我是我希望它的工作方式:
public class MyClass<E extends Enum<E>> {
E[] choices;
public MyClass() {
choices = E.values();
}
Run Code Online (Sandbox Code Playgroud)
但是,E.valuesEclipse中不接受调用,因为此方法未定义此方法.
接受使用此构造函数,但需要调用者提供值:
public MyClass(E[] e) {
choices = e;
}
Run Code Online (Sandbox Code Playgroud)
在我发现的文档中:
Java编程语言枚举类型比其他语言中的对应类型更强大.枚举声明定义了一个类(称为枚举类型).枚举类主体可以包括方法和其他字段.编译器在创建枚举时会自动添加一些特殊方法.例如,它们有一个静态值方法,该方法返回一个数组,该数组按照声明的顺序包含枚举的所有值.
有没有办法解决这个问题?
我是IntelliJ的新手,但是来自Eclipse我希望Maven的支持要好得多.它确实是,但我找不到如何在IntelliJ(14.1)中定义远程原型目录.
我所能找到的只是一种手动添加Archetype的方法,但这不是我需要的.我想指向远程服务器上的XML文件,其中包含所有可用的原型列表.
在Eclipse中,它看起来像这样:

当我检查JBoss日志时,我发现了很多这些错误
2012-03-29 12:01:27,358 WARN @ [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa] Could not find new XAResource to use for recovering non-serializable XAResource < 131075, 32, 30, 1--53e2af7c:eff6:4ec11bf7:2e1da4-53e2af7c:eff6:4ec11bf7:2e263d >
2012-03-29 12:01:27,398 WARN @ [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa] [com.arjuna.ats.internal.jta.resources.arjunacore.norecoveryxa] Could not find new XAResource to use for recovering non-serializable XAResource < 131075, 31, 29, 1--53e2af7c:d397:4e8c1b0e:25b6d-53e2af7c:d397:4e8c1b0e:29d09 >
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试发送JMS消息时,我看到了这个错误:
2012-03-29 12:02:43,778 WARN @ [com.arjuna.ats.jta.logging.loggerI18N] [com.arjuna.ats.internal.jta.resources.arjunacore.opcerror] [com.arjuna.ats.internal.jta.resources.arjunacore.opcerror] XAResourceRecord.commit_one_phase caught: java.lang.IllegalMonitorStateException
2012-03-29 12:02:43,778 WARN @ [org.springframework.jms.listener.DefaultMessageListenerContainer] Setup of JMS message listener invoker failed for destination 'queue/request' - trying to recover. Cause: …Run Code Online (Sandbox Code Playgroud) 我将我的Ant任务配置为
<target name="test" depends="init">
<jacoco:coverage destfile="target/jacoco.exec">
<junit printsummary="yes" haltonfailure="yes" fork="yes" forkmode="once">
<classpath refid="my_project.path"/>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest fork="false" todir="target/test-reports">
<fileset dir="test">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
</target>
Run Code Online (Sandbox Code Playgroud)
这产生了预期的junit结果.但是,target/jacoco.exec永远不会创建.我在ant test report任务执行期间没有任何错误.
测试:[jacoco:coverage]用覆盖率增强junit
Run Code Online (Sandbox Code Playgroud)... [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0,009 sec报告:[jacoco:report]加载执行数据文件/home/usr/Workspaces/my_project/target/jacoco.exec
BUILD FAILED /home/usr/Workspaces/my_project/build.xml:73:无法读取执行数据文件/home/usr/Workspaces/my_project/target/jacoco.exec
总时间:14秒
好像我错过了一些东西,无法看清楚到底是什么.
作为Camel和ServiceMix的用户,我经常需要监控这些工具以用于开发目的.我主要使用JConsole从ServiceMix和Camel访问MBean.它为ESB开发人员提供了一些非常有用的指标.
我还使用karaf(web)控制台来跟踪我的路线和捆绑状态.环顾StackOverflow,我发现了一个有趣的链接,解释了如何为ServiceMix 4设置Hyperic HQ:使用Hyperic HQ监控Servicemix.
它们是您认为值得学习/用于Camel/SMX开发的其他工具吗?
我对AngularJS很新,而且我被困了一会儿ng-repreat.
我试图用控制器函数ng-click来改变模型.首先,我使用了$index提供的变量ng-repeat.但是当我添加过滤器时,我无法获得正确的商品ID.(删除过滤器恢复预期的行为)
我做了一个简单的例子:http://jsfiddle.net/folkenda/wt7b2/
正如脚本中所示,我想使用friend.id而不是$index为了在我的friend变量中设置正确的值.
我有一个文本("Contacts.txt")文件,如下所示:
Pedro Melendez 7823455555 9395554444 myEmail@stack.com
Bob Ramirez 8725551234 9452455543 bob.ramirez@stack.com
LuisGonzález8907653456null luis.gonzalez@stack.com
是一个文本文件,我将保存人们的联系信息.(适用于Android应用程序)
我必须将此联系人信息保存到联系人(列表)类型列表中.联系人有以下变量:
如何使用扫描仪将信息保存在列表中的文本文件中?
我用过这个:
Scanner in = new Scanner(new File("Contacts.txt");
while(in.hasNextLine()){
this.contactList.add(new Contact(in.next(), in.next(), in.next(), in.next(), in.next()));
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用.将信息保存在列表中的最佳方法在哪里?
谢谢,
java ×5
android ×1
angularjs ×1
ant ×1
apache-camel ×1
enums ×1
esb ×1
file ×1
generics ×1
jacoco ×1
javascript ×1
jboss ×1
jms ×1
maven ×1
monitoring ×1
tomcat6 ×1
transactions ×1