Mulesoft Custom Policy Transform Extension - mule

I'm developing a custom validator policy for mulesoft runtime 4.1.0, and i need to modify the response when the policy isn't satisfied. To do this, i found this page on the mulesoft docs: https://docs.mulesoft.com/api-manager/v/2.x/http-policy-transform but when i try to use the xml namespace http-transform: i always get the error
Error loading:
/opt/mule/mule-4.1.2/policies/jwtvalidatorpolicy-315114/policy.xml,
Can't resolve
http://www.mulesoft.org/schema/mule/http-transform/current/mule-http-transform.xsd,
A dependency or plugin might be missing
Can someone provide the correct location/namespace?
Thank you!

here it is a full example that uses the mentioned extension
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http-policy="http://www.mulesoft.org/schema/mule/http-policy"
xmlns:http-transform="http://www.mulesoft.org/schema/mule/http-policy-transform"
xmlns="http://www.mulesoft.org/schema/mule/core"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http-policy-transform http://www.mulesoft.org/schema/mule/http-policy-transform/current/mule-http-policy-transform.xsd
http://www.mulesoft.org/schema/mule/http-policy http://www.mulesoft.org/schema/mule/http-policy/current/mule-http-policy.xsd">
<http-policy:proxy name="policy-deployment">
<http-policy:source>
<try>
<http-policy:execute-next/>
<http-transform:add-headers outputType="response">
<http-transform:headers>#[{'policyHeader': 'policyHeaderValue'}]</http-transform:headers>
</http-transform:add-headers>
</try>
</http-policy:source>
</http-policy:proxy>
</mule>
You will also need to add the following dependency to your custom policy project
<dependency>
<groupId>com.mulesoft.anypoint</groupId>
<artifactId>mule-http-policy-transform-extension</artifactId>
<version>1.1.0</version>
<classifier>mule-plugin</classifier>
</dependency>

For those that also run into this issue of missing dependency:
This is an enterprise-only plugin. This means that you need to configure your maven settings file to also search in the mulesoft enterprise repo. See https://docs.mulesoft.com/mule-runtime/3.9/configuring-maven-to-work-with-mule-esb for documentation how to do that. If you don't have a username/password for this repo yet, create a support ticket with an account linked to your enterprise subscription and they will provide you with the correct credentials.

Related

Is it possible to use messaging, and kafka-messaging separately from helidon?

I created library using helidon-messaging, helidon-messaging-kafka. Also I created an example Java SE app using that library and all works fine. But when I try to use that library in Java EE (Weblogic) legacy application I have got an exception while that application starts:
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Config with qualifiers #Default
at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] #Inject io.helidon.messaging.connectors.kafka.KafkaConnector(Config)
at io.helidon.messaging.connectors.kafka.KafkaConnector.<init>(KafkaConnector.java:0)
Is it possible some how to switch off CDI stuff there?
Did you try to exclude the connector package from bean scanning?
Something like this should help:
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
version="2.0"
bean-discovery-mode="annotated">
<scan>
<exclude name="io.helidon.messaging.connectors.kafka.**" />
</scan>
</beans>
More info can be found here

Wildfly 10 - How to use a newer version of jackson for an aplication

I have an application running on wildfly 10 that needs a newer version of jackson. Simply updating the maven dependency does not to work. Wildflys own version seems to interfere...
Somebody has a hint?
You can add a newer version of Jackson to your war and use that, but the JAX-RS subsystem of the container (Resteasy) will still use it's own jackson module to (de)serialize you HTTP request/response bodies.
You could add a module with the newer version, but you could run into dependency problems with other modules (see this pull request which already was accepted, so it should be in the next release, but I don't know of any planned Wildfly release dates).
Or you could package your own version of Jackson and register those MessageBodyReaders/Writers to be used by JAX-RS. This should do the job.
#Provider
public class CustomJacksonJsonProvider extends JacksonJsonProvider {}
You may also have to exclude the built-in Jackson by adding a jboss-deployment-structure.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
</exclusions>
</deployment>
</jboss-deployment-structure>

mule standalone 3.7.0: error deploying mule app

I am trying to deploy a mule app via mule standalone 3.7.0 but I'm getting an error, even though it works perfect via anypoint studio version 5.4.1 using 3.7.2 mule server. note: I have created a zip folder via anypoint studio.
This is my flow:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:amqp="http://www.mulesoft.org/schema/mule/amqp" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:magento="http://www.mulesoft.org/schema/mule/magento" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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"
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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/magento http://www.mulesoft.org/schema/mule/magento/current/mule-magento.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/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.xsd">
<amqp:connector name="AMQPConnector"
validateConnections="true"
doc:name="AMQPConnector"
/>
<magento:config name="Magento" username="test" password="test" address="http://127.0.0.1:8000/api/v2_soap/" doc:name="Magento"/>
<flow name="flow">
<amqp:inbound-endpoint queueName="test" responseTimeout="10000" exchange-pattern="request-response" connector-ref="AMQPConnector" doc:name="AMQP-0-9" exchangeType="topic"/>
<logger message="test!!" level="INFO" doc:name="Logger"/>
<magento:get-product config-ref="Magento" productId="1" doc:name="Magento">
<magento:attributes-names>
<magento:attributes-name>sku</magento:attributes-name>
</magento:attributes-names>
</magento:get-product>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<set-payload value="payload: #[payload]" doc:name="Set Payload"/>
</flow>
</mule>
This is he error:
ERROR 2016-01-10 18:40:46,877 [Mule.app.deployer.monitor.1.thread.1] org.mule.module.launcher.DefaultArchiveDeployer:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Failed to deploy artifact 'alone', see below +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
org.mule.module.launcher.DeploymentInitException: SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'amqp:connector'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":description, "http://www.springframework.org/schema/beans":beans, "http://www.springframework.org/schema/beans":bean, "http://www.springframework.org/schema/context":property-placeholder, "http://www.springframework.org/schema/beans":ref, "http://www.mulesoft.org/schema/mule/core":global-property, "http://www.mulesoft.org/schema/mule/core":configuration, "http://www.mulesoft.org/schema/mule/core":notifications, "http://www.mulesoft.org/schema/mule/core":abstract-extension, "http://www.mulesoft.org/schema/mule/core":abstract-shared-extension, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-extension, "http://www.mulesoft.org/schema/mule/core":abstract-agent, "http://www.mulesoft.org/schema/mule/core":abstract-security-manager, "http://www.mulesoft.org/schema/mule/core":abstract-transaction-manager, "http://www.mulesoft.org/schema/mule/core":abstract-shared-transaction-manager, "http://www.mulesoft.org/schema/mule/core":abstract-connector, "http://www.mulesoft.org/schema/mule/core":abstract-shared-connector, "http://www.mulesoft.org/schema/mule/core":abstract-global-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-exception-strategy, "http://www.mulesoft.org/schema/mule/core":abstract-flow-construct, "http://www.mulesoft.org/schema/mule/core":flow, "http://www.mulesoft.org/schema/mule/core":sub-flow, "http://www.mulesoft.org/schema/mule/core":abstract-model, "http://www.mulesoft.org/schema/mule/core":abstract-interceptor-stack, "http://www.mulesoft.org/schema/mule/core":abstract-filter, "http://www.mulesoft.org/schema/mule/core":abstract-transformer, "http://www.mulesoft.org/schema/mule/core":processor-chain, "http://www.mulesoft.org/schema/mule/core":custom-processor, "http://www.mulesoft.org/schema/mule/core":abstract-empty-processor, "http://www.mulesoft.org/schema/mule/core":invoke, "http://www.mulesoft.org/schema/mule/core":set-payload, "http://www.mulesoft.org/schema/mule/core":abstract-global-intercepting-message-processor, "http://www.mulesoft.org/schema/mule/core":custom-queue-store, "http://www.mulesoft.org/schema/mule/core":abstract-processing-strategy}' is expected.
Any ideas how to fix?
You are probally missing the dependency for the AMQP connector in your POM if you have a maven project.
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-amqp</artifactId>
<version>x.y.z</version>
</dependency>
Hope this helps
As stated above, you are probably missing activemq connector jar files, if you are using maven, place it on your pom and let it download the prescribed version for example:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.13.2</version>
</dependency>
http://activemq.apache.org/download.html
Hope this helps.
Hi i think amqp:connector is not present in your AnyPoint studio.
Go thru Help --> Install new Sofware --> select Anypoint Connectors Update Site - http://repository.mulesoft.org/connectors/releases/3.5.0.
Hope this helps as mentioned by others above.
This Error is thrown because ampq:connector is used in your flow, not installed in your setup.
To install ampq:connector , go to Help-> Install new Software -> http://repository.mulesoft.org/connectors/releases/3.5.0
and install following package from the list.
Than install Mule AMPQ Tranpost package and restart your Anypoint Studio.
This will solve your Problem.
Try changing your namespace reference from current to:
"http://www.mulesoft.org/schema/mule/amqp/3.1/mule-amqp.xsd".
You could also refer to:
https://docs.mulesoft.com/mule-user-guide/v/3.7/activemq-integration
i think amqp:connector is not present in your AnyPoint studio. try to download it in Studio by following steps.
Help --> Install new Sofware --> select Anypoint Connectors Update Site - http://repository.mulesoft.org/connectors/releases/3.5.0.
restart the studio...done..!!! please let me know if it helps.
Most likely the connector dependency is missing from the Mule project descriptor file, called mule-project.xml. This prevents Studio from attaching the proper connector JARs to the app, causing the Invalid content was found starting with element 'amqp:connector exception you experienced.
All connectors used by the app are declared in mule-project.xml inside a <muleExtension> tag:
<muleExtension name="AMQP-0-9" qualifier="mule-transport-amqp-contribution"/>
With dependency:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mule-project xmlns="http://www.mulesoft.com/tooling/project" runtimeId="org.mule.tooling.server.3.7.3.ee" schemaVersion="5.3.0.0">
<name>demo-amqp</name>
<description></description>
<muleExtension name="AMQP-0-9" qualifier="mule-transport-amqp-contribution"/>
</mule-project>
Without dependency:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mule-project xmlns="http://www.mulesoft.com/tooling/project" runtimeId="org.mule.tooling.server.3.7.3.ee" schemaVersion="5.3.0.0">
<name>demo-amqp</name>
<description></description>
</mule-project>
Solution 1 (from Studio)
Drag & drop the connector onto the canvas. This will force an update of the Mule app, automatically adding the dependency to the project's classpath.
Solution 2 (from Studio)
Manually add the connector dependency to the classpath:
Right-click on the project and navigate through Build Path > Configure Build Path.
Select the Libraries tab.
Click Add Library button > Anypoint Connector Dependencies
Select the desired connector/s and click Finish.
i think amqp:connector is not present in your AnyPoint studio. try to download it in Studio by following steps. Help --> Install new Sofware --> select Anypoint Connectors Update Site - http://repository.mulesoft.org/connectors/releases/3.5.0.
you are probably missing activemq connector jar files
looks like amqp:connector is not present in your AnyPoint studio. try to download it in Studio by following steps. Help --> Install new Sofware --> select Anypoint Connectors Update Site - http://repository.mulesoft.org/connectors/releases/3.5.0.
restart the studio...done..!!! please let me know if it helps.

How to Use JGit in Eclipse Plugin Project

I am creating an Eclipse plug-in that requires the use of JGit. However, I am not sure how to import the bundle as a dependency.
When I try to build with tycho I am greeted with errors about being unable to resolve the dependency. I have tried adding a dependency in the pom:
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>3.2.0.201312181205-r</version>
</dependency>
Adding the bundle to Required-Bundles in the manifest:
But all efforts lead back to being unable to resolve the dependency:
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: No solution found because the problem is unsatisfiable.: [Unable to satisfy dependency from com.inin.testing.eclipse.plugin.submit 0.5.0.qualifier to bundle org.eclipse.jgit 3.2.0.; Unable to satisfy dependency from org.eclipse.jdt.core 3.9.0.v_OTDT_r220_201306071800 to org.eclipse.objectteams.otdt.core.patch.feature.group [2.0.0,3.0.0).; Unable to satisfy dependency from org.eclipse.jdt.core 3.9.1.v_OTDT_r221_201309101918 to org.eclipse.objectteams.otdt.core.patch.feature.group [2.0.0,3.0.0).; No solution found because the problem is unsatisfiable.]
If anyone has had success using the JGit library in an eclipse plug-in project let me know how you are consuming it.
If you are working with PDE, JGit (or other dependencies) is best consumed through a Target Platform.
The definition below integrates JGit 3.2 from the projects' software repository at Eclipse.org.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?><target name="JGit" sequenceNumber="53">
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.jgit.feature.group" version="3.2.0.201312181205-r"/>
<unit id="org.eclipse.jgit.source.feature.group" version="3.2.0.201312181205-r"/>
<repository location="http://download.eclipse.org/egit/updates"/>
</location>
</locations>
</target>
Paste the snippet into a file within your workspace and open it with the (default) Target Definition Editor. Select the 'Set as Target Platform' link in the top-right corner. This will download JGit along with required bundles and make them your current target platform.

Using hibernate validator JodaTime bean validation constraints in JBoss

We have an enterprise application that uses the Joda DateTime library. The application is deployed into a JBoss 7.2.0 Alpha1 Container. Some classes in our domain model have #Past annotations on fields of type DateTime. In order to validate these constraints we'd like to use the constraint validators provided by hibernate-validator. Therefore we added a dependency 'org.hibernate.validator' to the MANIFEST.MF of our ear file. We are using version 2.0 of the Joda library. Therefore we have packaged the joda-time-2.0.jar file in our ear. We are not using the version 1.6.2 that is available as a module of JBoss 7
When validating an object with a DateTime field following exception is thrown:
10:51:41,140 ERROR [org.acme.GlobalExceptionHandler] (EJB default - 10) Exception caught by global exception handler: javax.validation.UnexpectedTypeException: No validator could be found for type: org.joda.time.DateTime
at org.hibernate.validator.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:383) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:364) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:313) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:144) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ConstraintTree.validateConstraints(ConstraintTree.java:117) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.metadata.MetaConstraint.validateConstraint(MetaConstraint.java:84) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:452) [hibernate-validator-4.2.0.Final.jar:4.2.0.Final]
After some debugging we detected that the call to 'TypeUtils.isAssignable( validatorType, type )' in 'ConstraintTree.findSuitableValidatorTypes' fails since the available validator types are taken from the Joda library that has been shipped with JBoss instead of the Joda library that is packaged in our ear file.
I guess we are doing something wrong regarding classloading. Can anybody give me a hint?
Have you tried adding a jboss-deployment-structure.xml to your ear file? This way you should be able to exclude the Joda time module:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.joda.time"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
See also https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7
Following Hardy's idea I solved my problem creating a jboss-deployment-structure.xml in my application's WEB-INF folder containing this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.hibernate.validator" />
</exclusions>
</deployment>
</jboss-deployment-structure>
In stead of excluding org.joda.time I excluded org.hibernate.validator. I hope this works for you too.