How do I fix the Spring XML validation in IntelliJ - intellij-idea

I am getting a "false positive" error in a Spring XML file....
Expected behavior: The inbound channel adapter element with header-mapper of DefaultAmqpHeaderMapper validates properly in IntelliJ
Actual behavior: IntelliJ reports that the header-mapper is not of type HeaderMapper
There was an issue that was fixed in 3.0 but it seems like my IntelliJ is validating the below applicationContext.xml against an old version of the amqp schema. How do I refresh it?
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/amqp http://www.springframework.org/schema/integration/amqp/spring-integration-amqp-4.2.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd">
<int-amqp:inbound-channel-adapter
channel="ch1" queue-names="queue"
connection-factory="amqpConnectionFactory" error-channel="errorChannel"
header-mapper="allHeadersMapper" concurrent-consumers="1" />
Edit: Was found in 14.1.5. Upgraded to 2016.3.4 on Linux and reproduced.
Reproduced with simple code at https://github.com/dcw312/intellij-validation-error. IntelliJ issue created: https://youtrack.jetbrains.com/issue/IDEA-167842

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

Intellij not recognising xml for bpmn

This just started to happen out of no where. I have an existing Activiti project. I have the Activiti BPMN Visualizer plugin installed. Now in every one of my .bpmn20.xml files, Idea is saying "element x must be declared" or "cannot resolve symbol" Here is an example:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI"
typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://www.activiti.org/processdef">
<process id="test" name="test" isExecutable="true">
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_test">
<bpmndi:BPMNPlane bpmnElement="test" id="BPMNPlane_test">
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
the tags for definitions and process are showing red, with errors in the problems tab. The namespaced tags, bpmndi:BPMNDiagram for example, are fine. What has happened and how do I fix it?
If it happens out of nowhere try to invalidate the cache and restart the ide.

Anypoint studio throws org.xml.sax.SAXParseException error

Im new to Mule/anypoint studio platform.
When i try to run mule projcet from anypoint studio I get following error[1].
I have added that particular jar in my classpath too (as an external jar, which appears in referenced libraries section too.) So i dont think it is classpath issue.
Also, same project works for others.only for me. I believe it is some environmental issue.The xml segment is as follows(namespace is defined correctly.)
What might be the cause for this? why anypoint studio is throwing error while deploying the project to runtime?
Im using anypoint studio version 7.4.1
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json-logger="http://www.mulesoft.org/schema/mule/json-logger"
....
<json-logger:logger doc:name="Log Get Locations .../>
[1]aused by: org.mule.runtime.core.api.config.ConfigurationException: There were '3' errors while parsing the given file 'implementation/impl-locations.xml'.
Full list:
org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 171; cvc-complex-type.2.4.a: Invalid content was found starting with element 'json-logger:logger'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":description, "http://www.mulesoft.org/schema/mule/core":abstract-message-source, "http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor}' is expected.
In addition to the namespace you have to add the schema location in the xsi:schemaLocation attribute.
Example:
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"></mule>

Mulesoft Custom Policy Transform Extension

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.

mule Config for app not found

I have mule flow, trying to deploy it, it says that "Config for app not found"
I have created a dummy mule-config.xml under src/main/app, given below. My flow is:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="EE-3.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.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">
<flow name="webservicesFlow1" doc:name="webservicesFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="slmule2.corp.local" port="8088" path="rest" doc:name="HTTP"/>
<jersey:resources doc:name="REST">
<component class="com.rest.sample.RestComponent"/>
</jersey:resources>
</flow>
</mule>
mule-deploy.properties
redeployment.enabled=true
encoding=UTF-8
domain=default
config.resources=webservices.xml
mule-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd">
<!-- empty config to avoid the hot deployment classloader choking on a missing config file -->
</mule>
Error message:
ERROR 2014-06-12 12:58:06,575 [Mule.app.deployer.monitor.1.thread.1] org.mule.module.launcher.MuleDeploymentService:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Failed to deploy app + +
'webservices-1.0.0-SNAPSHOT-v20140612-12+57', + + see below +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
org.mule.module.launcher.InstallException: Config for app 'historydata-1.0.0-SNAPSHOT-
v20140612-12+57' not found: /apps/mulesoft/mule-enterprise-standalone-3.4.2/apps
/webservices-1.0.0-SNAPSHOT-v20140612-12+57/webservices.xml at
org.mule.module.launcher.application.DefaultMuleApplication.install(DefaultMuleApplication.j
ava:107) at
org.mule.module.launcher.application.ApplicationWrapper.install(ApplicationWrapper.java:79)
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:42) at
org.mule.module.launcher.MuleDeploymentService.guardedDeploy(MuleDeploymentService.java:454)
at
org.mule.module.launcher.MuleDeploymentService.deployApplication(MuleDeploymentService.java:
191) at
org.mule.module.launcher.MuleDeploymentService.deployExplodedApp(MuleDeploymentService.java:
708) at
org.mule.module.launcher.MuleDeploymentService.deployExplodedApps(MuleDeploymentService.java
:661) at
org.mule.module.launcher.MuleDeploymentService.access$400(MuleDeploymentService.java:57) at
org.mule.module.launcher.MuleDeploymentService$AppDirWatcher.run(MuleDeploymentService.java:
808) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at
java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThr
eadPoolExecutor.java:178) at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPool
Executor.java:293) 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:744) INFO 2014-06-12 12:58:07,859 [2132436410#qtp-
1158879031-6] org.mule.module.launcher.MuleDeploymentService: ================== Request to
Undeploy Application: ambrosehistorydata-1.0.0-SNAPSHOT-v20140612-12+57 INFO 2014-06-12
12:58:07,860 [2132436410#qtp-1158879031-6]
org.mule.module.launcher.application.DefaultMuleApplication: App 'webservices-1.0.0-
SNAPSHOT-v20140612-12+57' never started, nothing to dispose of INFO 2014-0
I am using mule studio 3.5.0 and mule-ee 3.4.
I had the same problem.
when you build your zip, you should zip files, not a directory ...
Dan
Sometimes javaw.exe doesn't seem to let go of a running project and seems to lock access to the config file. Killing javaw.exe and rerunning the project again fixed it.
In your Mule configuration file (src/main/app/app-config-file.xml), you can specify the properties file you want to load.
<context:property-placeholder location="${environment.name}.properties" />
This is the description of the attribute location :
Attribute : location
The location of the properties file to resolve placeholders against,
as a Spring resource location: a URL, a "classpath:" pseudo URL, or
a relative file path. Multiple locations may be specified, separated
by commas. If neither location nor properties-ref is specified,
placeholders will be resolved against system properties.
${environment.name} must be a system environment variable. You need to make sure the system where you are deploying your app contains that variable. I think you can also specify it in the Maven build, if you are using Maven (clean install -Denvironment.name=test). You can try.
To test locally, right click on your project, select run as, select run configurations, click on Environment tab, add your variable "environment.name" and the value "local" (without quotation marks) and make sure your local.properties file exists in a location added to the build path. It can be src/main/app for example or in the resources folder.
I had the same problem too.
My solution, i believe, was simpler.
Instead of exporting the project somehow and then try to deploy it by uploading a zipped file through the browser, I deployed it through Anypoint studio itself.
Right click on the project
Anypoint platform
Deploy to cloud
Sign in with your credentials (if not signed in already)
Choose the proper application and runtime environment then hit deploy.