Foren

JSONFactoryImpl not able to inject

thumbnail
Rajesh Chaurasia, geändert vor 6 Jahren.

JSONFactoryImpl not able to inject

Regular Member Beiträge: 183 Beitrittsdatum: 18.08.11 Neueste Beiträge
Hi

I wanted to know how to inject JSONFactoryImpl in below way as I am unable to get access to JSONFactoryImpl in my maven project.Wjat dependency will give me access to it in Liferay 7 setup

JSONFactoryUtil jsonFactoryUtil = new JSONFactoryUtil();
 jsonFactoryUtil.setJSONFactory(new JSONFactoryImpl());
thumbnail
Samuel Kong, geändert vor 6 Jahren.

RE: JSONFactoryImpl not able to inject

Liferay Legend Beiträge: 1902 Beitrittsdatum: 10.03.08 Neueste Beiträge
There's no need to set the impl. JSONFactoryUtil already uses JSONFactoryImpl by default. To use JSONFactoryUtil, just call one of the static methods.
thumbnail
Rajesh Chaurasia, geändert vor 6 Jahren.

RE: JSONFactoryImpl not able to inject

Regular Member Beiträge: 183 Beitrittsdatum: 18.08.11 Neueste Beiträge
I am getting the below NPE exception

java.lang.NullPointerException
        at com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONArray(JSONFactoryUtil.java:57)
        at com.tollgroup.mytoll.pickup.test.BookAPickupControllerTest.testFindBusinessUnitSuccess(BookAPickupControllerTest.java:104)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
        at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
        at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:88)
        at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)
        at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
        at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)