Parent package is not defined : jfreechart-default [Unknown Location] - configuration

I am trying use Struts2 jfreechart plugin - using a Maven project.
In Maven dependencies I am able to see the jfree-chart jar file.
DO I need to use a separate package?
Getting following error:
SEVERE: Dispatcher initialization failed
Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:967)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:435)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:479)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4828)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5508)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: Parent package is not defined: jfreechart-default - [unknown location]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildPackageContext(XmlConfigurationProvider.java:674)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:523)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:295)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:264)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 17 more
My struts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true"></constant>
<package name="basicstruts2" extends="struts-default, jfreechart-default">
<action name="index">
<result>/index.jsp</result>
</action>
<action name="getchart" class="com.struts.charts.actions.ChartAction"
method="execute">
<result name="success" type="chart">
<param name="width">400</param>
<param name="height">300</param>
</result>
</action>
</package>
</struts>

In the struts.xml you have used the code that requires struts2-jfreechart-plugin-x.x.x.jar to be on classpath. This plugin has struts-plugin.xml where the jfreechart-default package is defined. You need this if your package extends jfreechart-default.
<package name="basicstruts2" extends="struts-default, jfreechart-default">

Related

Mail sending through gmail in Mule Flow

I am struggling with mail sending flow in mule, Getting below error:
Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=smtps://dummy.DevGroup:<password>#smtp.gmail.com, connector=SmtpsConnector
I have below configuration in my xml file (Updated with namespace declarations in the Mule XML):
<mule
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:twilio="http://www.mulesoft.org/schema/mule/twilio"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"
xmlns:smtps="http://www.mulesoft.org/schema/mule/smtps"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.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
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/3.3/mule-smtp.xsd
http://www.mulesoft.org/schema/mule/smtps http://www.mulesoft.org/schema/mule/smtps/current/mule-smtps.xsd
http://www.mulesoft.org/schema/mule/twilio http://www.mulesoft.org/schema/mule/twilio/1.0/mule-twilio.xsd">
<service name="tool.muleservice.emailServiceintegration">
<inbound>
<inbound-endpoint ref="tool.endpoint.emailNotification"/>
</inbound>
<outbound>
<pass-through-router>
<outbound-endpoint ref="tool.smtp.endpoint.emailNotification"/>
</pass-through-router>
</outbound>
</service>
<smtps:endpoint name="tool.smtp.endpoint.emailNotification"
user="#[message.inboundProperties['userName']]"
password="#[message.inboundProperties['password']]"
host="smtp.gmail.com"
port="465"
from="dummy.DevGroup%40gmail.com"
transformer-refs="customEmailTransformer"
connector-ref="myTSLSMTPConnnector">
</smtps:endpoint>
<smtps:connector name="myTSLSMTPConnnector">
<smtps:tls-client path="../cacerts" storePassword="changeit" />
<smtps:tls-trust-store path="../cacerts" storePassword="changeit" />
</smtps:connector>
I updated the xml file as below content, to use smtp-gmail-connector given here
<service name="tool.muleservice.emailServiceintegration">
<inbound>
<inbound-endpoint
ref="tool.endpoint.emailNotification" />
</inbound>
<outbound>
<pass-through-router>
<!-- <outbound-endpoint ref="tool.smtp.endpoint.emailNotification"/> -->
<smtp:outbound-endpoint connector-ref="smtpGmailConnector"
subject="test msg"
address="smtps://#[message.inboundProperties['userName']]:#[message.inboundProperties['password']]#smtp.gmail.com"
responseTimeout="10000" doc:name="Send notification email" />
</pass-through-router>
</outbound>
</service>
<smtp:gmail-connector name="smtpGmailConnector"
contentType="text/html" fromAddress="iip.claims.test#gmail.com"
replyToAddresses="iip.claims.test#gmail.com" >
<smtp:header key="foo" value="bar" />
<smtp:header key="baz" value="boz" />
</smtp:gmail-connector>
But after this I am getting below error:
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:/myApp-component-config/component-config.xml]
Offending resource: mule-bootstrap-config.xml; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:/myApp-integration-config/tool-mule-bootstrap-config.xml]
Offending resource: URL [vfs:/D:/Software/JBoss/jboss-eap-7.2/standalone/deployments/myApp.war/WEB-INF/lib/tool-intrg.jar/myApp-component-config/component-config.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath*:/myApp-integration-config/tool-intrg-flows.xml]
Offending resource: URL [vfs:/D:/Software/JBoss/jboss-eap-7.2/standalone/deployments/myApp.war/WEB-INF/lib/tool-intrg.jar/myApp-integration-config/tool-mule-bootstrap-config.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 91 in XML document from URL [vfs:/D:/Software/JBoss/jboss-eap-7.2/standalone/deployments/myApp.war/WEB-INF/lib/tool-intrg.jar/myApp-integration-config/tool-intrg-flows.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 91; columnNumber: 67; The prefix "doc" for attribute "doc:name" associated with an element type "smtp:outbound-endpoint" is not bound.
at deployment.myApp.war//org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
at deployment.myApp.war//org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at deployment.myApp.war//org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
at deployment.myApp.war//org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:235)
Any help will be appreciated.
There are many details missing however on rereading the issue I suspect you are not following the deprecated syntax <service> correctly by trying to use a current example. Since that syntax has been deprecated for 6+ years, I would advice to move to the more current <flow> definitions.
In case you are unable or unwilling to migrate, you need to define an endpoint outside the service and reference it you could try the following steps:
Ensure that the namespaces at the beginning of the file are correct. The error mentions that doc: is not recognized. Maybe the namespaces are outdated.
Ensure that the dependencies in the pom reference your Mule 3.9.x release and not an older version that may not define doc.
Try moving <smtp:outbound-endpoint> to a separate endpoint definition and reference it from the <pass-through-router> as in your original implementation.
Example:
<service name="tool.muleservice.emailServiceintegration">
<inbound>
<inbound-endpoint ref="tool.endpoint.emailNotification"/>
</inbound>
<outbound>
<pass-through-router>
<outbound-endpoint ref="tool.smtp.endpoint.gmailNotification"/>
</pass-through-router>
</outbound>
</service>
<smtps:endpoint name="tool.smtp.endpoint.gmailNotification"
connector-ref="smtpGmailConnector"
subject="test msg"
address="smtps://#[message.inboundProperties['userName']]:#[message.inboundProperties['password']]#smtp.gmail.com"
responseTimeout="10000" doc:name="Send notification email" >
</smtps:endpoint>
<smtp:gmail-connector name="smtpGmailConnector"
contentType="text/html" fromAddress="iip.claims.test#gmail.com"
replyToAddresses="iip.claims.test#gmail.com" >
<smtp:header key="foo" value="bar" />
<smtp:header key="baz" value="boz" />
</smtp:gmail-connector>
Finally if everything else fails you could try removing the doc:name attribute and see what happens.

Could not initialize Start up controller. TaskManager not found

i have written a scheduled task which call an Api in sequence in wso2 ei 6.4.0. my task is :
<task xmlns="http://ws.apache.org/ns/synapse"
name="GetMunicipalityAPIToken"
class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz">
<trigger interval="60"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
<test xmlns=""/>
</property>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="sequenceName"
value="GetTokenFromMunicipalityService"/>
<property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
name="injectTo"
value="sequence"/>
</task>
and my sequence is :
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="GetTokenFromMunicipalityService" xmlns="http://ws.apache.org/ns/synapse">
<send>
<endpoint>
<http method="POST" uri-template="http://x.x.x.x/api/MunicipalityBill/connect/token"/>
</endpoint>
</send>
</sequence>
but when i run integrator.bat in wso2eiHome/bin I got this error : "Could not initialize Start up controller. TaskManager not found" and the Api dont be called. Do i forget something ?
The error can be caused when you do not have org.wso2.carbon.mediation.ntask.NTaskTaskManager defined in the server. Could you please check whether the following is added in the synapse.xml file located in the [EI_HOME]/repository/deployment/server/synapse-configs/default/ directory
<definitions xmlns="http://ws.apache.org/ns/synapse">
<taskManager provider="org.wso2.carbon.mediation.ntask.NTaskTaskManager"/>
</definitions>

My own block class defined in community cood pool. But it not work with relevant template (Magento version 1.9 extension development)

I try to create small extension for displaying string in Product page Magento 1.9.2. So I did it using "community" code pool for effecting block (block name ="product.info") in catalog.xml layout but it did not work till. I think my code is right but I don't sure whether all relevant folders (Controller, helper, Observer) are included or not in my module(Dinod). Please any one can help me to create this extension by using "community" code pool in Magento 1.9.2.
I failed to get expected output by testing my extension using "community" code pool. But same extension structure work fine after using "core" code pool. So I stored my module(Dinod) inside "app/code/core/Mage" folder and that time worked properly.
This code structure does not generate any expected output through frontend (product page).
app/etc/modules/Jpdn_Dinod.xml
<config>
<modules>
<Jpdn_Dinod>
<active>true</active>
<codePool>community</codePool>
</Jpdn_Dinod>
</modules>
</config>
app/code/community/Jpdn/Dinod/etc/config.xml
<config>
<modules>
<Jpdn_Dinod>
<version>1.0.3</version>
</Jpdn_Dinod>
</modules>
<frontend>
<layout>
<updates>
<Jpdn_Dinod module="Jpdn_Dinod">
<file>jpdn_dinod.xml</file>
</Jpdn_Dinod>
</updates>
</layout>
</frontend>
<global>
<!-- adding block "Jpdn_Dinod_Block_Product_View" -->
<blocks>
<jpdn_dinod>
<class>Jpdn_Dinod_Block_Product_View</class>
</jpdn_dinod>
</blocks>
<!-- adding block "Jpdn_Dinod_Block_Product_View" -->
</global>
</config>
app/code/community/Jpdn/Dinod/Block/Product/View/dinod.php
class Jpdn_Dinod_Block_Product_View_Dinod extends Mage_Core_Block_Template
{
public function dinod_methodblock()
{
$name = "Informations from dinod_methodblock in Jpdn_Dinod";
return $name;
}
}
app/design/frontend/base/default/layout/jpdn_dinod.xml
<layout version="1.0.3">
<catalog_product_view>
<reference name="product.info">
<!--
<block type="dinod/product_view_dinod" name="mage.view.dinod" as="mage.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
-->
<block type="jpdn_dinod/product_view_dinod" name="jpdn.view.dinod" as="jpdn.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
</reference>
</catalog_product_view>
</layout>
app/design/frontend/base/default/template/dinod/product/view/dinod.phtml
<?php echo $this->dinod_methodblock(); ?>
Above code structure does not generate any expected output through frontend (product page).
After I created new block class file in "app/code/core/Mage" and edited code in template file as below so I got expected output without any error.
app/code/core/Mage/Dinod/Block/Product/View/dinod.php
class Mage_Dinod_Block_Product_View_Dinod extends Mage_Core_Block_Template
{
public function dinod_methodblock()
{
$name = "Informations from dinod_methodblock in Mage_Dinod";
return $name;
}
}
app/design/frontend/base/default/layout/jpdn_dinod.xml
<layout version="1.0.3">
<catalog_product_view>
<reference name="product.info">
<block type="dinod/product_view_dinod" name="mage.view.dinod" as="mage.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
<block type="jpdn_dinod/product_view_dinod" name="jpdn.view.dinod" as="jpdn.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
</reference>
</catalog_product_view>
</layout>
But I want to get same output only using "community" code pool instead of using "core" code pool for effecting block (block name ="product.info") in catalog.xml layout.
Your block definition is wrong
<blocks>
<jpdn_dinod>
<class>Jpdn_Dinod_Block_Product_View</class>
</jpdn_dinod>
</blocks>
this is not how you should declare it. Remove product_view
<class>Jpdn_Dinod_Block</class>
this should be enough

I ain't able to convert json in XML

I am relative new in wso2 and are having some little problems. I already asked here, how to make this conversion, and was able to do so in another moment. But now i tried to do the same with the code passed for stack overflow:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/Test" name="JsonToXmlApi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" uri-template="/xml/">
<inSequence>
<property name="messageType" scope="axis2" type="STRING" value="text/xml"/>
<header action="remove" name="To" scope="default"/>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
<send/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
And with the send equal request, of what was taught before:
But now i am receiving this error:
ERROR - PassThroughHttpSender Failed to submit the response
org.apache.axis2.AxisFault: Can not output XML declaration, after other output has already been done.
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:78)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:555)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:264)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:222)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:531)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:118)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.rest.Resource.process(Resource.java:343)
at org.apache.synapse.rest.API.process(API.java:399)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:123)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:101)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:75)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:325)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:371)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: Can not output XML declaration, after other output has already been done.
at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1522)
at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1551)
at com.ctc.wstx.sw.BaseStreamWriter.doWriteStartDocument(BaseStreamWriter.java:650)
at com.ctc.wstx.sw.BaseStreamWriter.writeStartDocument(BaseStreamWriter.java:638)
at com.ctc.wstx.sw.BaseStreamWriter.writeStartDocument(BaseStreamWriter.java:626)
at org.apache.axiom.om.impl.MTOMXMLStreamWriter.writeStartDocument(MTOMXMLStreamWriter.java:277)
at org.apache.synapse.commons.json.JsonDataSource.serialize(JsonDataSource.java:88)
at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:691)
at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeChildren(OMSerializerUtil.java:562)
at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:875)
at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283)
at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245)
at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:74)
... 24 more
[2017-07-25 15:35:50,646] ERROR - Axis2Sender Accept:*/*,Accept-Encoding:gzip, deflate, br,Accept-Language:pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4,Cache-Control:no-cache,Content-Type:application/soap+xml,Host:localhost:8280,Origin:chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop,Postman-Token:89253418-6c05-c959-5e21-2ce7555e0cb6,<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><jsonObject><location_response><name>cafe</name><tags>dsdsd</tags></location_response></jsonObject></soapenv:Body></soapenv:Envelope> Unexpected error sending message back
org.apache.axis2.AxisFault: Failed to submit the response
at org.apache.synapse.transport.passthru.PassThroughHttpSender.handleException(PassThroughHttpSender.java:613)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:266)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:222)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:531)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:118)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.rest.Resource.process(Resource.java:343)
at org.apache.synapse.rest.API.process(API.java:399)
at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:123)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:101)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:75)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:325)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:371)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:151)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.axis2.AxisFault: Can not output XML declaration, after other output has already been done.
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:78)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:555)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:264)
... 22 more
Caused by: javax.xml.stream.XMLStreamException: Can not output XML declaration, after other output has already been done.
at com.ctc.wstx.sw.BaseStreamWriter.throwOutputError(BaseStreamWriter.java:1522)
at com.ctc.wstx.sw.BaseStreamWriter.reportNwfStructure(BaseStreamWriter.java:1551)
at com.ctc.wstx.sw.BaseStreamWriter.doWriteStartDocument(BaseStreamWriter.java:650)
at com.ctc.wstx.sw.BaseStreamWriter.writeStartDocument(BaseStreamWriter.java:638)
at com.ctc.wstx.sw.BaseStreamWriter.writeStartDocument(BaseStreamWriter.java:626)
at org.apache.axiom.om.impl.MTOMXMLStreamWriter.writeStartDocument(MTOMXMLStreamWriter.java:277)
at org.apache.synapse.commons.json.JsonDataSource.serialize(JsonDataSource.java:88)
at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:691)
at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeChildren(OMSerializerUtil.java:562)
at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:875)
at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283)
at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245)
at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:74)
... 24 more
I already searched in the internet and in stackoverflow, but none of the resolutions used to this problem, solved in my case.
If anyone could help me i would stay quite grateful.
Thank you everyone.
The API you have shared is working fine. I have tried with postman and advanced rest client.
Refer https://docs.wso2.com/display/EI610/JSON+Support for more information about json support.
I can get the response for your api without error. Try with "application/xml" in the api instead of "text/xml".
<property name="messageType" value="application/xml" scope="axis2" type="STRING"/>

can't set Struts2 result type to json

I want to use json with Struts2. However, when I set the action return type to "json", I got "there is no result type defined for type 'json' mapped with name 'success'." Bellow is struts.xml file.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.custom.i18n.resources" value="resource"/>
<package extends="struts-default" name="test">
<action name="inputHandler" class="inputHandlerAction">
<result name="input">/index.jsp</result>
<result>/result.jsp</result>
</action>
<action name="setLangHandler" class="com.sesoft.test.setLanguageHandler">
<result>/index.jsp</result>
</action>
<action name="Handler" class="com.sesoft.test.Handler">
<result>/test2.jsp</result>
</action>
</package>
<package name="example" extends="json-default">
<action name="ajaxHandler" class="com.sesoft.test.AjaxHandler">
<result name="success" type="json" />
</action>
</package>
</struts>
Before I added the json Action, all other action performs fine. But after I added the json Action, the server failed to action with error code 503.
libs I've added "jsonplugin-0.33.jar" to the lib directory.
You don't have the JSON result defined in your struts.xml package. If you only need default things then you can just extend json-default instead of struts-default. If you need to customise the package then include the following and that should do the trick:
<result-types>
<result-type name="json" class="com.googlecode.jsonplugin.JSONResult"/>
</result-types>
you package should extends json-default
<package name="json-default" extends="struts-default">
<result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult"/>
</result-types>
<interceptors>
<interceptor name="json" class="org.apache.struts2.json.JSONInterceptor"/>
</interceptors>
</package>
If using Maven you may need to add the dependency e.g.
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>2.2.3</version>
</dependency>
Here is my configuration in pom.xml:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>2.3.1.2</version>
</dependency>
In the action result you only need to specify type="json" :
<result type="json"/>
Remember the variable getter and setter in type="json" response give getters in the action.
Include json-default in the extends parameter:
<package name="default" extends="struts-default,json-default">
<action>
...
...
</action>
</package>