Query execution failed for dataset... Incorrect syntax near '}' - reporting-services

The following error occurs when I run a report in SSRS Report Portal:
An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'DataSet1'. (rsErrorExecutingCommand)
Incorrect syntax near '}'.
<DataSet Name="EstimateYear">
<Query>
<DataSourceName>DataSource1</DataSourceName>
<CommandText>
SELECT
{
} ON 0,
{
(
[EstimateYear].[Year].[Year],
ORDER
(
[EstimateYear].[Version].[Version],
[EstimateYear].[Version].MEMBER_VALUE,
ASC
)
)
} ON 1
FROM
[Model]
WHERE
{
[EstimateYear].[CurrentVersion].[1]
}
</CommandText>
<rd:DesignerState>
<QueryDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/AnalysisServices/QueryDefinition">
...
</QueryDefinition>
</rd:DesignerState>
</Query>
<Fields>
<Field Name="Field1">
<DataField>...</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Field2">
<DataField>...</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Field3">
<Value>=...</Value>
</Field>
</Fields>
</DataSet>
Please note: I have a custom security extension applied to the Report Server. I am running tests at the time of writing to rule out whether the is causing the error.
Can you see an error with this or have any idea where else the error might be happening?

Related

DS Fault Message: Error in 'createProcessedPreparedStatement' in WSO2 DataService

I have created a Dataservice in WSO2 to execute SQL Query TRUNCATE TABLE Student and expose it as an API , but i got this error
[2022-12-07 16:33:57,222] ERROR {DBInOnlyMessageReceiver} - Error in
in-only message receiver DS Fault Message: Error in DS non result
invoke. DS Code: DATABASE_ERROR Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in
'SQLQuery.processStoredProcQuery': DS Fault Message: Error in
'createProcessedPreparedStatement' DS Code: UNKNOWN_ERROR Nested
Exception:- java.sql.SQLException: Unable to retrieve metadata for
procedure.
DS Code: DATABASE_ERROR Source Data Service:- Name: RADMINDataService
Location:
/home/master/Downloads/IntegrationStudio/runtime/microesb/tmp/carbonapps/-1234/1670427210936TestCompositeApplication_1.0.0.car/RADMINDataService_1.0.0/RADMINDataService-1.0.0.dbs
Description: Exposing the radmin data service as a REST service
Default Namespace: http://ws.wso2.org/dataservice/samples/json_sample
Current Request Name: _gettruncatenumseq Current Params: {} Nested
Exception:- DS Fault Message: Error in
'createProcessedPreparedStatement' DS Code: UNKNOWN_ERROR Nested
Exception:- java.sql.SQLException: Unable to retrieve metadata for
procedure.
at
org.wso2.micro.integrator.dataservices.core.dispatch.SingleDataServiceRequest.processSingleRequest(SingleDataServiceRequest.java:117)
at
org.wso2.micro.integrator.dataservices.core.dispatch.SingleDataServiceRequest.processRequest(SingleDataServiceRequest.java:66)
at
org.wso2.micro.integrator.dataservices.core.dispatch.DataServiceRequest.dispatch(DataServiceRequest.java:358)
at
org.wso2.micro.integrator.dataservices.core.DataServiceProcessor.dispatch(DataServiceProcessor.java:40)
at
org.wso2.micro.integrator.dataservices.core.DBInOnlyMessageReceiver.invokeBusinessLogic(DBInOnlyMessageReceiver.java:52)
at
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at
org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:376)
at
org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:190)
at
org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834) Caused by:
javax.xml.stream.XMLStreamException: DS Fault Message: Error in
'SQLQuery.processStoredProcQuery': DS Fault Message: Error in
'createProcessedPreparedStatement' DS Code: UNKNOWN_ERROR Nested
Exception:- java.sql.SQLException: Unable to retrieve metadata for
procedure.
This is my configuration file
<query id="truncatenum" useConfig="mysql">
<sql><![CDATA[TRUNCATE TABLE Student]]></sql>
</query>
<resource method="GET" path="truncatenum">
<description />
<call-query href="truncatenum"/>
</resource>
I don't think the error is caused by the code snippet you shared. The following seems correct.
<query id="truncatenum" useConfig="mysql">
<sql><![CDATA[TRUNCATE TABLE Student]]></sql>
</query>
<resource method="GET" path="truncatenum">
<description />
<call-query href="truncatenum"/>
</resource>
Probably one of the queries you have doesn't match the input parameters you are providing. Hence double check all the other queries you have.
Update
You are correct the TRUNCATE query is executed as a STOREDPROC. I had a closer look at the source-code and it seems if the QUERY String doesn't start with one of the following it's inferred as a STOREDPROC. This is definitely a bug in WSO2.
The weird thing is, in my case the TRUNCATE query is executed as a Stored Procedure successfully. So I assume there is a difference in your Dataeervice from the one I'm trying. Can you create the following Dataservice as it is and try it out? (Just change the connection parameters)
Dataservice
<data name="RESTDataService" serviceNamespace="http://ws.wso2.org/dataservice/samples/json_sample" transports="http https">
<description>Exposing the data service as a REST service.</description>
<config id="default">
<property name="driverClassName">com.mysql.jdbc.Driver</property>
<property name="url">jdbc:mysql://localhost:3306/school_db</property>
<property name="org.wso2.ws.dataservice.user">root</property>
<property name="org.wso2.ws.dataservice.password">root123456</property>
</config>
<resource method="GET" path="truncatenum">
<description />
<call-query href="truncatenum" />
</resource>
<query id="truncatenum" useConfig="default">
<sql><![CDATA[TRUNCATE TABLE students]]></sql>
</query>
</data>
Request
curl --location --request GET 'http://localhost:8290/services/RESTDataService/truncatenum'
If you still get the error. Please enable DEBUG logs for the package org.wso2.micro.integrator.dataservices and share the logs.

WSO2 Couldn't save JSON payload

I use WSO2 EI 6.6.0 and Micro Integrator 4.0.0. I have an api to get data, but for this I need to authenticate and get a token to use in a further request. for authentication I use separately created api and call it from first flow. For authentication I need to create a payload and send it in the request body to the server, but I get an error. The problem is repeated on different servers and I do not understand what is the reason.
My Auth API looks like this:
<api context="/auth" name="AuthGateway" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/gateway">
<inSequence>
<payloadFactory media-type="json">
<format>{"username": "adm", "password": "admin"}</format>
<args/>
</payloadFactory>
<call>
<endpoint>
<http method="post" uri-template="https://1537-212-90-188-166.ngrok.io/auth/login">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<log separator="
">
<property expression="json-eval($)" name="log_auth"/>
</log>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
My Data API looks like this:
<resource methods="GET" uri-template="/fieldCard?*">
<inSequence>
<propertyGroup>
<property name="uri.var.version" expression="$url:version" scope="default" type="STRING"/>
<property name="uri.var.size" expression="$url:size" scope="default" type="STRING"/>
<property name="uri.var.page" expression="$url:page" scope="default" type="STRING"/>
</propertyGroup>
<log level="full" separator="
">
<property name="version" expression="$ctx:uri.var.version"/>
<property name="size" expression="$ctx:uri.var.size"/>
<property name="page" expression="$ctx:uri.var.page"/>
</log>
<call>
<endpoint>
<http method="GET" uri-template="http://localhost:8290/auth/gateway"/>
</endpoint>
</call> .......
In the console I get messages:
[2022-05-02 19:16:12,962] ERROR {JsonStreamBuilder} - Error occurred while processing document for application/json java.lang.reflect.InvocationTargetException
Caused by: org.apache.axis2.AxisFault: #Can not parse stream. MessageID: urn:uuid:7ac6a4c9-0ed1-4973-87d4-69dad6d4a950. Error>>> #getNewJsonPayload. Could not save JSON payload. Invalid input stream found. Payload is not a JSON string.
org.apache.synapse.commons.json.JsonStreamBuilder.processDocument(JsonStreamBuilder.java:43)
... 21 more
Caused by: org.apache.axis2.AxisFault: #getNewJsonPayload. Could not save JSON payload. Invalid input stream found. Payload is not a JSON string.
[2022-05-02 19:16:12,963] ERROR {DeferredMessageBuilder} - Error building message org.apache.axis2.AxisFault
[2022-05-02 19:16:12,964] ERROR {RelayUtils} - Error while building Passthrough stream org.apache.axis2.AxisFault
[2022-05-02 19:16:12,964] ERROR {SequenceMediator} - {api:AuthGateway} Error while building message. Error while building Passthrough stream org.apache.axis2.AxisFault: Error while building Passthrough stream
I removed the detailed stack trace. If it is needed to understand the problem - I can add it.
P.S. When calling the auth API directly I get the token and the response is correct.
[2022-05-02 19:20:17,560] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: http://www.w3.org/2005/08/addressing/anonymous
WSAction:
SOAPAction:
MessageID: urn:uuid:817185a7-39a4-4418-a696-72473672997d
Direction: request
log_auth = {"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMyIsInVzZXJfbmFtZSI6Im...
Payload: {"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiMyIsInVzZXJfbmFtZSI6Im...
Please help me understand the problem.
UPD: I reinstalled the server because I thought the error might be there or I broke the config files. created a new project and wrote a new same thread, but the error still repeats.
Good. The problem was that Postman has a Header Accept-Encoding option. When this parameter was disabled, the request became correct and the response began to come without errors!

NLog with Windsor Castle - how to save log to database (.NET Core 3.1)

I am dealing with the following problem - I was able to use NLog with Windsor Castle after many tries, but it only works if I log a message string to a file. Now I want to save the custom log information to the database but I really don't know how to do it.
My nlog.config:
<targets>
<target name="file" xsi:type="File" fileName="C:\temp\example.log" layout="${longdate}|${level:uppercase=true}|${message}|${exception}" />
<target name="database" xsi:type="Database"
connectionString = "connectionString"
commandText="INSERT INTO [dbo].[EventLog]
(
[CreateDate],
[UserProfileId],
[IsError],
[Type],
[Username],
[Message],
[Description],
[StackTrace],
[AddressIP]
) VALUES (
#CreateDate,
#UserProfileId,
#IsError,
#Type,
#Username,
#Message,
#Description,
#StackTrace,
#AddressIP
)">
<parameter name="#CreateDate" layout="${event-properties:item=CreateDate}" />
<parameter name="#UserProfileId" layout="${event-properties:item=UserProfileId}" />
<parameter name="#IsError" layout="${event-properties:item=IsError}" />
<parameter name="#Type" layout="${event-properties:item=Type}" />
<parameter name="#Username" layout="${event-properties:item=Username}" />
<parameter name="#Message" layout="${event-properties:item=Message}" />
<parameter name="#Description" layout="${event-properties:item=Description}" />
<parameter name="#StackTrace" layout="${event-properties:item=StackTrace}" />
<parameter name="#AddressIP" layout="${event-properties:item=AddressIP}" />
</target>
</targets>
<rules>
<logger name="logger" minlevel="Trace" writeTo="database" />
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
With this config (with commented database part) I'm able to write logs to "example.log".
_logger.Info("test-info");
I tried something like this:
_logger.InfoFormat("\"CreateDate\": {0}, \"Message\": {1}, \"IsError\": {2}, \"Type\": {3}, \"Id\": {4}",
new object[] {
DateTime.Now,
"abcd",
true,
1,
Guid.NewGuid()
});
But exception says that it is impossible to parse Id to unique identifier. I tried to use CASE-END in nlog.config, and I figured out that Id is not passed as parameter (probably rest of data too).
First exception:
System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting from a character string to uniqueidentifier.
After adding CASE WHEN #Id = '' THEN NULL ELSE convert(uniqueidentifier, #Id) END,
System.Data.SqlClient.SqlException (0x80131904): Cannot insert the value NULL into column 'Id', table 'ERS.opt.Dev.dbo.EventLog'; column does not allow nulls. INSERT fails.
How to format log to pass data in schema shown above and save it to database?
You can use message templates to perform structured logging:
_logger.InfoFormat("\"CreateDate\": {CreateDate}, \"Message\": {Message}, \"IsError\": {IsError}, \"Type\": {Type}, \"Id\": {Id}",
new object[] {
DateTime.Now,
"abcd",
true,
1,
Guid.NewGuid()
});
See also: https://github.com/NLog/NLog/wiki/How-to-use-structured-logging
Notice that by default then database-target <parameter> uses DbType="String". If database-column is defined with other datatype, then make sure to explicit specify DbType so it matches the column.

JdbcTemplate - SQLWarning ignored: SQL state '22007', error code '1292', message [Truncated incorrect DOUBLE value: 'stepExecutionContext[toId]']

I am simply developing the Spring Batch partitioned code looking at http://www.mkyong.com/spring-batch/spring-batch-partitioning-example/ and already went through the link : Error Code 1292 - Truncated incorrect DOUBLE value - Mysql but it did not solved my purpose.
I have the following bean
<bean id="pagingItemReader" class="org.springframework.batch.item.database.JdbcPagingItemReader" scope="step">
<property name="dataSource" ref="dataSource" />
<property name="pageSize" value="200" />
<property name="queryProvider">
<bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="selectClause" value="SELECT customerNumber, checkNumber,paymentDate,amount" />
<property name="fromClause" value="FROM classicmodels.payments" />
<property name="whereClause" value="${payments.query.where.clause}" />
<property name="sortKey" value="customerNumber" />
</bean>
</property>
<!-- Inject via the ExecutionContext in rangePartitioner -->
<property name="parameterValues">
<map>
<entry key="fromId" value="stepExecutionContext[fromId]" />
<entry key="toId" value="stepExecutionContext[toId]" />
</map>
</property>
<property name="rowMapper">
<bean class="com.prateek.mapper.PaymentsRowMapper" />
</property>
</bean>
Getting below error:
2018-07-16 01:28:30 DEBUG o.s.jdbc.core.JdbcTemplate - SQLWarning ignored: SQL state '22007', error code '1292', message [Truncated incorrect DOUBLE value: 'stepExecutionContext[fromId]']
2018-07-16 01:28:30 DEBUG o.s.jdbc.core.JdbcTemplate - SQLWarning ignored: SQL state '22007', error code '1292', message [Truncated incorrect DOUBLE value: 'stepExecutionContext[fromId]']
2018-07-16 01:28:30 DEBUG o.s.jdbc.core.JdbcTemplate - SQLWarning ignored: SQL state '22007', error code '1292', message [Truncated incorrect DOUBLE value: 'stepExecutionContext[toId]']
2018-07-16 01:28:30 DEBUG o.s.jdbc.core.JdbcTemplate - SQLWarning ignored: SQL state '22007', error code '1292', message [Truncated incorrect DOUBLE value: 'stepExecutionContext[toId]']
2018-07-16 01:28:30 DEBUG o.s.b.repeat.support.RepeatTemplate - Repeat is complete according to policy and result value.
2018-07-16 01:28:30 DEBUG o.s.b.c.s.item.ChunkOrientedTasklet - Inputs not busy, ended: true
2018-07-16 01:28:30 DEBUG o.s.b.core.step.tasklet.TaskletStep - Applying contribution: [StepContribution: read=0, written=0, filtered=0, readSkips=0, writeSkips=0, processSkips=0, exitStatus=EXECUTING]
2018-07-16 01:28:30 DEBUG o.s.jdbc.core.JdbcTemplate - SQLWarning ignored: SQL state '22007', error code '1292', message [Truncated incorrect DOUBLE value: 'stepExecutionContext[fromId]']
2018-07-16 01:28:30 DEBUG o.s.jdbc.core.JdbcTemplate - SQL update affected 1 rows
2018-07-16 01:28:30 DEBUG o.s.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
2018-07-16 01:28:30 DEBUG o.s.b.s.t.ResourcelessTransactionManager - Participating in existing transaction
2018-07-16 01:28:30 DEBUG o.s.b.s.t.ResourcelessTransactionManager - Initiating transaction commit
database.properties:
#mysql datasource
spring.datasource.url=jdbc:mysql://localhost:3306/classicmodels?useSSL=false
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
payments.query.where.clause=WHERE customerNumber >= :fromId and customerNumber <= :toId
The error happens because the value stepExecutionContext[fromId] is not evaluated as a SpEL expression and goes raw (as is) to the database server.
The example you linked to uses the correct syntax: <entry key="fromId" value="#{stepExecutionContext[fromId]}" /> but in your example you have: <entry key="fromId" value="stepExecutionContext[fromId]" /> without the #{...}.
Even though the syntax in the example of mkyong is correct, I would recommend using simple quotes around keys in the execution context (<entry key="fromId" value="#{stepExecutionContext['fromId']}" />) as it is mentioned in the official documentation here: https://docs.spring.io/spring-batch/4.0.x/reference/html/step.html#late-binding

FreeMarker FMPP Failed to evaluate function "csv"

Using FMPP version 0.9.15, I'm following the documentation examples to pull data from a CSV file. If I use command line with config.fmpp:
sourceRoot: src
outputRoot: out
data: {tdd(data/style.tdd), birds:csv(data/birds.csv)}
Or ANT config:
<project name="FMPP test" default="build">
<taskdef name="fmpp" classname="fmpp.tools.AntTask">
<classpath>
<pathelement location="lib/fmpp.jar"/>
</classpath>
</taskdef>
<target name="build">
<fmpp
sourceRoot="src" outputRoot="out"
data="tdd(data/style.tdd), birds:csv(data/birds.csv)"
/>
</target>
</project>
I receive the following error either way:
TDD error: Failed to evaluate function "csv".
tdd(data/style.tdd), birds:csv(data/birds.csv)
^
On the other hand, If I switch to "birds:text..." or "birds:splitText..." I do not get the evaluation error. It looks like csv is still supported in the code. Any idea why the TDD data source is not recognizing the csv function?
Did you try adding a space between birds: and csv(data/birds.csv)?
data: {
tdd(data/style.tdd)
birds: csv(data/birds.csv)
}