Publish pacts to a pact broker using maven plugin - pact

I was able to generate a pact file and then verify it using the maven plugin. Now, I am trying to publish the pacts using a pact broker.
What I have done so far is based on the below link-
https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven#publishing-pact-files-to-a-pact-broker-version-320
<plugin>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-maven_2.11</artifactId>
<version>3.5.5</version>
<configuration>
<pactDirectory>target/pacts</pactDirectory> <!-- Defaults to ${project.build.directory}/pacts -->
<pactBrokerUrl>http://<localIP>:80</pactBrokerUrl>
<projectVersion>1.0.100</projectVersion> <!-- Defaults to ${project.version} -->
<trimSnapshot>true</trimSnapshot> <!-- Defaults to false -->
</configuration>
</plugin>
The question I have here is how do I generate the pactBrokerUrl? Does this involve using the dockerized image of the pact broker as stated here? https://github.com/DiUS/pact_broker-docker Or can I just use the Pact Broker Maven plugin by warmuuh?

you need to install the pact broker in a container as explained in the link in your question. the URL is the IP where the broker is installed. Also you need to use the maven plugin to callout your broker url.

PACT Broker required to publish PACT file generated by consumer, I have answered the PACT Broker config info for other question, https://stackoverflow.com/a/62300089/3056361

Related

How to create broker as war file?

I am using ActiveMQ Artemis, and I want to create a broker in war file to later deploy it on a Jetty server. However, I don't know how to configure Artemis to generate a war file.
ActiveMQ Artemis doesn't have any ability to generate a war file.
If you want to embed an instance of ActiveMQ Artemis in your web application you need to create your own war file and then add your class that creates the embedded broker instance.
For what it's worth, the broker ships with 2 examples of how to embed a broker instance using simple POJO configuration and also XML configuration. Those are in the examples/features/standard/embedded & examples/features/standard/embedded-simple respectively.

invoking wso2 admin services using wsdl2java

I have a web application from which i have to invoke a WSO2 Admin service..
I am following this https://docs.wso2.com/display/IS570/Calling+Admin+Services
When I used wsdl2java , I got a zip file...When i opened it , it has just a pom.xml..
How can i use this? My web app is using Maven itself..But no clue how to use this pom.xml and invoke admin service? How to generate stub out of this pom.xml?
Once you build it with maven client stubs will be generated. See [1] as a sample. Any way client stubs are already available in nexus for released products.
EX: If I want to use client stubs for ChallengeQuestionManagementAdminService I can do it by adding maven dependency
<dependency>
<groupId>org.wso2.carbon.identity.governance</groupId>
<artifactId>org.wso2.carbon.identity.recovery.stub</artifactId>
<version>xxx</version>
</dependency>
[1] https://github.com/wso2-extensions/identity-governance/tree/master/service-stubs/identity/org.wso2.carbon.identity.recovery.stub

Deploy a swagger generated RESTFUL API in websphere 8.5

I have created a REST Spring-MVC webservice using swagger plugin for maven. Here is the plugin definition and goals in my pom:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.1.5</version>
<executions>
<execution>
<id>generate-spring-mvc</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.sourceDirectory}/../resources/api.yaml</inputSpec>
<language>spring-mvc</language>
<modelPackage>com.myproject.ws.gen.model</modelPackage>
<apiPackage>com.myProject.ws.gen.api</apiPackage>
<templateDirectory>${project.build.sourceDirectory}/../templates/JavaSpringMVC</templateDirectory>
<configOptions>
<sourceFolder>src/main/java</sourceFolder>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</configOptions>
</configuration>
</execution>
<execution>
<id>generate-yaml-dist</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.sourceDirectory}/../resources/api.yaml</inputSpec>
<language>swagger</language>
<output>${project.build.directory}/site/api</output>
<addCompileSourceRoot>false</addCompileSourceRoot>
</configuration>
</execution>
</executions>
</plugin>
The plugin takes then the api.yaml file, wich contains the definition of the API and generates the java code with spring annotations, additionally, I am using CORS filter to manage the requests.
When I deploy the war in a Websphere Liberty profile server, all runs ok, but when I try to do the same in a full WebSphere 8.5, I always get "File not found" massage from server.
I have checked that the application is installed correctly and the generated .class files of the REST API are packaged in the .war and also that the request is processed by the CORS Filter, but for some reason it still does not work.
Can anybody help me?
It's possible the difference is in the CORS support, or misconfigured CORS support.
In WebSphere Liberty the support is configured in the server.xml using the cors tag.
In WebSphere Traditional 8.5 you may need some JAR file additions as described here along with the relevant app configuration.
If you're using a standard JEE servlet filter then it should work on both Liberty and WAS traditional. It doesn't seem like you're using Liberty's native CORS configuration, so I am assuming a regular servlet filter.
Have you tried accessing your endpoint from a client that doesn't trigger CORS (ie: java client), to ensure that the application is indeed running and accessible in your WAS traditional environment? A manual CORS filter should always work, without special configuration besides actually registering the filter with your app.

Deploy Spring MVC in WSO2 Application Server

I am trying to deploy my Spring MVC application on WSO2 Application Server by going to Main > Manage > Applications > Add > Web Applications and upload my Spring MVC's WAR file. The upload completed successfully, but I still can't run the web app itself. The error message just basically complaining it doesn't have org.springframework.
The same WAR file can be run on Apache Tomcat with no problem at all. All I did is dropping the same WAR file to \webapps, and it works.
Is there a special setting that needs to be configured to get Spring MVC run on WSO2 Application Server? I would assume WSO2 Application is also using Apache Tomcat, so why it won't run by just uploading the WAR file?
Thanks!
What is your WSO2 AS version ? please make sure to use latest AS 5.1.0 version. We have tested large number of Spring (including SpringMVC) based applications on AS 5.1.0, basically if something working on Tomcat it should be work on WSO2 AS too. If you still have issues on AS 5.1.0 please let me know.
I solved this issue by:
Upgrading WSO2 AS to latest version (5.1.0) as mentioned by Sagara Gunathunga. For some reasons, previous WSO2 AS doesn't take my JSTL templating (something like $ {blabla}). Only in 5.1.0 did the issue resolved. I start to wonder what this WSO2 is doing with its half-baked product.
Modify Maven POM file, specifically slf4j-api dependency. WSO2 has its own slf4j-api library and I have to set the scope of slf4j-api in my app to "provided" before deploying to WSO2. This solve the issue with unable to load all JavaScript files.
Downside for this is you will need the scope of slf4j-api to be "compiled" when you run this locally under regular Tomcat. Setting it to "provided" will not work under Tomcat. But in WSO2, the scope will need to be "provided" to run. So, there is manual work to change before deploying the application.
I did try to match the slf4j-api version to match what WSO2 and set the scope to "compile", but it still won't work. WSO2, for some bad reasons, can't use my app's compiled slf4j-api.
yes there is a separate workaround to deploy a spring service to wso2 appserver. Please follow [1] for instructions.
[1]. http://docs.wso2.org/wiki/display/AS510/Spring+Services
Thank you,
Dharshana
#stack247,
Well I'm from WSO2 and it's nice to hear that your JSTL issue is solved by now. But I completely disagree with " I start to wonder what this WSO2 is doing with its half-baked product" statement. You may know that spec like Servelt , JSP and JSTL having different versions and update it's version with time. Previous version of application server does not supported for latest JSP 2.0 and JSTL 1.2 specs hence you can't use application which depends on JSP 2.0 or JSTL 1.2 that was a known limitation but can't consider it as half-baked product due to that. This is very common nature with any software product and that's why we are actively developing, fixing issues, upgrading dependencies and frequently releasing new versions, also we are responding to community issues like this.
With Latest AS 5.1.0 release we officially support for Servelt 3.0, JSP 2.0 and JSTL 1.2 and any dependent applications too. When it come to logging case most of the application server having their own logging mechanisms and some cases it's required remove logging dependencies from applications.

where can i find wso2 jars to import into my program

I have been trying to follow the example at http://xacmlinfo.com/2011/12/18/writing-jdbc-pip-module/ in order to create a pip for the wso2 identity server and I cannot get it to work because I cannot import wso2 jars. I have tried using maven to build the projects thinking that maven would automatically download the necessary dependencies but it does not. could anyone please tell me were I could get the wso2 jars or point me in the right direction in order to be able to compile wso2 java programs. thank you
hey guys I figured it out, the packages for wso2 identity server programming are shipped with identity server. they are located in IS_HOME\repository\components\plugins. thanks guys for your help
All the released wso2 jars are hosted in wso2-nexus repository. You can simply add wso2-nexus under repositories for your app to download the wso2 released jars.
Following would help
<repository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
</repository>

Resources