Derby + EclipseLink + JUnit + Eclipse = ArrayIndexOutOfBoundsException - PullRequest
2 голосов
/ 11 марта 2012

Я использую встроенную базу данных Derby для модульного тестирования моего сервисного уровня с помощью JUnit.Это прекрасно работает, когда я запускаю тесты в Eclipse или использую Maven.Но если я попытаюсь запустить тесты в отладчике Eclipse, тесты завершатся сбоем из-за исключения ArrayIndexOutOfBoundsException, которое выдается при загрузке EmbeddedDriver.Что я сделал не так?

Вот трассировка стека:

Thread [main] (Suspended (exception ArrayIndexOutOfBoundsException))    
SignatureParser.current() line: 79 [local variables unavailable]    
SignatureParser.parseZeroOrMoreThrowsSignatures() line: 497 
SignatureParser.parseMethodTypeSignature() line: 436    
SignatureParser.parseMethodSig(String) line: 141    
MethodRepository(ConstructorRepository).parse(String) line: 37  
MethodRepository(ConstructorRepository).parse(String) line: 25  
MethodRepository(AbstractRepository<T>).<init>(String, GenericsFactory) line: 56    
MethodRepository(GenericDeclRepository<S>).<init>(String, GenericsFactory) line: 30 
MethodRepository(ConstructorRepository).<init>(String, GenericsFactory) line: 33    
MethodRepository.<init>(String, GenericsFactory) line: 28   
MethodRepository.make(String, GenericsFactory) line: 41 
Method.getGenericInfo() line: 94    
Method.getGenericReturnType() line: 236 
ConvertingMethod.<init>(Method) line: 184   
ConvertingMethod.from(Method) line: 27  
MXBeanIntrospector.mFrom(Method) line: 63   
MXBeanIntrospector.mFrom(Method) line: 33   
MBeanAnalyzer<M>.initMaps(Class<?>, MBeanIntrospector<M>) line: 118 
MBeanAnalyzer<M>.<init>(Class<?>, MBeanIntrospector<M>) line: 99    
MBeanAnalyzer<M>.analyzer(Class<?>, MBeanIntrospector<M>) line: 87  
MXBeanIntrospector.getAnalyzer(Class<?>) line: 53   
MXBeanIntrospector(MBeanIntrospector<M>).getPerInterface(Class<?>) line: 163    
MXBeanSupport(MBeanSupport<M>).<init>(T, Class<T>) line: 147    
MXBeanSupport.<init>(T, Class<T>) line: 48  
StandardMBean.construct(T, Class<T>, boolean, boolean) line: 163    
StandardMBean.<init>(T, Class<T>, boolean) line: 256    
ManagementFactory.addMXBean(MBeanServer, Object, String, NotificationEmitter) line: 249 
ManagementFactory.createPlatformMBeanServer() line: 310 
ManagementFactory.getPlatformMBeanServer() line: 504    
JMXManagementService$1.run() line: not available    
JMXManagementService$1.run() line: not available    
AccessController.doPrivileged(PrivilegedAction<T>) line: not available [native method]  
JMXManagementService.findServer() line: not available   
JMXManagementService.boot(boolean, Properties) line: not available  
BaseMonitor.boot(Object, boolean, Properties) line: not available   
TopService.bootModule(boolean, Object, ProtocolKey, Properties) line: not available 
FileMonitor(BaseMonitor).startModule(boolean, Object, String, String, Properties) line: not available   
Monitor.startSystemModule(String) line: not available   
FileMonitor(BaseMonitor).runWithState(Properties, PrintStream) line: not available  
FileMonitor.<init>(Properties, PrintStream) line: not available 
Monitor.startMonitor(Properties, PrintStream) line: not available   
JDBCBoot.boot(String, PrintStream) line: not available  
EmbeddedDriver.boot() line: not available   
EmbeddedDriver.<clinit>() line: not available   
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]   
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39    
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27    
Constructor<T>.newInstance(Object...) line: 513 
Class<T>.newInstance0() line: 355   
Class<T>.newInstance() line: 308    
ScenarioServiceTest(ServiceTest).setUpDB() line: 68 
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]  
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39  
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25  
Method.invoke(Object, Object...) line: 597  
FrameworkMethod$1.runReflectiveCall() line: 44  
FrameworkMethod$1(ReflectiveCallable).run() line: 15    
FrameworkMethod.invokeExplosively(Object, Object...) line: 41   
RunBefores.evaluate() line: 27  
RunAfters.evaluate() line: 31   
BlockJUnit4ClassRunner.runNotIgnored(FrameworkMethod, EachTestNotifier) line: 79    
BlockJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier) line: 71  
BlockJUnit4ClassRunner.runChild(Object, RunNotifier) line: 49   
ParentRunner$3.run() line: 193  
ParentRunner$1.schedule(Runnable) line: 52  
BlockJUnit4ClassRunner(ParentRunner<T>).runChildren(RunNotifier) line: 191  
ParentRunner<T>.access$000(ParentRunner, RunNotifier) line: 42  
ParentRunner$2.evaluate() line: 184 
BlockJUnit4ClassRunner(ParentRunner<T>).run(RunNotifier) line: 236  
JUnit4TestClassReference(JUnit4TestReference).run(TestExecution) line: 50   
TestExecution.run(ITestReference[]) line: 38    
RemoteTestRunner.runTests(String[], String, TestExecution) line: 467    
RemoteTestRunner.runTests(TestExecution) line: 683  
RemoteTestRunner.run() line: 390    
RemoteTestRunner.main(String[]) line: 197   

Код, который вызывает исключение:

@Before
public void setUpDB() throws Exception {
   org.apache.derby.jdbc.EmbeddedDriver.class.newInstance();
   // More code here
}

Обновление:

Проблема не возникает, если я использую Hibernate вместо Eclipse-Link.Возможно, проблема связана с переплетением кода?

...