Mule DB连接器抛出错误:null(java.lang.NullPointerException)。消息有效内容的类型为:String

时间:2014-07-31 13:42:28

标签: database-connection mule esb

在与OSB合作数月之后,我刚刚开始使用Mule。我试图使用数据库连接器从我的postgres数据库中选择数据。测试连接说它很成功。

XML:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
    <db:generic-config name="PostgreSQL_mule" url="jdbc:postgresl://localhost:5432/mule?user=mule&amp;password=mule" driverClassName="org.postgresql.Driver" doc:name="Generic Database Configuration"/>
    <flow name="CheckOnline" doc:name="CheckOnline">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8085" path="CheckOnline" doc:name="HTTP"/>
        <set-payload value="Winkel is online" doc:name="Set Payload"/>
    </flow>
    <flow name="BestelItems" doc:name="BestelItems">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8085" path="BestelItems" doc:name="HTTP"/>
        <db:select config-ref="PostgreSQL_mule" doc:name="Database">
            <db:parameterized-query><![CDATA[SELECT *
FROM OnlineWinkel.Items;]]></db:parameterized-query>
        </db:select>
        <set-payload value="blabla" doc:name="Set Payload"/>
    </flow>
</mule>

DB:

DB table Item

问题: 当我运行它时,我得到DB连接器的错误:

ERROR 2014-07-31 15:32:13,984 [[test].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : null (java.lang.NullPointerException). Message payload is of type: String
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
  org.mule.module.db.internal.domain.connection.DefaultDbConnection:99 (null)
2. null (java.lang.NullPointerException). Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
    at org.mule.module.db.internal.domain.connection.DefaultDbConnection.isClosed(DefaultDbConnection.java:99)
    at org.mule.module.db.internal.domain.connection.TransactionalDbConnectionFactory.releaseConnection(TransactionalDbConnectionFactory.java:150)
    at org.mule.module.db.internal.processor.AbstractDbMessageProcessor.process(AbstractDbMessageProcessor.java:87)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

我不知道出了什么问题。我不会在数据库连接器或我的查询中使用任何变量,因此它们不能是&#39; null&#39;。

任何人都知道出了什么问题或者我如何更好地调试它?错误信息根本不是帮助,也不是堆栈跟踪。

2 个答案:

答案 0 :(得分:0)

我的JDBC字符串中有一个拼写错误。

虽然Mule说测试连接成功,但字符串缺少“q&#39;

。”

答案 1 :(得分:0)

问题在于您的查询字符串。 删除查询字符串末尾的分号,然后重试。

我试过了,而且我的工作很顺利。

希望这有效