David Riccitelli
David Riccitelli

Reputation: 7812

WSO2 API Manager on PostgreSQL raising exception when user logging to a store

I have a WSO2 API Manager v1.4.0 configured to use PostgreSQL.

After signing up, users can't login to the store and an exception is raised in the console. I also tried logging on with the default admin account.

The error does not occur when using MySQL as DBMS or when logging in to the publisher Web UI.

How do I fix this error?

The full stack trace:

[2013-08-08 15:47:59,974] ERROR - JDBCUserStoreManager Cannot change transaction isolation level in the middle of a transaction.
org.postgresql.util.PSQLException: Cannot change transaction isolation level in the middle of a transaction.
        at org.postgresql.jdbc2.AbstractJdbc2Connection.setTransactionIsolation(AbstractJdbc2Connection.java:819)

(...)

[2013-08-08 15:47:59,980]  WARN - CarbonAuthenticationUtil Failed Administrator login attempt 'admin[-1234]' at [2013-08-08 15:47:59,980+0200]
[2013-08-08 15:47:59,981]  WARN - AuthenticationHandler Illegal access attempt at [2013-08-08 15:47:59,0981] from IP address 185.12.7.138 while trying to authenticate access to service UserAdmin
[2013-08-08 15:47:59,982] ERROR - AUDIT_LOG Illegal access attempt at [2013-08-08 15:47:59,0981] from IP address 185.12.7.138 while trying to authenticate access to service UserAdmin
[2013-08-08 15:47:59,983] ERROR - AxisEngine Access Denied. Authentication failed - System error occurred. Please check server logs for more details.
org.apache.axis2.AxisFault: Access Denied. Authentication failed - System error occurred. Please check server logs for more details.
        at org.wso2.carbon.server.admin.module.handler.AuthenticationHandler.authenticate(AuthenticationHandler.java:103)

(...)

[2013-08-08 15:47:59,990] ERROR - APIStoreHostObject Error occurred while checking for multiple user stores
[2013-08-08 15:48:00,045]  INFO - CarbonAuthenticationUtil '[email protected] [-1234]' logged in at [2013-08-08 15:48:00,044+0200]
[2013-08-08 15:48:00,124] ERROR - ApiMgtDAO Failed to get Subscriber for :admin
org.postgresql.util.PSQLException: ERROR: relation "am_subscriber" does not exist
  Position: 97
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2101)

(...)

[2013-08-08 15:47:59,978] ERROR - JDBCUserStoreManager Using sql : null
[2013-08-08 15:47:59,978] ERROR - BasicAccessAuthenticator Unable to get UserStoreManager for authentication. User - admin
org.wso2.carbon.user.core.UserStoreException: Authentication Failure
        at org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager.doAuthenticate(JDBCUserStoreManager.java:810)

(...)

[2013-08-08 15:48:00,129] ERROR - APIStoreHostObject Error while getting Subscriber
org.wso2.carbon.apimgt.api.APIManagementException: Failed to get Subscriber
        at org.wso2.carbon.apimgt.impl.AbstractAPIManager.handleException(AbstractAPIManager.java:621)

(...)

Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Failed to get Subscriber for :admin
        at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.handleException(ApiMgtDAO.java:3911)
        at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.getSubscriber(ApiMgtDAO.java:917)
        at org.wso2.carbon.apimgt.impl.APIConsumerImpl.getSubscriber(APIConsumerImpl.java:87)
        ... 52 more
Caused by: org.postgresql.util.PSQLException: ERROR: relation "am_subscriber" does not exist
  Position: 97
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2101)

(...)

[2013-08-08 15:48:00,133] ERROR - RhinoEngine org.mozilla.javascript.WrappedException: Wrapped org.wso2.carbon.apimgt.api.APIManagementException: Error while getting Subscriber (/store/modules/user/
login.jag#30)
[2013-08-08 15:48:00,134] ERROR - WebAppManager org.mozilla.javascript.WrappedException: Wrapped org.wso2.carbon.apimgt.api.APIManagementException: Error while getting Subscriber (/store/modules/use
r/login.jag#30)
org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.WrappedException: Wrapped org.wso2.carbon.apimgt.api.APIManagementException: Error while getting Subscriber (/store/modu
les/user/login.jag#30)
        at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:446)

(...)

Caused by: org.mozilla.javascript.WrappedException: Wrapped org.wso2.carbon.apimgt.api.APIManagementException: Error while getting Subscriber (/store/modules/user/login.jag#30)
        at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1654)

(...)

Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Error while getting Subscriber
        at org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject.handleException(APIStoreHostObject.java:134)

(...)

Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Failed to get Subscriber
        at org.wso2.carbon.apimgt.impl.AbstractAPIManager.handleException(AbstractAPIManager.java:621)

(...)

Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Failed to get Subscriber for :admin
        at org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO.handleException(ApiMgtDAO.java:3911)

(...)

Caused by: org.postgresql.util.PSQLException: ERROR: relation "am_subscriber" does not exist
  Position: 97
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2101)

(...)
[2013-08-08 15:48:00,202] ERROR - RhinoEngine org.mozilla.javascript.EcmaError: TypeError: Cannot read property "h1" from undefined (/store/site/themes/fancy/templates/errors/template.jag#18)
[2013-08-08 15:48:00,203] ERROR - WebAppManager org.mozilla.javascript.EcmaError: TypeError: Cannot read property "h1" from undefined (/store/site/themes/fancy/templates/errors/template.jag#18)
org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "h1" from undefined (/store/site/themes/fancy/templates/errors/template.jag#1
8)
        at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:446)

(...)

Upvotes: 0

Views: 1644

Answers (1)

thariyarox
thariyarox

Reputation: 464

This issue is fixed in the later versions of API Manager where you have to add the,

<defaultAutoCommit>true</defaultAutoCommit> 

property to the datasource configuration.

Also, remove the element,

<validationQuery>SELECT 1</validationQuery> 

from the configuration.

This is mentioned in https://docs.wso2.com/display/IS510/Setting+up+PostgreSQL

Sample is below.

<datasource>
            <name>WSO2AM_DB</name>
            <description>The datasource used for API Manager database</description>
            <jndiConfig>
                <name>jdbc/WSO2AM_DB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:postgresql://localhost:5432/amdb</url>
                    <username>sdpuser</username>
                    <password>sdpuser</password>
                    <defaultAutoCommit>true</defaultAutoCommit>
                    <driverClassName>org.postgresql.Driver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

Upvotes: 3

Related Questions