2009-10-12 90 views
0

我在WebSphere上的Rational Application Developer配置队列访问一个队列,采用了“V5默认消息提供者”和Websphere6.1从独立代码

我现在尝试使用一个独立的应用程序来访问它( JUnit测试),以便在其中添加一些消息。我目前使用下面的代码:

 Hashtable env = new Hashtable(); 
     env.put(Context.INITIAL_CONTEXT_FACTORY, 
       "com.ibm.websphere.naming.WsnInitialContextFactory"); 
     env.put(Context.PROVIDER_URL, "corbaloc::localhost:2809"); 
     InitialContext ctx = new InitialContext(env); 

     javax.jms.Queue queue = (javax.jms.Queue) ctx.lookup("Topic"); 

在最后一行我得到以下异常:

javax.naming.NamingException: The JNDI operation "lookupExt"on the context "vwagwolot0awNode01Cell/nodes/vwagwolot0awNode01/servers/server1" with the name "Topic" failed. Please get the root cause Throwable contained in this NamingException for more information. Root exception is java.lang.NoSuchMethodError: com.ibm.ejs.ras.TraceComponent: method isAnyTracingEnabled()Z not found 
    at com.ibm.websphere.pmi.reqmetrics.PmiReqMetrics.register(PmiReqMetrics.java:949) 
    at com.ibm.websphere.pmi.reqmetrics.PmiReqMetrics.<clinit>(PmiReqMetrics.java:273) 
    at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1505) 
    at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1358) 
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:172) 
    at javax.naming.InitialContext.lookup(InitialContext.java:361) 
    at de.volkswagen.oracle.provisioning.util.test.QueueTest.testQueue(QueueTest.java:33) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) 
    at java.lang.reflect.Method.invoke(Method.java:391) 
    at junit.framework.TestCase.runTest(TestCase.java:164) 
    at junit.framework.TestCase.runBare(TestCase.java:130) 
    at junit.framework.TestResult$1.protect(TestResult.java:106) 
    at junit.framework.TestResult.runProtected(TestResult.java:124) 
    at junit.framework.TestResult.run(TestResult.java:109) 
    at junit.framework.TestCase.run(TestCase.java:120) 
    at junit.framework.TestSuite.runTest(TestSuite.java:230) 
    at junit.framework.TestSuite.run(TestSuite.java:225) 
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) 
root cause: 
java.lang.NoSuchMethodError: com.ibm.ejs.ras.TraceComponent: method isAnyTracingEnabled()Z not found 
    at com.ibm.websphere.pmi.reqmetrics.PmiReqMetrics.register(PmiReqMetrics.java:949) 
    at com.ibm.websphere.pmi.reqmetrics.PmiReqMetrics.<clinit>(PmiReqMetrics.java:273) 
    at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1505) 
    at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1358) 
    at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:172) 
    at javax.naming.InitialContext.lookup(InitialContext.java:361) 
    at <package name here>.QueueTest.testQueue(QueueTest.java:33) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60) 
    at java.lang.reflect.Method.invoke(Method.java:391) 
    at junit.framework.TestCase.runTest(TestCase.java:164) 
    at junit.framework.TestCase.runBare(TestCase.java:130) 
    at junit.framework.TestResult$1.protect(TestResult.java:106) 
    at junit.framework.TestResult.runProtected(TestResult.java:124) 
    at junit.framework.TestResult.run(TestResult.java:109) 
    at junit.framework.TestCase.run(TestCase.java:120) 
    at junit.framework.TestSuite.runTest(TestSuite.java:230) 
    at junit.framework.TestSuite.run(TestSuite.java:225) 
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) 

任何提示,我可以为了解决这个问题呢? 为了实现这一目标,我将ws_runtime.jar添加到了类路径中,我在RAD安装中找到了它。

回答

1

您可能想要检查您在类路径中具有哪些JAR。粗略的一瞥表明某处存在不匹配。这条线:

java.lang.NoSuchMethodError: com.ibm.ejs.ras.TraceComponent: method isAnyTracingEnabled()Z not found 

告诉你,com.ibm.websphere.pmi.reqmetrics.PmiReqMetrics.register方法试图调用isAnyTracingElementEnabled方法上TraceComponent,但TraceComponent没有该方法。我猜测那个有TraceComponent的JAR是错误的。

+0

我同意。我想这是ws_runtime.jar,但现在我正在写这个,我想我应该检查一下。但问题是:我在哪里得到正确的版本? – 2009-10-12 10:49:44

+0

无法帮到你,我没有使用有问题的应用程序 – tddmonkey 2009-10-12 10:59:56

+0

需要解决两个问题:我在与EJB相同的项目中测试了代码。这导致了所描述的问题,因为EJB带来了许多我不希望用于测试的类路径条目。对于正确的库,RAD提供了一个服务器运行时库,我们将其添加到构建路径中,至少解决了这个问题 – 2009-10-13 12:03:49