Тест верблюда: вызван: java.lang.ClassNotFoundException: com.ibm.ws.bootstrap.RASWsLoggerFactory
Я изучаю набор инструментов Camel-Test для сервера Camel-CXF. Насколько я знаю, Junit используется, потому что мы можем проверить и без сервера. но когда я запускаю этот Junit, он показывает мне исключение.
Трассировки стека:
java.lang.NoClassDefFoundError: com.ibm.ws.bootstrap.RASWsLoggerFactory
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:85)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:162)
at com.ibm.websphere.naming.WsnInitialContextFactory.<clinit>(WsnInitialContextFactory.java:79)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:228)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:170)
at javax.naming.spi.NamingManager$3.run(NamingManager.java:873)
at javax.naming.spi.NamingManager$3.run(NamingManager.java:870)
at java.security.AccessController.doPrivileged(AccessController.java:229)
at javax.naming.spi.NamingManager.factoryForName(NamingManager.java:869)
at javax.naming.spi.NamingManager.factoryForName(NamingManager.java:820)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:246)
at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:318)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:348)
at javax.naming.InitialContext.internalInit(InitialContext.java:286)
at javax.naming.InitialContext.<init>(InitialContext.java:211)
at org.apache.camel.test.junit4.CamelTestSupport.createJndiContext(CamelTestSupport.java:506)
at org.apache.camel.test.junit4.CamelTestSupport.createRegistry(CamelTestSupport.java:492)
at org.apache.camel.test.junit4.CamelTestSupport.createCamelContext(CamelTestSupport.java:486)
at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:246)
at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:216)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: com.ibm.ws.bootstrap.RASWsLoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:665)
at java.lang.ClassLoader.loadClass(ClassLoader.java:644)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:627)
... 55 more
Ниже мой код:
import java.io.FileNotFoundException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
import org.apache.camel.test.spring.DisableJmx;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.util.Log4jConfigurer;
import com.bac.baclws.ngen.command.AdministerContactPreferencesRequest;
import com.bac.baclws.ngen.command.RetrieveContactPreferencesRequest;
@RunWith(CamelSpringJUnit4ClassRunner.class)
@DisableJmx(true)
//@Ignore
@ContextConfiguration(locations = {
"classpath:/META-INF/spring/mockTest.xml"
})
public class DataValidationTest extends CamelTestSupport {
@EndpointInject(uri="direct:rcp")
ProducerTemplate template;
@Test
public void testQuote() throws Exception {
String s="<p:Account xmlns:p=\"http://url.xsd\">"
+" <p:data>"
+ " <p:number>30013</p:number>"
+" </data>"
+" </p:Account>";
Map<String, Object> headers=new HashMap<String, Object>();
headers.put("header1", "value1");
headers.put("header2", "value2");
template.sendBodyAndHeaders(s, headers);
}
}
class RCP extends RouteBuilder{
@Override
public void configure() throws Exception {
from("direct:rcp")
.log(LoggingLevel.DEBUG, "${body}");
}
}
Ниже мой xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:camel="http://camel.apache.org/schema/spring" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<cxf:rsServer id="EndPoint"
address="/PreferenceReporting/account" serviceClass="myEndPoint.EndpointManagement">
</cxf:rsServer>
<cxf:rsClient id="EndPointClient"
address="/PreferenceReporting/account" serviceClass="myEndPoint.EndpointManagement">
</cxf:rsClient>
</beans>
Пожалуйста, помогите мне, где я иду не так
1 ответ
Я думаю, что это не проблема с верблюдом. Вы добавили jar ws.runtime в ваш classpath, который создает проблему, если вы хотите запустить junit вместе с ws.runtime, вы должны настроить свой контекст и JVM на основе ibm jdk, иначе вы можете пропустить банку для модульного теста
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<classpathDependencyExcludes>
<classpathDependencyExclude>com.ibm:ws.runtime</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
</plugins