We wanted to integrate Realm in our app, and we encountered following problem:
FATAL EXCEPTION: XService
Process: xx.xxx.xxxx, PID: 16462
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/gradle/logging/internal/slf4j/OutputEventListenerBackedLoggerContext;
at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:30)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:27)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:265)
at xx.xxx.xxxx.xxxxx.impl.core.StateMachine.<init>(StateMachine.java:52)
at xx.xxx.xxxx.xxxxx.android.XService$ServiceHandler.startController(XService.java:670)
at xx.xxx.xxxx.xxxxx.android.XService$ServiceHandler.handleMessage(XService.java:536)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.gradle.logging.internal.slf4j.OutputEventListenerBackedLoggerContext" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/xx.xxx.xxxx-2/base.apk"],nativeLibraryDirectories=[/data/app/xx.xxx.xxxx-2/lib/arm, /data/app/xx.xxx.xxxx-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:30)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:27)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:265)
at xx.xxx.xxxx.xxxxx.impl.core.StateMachine.<init>(StateMachine.java:52)
at xx.xxx.xxxx.xxxxx.android.XService$ServiceHandler.startController(XService.java:670)
at xx.xxx.xxxx.xxxxx.android.XService$ServiceHandler.handleMessage(XService.java:536)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Suppressed: java.lang.ClassNotFoundException: org.gradle.logging.internal.slf4j.OutputEventListenerBackedLoggerContext
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Where StaticLoggerBinder looks like:
public class StaticLoggerBinder implements LoggerFactoryBinder {
private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
private static final String loggerFactoryClassStr = AndroidCustomLoggerFactory.class.getName();
private final ILoggerFactory loggerFactory = new AndroidCustomLoggerFactory();
private StaticLoggerBinder() {
}
public static final StaticLoggerBinder getSingleton() {
return SINGLETON; // line 27
}
public ILoggerFactory getLoggerFactory() { //line 30
return this.loggerFactory;
}
public String getLoggerFactoryClassStr() {
return loggerFactoryClassStr;
}
}
From my understanding, problem is probably with Realm's transformer. It wants to include some unknown logger to our code. Main problem with our app is, that we have some 3rd party library, that uses also SLF4J, and we can't modify it. I tried with 0.90.1 version, while SLF4J used by 3rd party library is in 1.6.4 version. Dexguard is 7.1.26.
Also, note that, Realm works with my environment and another project with same dependencies except this 3rd party library and SLF4J.
List of dependencies:
plugins:
apply plugin: 'com.android.library'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'dexguard'
apply plugin: 'realm-android'
dependencies:
provided 'javax.annotation:jsr250-api:1.0'
apt 'com.google.dagger:dagger-compiler:2.0.2'
compile([
'com.google.dagger:dagger:2.0.2',
'com.mcxiaoke.volley:library:1.0.18',
'com.google.code.gson:gson:2.3.1',
'io.reactivex:rxjava:1.0.11',
'io.reactivex:rxandroid:0.24.0',
'com.jakewharton.timber:timber:3.1.0',
'com.squareup.okhttp:okhttp:2.6.0',
'com.squareup.okio:okio:1.6.0',
'com.android.support:support-v4:22.1.1'
])
compile files('libs/libconceal.jar')
compile files('libs/conceal_android.jar')
compile files('../dexguard/dexguard-runtime.jar')
compile files('libs/slf4j-api-1.6.4.jar')
compile files('libs/lib3rdparty.jar')
retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:2.3.0'
Is this possible, that Realm mess up here with that implementation? Is there any way to prevent it?
Related
I tried to call the test class programmatically and follow the instructor in the TestNG docs. When i called it in Eclipse, it worked, but when i switch to Intellij to be more convenient to use JavaFX so that i can make a UI program, it doesn't work and show this error.
This is my test call class
package com.vinh.testing.CallTest;
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
import tests.LogOutTest;
public class TestLogOutCall {
public void callLogOutTest() {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { LogOutTest.class });
testng.addListener(tla);
testng.run();
}
}
and this is my test class
package tests;
import static io.restassured.RestAssured.*;
import static org.testng.Assert.assertNotEquals;
import org.testng.annotations.Test;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
public class LogOutTest {
String ACCESS_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hdWN0aW9uLWFwcDMuaGVyb2t1YXBwLmNvbVwvYXBpXC9sb2dpbiIsImlhdCI6MTY1NTUzNzg2OSwiZXhwIjoxNjU1ODk3ODY5LCJuYmYiOjE2NTU1Mzc4NjksImp0aSI6InJuejdrMHhSQmNUTHB2TnkiLCJzdWIiOjY1LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.sX-pWrwDyGfCIhlqy_1huxTt3GSElXrQtnpKV53q4BM";
#Test
public void Test01() {
baseURI = "https://auction-app3.herokuapp.com/api";
Response response = given().
header("Authorization", "bearer" + ACCESS_TOKEN).
contentType("application/json").
when().
post("/logout");
response.then().statusCode(200);
System.out.println(response.getBody().asString());
JsonPath jpath = response.jsonPath();
int code = jpath.getInt("code");
System.out.println(code);
assertNotEquals(code, 1000);
}
}
and then i met this
C:\Users\Lenovo\.jdks\openjdk-18.0.1.1\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.1.1\lib\idea_rt.jar=50009:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.1.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-controls\18\javafx-controls-18.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-graphics\18\javafx-graphics-18.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-base\18\javafx-base-18.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-fxml\18\javafx-fxml-18.jar;C:\Users\Lenovo\.m2\repository\org\apache\groovy\groovy\4.0.1\groovy-4.0.1.jar;C:\Users\Lenovo\.m2\repository\org\apache\groovy\groovy-xml\4.0.1\groovy-xml-4.0.1.jar;C:\Users\Lenovo\.m2\repository\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;C:\Users\Lenovo\.m2\repository\org\apache\httpcomponents\httpcore\4.4.13\httpcore-4.4.13.jar;C:\Users\Lenovo\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\Lenovo\.m2\repository\commons-codec\commons-codec\1.11\commons-codec-1.11.jar;C:\Users\Lenovo\.m2\repository\org\apache\httpcomponents\httpmime\4.5.13\httpmime-4.5.13.jar;C:\Users\Lenovo\.m2\repository\org\hamcrest\hamcrest\2.1\hamcrest-2.1.jar;C:\Users\Lenovo\.m2\repository\org\ccil\cowan\tagsoup\tagsoup\1.2.1\tagsoup-1.2.1.jar;C:\Users\Lenovo\.m2\repository\org\apache\groovy\groovy-json\4.0.1\groovy-json-4.0.1.jar;C:\Users\Lenovo\.m2\repository\io\rest-assured\rest-assured-common\5.1.1\rest-assured-common-5.1.1.jar;C:\Users\Lenovo\.m2\repository\io\rest-assured\xml-path\5.1.1\xml-path-5.1.1.jar;C:\Users\Lenovo\.m2\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;C:\Users\Lenovo\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\Lenovo\.m2\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\Users\Lenovo\.m2\repository\com\beust\jcommander\1.82\jcommander-1.82.jar;C:\Users\Lenovo\.m2\repository\org\webjars\jquery\3.6.0\jquery-3.6.0.jar;C:\Users\Lenovo\.m2\repository\junit\junit\4.10\junit-4.10.jar;C:\Users\Lenovo\.m2\repository\org\hamcrest\hamcrest-core\1.1\hamcrest-core-1.1.jar -p D:\Testing\target\classes;C:\Users\Lenovo\.m2\repository\org\testng\testng\7.6.0\testng-7.6.0.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-base\18\javafx-base-18-win.jar;C:\Users\Lenovo\.m2\repository\org\apache\commons\commons-lang3\3.11\commons-lang3-3.11.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-fxml\18\javafx-fxml-18-win.jar;C:\Users\Lenovo\.m2\repository\io\rest-assured\json-path\5.1.1\json-path-5.1.1.jar;C:\Users\Lenovo\.m2\repository\io\rest-assured\rest-assured\5.1.1\rest-assured-5.1.1.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-graphics\18\javafx-graphics-18-win.jar;C:\Users\Lenovo\.m2\repository\com\googlecode\json-simple\json-simple\1.1.1\json-simple-1.1.1.jar;C:\Users\Lenovo\.m2\repository\org\openjfx\javafx-controls\18\javafx-controls-18-win.jar;C:\Users\Lenovo\.m2\repository\org\controlsfx\controlsfx\11.1.1\controlsfx-11.1.1.jar -m com.vinh.testing/com.vinh.testing.AutomationTesting
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml#18/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1857)
at javafx.fxml#18/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1724)
at javafx.base#18/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base#18/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at javafx.base#18/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base#18/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base#18/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base#18/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base#18/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base#18/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base#18/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base#18/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base#18/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base#18/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base#18/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics#18/javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3586)
at javafx.graphics#18/javafx.scene.Scene$MouseHandler.process(Scene.java:3890)
at javafx.graphics#18/javafx.scene.Scene.processMouseEvent(Scene.java:1874)
at javafx.graphics#18/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2607)
at javafx.graphics#18/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
at javafx.graphics#18/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:301)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics#18/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:450)
at javafx.graphics#18/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:424)
at javafx.graphics#18/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
at javafx.graphics#18/com.sun.glass.ui.View.handleMouseEvent(View.java:551)
at javafx.graphics#18/com.sun.glass.ui.View.notifyMouse(View.java:937)
at javafx.graphics#18/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics#18/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:77)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:577)
at javafx.base#18/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml#18/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:84)
at javafx.fxml#18/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1854)
... 29 more
Caused by: org.testng.TestNGException:
An error occurred while instantiating class tests.LoginTest: Unable to make public tests.LoginTest() accessible: module com.vinh.testing does not "exports tests" to module org.testng
at org.testng#7.6.0/org.testng.internal.objects.SimpleObjectDispenser.createInstance(SimpleObjectDispenser.java:99)
at org.testng#7.6.0/org.testng.internal.objects.SimpleObjectDispenser.dispense(SimpleObjectDispenser.java:40)
at org.testng#7.6.0/org.testng.internal.objects.GuiceBasedObjectDispenser.dispense(GuiceBasedObjectDispenser.java:28)
at org.testng#7.6.0/org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:106)
at org.testng#7.6.0/org.testng.internal.ClassImpl.getInstances(ClassImpl.java:136)
at org.testng#7.6.0/org.testng.TestClass.getInstances(TestClass.java:129)
at org.testng#7.6.0/org.testng.TestClass.initTestClassesAndInstances(TestClass.java:109)
at org.testng#7.6.0/org.testng.TestClass.init(TestClass.java:101)
at org.testng#7.6.0/org.testng.TestClass.<init>(TestClass.java:66)
at org.testng#7.6.0/org.testng.TestRunner.initMethods(TestRunner.java:463)
at org.testng#7.6.0/org.testng.TestRunner.init(TestRunner.java:335)
at org.testng#7.6.0/org.testng.TestRunner.init(TestRunner.java:288)
at org.testng#7.6.0/org.testng.TestRunner.<init>(TestRunner.java:178)
at org.testng#7.6.0/org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:639)
at org.testng#7.6.0/org.testng.SuiteRunner.init(SuiteRunner.java:225)
at org.testng#7.6.0/org.testng.SuiteRunner.<init>(SuiteRunner.java:115)
at org.testng#7.6.0/org.testng.TestNG.createSuiteRunner(TestNG.java:1349)
at org.testng#7.6.0/org.testng.TestNG.createSuiteRunners(TestNG.java:1325)
at org.testng#7.6.0/org.testng.TestNG.runSuitesLocally(TestNG.java:1167)
at org.testng#7.6.0/org.testng.TestNG.runSuites(TestNG.java:1099)
at org.testng#7.6.0/org.testng.TestNG.run(TestNG.java:1067)
at com.vinh.testing/com.vinh.testing.CallTest.TestLoginCall.CallTestLogin(TestLoginCall.java:16)
at com.vinh.testing/com.vinh.testing.Controller.Test(Controller.java:63)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 36 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public tests.LoginTest() accessible: module com.vinh.testing does not "exports tests" to module org.testng
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:191)
at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:184)
at org.testng#7.6.0/org.testng.internal.objects.SimpleObjectDispenser.instantiateUsingDefaultConstructor(SimpleObjectDispenser.java:177)
at org.testng#7.6.0/org.testng.internal.objects.SimpleObjectDispenser.createInstance(SimpleObjectDispenser.java:87)
... 59 more
Im new to TestNG, pls help me.
I have a series of popups where I edit or view specific objects. I use these popups for editing various objects that are handled by and ORM (ORMLite), what I am trying to achieve is to have a generic/abstract class that implements similar behaviours through encapsulating methods. As I don't want to have the same FXML for all of the
popup dialogs what I came up with was to create a "template" FXML, load it through loadFXML() function provided by Griffon and store it in a Node object to be the root of the created Scene at the Abstract Class. I am familiar with dependency injection, but I am not aware of the AST of the framework so my Abstract class is able to call loadFromFXML() within the Abstract class I created.
I post my code here:
Concrete class implementing the abstract ViewPopUp class I created:
#ArtifactProviderFor(GriffonView.class)
public class VerConductoresView extends AbstractViewPopUp<ObservablePlanilla> {
private VerConductoresController controller;
private ConductoresModel model;
VerConductoresView() {
super(ObservablePlanilla.class, Conductor.class);
nodeM = new GridPane();
super.setController(controller);
}
#Override
public void initUI() {
Stage stage = (Stage) getApplication()
.createApplicationContainer(Collections.<String,Object>emptyMap());
stage.setTitle(getApplication().getConfiguration().getAsString("application.title"));
stage.setScene(init());
stage.sizeToScene();
getApplication().getWindowManager().attach("ver-conductores", stage);
}
}
Abstract view PopUp I created:
public abstract class AbstractViewPopUp<T> extends AbstractJavaFXGriffonView {
protected Class klazz;
protected Class<T> klazz2;
protected Scene viewScene;
protected ViewControllerPopUp viewController;
protected TableView tableView;
protected GridPane gridPane;
protected String[] ignoredNames;
protected String[] columnNames;
protected IModel<T> viewModel;
protected Node nodeM;
#MVCMember
public void setController(ViewControllerPopUp controller) {
this.viewController = controller;
}
AbstractViewPopUp(Class<T> k1, Class k2, Node node){
klazz = k2;
klazz2 = k1;
nodeM = node;
nodeM = loadFromFXML("com.softgan.viewPopUp");
nodeM = node;
}
AbstractViewPopUp(Class<T> k1, Class k2){
klazz = k2;
klazz2 = k1;
nodeM = loadFromFXML("com.softgan.viewPopUp");
}
protected Scene init() {
Scene scene = new Scene(new Group());
if (nodeM instanceof Parent) {
scene.setRoot((Parent) nodeM);
} else {
((Group) scene.getRoot()).getChildren().addAll(nodeM);
}
connectActions(nodeM, viewController);
connectMessageSource(nodeM);
return scene;
}
}
I want to load the FXML through the Abstract class and then store it so the concrete class can access the loaded FXML so I am able to manipulate its contents, adding labels and textfields dynamically. The problem seems to be that loadFromFXML is throwing a NullPointerException as it is not able to resolve the FXML file from the resources. I already tried to use an AST transformation to make it resources aware, but it seems to not be a valid approach as Guice is not able to resolve, I think, the ResourceHandler.
EDIT
This is the Stacktrace I am getting:
[griffon-pool-1-thread-2] WARN org.codehaus.griffon.runtime.core.controller.AbstractActionManager - An exception occurred when executing com.softgan.ConductoresController.view
griffon.exceptions.InstanceMethodInvocationException: An error occurred while invoking instance method com.softgan.ConductoresController.view()
at griffon.util.GriffonClassUtils.invokeExactInstanceMethod(GriffonClassUtils.java:3186)
Caused by: griffon.exceptions.GriffonException: An error occurred while executing a task inside the UI thread
at com.softgan.ConductoresController.view(ConductoresController.java:122)
at griffon.util.MethodUtils.invokeExactMethod(MethodUtils.java:407)
at griffon.util.MethodUtils.invokeExactMethod(MethodUtils.java:356)
at griffon.util.GriffonClassUtils.invokeExactInstanceMethod(GriffonClassUtils.java:3182)
Caused by: java.util.concurrent.ExecutionException: griffon.exceptions.InstanceNotFoundException: Could not find an instance of type com.softgan.VerConductoresView
... 4 more
Caused by: griffon.exceptions.InstanceNotFoundException: Could not find an instance of type com.softgan.VerConductoresView
Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.NullPointerException
at com.softgan.VerConductoresView.<init>(VerConductoresView.java:31)
while locating com.softgan.VerConductoresView
1 error
at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:226)
at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1053)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1086)
Caused by: java.lang.NullPointerException
at com.softgan.AbstractViewPopUp.<init>(AbstractViewPopUp.java:72)
at com.softgan.VerConductoresView.<init>(VerConductoresView.java:31)
at com.softgan.VerConductoresView$$FastClassByGuice$$d0c2bde8.newInstance(<generated>)
at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:32)
at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:98)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:112)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:120)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:66)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:93)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050)
... 1 more
[griffon-pool-1-thread-2] ERROR griffon.core.GriffonExceptionHandler - Uncaught Exception. Stacktrace was sanitized. Set System property 'griffon.full.stacktrace' to 'true' for full report.
griffon.exceptions.InstanceMethodInvocationException: An error occurred while invoking instance method com.softgan.ConductoresController.view()
at griffon.util.GriffonClassUtils.invokeExactInstanceMethod(GriffonClassUtils.java:3186)
Caused by: griffon.exceptions.GriffonException: An error occurred while executing a task inside the UI thread
at com.softgan.ConductoresController.view(ConductoresController.java:122)
at griffon.util.MethodUtils.invokeExactMethod(MethodUtils.java:407)
at griffon.util.MethodUtils.invokeExactMethod(MethodUtils.java:356)
at griffon.util.GriffonClassUtils.invokeExactInstanceMethod(GriffonClassUtils.java:3182)
Caused by: java.util.concurrent.ExecutionException: griffon.exceptions.InstanceNotFoundException: Could not find an instance of type com.softgan.VerConductoresView
... 4 more
Caused by: griffon.exceptions.InstanceNotFoundException: Could not find an instance of type com.softgan.VerConductoresView
Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.NullPointerException
at com.softgan.VerConductoresView.<init>(VerConductoresView.java:31)
while locating com.softgan.VerConductoresView
1 error
at com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:226)
at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1053)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1086)
Caused by: java.lang.NullPointerException
at com.softgan.AbstractViewPopUp.<init>(AbstractViewPopUp.java:72)
at com.softgan.VerConductoresView.<init>(VerConductoresView.java:31)
at com.softgan.VerConductoresView$$FastClassByGuice$$d0c2bde8.newInstance(<generated>)
at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:32)
at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:98)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:112)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:120)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:66)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:93)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050)
... 1 more
UPDATE
I already found what the problem was. The constructor was not aware of the loadFromFXML method as in the constructor of the view the UI has not been loaded yet. What I did was simply put the loadFromFXML() inside the init() method of the Abstract Class and call it directly from the Concrete View Class. I found out this by calling the loadFromFXML from the initUI method, which is where the UI can be accessed.
AST transformations only apply if you're compiling Groovy code, which may not be what you're doing. The loadFromFXML() method expects a resource to be available on the classpath by matching the given argument using the following value transformation
arg.replaceAll('.', '/') + ".fxml"
This means your code resolves "com.softgan.viewPopUp" to "com/softgan/viewPopUp.fxml". Does that file exist in src/main/resources or griffon-app/resources?
Added LeakCanary (1.3) to my Application:
#Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
LeakCanary.install(this);
When I run the Robolectric test suite for my application I get a NullPointerException in LeakCanary.
Caused by: java.lang.NullPointerException
at com.squareup.leakcanary.LeakCanary.isInServiceProcess(LeakCanary.java:165)
at com.squareup.leakcanary.LeakCanary.isInAnalyzerProcess(LeakCanary.java:141)
at com.squareup.leakcanary.LeakCanary.install(LeakCanary.java:52)
at com.squareup.leakcanary.LeakCanary.install(LeakCanary.java:43)
at com.package.application.MyApplication.onCreate(MyApplication.java:50)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:131)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:431)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:224)
I added that Im using Crashlytics to point out that it (and other methods as well) receives the same Application but does not throw any Exceptions.
Wasn't sure if this should be here or on GitHub issues for LeakCanary. Anyone else experiencing this issue?
Converting my comment to the answer.
Robolectric provides way to deal with different initialisations and application test lifecycles through test application.
Here is your application class:
public class <YourAppplication> extends Application {
#Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
LeakCanary.install(this);
}
}
You should put in test sources in the same package as yours application next class:
public class Test<YourAppplication> extends <YourApplication> {
#Override
public void onCreate() {
}
}
Robolectric will load it instead of your application. As you can see I suppress all static initialisations from your application.
You can find more details here
A simple way to avoid the NullPointerException is to disable LeakCanary for unit tests by specifying the release (no-op) version in the testCompile directive in build.gradle. For instance:
dependencies {
...
testCompile (
'junit:junit:4.12',
'org.robolectric:robolectric:3.0',
'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
)
...
}
I created a new project using Android Studio and copied a jar file into my application's libs. Then added it as a library, which made the IDE recognize it. Later, I added it to the build.gradle and it now compiles just fine. However, when I attempt to run the application on a device it crashes with NoClassDefFoundError.
Attached and in order:
The project tree on Android Studio. Notice the test-jar-to-import.jar inside HelloSheepProject/HelloSheep/libs/.
The contents of the MainActivity.java. It is attempting to create a new MyFile. Nothing else.
The build.gradle inside HelloSheepProject/HelloSheep/. I added the line compile files('libs/test-jar-to-import.jar').
The contents of MyFile.java. It was created in Eclipse and exported as a jar file.
The error when I trying to run it on a device.
Any ideas on what I am missing? I have tried a ./gradlew clean in HelloSheepProject but it didn't help.
package top.furrylamb.example.hellosheep;
import android.os.Bundle;
import android.app.Activity;
import top.furrylamb.example.MyFile;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MyFile myFile = new MyFile("hi", "there");
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
//compile fileTree(dir: "libs", include: "*.jar")
compile files('libs/test-jar-to-import.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
package top.furrylamb.example;
public class MyFile {
public final String left;
public final String right;
public MyFile(String left, String right) {
this.left = left;
this.right = right;
}
}
07-19 19:26:33.855 13656-13656/? E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: top.furrylamb.example.MyFile
at top.furrylamb.example.hellosheep.MainActivity.onCreate(MainActivity.java:15)
at android.app.Activity.performCreate(Activity.java:5206)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
at android.app.ActivityThread.access$600(ActivityThread.java:140)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
I found the solution to my problem. Since I've been lost on this for hours I'll keep the thread instead of deleting it.
The jar I was importing had been compiled/exported with Java 7 in mind. Once I enabled compliance with Java 6 it worked fine.
To sum it up, when adding an external jar file in Android Studio:
Copy jar to root/project/libs folder;
Right-click and add as library;
Add the jar to root/project/build.gradle (something like compile files('libs/test-jar-to-import.jar'));
Make sure the imported jar complies with Java 6 (7 will not do, for now).
In my case, I was getting the same NoClassDefFoundError error at runtime, even though it compiled ok. It had been working fine previously. But one day, I added a new package to my app, which resulted in the package name-space being changed. My jar had already been a part of the application's structure, so I was somewhat surprised at this new runtime error suddenly complaining about an unknown class in a jar library that was working previously.
The fix, in my case, was a simple Build->Clean Project.
I have 2 POJOs, in which one of them is an EJB and the other is a helper class.
//EJB Bean class
#Singleton
#LocalBean
#Startup
public class EJBBean{
#PostConstruct
public void init(){
HelperClass helper = new HelperClass();
helper.init();
}
}
//Helper class
public class HelperClass{
private static Log LOG = LogFactory.getLog("HelperClass");
private static Long currentTime = new Date().getTime();
public void init(){
//Some statements that use Log and do other Initialization
}
}
When I deploy this EJB jar I am getting an error
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
I have the commons-logging-1.1.1.jar in the classpath; also, I have configured it to use Log4J. As a standalone app that is without EJB meta-data it works fine. Am I missing some EJB config?
BTW I am pretty new to EJB. I am using GlassFish 3.1, Eclipse Helios as IDE and EJB3.1.
This could be because you put the commons-logging-1.1.1.jar into the wrong directory or because your server already provides server-wide library which consists of logging classes.
By the way - I remember a lot of strange 'NoClassDefFoundError' because of mixing commons-logging, log4j and slf4j (especially in mismatching versions).