mardi 13 mai 2014

mule - connecteur configuration MongoDB en MuleStudio lorsque l'authentification est désactivée - « impossible de se connecter » erreur - Stack Overflow


I'm writing some flows in MuleStudio that save to and query a MongoDB database. The flows work fine when pointed at a database that has one user with dbAdmin and userAdmin roles and is configured with that user's credentials. However, when I point it to a different database with no users added, I get the error below. I kept the username and password in the MongoDB connector config in Mule, as dummy text as is suggested in the documentation, then took them out, but to no avail. I'm using 3.3.1 CE runtime.


Error message with dummy credentials:


ERROR 2013-10-10 14:48:08,176 [[sso-mds].connector.http.mule.default.receiver.02] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Work Descriptor. Root Exception was: Could not create a validated object, cause: Couldn't connect with the given credentials. Type: class java.util.NoSuchElementException
ERROR 2013-10-10 14:48:08,181 [[sso-mds].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Failed to invoke findObjectsUsingQueryMap. Message payload is of type: LinkedHashMap
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Could not create a validated object, cause: Couldn't connect with the given credentials (java.util.NoSuchElementException)
org.apache.commons.pool.impl.GenericKeyedObjectPool:1219 (null)
2. Failed to invoke findObjectsUsingQueryMap. Message payload is of type: LinkedHashMap (org.mule.api.MessagingException)
org.mule.module.mongo.processors.FindObjectsUsingQueryMapMessageProcessor:177 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.util.NoSuchElementException: Could not create a validated object, cause: Couldn't connect with the given credentials
at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1219)
at org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionManager.acquireConnection(MongoCloudConnectorConnectionManager.java:437)
at org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionManager.acquireConnection(MongoCloudConnectorConnectionManager.java:27)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

Error message with no credentials:


ERROR 2013-10-10 14:19:48,572 [[sso-mds].connector.http.mule.default.receiver.02] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Work Descriptor. Root Exception was: null. Type: class java.lang.NullPointerException
ERROR 2013-10-10 14:19:48,574 [[sso-mds].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Failed to invoke findObjectsUsingQueryMap. Message payload is of type: LinkedHashMap
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionKey:86 (null)
2. Failed to invoke findObjectsUsingQueryMap. Message payload is of type: LinkedHashMap (org.mule.api.MessagingException)
org.mule.module.mongo.processors.FindObjectsUsingQueryMapMessageProcessor:177 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionKey.hashCode(MongoCloudConnectorConnectionKey.java:86)
at java.util.HashMap.hash(Unknown Source)
at java.util.HashMap.getEntry(Unknown Source)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

Mule config:


<mongo:config name="Mongo_DB"  doc:name="Mongo DB" database="${mongo.db}" host="${mongo.host}" port="${mongo.port}" password="${db.password}" username="${db.username}>
<mongo:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>
</mongo:config>
<flow name="user_gets_simple" doc:name="user_gets_simple">
<composite-source doc:name="Composite Source">
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/getAll" doc:name="HTTP /user/getAll"/>
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/getByUsername" doc:name="HTTP /user/getByUsername"/>
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/getById" doc:name="HTTP /user/getById"/>
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/getByEmail" doc:name="HTTP /user/getByEmail"/>
</composite-source>
<flow-ref name="get_from_MongoDB" doc:name="Get from MongoDB subflow"/>
</flow>

<flow name="user_save_flow" doc:name="user_save_flow">
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/save" doc:name="HTTP /user/save" />
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.util.Map"/>
<mongo:insert-object-from-map config-ref="Mongo_DB" collection="${mongo.collection}" doc:name="Insert in Mongo DB" >
<mongo:element-attributes>
<mongo:element-attribute key="firstName">#[payload.firstName]</mongo:element-attribute>
<mongo:element-attribute key="lastName">#[payload.lastName]</mongo:element-attribute>
<mongo:element-attribute key="location">#[payload.location]</mongo:element-attribute>
</mongo:element-attributes>
</mongo:insert-object-from-map>
<set-payload value="Saved successfully" doc:name="Set Payload"/>
</flow>

<sub-flow name="get_from_MongoDB" doc:name="get_from_MongoDB">
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<mongo:find-objects-using-query-map config-ref="Mongo_DB" collection="${mongo.collection}" doc:name="Find objects in Mongo DB" limit="5">
<mongo:query-attributes ref="#[payload]"/>
</mongo:find-objects-using-query-map>
<mongo:mongo-collection-to-json doc:name="Mongo collection to JSON"/>
</sub-flow>

Any suggestions on how I can connect to this database without adding a user?



I'm writing some flows in MuleStudio that save to and query a MongoDB database. The flows work fine when pointed at a database that has one user with dbAdmin and userAdmin roles and is configured with that user's credentials. However, when I point it to a different database with no users added, I get the error below. I kept the username and password in the MongoDB connector config in Mule, as dummy text as is suggested in the documentation, then took them out, but to no avail. I'm using 3.3.1 CE runtime.


Error message with dummy credentials:


ERROR 2013-10-10 14:48:08,176 [[sso-mds].connector.http.mule.default.receiver.02] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Work Descriptor. Root Exception was: Could not create a validated object, cause: Couldn't connect with the given credentials. Type: class java.util.NoSuchElementException
ERROR 2013-10-10 14:48:08,181 [[sso-mds].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Failed to invoke findObjectsUsingQueryMap. Message payload is of type: LinkedHashMap
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Could not create a validated object, cause: Couldn't connect with the given credentials (java.util.NoSuchElementException)
org.apache.commons.pool.impl.GenericKeyedObjectPool:1219 (null)
2. Failed to invoke findObjectsUsingQueryMap. Message payload is of type: LinkedHashMap (org.mule.api.MessagingException)
org.mule.module.mongo.processors.FindObjectsUsingQueryMapMessageProcessor:177 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.util.NoSuchElementException: Could not create a validated object, cause: Couldn't connect with the given credentials
at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1219)
at org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionManager.acquireConnection(MongoCloudConnectorConnectionManager.java:437)
at org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionManager.acquireConnection(MongoCloudConnectorConnectionManager.java:27)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

Error message with no credentials:


ERROR 2013-10-10 14:19:48,572 [[sso-mds].connector.http.mule.default.receiver.02] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Work Descriptor. Root Exception was: null. Type: class java.lang.NullPointerException
ERROR 2013-10-10 14:19:48,574 [[sso-mds].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Failed to invoke findObjectsUsingQueryMap. Message payload is of type: LinkedHashMap
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionKey:86 (null)
2. Failed to invoke findObjectsUsingQueryMap. Message payload is of type: LinkedHashMap (org.mule.api.MessagingException)
org.mule.module.mongo.processors.FindObjectsUsingQueryMapMessageProcessor:177 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionKey.hashCode(MongoCloudConnectorConnectionKey.java:86)
at java.util.HashMap.hash(Unknown Source)
at java.util.HashMap.getEntry(Unknown Source)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

Mule config:


<mongo:config name="Mongo_DB"  doc:name="Mongo DB" database="${mongo.db}" host="${mongo.host}" port="${mongo.port}" password="${db.password}" username="${db.username}>
<mongo:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_GROW"/>
</mongo:config>
<flow name="user_gets_simple" doc:name="user_gets_simple">
<composite-source doc:name="Composite Source">
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/getAll" doc:name="HTTP /user/getAll"/>
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/getByUsername" doc:name="HTTP /user/getByUsername"/>
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/getById" doc:name="HTTP /user/getById"/>
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/getByEmail" doc:name="HTTP /user/getByEmail"/>
</composite-source>
<flow-ref name="get_from_MongoDB" doc:name="Get from MongoDB subflow"/>
</flow>

<flow name="user_save_flow" doc:name="user_save_flow">
<http:inbound-endpoint exchange-pattern="request-response" host="${my.host}" port="${my.ID}" path="user/save" doc:name="HTTP /user/save" />
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.util.Map"/>
<mongo:insert-object-from-map config-ref="Mongo_DB" collection="${mongo.collection}" doc:name="Insert in Mongo DB" >
<mongo:element-attributes>
<mongo:element-attribute key="firstName">#[payload.firstName]</mongo:element-attribute>
<mongo:element-attribute key="lastName">#[payload.lastName]</mongo:element-attribute>
<mongo:element-attribute key="location">#[payload.location]</mongo:element-attribute>
</mongo:element-attributes>
</mongo:insert-object-from-map>
<set-payload value="Saved successfully" doc:name="Set Payload"/>
</flow>

<sub-flow name="get_from_MongoDB" doc:name="get_from_MongoDB">
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<mongo:find-objects-using-query-map config-ref="Mongo_DB" collection="${mongo.collection}" doc:name="Find objects in Mongo DB" limit="5">
<mongo:query-attributes ref="#[payload]"/>
</mongo:find-objects-using-query-map>
<mongo:mongo-collection-to-json doc:name="Mongo collection to JSON"/>
</sub-flow>

Any suggestions on how I can connect to this database without adding a user?


0 commentaires:

Enregistrer un commentaire