3

I encounter the following exception in the WSO API Manager

ERROR {JAGGERY.modules.analytics.add.jag}Error occurred while saving Analytics configuration (Cause:Cannot call property getInstance in object [JavaPackage org.wso2.carbon.apimgt.impl.APIManagerAnalyticsConfiguration]. It is not a function, it is "object".){JAGGERY.modules.analytics.add.jag}

We have no clue what leads to this problem, we are sure that we didn't change the jag files,but we did replace one class file(within the jar) with our own compiled class and replace it into the jar.

When we change back to the original jar and restart the server,the problem is still there,does anyone know what may lead to this problem and how to fix?

piyushj
  • 1,546
  • 5
  • 21
  • 29
Tom
  • 5,848
  • 12
  • 44
  • 104

2 Answers2

1

This can happen if APIManagerAnalyticsConfiguration class is not available in OSGi rumtime. Most possible reason is that corresponding jar is not ACTIVE. You can start the server with -DosgiConsole and see if that's the case. Here is a guide.

Did you replace a jar in plugins directory? That's actually not recommended. And that can cause OSGi activating issues too. If you really want to replace a jar, you should patch the jar by placing the jar inside <APIM_HOME>/repository/components/patches/patch0100/. Here 0100 is an arbitrary number.

Bee
  • 12,251
  • 11
  • 46
  • 73
  • Thanks Bhathiya for the answer! I cound run the osgi prompt in windows shell using -DosgiConsole, so that I can enter osgi commands(such as ss),but I am unable to do it in Linux(I could start wso2server as foreground process,but there is no way to enter osgi commands. I am using the command(modify wso2server.sh to make it run as forground process) : sh bin/wso2server.sh -Dprofile=gateway-manager -DosgiConsole start – Tom Aug 22 '16 at 01:46
  • To run it in forground you can simply drop `start` like this. `sh bin/wso2server.sh -Dprofile=gateway-manager -DosgiConsole` – Bee Aug 22 '16 at 02:43
  • Thanks Bhathiya. I am able to run with osgiconsole.When the server starts,in the OSGI prompt, i entered ss impl, and I found the bundle org.wso2.carbon.apimgt.impl is active, so it may not be a bundle activating issue. – Tom Aug 22 '16 at 03:14
  • Any other thing that may lead to this problem? @Bhathiya – Tom Aug 22 '16 at 06:21
  • what is the jar you changed? did you follow patching approach? – Bee Aug 22 '16 at 06:22
  • I am changing org.wso2.carbon.apimgt.impl.XXX.jar, In the IDE, i make a small change to one java file and compile it into class,and I replace it into the jar using rar/zip tools. I didn't follow the patching approach, actually we have used replacement approach for several times. I didn't try to follow the patching approach, it looks to me the replacement approach won't do the harm that could affect the osgi activating – Tom Aug 22 '16 at 06:58
  • What is the JDK version you used to compile? Are you using the same JRE version in the runtime? What is your APIM version? – Bee Aug 22 '16 at 08:10
  • The JRE that runs APIM and the jdk to compile the java file are the same:1.7.0_79. The APIM version is 1.9.0. When we change back to the original jar(shipped in APIM), the problem still there. Are the jars or temp files cached somewhere after the wso2server startup? if so, looks I need to clean the cached files. – Tom Aug 22 '16 at 09:27
  • Can you check md5sum of jar before and after server startup? – Bee Aug 22 '16 at 09:50
  • Thanks @Bhathiya for the replay. I am using Linux md5sum to calculate the md5 sum on the jar $APIM_HOME/repository/components/plugins/org.wso2.carbon.apimgt.impl_1.2.4.jar before and after the server starts up, and md5 sum are the same. – Tom Aug 22 '16 at 10:01
  • Ok. 1 more thing to check. Using OSGi console, check if `org.wso2.carbon.apimgt.impl` package is exported by the impl jar. – Bee Aug 22 '16 at 11:22
  • Thanks @Bhathiya for the replay. I am using osgi command packages to list the exported packages of bundle org.wso2.carbon.apimgt.impl. But it looks that the exported packages shown are only the packages belonging to the 3rd party library? That is, the packages that belongs to org.wso2.carbon.apimgt.impl itsefl are not shown using packages commands, Is there command to show the bundle's owning exported package? – Tom Aug 23 '16 at 03:53
  • use `b ` – Bee Aug 23 '16 at 03:56
  • Thanks @Bhathiya. I checked the bundle org.wso2.carbon.apimgt.impl and the package is exported .. – Tom Aug 23 '16 at 07:01
  • This issue is resolved due to some class loading issue,Thanks @Bhathiya for the patient help. – Tom Aug 24 '16 at 06:10
  • Great. You're welcome. It's better if you can post an answer about the issue you had and how you resolved it. That might help someone else too. – Bee Aug 24 '16 at 06:55
  • 1
    We are deploying our own war app on the APIM Console. Looks the war contains a CXF jar, which conflicts with APIM's own CXF jar that leads to the problem.We are simply un-deploy the war,and the problem is gone. – Tom Aug 24 '16 at 08:16
  • Great. Please post it as an answer. – Bee Aug 24 '16 at 08:33
1

We are deploying our own war app on the APIM Console. Looks the war contains a CXF jar, which conflicts with APIM's own CXF jar that leads to the problem.We are simply un-deploy the war,and the problem is gone

Tom
  • 5,848
  • 12
  • 44
  • 104