i'm trying to define a message driven bean with annotations and deployment descriptors on wildfly 8.2.0-Final . I want to declare the static parts of the configuration with annotations, variable parts with xml deployment descriptors. When deploying the following mdb, i'm getting an exception.
Here's the content of the .failed-File:
{"JBAS014671: Failed services" => {"jboss.deployment.unit.\"MdbWithAnnotationsAndDescritors.jar\".component.NewMessageBean.START" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"MdbWithAnnotationsAndDescritors.jar\".component.NewMessageBean.START: java.lang.RuntimeException: javax.resource.spi.InvalidPropertyException: Destination is mandatory
Caused by: java.lang.RuntimeException: javax.resource.spi.InvalidPropertyException: Destination is mandatory
Caused by: javax.resource.spi.InvalidPropertyException: Destination is mandatory"}}
The mdb is
package test;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSDestinationDefinition;
import javax.jms.Message;
import javax.jms.MessageListener;
#JMSDestinationDefinition(name = "testQueue", interfaceName = "javax.jms.Queue", resourceAdapter = "jmsra", destinationName = "testQueue")
#MessageDriven(activationConfig = {
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class NewMessageBean implements MessageListener {
public NewMessageBean() {
}
#Override
public void onMessage(Message message) {
}
}
and the jboss.xml deployment descriptor:
<jboss xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss_5_0.xsd" version="3.0">
<security-domain>tutorial-default</security-domain>
<enterprise-beans>
<message-driven>
<ejb-name>testQueue</ejb-name>
<destination-jndi-name>testQueue</destination-jndi-name>
</message-driven>
</enterprise-beans>
</jboss>
the ejb-jar.xml is empty:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://xmlns.jcp.org/xml/ns/javaee"
version="3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd">
</ejb-jar>
Got it, i added the destination ActivationConfigProperty to the mdb class to get rid of the exception:
package test;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSDestinationDefinition;
import javax.jms.Message;
import javax.jms.MessageListener;
/**
*
* #author rainer
*/
#MessageDriven(activationConfig = {
#ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#ActivationConfigProperty(propertyName = "destination", propertyValue = "willBeOverwrittenInDeploymentDescriptor")
})
public class NewMessageBean implements MessageListener {
public NewMessageBean() {
}
#Override
public void onMessage(Message message) {
}
}
I removed the JMSDestinationDefinition because its not needed, i created the queue with the management console.
To overwrite the destination jndi name, i created the following ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
<enterprise-beans>
<message-driven>
<ejb-name>NewMessageBean</ejb-name>
<ejb-class>test.NewMessageBean</ejb-class>
<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>/jms/testClientQueue</activation-config-property-value>
</activation-config-property>
</activation-config>
</message-driven>
</enterprise-beans>
</ejb-jar>
Now the mdb gets deployed and listens to the queue jms/testClientQueue
You need to define in ejb-jar.xml not jboss.xml
You might however prefer to use annotation substitution where the values are pulled from system properties or in jboss.properties in newer versions of wildfly or EAP 6.4
Related
I have been attempting to test out an insert of a Cassandra UDT, and i keep running into the following error:
Exception in thread "main" java.lang.IllegalArgumentException: UserTypeResolver must not be null
After just trying to figure my own way through it, i attempted to exactly replicate the approach outlined in the following:
User Defined Type with spring-data-cassandra
However, i still get the same error.
I am able to insert to the target DB when i remove the UDT and just insert the simple types, so I know that I am connecting appropriately. My config is as follows:
#Configuration
#PropertySource(value = { "classpath:cassandra.properties" })
//#EnableCassandraRepositories(basePackages = { "org.spring.cassandra.example.repo" })
public class CassandraConfig {
private static final Logger LOG = LoggerFactory.getLogger(CassandraConfig.class);
#Autowired
private Environment env;
#Bean
public CassandraClusterFactoryBean cluster() {
CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean();
cluster.setContactPoints(env.getProperty("cassandra.contactpoints"));
cluster.setPort(Integer.parseInt(env.getProperty("cassandra.port")));
return cluster;
}
#Bean
public CassandraMappingContext mappingContext() {
BasicCassandraMappingContext mappingContext = new BasicCassandraMappingContext();
mappingContext.setUserTypeResolver(new SimpleUserTypeResolver(cluster().getObject(), "campaign_management"));
return mappingContext;
}
#Bean
public CassandraConverter converter() {
return new MappingCassandraConverter(mappingContext());
}
#Bean
public CassandraSessionFactoryBean session() throws Exception {
CassandraSessionFactoryBean session = new CassandraSessionFactoryBean();
session.setCluster(cluster().getObject());
session.setKeyspaceName(env.getProperty("cassandra.keyspace"));
session.setConverter(converter());
session.setSchemaAction(SchemaAction.NONE);
return session;
}
#Bean
public CassandraOperations cassandraTemplate() throws Exception {
return new CassandraTemplate(session().getObject());
}
}
My Address and Employee classes are exactly as shown in the SO question i reference above, and my Main is simply:
public class MainClass {
public static void main(String[] args) {
ApplicationContext service = new AnnotationConfigApplicationContext(CassandraConfig.class);
Employee employee = new Employee();
employee.setEmployee_id(UUID.randomUUID());
employee.setEmployee_name("Todd");
Address address = new Address();
address.setAddress_type("Home");
address.setId("ToddId");
employee.setAddress(address);
CassandraOperations operations = service.getBean("cassandraTemplate", CassandraOperations.class);
operations.insert(employee);
System.out.println("Done");
}
}
I am using:
datastax.cassandra.driver.version=3.1.3
spring.data.cassandra.version=1.5.1
spring.data.commons.version=1.13.1
spring.cql.version=1.5.1
The version referenced in the previous SO question is 1.5.0, though spring.io lists 1.5.1 as current, so I am using that, and no 1.5.0 is shown available.
Any help would be appreciated, as this is driving me somewhat nuts.
You typically get this error when you miss a UserTypeResolver under your cassandra Mapping, itself used by the cassandra Converter, itself used by the Spring Data Cassandra Template
For the details:
Assuming you have a basic Spring MVC Controller up and running elsewhere...
UserDefinedTypes in Cassandra being most interesting within SETs and MAPs, the example below is of such kind.
Example Spring Bean configuration with all defaults (Spring XML application context extract):
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
...
<!-- ===== CASSANDRA ===== -->
<!-- Loads the properties into the Spring Context and uses them to fill in placeholders in bean definitions below -->
<context:property-placeholder location="/WEB-INF/spring/cassandra.properties" />
<!-- REQUIRED: The Cassandra Cluster -->
<cassandra:cluster contact-points="${cassandra.contactpoints}"
port="${cassandra.port}" username="cassandra" password="cassandra"
auth-info-provider-ref="authProvider" />
<!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching to a keyspace -->
<cassandra:session keyspace-name="${cassandra.keyspace}" />
<!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter
DO include a userTypeResolver for UDT support -->
<cassandra:mapping entity-base-packages="fr.woobe.model">
<cassandra:user-type-resolver keyspace-name="${cassandra.keyspace}" />
</cassandra:mapping>
<!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate -->
<cassandra:converter />
<bean id="authProvider" class="com.datastax.driver.core.PlainTextAuthProvider">
<constructor-arg index="0" value="myCassandraUser" />
<constructor-arg index="1" value="somePassword" />
</bean>
<!-- REQUIRED: The Cassandra Template is the building block of all Spring Data Cassandra -->
<cassandra:template id="cassandraTemplate" />
...
and then in java, typically within your Spring MVC controller:
import org.springframework.data.cassandra.core.CassandraOperations;
...
// acquire DB template
CassandraOperations cOps = this.beanFactory.getBean("cassandraTemplate", CassandraOperations.class);
// for instance: load everything
List<MyData> rows = cOps.select("SELECT * FROM mydatatable", MyData.class);
// assuming an entry with index i exists...
Set<Pair> mySetOfPairs = rows.get(i).pairSet;
if (mySetOfPairs!=null)
for (Pair p : mySetOfPairs) {
... handle p.first and p.second ...
...
with this kind of entity mappings:
package example.model;
import java.util.Set;
import org.springframework.data.cassandra.core.mapping.CassandraType;
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
import org.springframework.data.cassandra.core.mapping.Table;
import com.datastax.driver.core.DataType.Name;
#Table public class MyData {
#PrimaryKey
public String myKey;
// some other basic fields...
public String moreStuff;
// a SET of user defined 'pair type'
#CassandraType(type = Name.SET, userTypeName = "pairType")
public Set<Pair> pairSet;
// your constructors and other methods here...
}
and a user defined entity like:
package example.model;
import org.springframework.data.cassandra.core.mapping.UserDefinedType;
#UserDefinedType("pairType")
public class Pair {
public String first;
public String second;
public Pair() {
}
public Pair(String f, String s) {
this.first= f;
this.second= s;
}
}
all based on a Cassandra table created as:
CREATE TYPE pairType (first text, second text);
CREATE TABLE MyData (
myKey text,
moreStuff text,
pairSet set<frozen<pairType>>,
PRIMARY KEY (myKey)
) ;
INSERT INTO MyData (myKey, moreStuff, pairSet)
VALUES ('hello', 'world', {
{ first:'one', second:'two' },
{ first:'out', second:'there' } }
) ;
In term of Maven artifacts or libraries, spring-webmvc is indeed required if you run within a Web MVC Spring Controller, and then spring-context-support, and spring-data-cassandra. The DataStax cassandra driver comes along as a dependency.
I am using spring security in my application through XML configuration.
This is my password encoder bean
<b:bean id="passwordEncoder"
class="org.springframework.security.crypto.password.StandardPasswordEncoder">
<b:constructor-arg value="ThisIsASecretSoChangeMe" />
</b:bean>
I want to replace it with Jasypt encryption.
How to integrate jasypt 1.9 with spring security 4.0.1.RELEASE?
If you are using spring-boot use this dependeny in pom
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>${jasypt-spring-boot-starter.version}</version>
</dependency>
and in your application.yml or application.properties file just put the Encrypted password enclosed with ENC() instead of plainpassword. Example
password:
encrypted:
password: ENC(nZ3U2bdJ05FHp1LYQbAVvDKkVs8Pi3Ke)
jasypt:
encryptor:
password: IfYouAreGoodAtSomethingNeverDoItForFree
Before this you need to generate this encrypted password from your plaintext password and the jasypt.encryptor.password(similar to salt, in this case IfYouAreGoodAtSomethingNeverDoItForFree). This can be done by something like this
java -cp ~/.m2/repository/org/jasypt/jasypt/1.9.2/jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="PasswordToBeEncrypted" password=<SecretKeyToEncryptDecrypt> algorithm=PBEWithMD5AndDES
or torough a java code. Here is a rough draft.
public class Md5Test {
public static void main(String[] args) throws NoSuchAlgorithmException {
String password = "plaintextpassword";
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
textEncryptor.setPassword("IfYouAreGoodAtSomethingNeverDoItForFree ");
String myEncryptedText = textEncryptor.encrypt(password);
System.out.println(myEncryptedText);
BasicTextEncryptor textDecryptor = new BasicTextEncryptor();
textDecryptor.setPassword("IfYouAreGoodAtSomethingNeverDoItForFree ");
String plainText = textDecryptor.decrypt("QBPaH8HKE8JDaeIpJk66Kc8nGHtBfY+L");
System.out.println(plainText);
}
}
generated encrypted string from command does not give desired result as it can not encrypt special chards like "!".and gives error "event not found"
KAD#ashutosh MINGW64 ~/Desktop
$ java -cp
~/.m2/repository/org/jasypt/jasypt/1.9.3/jasypt-1.9.3.jar
org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI
input="Test!email30#password" password="some_salt"
algorithm=PBEWithMD5AndDES
bash: !email30#password: event not found
Here is an example using org.jasypt.util.text.AES256TextEncryptor
This is a utility class for easily performing high-strength encryption of texts.
This class internally holds a StandardPBEStringEncryptor configured this way:
Algorithm: PBEWithHMACSHA512AndAES_256.
Key obtention iterations: 1000.
The required steps to use it are:
Create an instance (using new).
Set a password (using setPassword(String) or setPasswordCharArray(char[])).
Perform the desired encrypt(String) or decrypt(String) operations.
pom.xml:
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
You can use jasypt latest 2.1.2(with boot 2.1.1) or jasypt-1.9.3.jar.
Java Code:
import org.jasypt.util.text.AES256TextEncryptor;
import java.security.NoSuchAlgorithmException;
public class JasyptPasswordEcryptor {
public static void main(String[] args) throws NoSuchAlgorithmException {
String password = "Test!email30#password";
AES256TextEncryptor encryptor = new AES256TextEncryptor();
encryptor.setPassword("some_salt");
String myEncryptedText = encryptor.encrypt(password);
System.out.println("Encrypted: "+myEncryptedText);
String plainText = encryptor.decrypt(myEncryptedText);
System.out.println("Decrypted: "+plainText);
}
}
Output:
Encrypted:
fureWQHrflMinY+KBOcNeJyYmQv+7Ung/IclGz3iSBYKqTNdgslADg+TMcfFI/unaqZ/P3kDGPco2jZ4vIhrFw==
Decrypted: Test!email30#password
Spring Boot Integration:
You can use #EnableEncryptableProperties in your any configuration class or #SpringBootApplication. See example:
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
#EnableEncryptableProperties
#SpringBootApplication
#ComponentScan(basePackages = {"com.company"})
#EntityScan(basePackages = {"com.company.persistence.entities"})
#EnableJpaRepositories(value = {"com.company.persistence.repository"})
#EnableTransactionManagement
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
And in any properties/yml file:
email:
password:
# DO-NOT-USE/REMOVE THIS
plain: 'Test!email30#password'
# use this encrypted one
encrypted: ENC(fureWQHrflMinY+KBOcNeJyYmQv+7Ung/IclGz3iSBYKqTNdgslADg+TMcfFI/unaqZ/P3kDGPco2jZ4vIhrFw==)
jasypt:
encryptor:
password: some_salt
I'm working on an integration between Spring SAML and Microsoft ADFS 3.0. Even it is already stated in the documentation of Spring SAML as:
Open the provider by double-clicking it, select tab Advanced and change
"Secure hash algorithm" to SHA-1
that I understand that Spring SAML supports currently only SHA-1 as hash algorithm, but my requirement is using SHA-256. If I try configure only in ADFS for SHA-256, it doesn't work. I suppose that I have to do something with Spring SAML. Do you have any idea how to do so?
You should configured the Spring security configuration to use SHA-256 signature algorithm.
You could either override the SAMLBootstrap or configure a initializing bean like this:
Spring configuration:
<bean id="samlProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:saml.properties" />
</bean>
<bean class="your.package.SAMLConfigurationBean">
<property name="signatureAlgorithm" value="${saml.signatureAlgorithm:SHA1}" />
</bean>
properties file (saml.properties):
saml.signatureAlgorithm=SHA256
Initializing bean:
package your.package;
import org.opensaml.Configuration;
import org.opensaml.xml.security.BasicSecurityConfiguration;
import org.opensaml.xml.signature.SignatureConstants;
import org.springframework.beans.factory.InitializingBean;
public class SAMLConfigurationBean implements InitializingBean {
private String signatureAlgorithm ;
private String digestAlgorithm;
public void setSignatureAlgorithm(String algorithm) {
switch (algorithm) {
case "SHA256" :
signatureAlgorithm = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256;
digestAlgorithm = SignatureConstants.ALGO_ID_DIGEST_SHA256;
break;
case "SHA512" :
signatureAlgorithm = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA512;
digestAlgorithm = SignatureConstants.ALGO_ID_DIGEST_SHA512;
break;
default:
signatureAlgorithm = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1;
digestAlgorithm = SignatureConstants.ALGO_ID_DIGEST_SHA1;
}
}
#Override
public void afterPropertiesSet() throws Exception {
BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
config.registerSignatureAlgorithmURI("RSA", signatureAlgorithm);
config.setSignatureReferenceDigestMethod(digestAlgorithm);
}
}
You could also skip the configurable part and just settle for this:
Initializing bean:
package your.package;
import org.opensaml.Configuration;
import org.opensaml.xml.security.BasicSecurityConfiguration;
import org.opensaml.xml.signature.SignatureConstants;
import org.springframework.beans.factory.InitializingBean;
public class SAMLConfigurationBean implements InitializingBean {
#Override
public void afterPropertiesSet() throws Exception {
BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration();
config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
}
}
I recommend to refer to this GitHub example project: https://github.com/choonchernlim/spring-security-adfs-saml2
which provides ADFS dedicated configuration information and details how to enable SHA-256 signature.
I have input complex big XML files for the Mule flow.
File end point-> Byte Array to String -> Splitter -> ....
I have got org.xml.sax.SAXParseException: Content is not allowed in prolog when I try to process input files by using Splitter component. When I create new XML file and copy content of original file to the file, input files are processed.
I delete BOM marker when I create new file. Original file has EF BB BF since the beginning of the file, local file has not.
Mule config:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/file
http://www.mulesoft.org/schema/mule/file/current/mule-file.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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/ee/tracking
http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<mulexml:dom-to-xml-transformer name="domToXml"/>
<flow name="SplitterFlow1" doc:name="SplitterFlow1">
<file:inbound-endpoint path="D:\WORK\Input"
moveToDirectory="D:\WORK\Output"
responseTimeout="10000" doc:name="File" fileAge="200" encoding="UTF-8"/>
<byte-array-to-string-transformer doc:name="Byte Array to String" />
<splitter evaluator="xpath" expression="/Invoices/invoice"
doc:name="Splitter"/>
<transformer ref="domToXml" doc:name="Transformer Reference"/>
<tracking:custom-event event-name="Invoice ID" doc:name="Custom Business event">
</tracking:custom-event>
<logger level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="D:\WORK\Output"
outputPattern="#[function:dateStamp:dd-MM-yyyy-HH.mm.ss]-#[header:OUTBOUND:MULE_CORRELATION_SEQUENCE]"
responseTimeout="10000" doc:name="File"></file:outbound-endpoint>
</flow>
</mule>
Please advise me how I can do it in the Mule flow. Thank you in advance.
It's a pretty old post but here is my contribution.
Additionaly to the Java transformer approach suggested by #alexander-shapkin, I strongly recommend that you use Apache Commons' org.apache.commons.io.BOMInputStream to handle BOM marker out-of-the-box. The code would look something like below:
import java.io.InputStream;
import org.apache.commons.io.ByteOrderMark;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.BOMInputStream;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractMessageTransformer;
public class DeleteBOM extends AbstractMessageTransformer {
#Override
public Object transformMessage(MuleMessage message, String outputEncoding)
throws TransformerException {
try (InputStream in = new BOMInputStream(IOUtils.toInputStream(message.getPayloadAsString()), ByteOrderMark.UTF_8)) {
return IOUtils.toString(in);
} catch (Exception e) {
throw new RuntimeException("Could not remove BOM marker");
}
}
}
I partially reproduced your Mule app with the following configuration:
<file:connector name="File" autoDelete="false" streaming="true" validateConnections="true" doc:name="File" />
<mulexml:dom-to-xml-transformer name="DOM_to_XML" doc:name="DOM to XML"/>
<flow name="lalaFlow">
<file:inbound-endpoint path="D:\WORK\Input" moveToDirectory="D:\WORK\Output" responseTimeout="10000" doc:name="File" fileAge="200" encoding="UTF-8"/>
<component class="org.mule.bom.DeleteBOM" doc:name="Java"/>
<transformer ref="DOM_to_XML" doc:name="Transformer Reference"/>
...
</flow>
For further reference, go to https://commons.apache.org/proper/commons-io/javadocs/api-2.2/org/apache/commons/io/input/BOMInputStream.html
You can add before splitter an Java transformer with class:
package importxmltoapis;
import org.mule.api.MuleMessage;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractMessageTransformer;
public class DeleteBOM extends AbstractMessageTransformer{
public static final String BOM = "\uFEFF";
#Override
public Object transformMessage(MuleMessage message, String outputEncoding)
throws TransformerException {
String s="";
try {s = removeBOM(message.getPayloadAsString());} catch (Exception e) {e.printStackTrace();}
return s;
}
private static String removeBOM(String s) {
if (s.startsWith(BOM)) {
s = s.substring(1);
}
return s;
}
}
Try the following
1.Use the file to string transformer instead of bytearray to string transformer .
2.Check if you big xml is read completely and if not use the file age property of the file endpoint which will enable you to read your large file completely.
See https://stackoverflow.com/questions/41810306/appointment-scheduling....
The support for Sesssion.setIdleTimeout(long ms) was added recently to support JSR-356 (javax.websocket) work we are currently doing.
However, with 9.0.0.RC2 you can do the following to set idle timeout early, before the Session is created (this is being fixed, hopefully will make it into RC3)
Server Side option A: WebSocketServlet init-param
In your WEB-INF/web.xml for your websocket servlet, specify the following init-param
<init-param>
<param-name>maxIdleTime</param-name>
<param-value>10000</param-value>
</init-param>
Server Side option B: As policy change on WebSocketFactory
In your WebSocketServlet.configure(WebSocketServletFactory factory) call
#Override
public void configure(WebSocketServletFactory factory)
{
factory.getPolicy().setIdleTimeout(10000);
}
Client Side option A: As WebSocketClient setting
WebSocketClient client = new WebSocketClient();
client.getPolicy().setIdleTimeout(10000);
client.start();
Annotated #WebSocket option
This will work for server or client websockets.
Note: you cannot mix WebSocketListener and #WebSocket annotations together
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketError;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
#WebSocket(maxIdleTime=10000)
public class MySocket
{
#OnWebSocketClose
public void onClose(int statusCode, String reason)
{
}
#OnWebSocketConnect
public void onConnect(Session sess)
{
}
#OnWebSocketError
public void onError(Throwable cause)
{
}
#OnWebSocketMessage
public void onText(String message)
{
}
}