java - "Failed to transform class with name [CLASS NAME]. Reason: javax.servlet.ServletContext" when running tests in an ANT script -


i initialization error in logs when try run particular suite of tests after running ant test tasks. full stack trace follows:

failed transform class name [class name]. reason: javax.servlet.servletcontext  java.lang.illegalstateexception: failed transform class name [class name]. reason: javax.servlet.servletcontext @ org.powermock.core.classloader.mockclassloader.loadmockclass(mockclassloader.java:266) @ org.powermock.core.classloader.mockclassloader.loadmodifiedclass(mockclassloader.java:180) @ org.powermock.core.classloader.defersupportingclassloader.loadclass(defersupportingclassloader.java:68) @ java.lang.classloader.loadclass(classloader.java:357) @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:792) @ java.lang.classloader.defineclass(classloader.java:635) @ org.powermock.core.classloader.mockclassloader.loadmockclass(mockclassloader.java:269) @ org.powermock.core.classloader.mockclassloader.loadmodifiedclass(mockclassloader.java:180) @ org.powermock.core.classloader.defersupportingclassloader.loadclass(defersupportingclassloader.java:68) @ java.lang.classloader.loadclass(classloader.java:357) @ java.lang.class.forname0(native method) @ java.lang.class.forname(class.java:270) @ java.lang.class.initannotationsifnecessary(class.java:3168) @ java.lang.class.getannotation(class.java:3127) @ org.powermock.modules.junit4.internal.impl.powermockjunit44runnerdelegateimpl.validate(powermockjunit44runnerdelegateimpl.java:108) @ org.powermock.modules.junit4.internal.impl.powermockjunit44runnerdelegateimpl.<init>(powermockjunit44runnerdelegateimpl.java:70) @ org.powermock.modules.junit4.internal.impl.powermockjunit47runnerdelegateimpl.<init>(powermockjunit47runnerdelegateimpl.java:42) @ org.powermock.modules.junit4.internal.impl.powermockjunit49runnerdelegateimpl.<init>(powermockjunit49runnerdelegateimpl.java:25) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ org.powermock.modules.junit4.common.internal.impl.junit4testsuitechunkerimpl.createdelegatorfromclassloader(junit4testsuitechunkerimpl.java:156) @ org.powermock.modules.junit4.common.internal.impl.junit4testsuitechunkerimpl.createdelegatorfromclassloader(junit4testsuitechunkerimpl.java:40) @ org.powermock.tests.utils.impl.abstracttestsuitechunkerimpl.createtestdelegators(abstracttestsuitechunkerimpl.java:244) @ org.powermock.modules.junit4.common.internal.impl.junit4testsuitechunkerimpl.<init>(junit4testsuitechunkerimpl.java:61) @ org.powermock.modules.junit4.common.internal.impl.abstractcommonpowermockrunner.<init>(abstractcommonpowermockrunner.java:32) @ org.powermock.modules.junit4.powermockrunner.<init>(powermockrunner.java:34) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ java.lang.reflect.constructor.newinstance(constructor.java:526) caused by: javassist.notfoundexception: javax.servlet.servletcontext @ javassist.classpool.get(classpool.java:450) @ javassist.bytecode.descriptor.toctclass(descriptor.java:592) @ javassist.bytecode.descriptor.getreturntype(descriptor.java:489) @ javassist.ctbehavior.getreturntype0(ctbehavior.java:306) @ javassist.ctmethod.getreturntype(ctmethod.java:217) @ org.powermock.core.transformers.impl.mainmocktransformer.modifymethod(mainmocktransformer.java:163) @ org.powermock.core.transformers.impl.mainmocktransformer.allowmockingofstaticandfinalandnativemethods(mainmocktransformer.java:133) @ org.powermock.core.transformers.impl.mainmocktransformer.transform(mainmocktransformer.java:65) @ org.powermock.core.classloader.mockclassloader.loadmockclass(mockclassloader.java:251) 

the problem started when added following start of test suite:

@runwith(powermockrunner.class) @preparefortest({problemclass.class, classbeingtested.class}) 

with goal being when class being tested attempts instantiate problemclass, it'll create mock object instead of real instance.

the classbeingtested extends class that's mentioned in stack trade. i.e. classbeingtested extends [class name].

i spying on implementation of classbeingtested, method nothing when called rather being called.

i'm not sure if prehaps there kind of interference it's not ok both prepare class test , insert mocked constructor in there as as spy on it?


note: can run tests fine in intellij using either run/debug. in both cases test completes , shown passing. it's when ant build occurs fails.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -