我正在使用Clojure,我想抓住我可以记录的堆栈跟踪(理想情况下,我想将它作为String).
我看到它(.getStackTrace e)
返回了一个,StackTraceElement[]
但我不知道如何打印出有意义的东西.我的第二种方法是(.printStackTrace e)
使用PrintWriter作为参数(因为我知道这在Java中是可行的),但我似乎没有得到正确的语法.
谢谢.
如何逃避"*"
到"\*"
Clojure中?似乎无法让它工作:
(s/replace "A*B" #"*" "*")
产生 "A*B"
(当然)
(s/replace "A*B" #"*" "\*")
失败: Unsupported escape character: *
(s/replace "A*B" #"*" "\\*")
又产生 "A*B"
了!
(s/replace "A*B" #"*" "\\\*")
失败了:Unsupported escape character: *
再次!
(s/replace "A*B" #"\\\\*" "*")
产生 "A\\*B"
我不能让它产生A\*B
任何想法?谢谢
我正在使用 JodaTime 在 Java 应用程序中处理时区。尝试从 Java 时区的 id 构建 DateTimeZone (JodaTime) 对象时遇到问题。乔达抛出一个
java.lang.IllegalArgumentException: The datetime zone id 'SystemV/HST10' is not recognised
Run Code Online (Sandbox Code Playgroud)
对于以下时区列表:
这些时区有什么用?它们与非程序员相关吗?为一般用途设计的应用程序是否应该支持这些时区?
谢谢。
我有一个Jmx客户端,用于测试我写的jmx bean.这是客户端的代码:
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:8686/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
ObjectName mbeanName = new ObjectName("com.spmsoftware.processing.ping:type=ProcessingPing");
ProcessingPing mbeanProxy = JMX.newMBeanProxy(mbsc, mbeanName, ProcessingPing.class, true);
System.out.println("\nResult = " + mbeanProxy.ping(346, 0).getResultCode());
jmxc.close();
Run Code Online (Sandbox Code Playgroud)
ProcessingPing及其所有依赖项都存在于IntelliJ库中.
我的jmx bean是:
public interface ProcessingPing {
public PingResult ping(Integer environmentId, Integer timeout);
}
Run Code Online (Sandbox Code Playgroud)
和
@Service("ProcessingPing")
@ManagedResource(description = "")
public class ProcessingPingImpl implements ProcessingPing {
private static final Integer DEFAULT_TIMEOUT = 5000;
@Autowired
private PingProcessService pingProcessService;
@Override
@ManagedOperation(description = "")
public PingResult ping(Integer environmentId, Integer …
Run Code Online (Sandbox Code Playgroud) 我需要更好地了解Glassfish域文件夹中"生成"目录的内容.我可以看到部署的应用程序在那里存储了一些资源文件,(xmls,属性,清单......)但是并不真正理解为什么.谷歌这次不是很有用.有人能指点我一些相关的文件吗?谢谢.
编辑:我需要知道这些细节,因为我想/需要在重新启动服务器时删除此文件夹.
我需要一种从Glassfish取消部署所有应用程序的方法.通常,我会asadmin undeploy --target=[target] [appname]"
用于每个应用程序.我的问题是我不知道服务器上存在的所有应用程序的名称.是否有一个命令允许我取消部署所有内容?谢谢.
我试图在Intellij Coummunity Edition 13.1.3中运行Scala测试(specs2).我收到以下错误:
Connected to the target VM, address: '127.0.0.1:57980', transport: 'socket'
'Start' method is not found in MyNotifierRunner null
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
Disconnected from the target VM, address: '127.0.0.1:57980', transport: 'socket'
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.runSingleTest(JavaSpecs2Runner.java:123)
at org.jetbrains.plugins.scala.testingSupport.specs2.JavaSpecs2Runner.main(JavaSpecs2Runner.java:69)
Caused by: java.lang.NoSuchMethodError: org.specs2.matcher.MatchResult$.matchResultAsResult()Lorg/specs2/execute/AsResult;
at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply$mcV$sp(ReportsDemographicsComponentTest.scala:14)
at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply(ReportsDemographicsComponentTest.scala:13)
at components.reports.ReportsDemographicsComponentTest$$anonfun$1.apply(ReportsDemographicsComponentTest.scala:13)
at org.specs2.mutable.SideEffectingCreationPaths$$anonfun$executeBlock$1.apply$mcV$sp(FragmentsBuilder.scala:292)
at org.specs2.mutable.SideEffectingCreationPaths$class.replay(FragmentsBuilder.scala:264)
at org.specs2.mutable.Specification.replay(Specification.scala:12)
at org.specs2.mutable.FragmentsBuilder$class.fragments(FragmentsBuilder.scala:27)
at org.specs2.mutable.Specification.fragments(Specification.scala:12)
at org.specs2.mutable.SpecificationLike$class.is(Specification.scala:14)
at org.specs2.mutable.Specification.is(Specification.scala:12)
at org.specs2.specification.SpecificationStructure$$anonfun$content$1.apply(BaseSpecification.scala:56)
at org.specs2.specification.SpecificationStructure$$anonfun$content$1.apply(BaseSpecification.scala:56)
at org.specs2.specification.SpecificationStructure$class.map(BaseSpecification.scala:44)
at org.specs2.mutable.Specification.map(Specification.scala:12) …
Run Code Online (Sandbox Code Playgroud) 我正在使用Kafka 0.8.2-beta并拥有2个Ubuntu 14虚拟机:
我正在启动Zookeeper实例,一切都很好.然后我尝试启动代理并将其连接到172.30.141.127:2181.它似乎能够在特定端口上连接并建立会话,但由于某些异常似乎没有记录,它会丢失连接.
经纪人输出:
[2015-01-19 11:03:55,029] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
[2015-01-19 11:03:55,030] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)
[2015-01-19 11:03:55,031] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
[2015-01-19 11:03:55,031] INFO Client environment:os.arch=i386 (org.apache.zookeeper.ZooKeeper)
[2015-01-19 11:03:55,032] INFO Client environment:os.version=3.16.0-23-generic (org.apache.zookeeper.ZooKeeper)
[2015-01-19 11:03:55,033] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)
[2015-01-19 11:03:55,033] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)
[2015-01-19 11:03:55,037] INFO Client environment:user.dir=/home/osboxes/Desktop/kafka_2.11-0.8.2-beta (org.apache.zookeeper.ZooKeeper)
[2015-01-19 11:03:55,039] INFO Initiating client connection, connectString=172.30.141.127:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@1ecf473 (org.apache.zookeeper.ZooKeeper)
[2015-01-19 11:03:55,129] INFO Opening socket connection to server 172.30.141.127/172.30.141.127:2181. Will not attempt to authenticate using …
Run Code Online (Sandbox Code Playgroud) 我试图在Scala应用程序的函数内获取调用者类和方法名称.我目前正在使用堆栈跟踪,但性能已降低.我正在做类似的事情
stackTrace(CodeDepth).getClassName
stackTrace(CodeDepth).getMethodName
Run Code Online (Sandbox Code Playgroud)
我发现Java反射更快,但我只能得到类名
sun.reflect.Reflection.getCallerClass(CodeDepth).getName()
Run Code Online (Sandbox Code Playgroud)
有没有办法通过反射获取方法名称(和可选的行号)?也许使用Scala的反思?
谢谢
我有一些用clojure编写的测试.这是一个简单的例子:
(defn test1
[]
(start-server)
(run-pvt-and-expect "PVT-0")
(stop-server)
)
Run Code Online (Sandbox Code Playgroud)
我想返回"run-pvt-and-expect"的结果,但我需要在它之后执行其他函数.我怎么能以功能的方式在clojure中做到这一点(不使用像"let"这样的结构)?谢谢.
注意:我阅读了这个问题及其答案,但无法将其应用于我的案例.此外,评论要求提供从未给出的示例,因此请将此视为一个示例......