Continue the exception from one camel route and handle it in another camel route - exception

I have an Apache Camel route which invokes restlet component and would like to use the redelivery mechanism from the exception handler which performs some processing on every failure to update my database record which should be done on generic route. So, I'm trying to continue the exception in one route and handle the same exception in another route through direct component. But exception is not continuing to generic route.
1st route:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:cxf="http://camel.apache.org/schema/cxf"
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.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<!-- CXF Rest Endpoint Declaration -->
<cxf:rsServer address="http://localhost:9092/rest/corp"
id="FetchCDFRestRequest" serviceClass="com.tcl.Service.Service" />
<bean class="com.tcl.ExceptionOccurredRefProcessor" id="exProc" />
<bean class="org.apache.camel.builder.DeadLetterChannelBuilder"
id="DLCErrorHandler">
<property name="deadLetterUri"
value="activemq:queue:DMS.FAILURES.DLQ" />
<property name="redeliveryPolicy" ref="redeliveryPolicy" />
</bean>
<bean class="org.apache.camel.processor.RedeliveryPolicy"
id="redeliveryPolicy">
<property name="maximumRedeliveries"
value="3" />
<property name="maximumRedeliveryDelay" value="2000" />
<property name="retryAttemptedLogLevel" value="WARN" />
</bean>
<camelContext id="Corp"
xmlns="http://camel.apache.org/schema/spring">
<errorHandler id="eh" onExceptionOccurredRef="exProc">
<redeliveryPolicy id="redeliveryPolicy" />
</errorHandler>
<route id="MainRouteOppIDFolder" streamCache="true">
<from id="_CreateOppIDFolder"
uri="restlet:http://localhost:9092/rest/corp/createOppIDFolder?restletMethod=POST" />
----------
<to uri="restlet:http://localhost:9902/CreateOppIDFolder?restletMethod=POST" />
------------
<onException id="_onException1" useOriginalMessage="true">
<exception>java.lang.Exception</exception>
<handled>
<simple>false</simple>
</handled>
<log id="_log1" message="Cont... ex >>>>> ${exception.message} "/>
<to uri="direct:ExceptionHandle"/>
</onException>
</route>
</camelContext>
</beans>
2nd route:
<route errorHandlerRef="DLCErrorHandler" >
<from id="_from2" uri="direct:ExceptionHandle"/>
<log id="_log4" message="Req>>>>> ${body}"/>
<onException id="_onException2"
onExceptionOccurredRef="exProc" redeliveryPolicyRef="redeliveryPolicy">
<exception>java.lang.Exception</exception>
<handled>
<simple>true</simple>
</handled>
<log id="_log3" loggingLevel="INFO" message="Handled ex >>>>> ${exception.message} "/>
<choice id="_choice1">
<when id="_when1">
<simple>${header.errorMessage} contains 'Could not send Message' || ${header.errorMessage} contains 'Connection timed out'</simple>
<to id="_to1" pattern="OutOnly" uri="activemq:queue:DMS.FAILURES"/>
</when>
<otherwise id="_otherwise1">
<log id="_log5" loggingLevel="ERROR" message="Exception occured in otherwise block >>>>>> ${exception.stacktrace} "/>
</otherwise>
</choice>
</onException>
</route>
12:11:24.384 [Restlet-781390346] WARN o.a.c.processor.DeadLetterChannel - Failed delivery for (MessageId: ID-DESKTOP-P2DBOO5-1580280046927-0-8 on ExchangeId: ID-DESKTOP-P2DBOO5-1580280046927-0-7).On delivery attempt: 0 caught: org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
Caused by: java.net.ConnectException: ConnectException invoking http://172.16.18.113:7001/services/TCLDMSSFDCService/TCLDMSSFDCService: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect
12:11:24.392 [Restlet-781390346] INFO MainRouteOppIDFolder - Cont... ex >>>>> Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
Caused by: java.net.ConnectException: ConnectException invoking http://172.16.18.113:7001/services/TCLDMSSFDCService/TCLDMSSFDCService: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect
12:11:24.396 [Restlet-781390346] INFO _route1 - Req>>>>> {
"oppID" : "10268216",
"salesOrganization" : "Commerical Finance",
"salesVertical" : "CEQ",
"productName" : "Construction Equipment Finance",
"applicantName" : "SGS INFRASTRUCTURE",
"docName" : null,
"appNature" : null,
"docType" : null,
"base64Content" : null
}
12:11:24.405 [Restlet-781390346] ERROR o.a.c.processor.DeadLetterChannel - Failed delivery for (MessageId: ID-DESKTOP-P2DBOO5-1580280046927-0-8 on ExchangeId: ID-DESKTOP-P2DBOO5-1580280046927-0-7). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
Caused by: java.net.ConnectException: ConnectException invoking http://172.16.18.113:7001/services/TCLDMSSFDCService/TCLDMSSFDCService: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect
. Processed by failure processor: FatalFallbackErrorHandler[Pipeline[[Channel[Log(MainRouteOppIDFolder)[Cont... ex >>>>> ${exception.message} ]], Channel[sendTo(direct://ExceptionHandle)], Channel[Log(MainRouteOppIDFolder)]]]]
Message History
RouteId ProcessorId Processor Elapsed (ms)
[MainRouteOppIDFold] [MainRouteOppIDFold] [restlet://http://localhost:9092/rest/corp/createOppIDFolder?restletMethod=POST] [ 21608]
[MainRouteOppIDFold] [_CreateOppIDFolder] [restlet:http://localhost:9902/CreateOppIDFolder?restletMethod=POST ] [ 21319]
[MainRouteOppIDFold] [_to2 ] [direct:ExceptionHandle ] [ 1]
[_route1 ] [_log4 ] [log ] [ 1]
Stacktrace
org.apache.camel.component.restlet.RestletOperationException: Restlet operation failed invoking http://localhost:9902/CreateOppIDFolder with statusCode: 500 /n responseBody:org.apache.cxf.interceptor.Fault: Could not send Message.
Caused by: java.net.ConnectException: ConnectException invoking http://172.16.18.113:7001/services/TCLDMSSFDCService/TCLDMSSFDCService: Connection timed out: connect
Caused by: java.net.ConnectException: Connection timed out: connect```
**Any suggestions please?**

To be honest: I don't see your problem.
Your exception block does
<log id="_log1" message="Cont... ex >>>>> ${exception.message} "/>
<to uri="direct:ExceptionHandle"/>
The direct route does
<log id="_log4" message="Req>>>>> ${body}"/>
And your log shows
Cont... ex >>>>> [error message]
Req>>>>> [message body]
So everything works as you expect. Am I missing something?
Update due to comment
The onException block of the second route is NOT called as long as no Exception occurs in the second route. The second route normally receives a message and processes it.
You can still access the exception information on the message with ${exception}.

Related

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!

camel Spring DSL onException doesn't fire at all

I am using the Camel DSL Spring route as reported below.
As you can see, I want to convert an xls file and if an exception occurs I need to log an error and move file in a specific folder.
It seems none of these steps happen, I just got an exception when converting the file and got a moveFailed of "file" component .
I suspect the exception mechanism does not transpose the handled flag and then the exception returns to caller , the file comp, and it proceeds with the moving.
How do I execute onException mechanism on exception
<route>
<from uri="file:C:/Users/Administrator/Desktop/HB_DATA/mov?delay=1000&move=../mov_done&moveFailed=../mov_fail"/>
<process ref="processor"/>
<to uri="bean:excelConverter"/>
<onException>
<exception >org.savino.hb.dataprovider.DataProviderException</exception>
<handled>
<constant>true</constant>
</handled>
<log loggingLevel="ERROR" message="HEY I GOT AN EXCEPTION" />
<to uri="file:C:/Users/Administrator/Desktop/HB_DATA/mov_fail?fileName={header.X_UID}"/>
<process ref="processorEx"/>
</onException>
<to uri="bean:finish"/>
</route>
The <onException> has to precede the code that is eager to run in error.
In your particular case, just move the exception handling immediately after the 'from', eg:
<route>
<from uri="..."/>
<!-- Exception handling -->
<onException>
<exception>org.savino.hb.dataprovider.DataProviderException</exception>
<handled>
<constant>true</constant>
</handled>
<log loggingLevel="ERROR" message="HEY I GOT AN EXCEPTION" />
<onException>
<!-- The route definition -->
<process ref="processor"/>
<to uri="bean:excelConverter"/>
<to uri="file:..."/>
<to uri="bean:finish"/>
</route>
A possible (more natural) alternative is a try-catch:
http://people.apache.org/~dkulp/camel/try-catch-finally.html

Why does a mule rollback exception propagate to the flow that called it?

I have a mule project where a flow with a rollback exception is causing an exception to be thrown in the flow that references it. Is this normal behaviour?
Here is the code:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file"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="CE-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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<file:connector name="File" autoDelete="true" streaming="false" validateConnections="true" doc:name="File"/>
<flow name="rollbacktestFlow2" doc:name="rollbacktestFlow2">
<file:inbound-endpoint path="C:\RollbackTEst\In" responseTimeout="10000" doc:name="File" connector-ref="File"/>
<logger message="File Rx" level="INFO" doc:name="FileRx"/>
<flow-ref name="rollbacktestFlow1" doc:name="Flow Reference"/>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger message="Rollbacktestflow 2" level="INFO" doc:name="Rollbacktestflow2"/>
</catch-exception-strategy>
</flow>
<flow name="rollbacktestFlow1" doc:name="rollbacktestFlow1" >
<logger message="Rollback trigger" level="INFO" doc:name="RollbackTrigger"/>
<expression-component doc:name="Expression"><![CDATA[forceException]]></expression-component>
<rollback-exception-strategy maxRedeliveryAttempts="4" doc:name="Rollback Exception Strategy">
<logger message="retry" level="INFO" doc:name="retry"/>
<expression-component doc:name="Copy_of_Expression"><![CDATA[forceException]]></expression-component>
<on-redelivery-attempts-exceeded doc:name="Redelivery exhausted">
<logger message="exhausted" level="INFO" doc:name="exhausted"/>
</on-redelivery-attempts-exceeded>
</rollback-exception-strategy>
</flow>
Should the rollback section of the exception not be executed 4 times and then the redelivery exhausted exception be thrown?
Here is the log:
INFO 2014-11-12 15:36:40,529 [main] org.mule.module.launcher.MuleDeploymentService:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'rollbacktest' +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2014-11-12 15:36:40,544 [main] org.mule.module.launcher.DeploymentDirectoryWatcher:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Mule is up and kicking (every 5000ms) +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2014-11-12 15:37:18,031 [[rollbacktest].File.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\RollbackTEst\In\New Text Document.txt
INFO 2014-11-12 15:37:18,048 [[rollbacktest].rollbacktestFlow2.stage1.02] org.mule.api.processor.LoggerMessageProcessor: File Rx
INFO 2014-11-12 15:37:18,048 [[rollbacktest].rollbacktestFlow2.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Rollback trigger
ERROR 2014-11-12 15:37:18,079 [[rollbacktest].rollbacktestFlow2.stage1.02] org.mule.exception.RollbackMessagingExceptionStrategy:
********************************************************************************
Message : Execution of the expression "forceException" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: byte[]
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. [Error: unresolvable property or identifier: forceException]
[Near : {... forceException ....}]
^
[Line: 1, Column: 1] (org.mule.mvel2.PropertyAccessException)
org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer:692 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/mvel2/PropertyAccessException.html)
2. Execution of the expression "forceException" failed. (org.mule.api.expression.ExpressionRuntimeException)
org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
3. Execution of the expression "forceException" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: byte[] (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:
[Error: unresolvable property or identifier: forceException]
[Near : {... forceException ....}]
^
[Line: 1, Column: 1]
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:692)
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:337)
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
INFO 2014-11-12 15:37:18,079 [[rollbacktest].rollbacktestFlow2.stage1.02] org.mule.api.processor.LoggerMessageProcessor: retry
ERROR 2014-11-12 15:37:18,079 [[rollbacktest].rollbacktestFlow2.stage1.02] org.mule.exception.RollbackMessagingExceptionStrategy: Failed to dispatch message to error queue after it failed to process. This may cause message loss.Logging Message here:
org.mule.DefaultMuleMessage
{
id=c8cf45f1-6a81-11e4-887d-005056b6086b
payload=[B
correlationId=<not set>
correlationGroup=-1
correlationSeq=-1
encoding=UTF-8
exceptionPayload=org.mule.message.DefaultExceptionPayload#1975a694
Message properties:
INVOCATION scoped properties:
originalFilename=New Text Document.txt
INBOUND scoped properties:
MULE_ORIGINATING_ENDPOINT=endpoint..C.Users.mik119.Desktop.RollbackTEst.In
directory=C:\RollbackTEst\In
fileSize=0
originalFilename=New Text Document.txt
timestamp=1415806637595
OUTBOUND scoped properties:
MULE_ENCODING=UTF-8
SESSION scoped properties:
}
org.mule.api.MessagingException: Execution of the expression "forceException" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: byte[]
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:32)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:94)
at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
at org.mule.processor.chain.InterceptingChainLifecycleWrapper.doProcess(InterceptingChainLifecycleWrapper.java:50)
at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
at org.mule.processor.chain.InterceptingChainLifecycleWrapper.access$001(InterceptingChainLifecycleWrapper.java:22)
at org.mule.processor.chain.InterceptingChainLifecycleWrapper$1.process(InterceptingChainLifecycleWrapper.java:66)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.chain.InterceptingChainLifecycleWrapper.process(InterceptingChainLifecycleWrapper.java:61)
at org.mule.exception.TemplateMessagingExceptionStrategy.route(TemplateMessagingExceptionStrategy.java:139)
at org.mule.exception.RollbackMessagingExceptionStrategy.route(RollbackMessagingExceptionStrategy.java:104)
at org.mule.exception.TemplateMessagingExceptionStrategy.handleException(TemplateMessagingExceptionStrategy.java:45)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:37)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:54)
at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
at org.mule.execution.ErrorHandlingExecutionTemplate.execute(ErrorHandlingExecutionTemplate.java:59)
at org.mule.execution.ErrorHandlingExecutionTemplate.execute(ErrorHandlingExecutionTemplate.java:30)
at org.mule.construct.Flow.process(Flow.java:76)
at org.mule.config.spring.factories.FlowRefFactoryBean$2.process(FlowRefFactoryBean.java:145)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.chain.DefaultMessageProcessorChain.doProcess(DefaultMessageProcessorChain.java:94)
at org.mule.processor.chain.AbstractMessageProcessorChain.process(AbstractMessageProcessorChain.java:67)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.AbstractInterceptingMessageProcessorBase.processNext(AbstractInterceptingMessageProcessorBase.java:102)
at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:51)
at org.mule.processor.AsyncInterceptingMessageProcessor.processNextTimed(AsyncInterceptingMessageProcessor.java:118)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:189)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker$1.process(AsyncInterceptingMessageProcessor.java:182)
at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:54)
at org.mule.execution.ResolvePreviousTransactionInterceptor.execute(ResolvePreviousTransactionInterceptor.java:44)
at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
at org.mule.execution.ValidateTransactionalStateInterceptor.execute(ValidateTransactionalStateInterceptor.java:40)
at org.mule.execution.IsolateCurrentTransactionInterceptor.execute(IsolateCurrentTransactionInterceptor.java:41)
at org.mule.execution.ExternalTransactionInterceptor.execute(ExternalTransactionInterceptor.java:48)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:109)
at org.mule.execution.TransactionalErrorHandlingExecutionTemplate.execute(TransactionalErrorHandlingExecutionTemplate.java:30)
at org.mule.processor.AsyncInterceptingMessageProcessor$AsyncMessageProcessorWorker.doRun(AsyncInterceptingMessageProcessor.java:181)
at org.mule.work.AbstractMuleEventWork.run(AbstractMuleEventWork.java:39)
at org.mule.work.WorkerContext.run(WorkerContext.java:286)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.mule.api.expression.ExpressionRuntimeException: Execution of the expression "forceException" failed.
at org.mule.el.mvel.MVELExpressionLanguage.evaluateInternal(MVELExpressionLanguage.java:202)
at org.mule.el.mvel.MVELExpressionLanguage.evaluate(MVELExpressionLanguage.java:154)
at org.mule.el.mvel.MVELExpressionLanguage.evaluate(MVELExpressionLanguage.java:133)
at org.mule.el.ExpressionLanguageComponent.process(ExpressionLanguageComponent.java:51)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
... 56 more
Caused by: [Error: unresolvable property or identifier: forceException]
[Near : {... forceException ....}]
^
[Line: 1, Column: 1]
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:692)
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:337)
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)
at org.mule.mvel2.ast.ASTNode.optimize(ASTNode.java:159)
at org.mule.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115)
at org.mule.mvel2.MVELRuntime.execute(MVELRuntime.java:86)
at org.mule.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123)
at org.mule.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119)
at org.mule.mvel2.MVEL.executeExpression(MVEL.java:943)
at org.mule.el.mvel.MVELExpressionExecutor.execute(MVELExpressionExecutor.java:72)
at org.mule.el.mvel.MVELExpressionLanguage.evaluateInternal(MVELExpressionLanguage.java:198)
... 60 more
ERROR 2014-11-12 15:37:18,095 [[rollbacktest].rollbacktestFlow2.stage1.02] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : Execution of the expression "forceException" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: byte[]
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. [Error: unresolvable property or identifier: forceException]
[Near : {... forceException ....}]
^
[Line: 1, Column: 1] (org.mule.mvel2.PropertyAccessException)
org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer:692 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/mvel2/PropertyAccessException.html)
2. Execution of the expression "forceException" failed. (org.mule.api.expression.ExpressionRuntimeException)
org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
3. Execution of the expression "forceException" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: byte[] (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:
[Error: unresolvable property or identifier: forceException]
[Near : {... forceException ....}]
^
[Line: 1, Column: 1]
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:692)
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:337)
at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
INFO 2014-11-12 15:37:18,095 [[rollbacktest].rollbacktestFlow2.stage1.02] org.mule.api.processor.LoggerMessageProcessor: Rollbacktestflow 2
The exhausted logger is not getting called, instead the Rollbacktestflow2 logger in the initial flow is called.
Can anyone explain why? Thanks
Why the rollback-exception-strategy doesn't retry?:
The rollback-exception-strategy behaves differently depending on if the flow has a transaction or not, and on the kind of inbound connector ( transactional or reliable ).
To be able to reprocess the message, you need an inbound transport, so the rollback-exception-strategy can either rollback the transaction ( transactional transport with an open transaction ) or discard the message and try again ( reliable transport )
In your example you don't have an inbound connector on the second flow, so the rollback-exception-strategybehaves as section "Use Rollback Exception Strategy for Unhandled Exceptions" on the mule doc describes: "When the flow exchange pattern is request-response, rollback exception strategy changes the payload of a message and returns it to the client"
Although the doc is not explicit, when the flow doesn't have an inbound connector the rollback-exception-strategy doesn't retry.
If you want to implement a flow that retries, you can use a vm transport between the two flows.
Example:
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:https="http://www.mulesoft.org/schema/mule/https"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
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.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd
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/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<file:connector name="File" autoDelete="true" streaming="false" validateConnections="true" doc:name="File"/>
<flow name="pickFiles" >
<file:inbound-endpoint path="/Users/ramiro/tmp/rollback/in" responseTimeout="10000" doc:name="File" connector-ref="File"/>
<logger message="File Rx" level="INFO" doc:name="FileRx"/>
<vm:outbound-endpoint path="buffer" exchange-pattern="one-way" doc:name="VM"/>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger message="Rollbacktestflow 2" level="INFO" doc:name="Rollbacktestflow2"/>
</catch-exception-strategy>
</flow>
<flow name="processQueue" >
<vm:inbound-endpoint path="buffer" exchange-pattern="one-way" doc:name="VM">
<vm:transaction action="ALWAYS_BEGIN" />
</vm:inbound-endpoint>
<logger message="about to throw Exception..." level="INFO" doc:name="RollbackTrigger"/>
<scripting:component doc:name="throw Exception">
<scripting:script engine="Groovy"><![CDATA[
throw new Exception('some very bad error')
]]></scripting:script>
</scripting:component>
<!-- we never get here -->
<file:outbound-endpoint path="/Users/ramiro/tmp/rollback/success " doc:name="dlq" connector-ref="File"/>
<rollback-exception-strategy maxRedeliveryAttempts="4" doc:name="Rollback Exception Strategy">
<logger message="retry" level="INFO" doc:name="retry"/>
<on-redelivery-attempts-exceeded >
<logger message="exhausted" level="INFO" doc:name="exhausted"/>
<file:outbound-endpoint path="/Users/ramiro/tmp/rollback/dlq" doc:name="dlq" connector-ref="File"/>
</on-redelivery-attempts-exceeded>
</rollback-exception-strategy>
</flow>
</mule>
Here we get a file and send it via a vm transport. The second flow picks the message from the vm and if there's an exception ( always in the example ), will abort the transaction and try to process again the message, and if it fails 4 times then send it to a DLQ.
About until-successful
You say that you used until-successful as a workaround. In my opinion using rollback-exception-strategy is more appropriate when you have a unit of work that you need to handle as a transaction ( maybe a flow with several transformations and enrichments ), and until-successful when you just need to retry a step that may fail ( like calling a REST service that may fail because of a temporary network condition )

javax.persistence.PersistenceException: Unable to build entity manager factory

When I'm trying to create a new EntityManager to persist my data, i get the following Error:
javax.persistence.PersistenceException: Unable to build entity manager factory
I using the JPA-Persistence Provider of Hibernate...
unluckily I couldn't find any helpful post in stackoverflow / with googling...
Does anybody have an idea where the cause of the error could lie?
Thank you for your help!
code-snippets:
creation of entitymanager
EntityManager em;
EntityManagerFactory fact = Persistence.createEntityManagerFactory("bachelordebug"); // Here it crashes
em = fact.createEntityManager();
stacktrace
javax.persistence.PersistenceException: Unable to build entity manager factory
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:81)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at com.uzh.platform.api.util.AssignmentUtil.findAll(AssignmentUtil.java:20)
at com.uzh.platform.api.services.GetAssignments.getAssignments(GetAssignments.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:402)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:349)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:106)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:259)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1010)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:345)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:220)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:156)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:233)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="bachelordebug" transaction-type="RESOURCE_LOCAL">
<!-- <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> -->
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.uzh.platform.data.dao.Assignment</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://127.0.0.1:5432/bachelor"/>
<property name="javax.persistence.jdbc.user" value="bachelor"/>
<property name="javax.persistence.jdbc.password" value="bachelor14"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.connection.release_mode" value="after_statement"/>
<property name="connection.pool_size" value="1"/>
<property name="dialect" value="org.postgresql.Driver"/>
<property name="current_session_context_class" value="thread"/>
<property name="cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="show_sql" value="true"/>
</properties>
</persistence-unit>
(Question answered in comments and edits. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
SOLVED
I finally found my error!
In my JPA-Entity class, I misspelled my Named-Query Annotation (even though I don't use it)
#NamedQuery(name="Assignment.findAll", query ="SELECT * FROM assignment")
of course one has to write that in capital Letters, i.e. "Assignment" (i.e. all terms like they appear in the service-class!)
3 days wasted with this stupid error - but now I learned how to do it! :-)
Thanks anyway for your help!
Since the error can indicate a lot of different causes it seems best to get to the cause examining the Hibernate DEBUG log statements (we use logback, but it should work in any other logging framework similarly):
With this you get a lot of output, but can determine the actually interesting classes (it is very likely you will spot the cause here already):
// (logback.groovy)
logger( "org.hibernate", DEBUG )
Which for us showed something like the following (where Mapping collection: foo.Bar.field -> some_tab_x was the info we needed to spot the faulty mapping):
07:32:43.720 D~ [main ~ main] [ : ] CollectionSecondPass:SecondPass: 67|
Second pass for collection: foo.Bar.field
07:32:43.720 D~ [main ~ main] [ : ] c.a.CollectionBinder:SecondPass: 823|
Binding a OneToMany: foo.Bar.field through a foreign key
07:32:43.720 D~ [main ~ main] [ : ] c.a.CollectionBinder:SecondPass: 861|
Mapping collection: foo.Bar.field -> some_tab_x
07:32:43.727 D~ [main ~ main] [ : ] ePersistenceProvider:gerFactory: 82|
Unable to build entity manager factory
07:32:43.743 E~ [main ~ main] [ : ] .l.f.m.m.MgFooTstJu:AndRethrow: 74|
MyException: unit test error loading Foo with id: 4342153208-2:
<java.lang.NullPointerException> =>
<javax.persistence.PersistenceException: Unable to build entity manager factory>
To restrict the logging again (if there are multiple places to fix your JPA mapping), we then used something like the following:
// (logback.groovy)
//logger( "org.hibernate", DEBUG ) // log everything
// infos on annotation mappping, e.g. getting NullPointerExceptions with
// javax.persistence.PersistenceException: Unable to build entity manager factory
logger( "org.hibernate.cfg.annotations.CollectionBinder", DEBUG )
(E.g. in Eclipse just use CTRL+SHIFT+T to search for the type you like to debug, if the log output does not show the complete classname)
I encountered the same error, and unfortunately the above answer didn't help me a lot. So I looked to other errors reported in my case where I found this error:
com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value 'EEST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
I solved it as specified the this answer and it's comments, by replacing my connection url with : "jdbc:mysql://localhost:3306/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"
That solved all errors including the one noted in this question:
javax.persistence.PersistenceException: Unable to build entity manager factory
I hope this helps others coming across the same issue I faced.
add the id annotation in your entity class
#Entity
public class yourClass{
#Id
private Long id;
...
}

Without internet PrimeFaces 4.0 is not working

Technologies are
spring-web-flow2.3.0.
jsf2.0
springsecurity3.0
primefaces4.0
I am getting below Error.
please suggest me....
Error:
18:15:47,076 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-5) Context initialization failed: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [webmvc-config.xml]
Offending resource: ServletContext resource [/WEB-INF/config/web-application-config.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/config/webmvc-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 21; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'faces:resources'.
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/config/webmvc-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 21; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'faces:resources'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:255) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
... 27 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 21; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'faces:resources'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
at org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:132)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:285)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
... 30 more
18:15:47,096 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/eSociety-web]] (MSC service thread 1-5) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [webmvc-config.xml]
Offending resource: ServletContext resource [/WEB-INF/config/web-application-config.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/config/webmvc-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 21; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'faces:resources'.
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) [spring-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/config/webmvc-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 21; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'faces:resources'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:255) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
... 27 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 21; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'faces:resources'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:196)
at org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:132)
at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:390)
at org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:322)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:285)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
... 30 more
18:15:47,249 INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-5) Initializing Mojarra 2.1.7-jbossorg-1 (20120227-1401) for context '/eSociety-web'
18:15:50,509 INFO [org.primefaces.webapp.PostConstructApplicationEventListener] (MSC service thread 1-5) Running on PrimeFaces 4.0
18:15:50,527 INFO [org.primefaces.extensions.application.PostConstructApplicationEventListener] (MSC service thread 1-5) Running on PrimeFaces Extensions 0.6.3
18:15:50,588 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-5) Error listenerStart
18:15:50,588 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-5) Context [/eSociety-web] startup failed due to previous errors
18:15:50,589 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/eSociety-web]] (MSC service thread 1-5) Closing Spring root WebApplicationContext
18:15:50,589 INFO [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-5) Closing Root WebApplicationContext: startup date [Fri Jan 31 18:14:22 IST 2014]; root of context hierarchy
18:15:50,591 WARN [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-5) Exception thrown from ApplicationListener handling ContextClosedEvent: java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Fri Jan 31 18:14:22 IST 2014]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
18:15:50,596 WARN [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-5) Exception thrown from LifecycleProcessor on context close: java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Fri Jan 31 18:14:22 IST 2014]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
18:15:50,600 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/eSociety-web]] (MSC service thread 1-5) Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener: java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171) [spring-context-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
18:15:50,616 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.web.deployment.default-host./eSociety-web: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./eSociety-web: JBAS018040: Failed to start context
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
]
This is my webmvc-flow.xml
please suggest me.....
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:faces="http://www.springframework.org/schema/faces"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.4.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<faces:resources />
<!-- Maps request URIs to controllers. Here we have two kinds of flows one is login flow and another is main flow -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/main=flowController
/login=loginController
</value>
</property>
<property name="defaultHandler">
<!-- Selects view names to render based on the request URI: e.g. /main selects "main" -->
<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
</property>
</bean>
<!-- it is used to handle the flow control Adaptor in 2.3.0. This will come from spring framework.web.servlet3.2.1 -->
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
<!-- it trigers to the loginFlowController -->
<bean id="loginController" class="com.LoginFlowController">
<property name="flowExecutor" ref="flowExecutor"/>
</bean>
<!-- Handles requests mapped to the Spring Web Flow system and ajaxHandler.
after security we need to enable the ajax for that we need to write one property i.e ajaxHandler -->
<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
<property name="flowExecutor" ref="flowExecutor" />
<property name="ajaxHandler">
<bean class="org.springframework.faces.webflow.JsfAjaxHandler"/>
</property>
</bean>
<!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to '/WEB-INF/search.xhtml' -->
<bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".xhtml" />
</bean>
<bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />
<!-- ========================= MESSAGE SOURCE DEFINITION ========================= -->
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages" />
</bean>
</beans>
Had the same issue!
Using the schema location
http://www.springframework.org/schema/faces/spring-faces-2.2.xsd
instead of
http://www.springframework.org/schema/faces/spring-faces-2.4.xsd
(as proposed in the official documentation) worked like a charm!