Mule - data weave throwing error during munit test, error is There are two transformers that are an exact match for input - maven

The transformation (xml to json) works completely fine during normal run, but when the same flow is being tested using MUnit it fails at dataweave with error message
There are two transformers that are an exact match for input: interface org.mule.api.transport.OutputHandler, output: class java.lang.String.
Transformers are: ObjectToAtomString(class org.mule.transformer.simple.ObjectToString) and ObjectToString(class org.mule.transformer.simple.ObjectToString$$EnhancerByMUNIT$$99111c4f)
I have added the input MIME TYPE in data transformation as well.
I tried to check the tranformation in another demo project to test it using munit and it passed dataweave successfully without any error.
I have data mapper 3.7.3 jar included in the project and pom file.

We faced similar issue with DataWeave in Mule 3.8.2 version for munit, though normal run was working fine. we resolved it with below workaround:
We had Byte Array to String transformer which was throwing this exception. We changed it to Byte Array to Object and in the object we gave class as java.lang.String.

Related

How to solve Error starting application: Error creating query engine Drools when using SWRL API?

I get this error message
Error starting application: Error creating query engine Drools. Exception: java.lang.NoSuchMethodError. Message: 'void org.semanticweb.owlapi.util.PriorityCollection.add(java.io.Serializable)'
I am using SWRL API for Java to run SQWRL queries on OWL ontologies. So, I built edu.stanford.swrl swrlapi-example from Maven updating in the pom file the default swrl API and swrlapi-drools-engine from versions 1.0.3 to 2.0.9 and the owl API from default 4.2.3 to 5.1.17. I am runnig this code in the executable main :
OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
File file = new File("C:\\Users\\Hugo\\Desktop\\Universidad\\SUPAERO\\S4\\SWRLapiTEST\\Prueba.owl");
OWLOntology ontology = ontologyManager.loadOntologyFromOntologyDocument(file);
ontologyManager.createOntology();
SQWRLQueryEngine queryEngine = SWRLAPIFactory.createSQWRLQueryEngine(ontology);
The program stops at the last command. I don't know what I am doing wrong. If I use the version 1.0.3 of swrl api and swrlapi-drools-engine it works, bu I wanted to use some commands incuded in the tbox and abox libraries that are not implemented in that ancient version.
The exception you're seeing is a symptom of multiple incompatible OWLAPI versions in your classpath. Make sure you only have one version in use (5.1.17 from what you say). If you cannot find the problem, please add details on how you're setting your classpath (you can print the java.class.path environment variable at the beginning of your code to get the exact classpath being used).

Converting JSON to POJO using json string as report parameter

We are trying to convert JSON to POJO and then use this POJO data source in BIRT. We are passing json string as a report parameter. We have also linked the same to dataset parameter.
Conversion of json string to java objects works when run individually in eclipse. However when we run the report, we get the below exception:
org.eclipse.birt.report.engine.api.EngineException: Cannot execute the
statement. org.eclipse.datatools.connectivity.oda.OdaException ;
java.lang.reflect.InvocationTargetException
Due to this exception we are unable to view the report in BIRT. Has anyone faced such an issue before? If yes, please let us know the resolution. Any pointers to solve this exception is really helpful.
Thanks in advance.
Even I was facing the same issue.
Then I realized I had not added supported jars in the BIRT POJO Data Source.
Along with the main POJO jar file, please add all the supporting libraries or jar files the classes in POJO jar refers to in the POJO Data Source.
For example if the class needs GSON jar, add that jar file in the POJO Data Source.

How to let JPA find generated entities (with spring-data)?

I am writing a Maven plugin that is supposed to generated JPA entities from a DSL. The entities are generated directly as ByteCode, i.e. without an intermediate java source (using ByteBuddy). The generation works fine. But the problem is that my entity isn't found by the hibernate orm. The error occurs in: org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:242), and the exception is a ClassNotFoundException. Does the hibernate instrumentation require the java code of the entity? Or how can I let hibernate know about my entity?
Further background: I use spring-data-jpa, and configured the EntityScan with the correct basePackage. My maven plugin is run in the compile phase (immediately after the compilation of the source code).
Works as designed. The only problem is to take care that the package of the class and the folder hierarchy match, and that these packages are added as basePackages for the EntityScan.

Acceleo maven generation multi artifact/project

I am trying to construct a maven acceleo generator.
The generator consists of multiple acceleo projects (artifacts in maven), with inter-dependencies.
I am running into a problem with the dependencies between emtl files.
At runtime, I get errors stating that there are compilation errors in the mtl, (there are not).
I am guessing it may be the hrefs within the compiled emtl files.
There is an acceleo maven compile plugin that allows for these to be either:
a) absolute paths (ending up to be via the maven repository)
b) 'platform:/plugin/...' paths.
(a) works if the acceleo projects (maven artifacts) are build on the same machine as the one on which we do the generation, but if the location of the maven repository changes, we have a problem. Hence deploying the maven artifacts ends up being pointless.
(b) doesn't work because running from within maven, 'platform:/plugin/' cannot be resolved.
I have tried to override the 'createURIConverter' method in the AbstractAcceleoGenerator,
then using a URLClassLoader we can decode the 'platform:/plugin/' hrefs and find the correct emtl file.
I can verify that this seems to be working, however I still get the reported
"org.eclipse.acceleo.engine.AcceleoEvaluationException: Unresolved compilation error in generation module"
any suggestions?
The exception was caused by hrefs in the EMTL model resolving to null.
The problem with resolving the hrefs was just a lack of resource factories being registered (the exception informing me of this gets lost in EcoreUtil.resolve which catches the exception with "// Failure to resolve is ignored." - most unhelpful).
So it seems that my approach of "override the ‘createURIConverter’ method, and get it to decode the ‘platform:/plugin/..’ using a URLClassLoader" does work.
Building the URLClassLoader using the same method done in the AcceleoParserMojo.

SOAP UI: Can I add assertion to validate with local XML Schema file?

I have created a Web Service (with Java, Axis). Depending on the content of the request, the response may have a different XSD. So, the WSDL only specifies that the response is of a generic XSD, and the responses comply to XSDs that import and extend the generic XSD.
Unfortunately, the Schema assertion fail because the XSD specified in the WSDL can only the generic one. Is there a way to manually specify which XSD I want the assertion to use? For instance, depending on the request I prepare, I know the specific XSD of the response. So, it would be perfect if I could say to SoapUI to assert the response by that XSD, which I can store either locally or at a url.
So, is there a way to make a schema assertion using a locally (or remotely) stored XML schema?
Thanks,
Markos
What I did after all is that I created a simple class to do this in Java.I exported the project as a jar, imported it in Groovy and just called it.
This is normal, as both Java and Groovy both play on the JVM, so it is perfectly normal to call classes and methods from one another.

Resources