掲示板

JSONFactoryImpl not able to inject

thumbnail
6年前 に Rajesh Chaurasia によって更新されました。

JSONFactoryImpl not able to inject

Regular Member 投稿: 183 参加年月日: 11/08/18 最新の投稿
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
6年前 に Samuel Kong によって更新されました。

RE: JSONFactoryImpl not able to inject

Liferay Legend 投稿: 1902 参加年月日: 08/03/10 最新の投稿
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
6年前 に Rajesh Chaurasia によって更新されました。

RE: JSONFactoryImpl not able to inject

Regular Member 投稿: 183 参加年月日: 11/08/18 最新の投稿
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)