WSO2 - Error while invoking APIUsageStatisticsClient for ProviderAPIUsage - wso2

I have setup WSO2 API Manager (version 1.9.1) and have configured it with BAM (version 2.5.0) following the instructions provided here to the letter:
https://docs.wso2.com/display/AM191/Publishing+API+Runtime+Statistics
I am using MySQL server and can see the api_* tables created and getting updated as I make API calls. However, when I go to look at the statistics, I see an exception on the console, while the UI tells me that I need to configure BAM to see the dashboards.
Here is a snippet of the ERRORs seen in wso2carbon.log
TID: [0] [AM] [2015-11-19 11:27:39,110] ERROR {org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject} - Error while invoking APIUsageStatisticsClient for ProviderAPIUsage {org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject}
org.wso2.carbon.apimgt.usage.client.exception.APIMgtUsageQueryServiceClientException: Error occurred while querying from JDBC databasecom.mysql.jdbc.driver
at org.wso2.carbon.apimgt.usage.client.APIUsageStatisticsClient.queryFirstAccess(APIUsageStatisticsClient.java:2762)
at org.wso2.carbon.apimgt.usage.client.APIUsageStatisticsClient.getFirstAccessTime(APIUsageStatisticsClient.java:2706)
... 65 more
Caused by: java.sql.SQLException: com.mysql.jdbc.driver
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635)
at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:188)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:128)
at org.wso2.carbon.apimgt.usage.client.APIUsageStatisticsClient.queryFirstAccess(APIUsageStatisticsClient.java:2730)
... 65 more
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.driver
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:475)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:246)
... 71 more
TID: [0] [AM] [2015-11-19 11:27:39,138] ERROR {JAGGERY.modules.statistics.usage:jag} - java.lang.NullPointerException: null {JAGGERY.modules.statistics.usage:jag}
I have looked at other similar posts but nothing seems to be exactly relevant. The closest similar post had a SQL Server specific issue, but I am using MySQL.
Additional Information: I am running BAM and API Manager on the same machine. I have set offset on BAM to 3 as recommended in the guide.

Apparently, you have not added the SQL connector to /repository/components/lib and /repository/components/lib folders. This is mentioned in the step 5 of https://docs.wso2.com/display/AM191/Publishing+API+Runtime+Statistics.
Make sure that the SQL connector is correctly placed on those locations

If you are trying above scenario in a Windows environment, please use "mysql-connector-java-5.1.30" connector and place it in /repository/components/lib and /repository/components/lib folders. This could be due to a connector version problem.

Related

Exception running the WSO2 Identity Server STS Client

I running the STS Client from sample located in
https://docs.wso2.com/display/IS540/Downloading+a+Sample
I am using 'sts-policy-ut.xml' as my policy (please refer to the code). I get the SAML2 tokens and I can validate too. When when I enable relyingPary flag in the 'client.properties' file, I get the following error :
java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMElementImpl cannot be cast to org.w3c.dom.Element
at org.apache.rampart.builder.BindingBuilder.handleSupportingTokens(BindingBuilder.java:392)
at org.apache.rampart.builder.SymmetricBindingBuilder.doSignBeforeEncrypt(SymmetricBindingBuilder.java:499)
at org.apache.rampart.builder.SymmetricBindingBuilder.build(SymmetricBindingBuilder.java:86)
at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:144)
at org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:65)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:427)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:406)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:555)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:531)
at org.wso2.carbon.identity.samples.sts.Client.run(Client.java:239)
at org.wso2.carbon.identity.samples.sts.Client.main(Client.java:95)
Please let me know how to fix it. I just using the recommended Maven way to build the project and running the supplied batch file.
I finally upgraded the Axis 2 library including the Ramapart jars to the following :
i) Axis 2 - 1.7.7
ii) Rampart - 1.7.0
This solved the problem. So this seems to be a bug with Axis 1.6.1 the version which the WSO2 uses for its examples.

WSO2 EI Analytics Profile Database configuration

I'm configuring WSO2 EI Analytics profile to use PostgreSQL instead of H2 database.
I have changed the following files:
analytics-datasources.xml,
master-datasources.xml,
metrics-datasources.xml
in \wso2\analytics\conf\datasources.
I have, also, executed the scripts to create the database in dbscripts. The scripts generate only tables for metrics and master, but they do not create tables for analytics.
Anyway when I run the analytics server i have some errors as shown below:
Failed to perform Category Drilldown on table: org_wso2_esb_analytics_stream_MediatorStatPerMinute: Error while connecting to the remote service. Connection refused (Connection refused) {JAGGERY.controllers.apis.eianalytics:jag}
TID: [-1234] [] [2017-11-06 16:43:00,262] ERROR {org.wso2.carbon.databridge.core.internal.queue.QueueWorker} - Dropping wrongly formatted event sent for -1234 {org.wso2.carbon.databridge.core.internal.queue.QueueWorker}
org.wso2.carbon.databridge.core.exception.EventConversionException: Error when converting org.wso2.esb.analytics.stream.FlowEntry:1.0.0 of event bundle with events 1
at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.createEventList(ThriftEventConverter.java:181)
at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.toEventList(ThriftEventConverter.java:90)
at org.wso2.carbon.databridge.core.internal.queue.QueueWorker.run(QueueWorker.java:73)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.wso2.carbon.databridge.core.exception.EventConversionException: No StreamDefinition for streamId org.wso2.esb.analytics.stream.FlowEntry:1.0.0 present in cache
at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.createEventList(ThriftEventConverter.java:166)
... 7 more
It seems they are missing some database tables, but i don't know how to create them.
These errors are not present when i use H2 database with the default configuration.
Anyone can help me?
I solved the problem.
It was a JDBC driver problem.
With JDK 1.8 it is necessary to use the PostgreSQL JDBC 42.1.4.
I hope it will be useful for someone.

WSO2 API Manager 2.1 Analytics cannot be restarted when using Oracle DB

When restarting APIM Analytics the following error appears in log (the first run is ok). We need to truncate ANX___8GEKYOMM_ table for being able to start it again.
TID: [-1234] [] ERROR {org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceComponent} - Error in activating analytics data service: null {org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceComponent}
java.lang.RuntimeException
at org.wso2.carbon.analytics.datasource.rdbms.RDBMSAnalyticsRecordStore$RDBMSResultSetIterator.next(RDBMSAnalyticsRecordStore.java:881)
at org.wso2.carbon.analytics.datasource.rdbms.RDBMSAnalyticsRecordStore$RDBMSResultSetIterator.hasNext(RDBMSAnalyticsRecordStore.java:843)
at org.apache.commons.collections.IteratorUtils.toList(IteratorUtils.java:848)
at org.apache.commons.collections.IteratorUtils.toList(IteratorUtils.java:825)
at org.wso2.carbon.analytics.datasource.core.util.GenericUtils.listRecords(GenericUtils.java:284)
at org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceImpl.readTenantIds(AnalyticsDataServiceImpl.java:468)
Caused by: java.lang.NullPointerException
at java.io.OutputStream.write(OutputStream.java:75)
at org.wso2.carbon.analytics.datasource.rdbms.RDBMSAnalyticsRecordStore$RDBMSResultSetIterator.extractDataFromRS(RDBMSAnalyticsRecordStore.java:890)
at org.wso2.carbon.analytics.datasource.rdbms.RDBMSAnalyticsRecordStore$RDBMSResultSetIterator.next(RDBMSAnalyticsRecordStore.java:863)
... 124 more
I have solved it upgrading from org.wso2.carbon.analytics.datasource.rdbms-1.3.0.jar to org.wso2.carbon.analytics.datasource.rdbms-1.3.6.jar

WSO2 DAS server configuration issue - Dropping wrongly formatted event sent for -1234

I have configured DAS with API manager server using REST client, but not able to push data to DAS server. Please see error logs in DAS server. Could you please help me to understand what is wring in configuration?
TID: [-1234] [] [2016-05-20 18:07:05,566] ERROR {org.wso2.carbon.databridge.core.internal.queue.QueueWorker} - Dropping wrongly formatted event sent for -1234 {org.wso2.carbon.databridge.core.internal.queue.QueueWorker}
org.wso2.carbon.databridge.core.exception.EventConversionException: Error when converting org.wso2.apimgt.statistics.throttle:1.0.0 of event bundle with events 1
at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.createEventList(ThriftEventConverter.java:181)
at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.toEventList(ThriftEventConverter.java:90)
at org.wso2.carbon.databridge.core.internal.queue.QueueWorker.run(QueueWorker.java:73)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.wso2.carbon.databridge.core.exception.EventConversionException: No StreamDefinition for streamId org.wso2.apimgt.statistics.throttle:1.0.0 present in cache
at org.wso2.carbon.databridge.receiver.thrift.converter.ThriftEventConverter.createEventList(ThriftEventConverter.java:166)
... 7 more
Can you try redeploying the car app again. For that first do following
Delete the .car application from /repository/deployment/server/carbonapps
Delete any existing streams defs (related to APIM stats) by login to DAS management console and going to Manage > Event > Streams
Re deploy car app by putting it in /repository/deployment/server/carbonapps
If everything goes well you would see two scripts in Manage > Batch Analytics > Scripts section. Try to execute each script and see if there is any error.

Axis2 + spring + mongodb

I am trying to integrate Axis2/Spring/Mongodb on wso2 application server.
I got spring context hooked up to the axis2 webservice. Once I am trying to access
MongoDB,the following error occurs
Caused by: java.lang.ClassNotFoundException: org.springframework.transaction.support.ResourceHolder
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:475)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 53 more
The error should be pretty straight forward to solve, fix my dependencies/copy the jar spring-tx jar file in somekind of a lib folder....
It seems that it is not so obvious with wso2 application server. Where should I put my jar files in order to have them loaded ?
Many thanks,
Skip