I found on internet that problem is that soap request contain unicode char for ,,ctrl + v", which is illegal character in Xml. I dont know how this get into String, but I want simple to remove it on server side.
Can plase someone give me the point how to solve this issue?
I found this snippet :
XMLOutputFactory f = new WstxOutputFactory();
f.setProperty(WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER,
new InvalidCharHandler.ReplacingHandler(' '));
XMLStreamWriter sw = f.createXMLStreamWriter(...);
Can someone tell me how to configure Spring for construction of WstxOutputFactory with this handler? - InvalidCharHandler.ReplacingHandler(' '). Thanks for advice.
The solution is pretty simple :
<jaxws:endpoint id="kservice"
implementor="#kostrounService"
address="/call_kostroun" >
<jaxws:properties>
<entry key="javax.xml.stream.XMLOutputFactory" valueref="xmlOutputFactory" />
</jaxws:properties>
</jaxws:endpoint>
<bean id="invalidCharHandler" class="com.ctc.wstx.api.InvalidCharHandler$ReplacingHandler">
<constructor-arg value=" "/>
</bean>
<bean id="xmlOutputFactory" class="com.ctc.wstx.stax.WstxOutputFactory"/>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject">
<ref local="xmlOutputFactory" />
</property>
<property name="targetMethod">
<value>setProperty</value>
</property>
<property name="arguments">
<list>
<util:constant static-field="com.ctc.wstx.api.WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER"/>
<ref bean="invalidCharHandler" />
</list>
</property>
</bean>
This snippet of configuration remove illegal characters from soap message, and app then run ;-)
Related
The path param value is truncated randomly.
ex : myapplication/{pathparam}
Actual value "ab-cd-626-1.2.3.4 .6" is actually parsed as ab-cd-626-1.2.3.4.
No idea why this is happening, please help
I am not shure where you use that pathparam, may be in a #RequestMapping of a controller method ?
I experienced problems,when the path param contains '.', so I avoid that at all. The problem stems from the way, the url is parsed by spring.
More discussion on that : pathvariable with dot is getting truncated
<bean id="contentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="false" />
<property name="favorParameter" value="true" />
<property name="mediaTypes">
<value>
json=application/json
xml=application/xml
</value>
</property>
</bean>
<mvc:annotation-driven
content-negotiation-manager="contentNegotiationManager">
<mvc:path-matching suffix-pattern="false" registered-suffixes-only="true" />
</mvc:annotation-driven>
I am trying to pass this arguments to the method call Calendar.add(Calendar.YEAR, -10) in the Spring config. How to pass Calendar.YEAR which is actually an int, but Spring config treats it as a String and throws error.
It works if I call without Spring like:
from = from.add(Calendar.YEAR, -10);
Config:
<bean id="currCalendar"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="java.util.Calendar"/>
<property name="staticMethod">
<value>java.util.Calendar.getInstance</value>
</property>
</bean>
<bean id="from1"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject">
<ref local="currCalendar"/>
</property>
<property name="targetMethod" value="add"/>
<property name="arguments">
<list>
<value type="int">currCalendar.YEAR</value>
<value type="int">-50</value>
</list>
</property>
</bean>
Please suggest how to do in Spring
You almost had it, use the #{} placeholder:
<list>
<value type="int">#{currCalendar.YEAR}</value>
<value type="int">-50</value>
</list>
I wanna make java.util.Date bean. Date must be specified in human readable format (for example as string "02/25/1990").
How do it easiest (without using deprecated Date() constructors)?
<bean id="date" class="java.util.Date" >
<!-- Need 02/25/1990 -->
</bean>
I found easier solution:
<bean id="dateFormat" class="java.text.SimpleDateFormat">
<constructor-arg value="MM/dd/yyyy"/>
</bean>
<bean id="date" factory-bean="dateFormat" factory-method="parse">
<constructor-arg value="02/25/1990"/>
</bean>
Using the non-deprecated Date(long) constructor:
<bean id="date" class="java.util.Date">
<constructor-arg type="java.lang.Long" value="635904000000"/>
</bean>
If you want to use a String instead of the milliseconds you could do the following (uses SimpleDateFormat to produce a Date, while taking advantage of MethodInvokingFactoryBean to invoke it with the specified arguments):
<bean id="dateFormat" class="java.text.SimpleDateFormat">
<constructor-arg value="MM/dd/yyyy" />
</bean>
<bean id="date" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="dateFormat"/>
<property name="targetMethod" value="parse"/>
<property name="arguments">
<list>
<value type="java.lang.String">02/25/1990</value>
</list>
</property>
</bean>
Of course you need to use the correct pattern for SimpleDateFormat or could end up with unexpected results
I've been googling this for about a hour, with little success.
Suppose that in my web.xml I have :
<Parameter name="hibernate.websitespecific.entityscanpackages" value="com.mystuff.pojo.entities, com.mystuff.otherpackage.pojo.entities"/>
and in my spring context config I have:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="packagesToScan">
<list>
<value>com.mystuff.somethingelse.pojo</value>
<value>com.mystuff.weirdbeans.domain</value>
</list>
</property>
[...]
I'd like to add hibernate.websitespecific.entityscanpackages to the list of packages to scan in a clean way. How do I do that?
You can reference context parameters in bean definition files using SPEL:
For example:
<property name="foo" value="#{contextParameters.fooParamName}" />
Edit
To merge the both package list:
<property name="packagesToScan" value="#{contextParameters.paramName + ',pk1,pk2,pk3'}"/>
or
<property name="packagesToScan" value="#{contextParameters.paramName + ',' + T(org.springframework.util.StringUtils).collectionToCommaDelimitedString(#someList)}" />
<util:list id="someList">
<value>pk1</value>
<value>pk2</value>
...
</util:list>
Within alfresco activiti, could I call a spring bean using the servicetask like :
<serviceTask id="assignApplicationId" name="Assign Application Id"
activiti:expression="${sequenceUtil.getOutboundId(task.id)}"
activiti:resultVariable="OutboundWF_ApplicationNumber"/>
however, in my custom context I declared the sequenceUtil as the following:
<bean id="sequenceUtil" name="sequenceUtil" class="com.tts.mersal.presentation.bean.dialog.util.SequenceUtil">
<property name="searchService">
<ref bean="searchService" />
</property>
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="workflowService">
<ref bean="WorkflowService" />
</property>
</bean>
Actually I got the following exception
org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'sequenceUtil'
at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:79)
at org.activiti.engine.impl.juel.AstMethod.eval(AstMethod.java:75)
at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)
at org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26)
at org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:46)
I got it :)
I have to override the activitiProcessEngineConfiguration bean to include my custom bean within beans property
<!-- -->
<!-- Activiti Process Engine -->
<!-- -->
<bean id="activitiProcessEngineConfiguration"
class="org.alfresco.repo.workflow.activiti.AlfrescoProcessEngineConfiguration">
<property name="dataSource" ref="wrappedDataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="${db.schema.update}" />
<property name="history" value="full" />
<property name="jobExecutorActivate" value="true" />
<!-- Limit the visible beans in expressions -->
<property name="beans">
<map>
<entry key="services" value-ref="ServiceRegistry" />
<entry key="sequenceUtil" value-ref="sequenceUtil" />
</map>
</property>
<property name="customTypes">
<list>
<ref bean="activitiScriptNodeType" />
<ref bean="activitiScriptNodeListType" />
</list>
</property>
<property name="customPreBPMNParseListeners">
<list>
<ref bean="activitiParseListener" />
</list>
</property>
</bean>
There is a much better way to map bean names to el epressions. At least for alfresco 5.2.
Originally activitiProcessEngineConfiguration defined like that:
<bean id="activitiProcessEngineConfiguration" class="org.alfresco.repo.workflow.activiti.AlfrescoProcessEngineConfiguration">
<!-- Limit the visible beans in expressions -->
<property name="beans" ref="activitiBeanRegistry" />
</bean>
Where activitiBeanRegistry defined like that:
<util:map id="activitiBeanRegistry" map-class="java.util.HashMap">
<entry key="services" value-ref="ServiceRegistry" />
</util:map>
So you can easy add your beans with names without touching original activitiProcessEngineConfiguration. Like that:
<bean id="my.activitiBeanRegistry" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="activitiBeanRegistry">
<property name="targetObject">
<ref bean="activitiBeanRegistry" />
</property>
<property name="targetMethod" value="put" />
<property name="arguments">
<list>
<value>sequenceUtil</value>
<ref bean="sequenceUtil" />
</list>
</property>
Open for extension closed for modification :)
Full source can be found here
See also activiti-context.xml