How to generate Java client for Jira WADL? - java

all
I tried to generate Java client from Jira wadl descriptor, but it does not work:
java.lang.IllegalStateException: Single WADL resources element is expected
WADL file used: https://docs.atlassian.com/jira/REST/7.0.4/jira-rest-plugin.wadl
Build used:
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-wadl2java-plugin</artifactId>
<version>3.1.9</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wadlOptions>
<wadlOption>
<wadl>${basedir}/src/main/resources/jira-rest-plugin.wadl</wadl>
<impl>true</impl>
<packagename>com.mycompany.jira</packagename>
<schemaPackagenames>
<schemaPackagename>http://mycompany=com.mycompany.jira.schema</schemaPackagename>
</schemaPackagenames>
</wadlOption>
</wadlOptions>
</configuration>
<goals>
<goal>wadl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I had a hope that they fixed their WADL in 7.x ...
Anybody who made it work?

It does not look like valid WADL file, it explains individual services, with input, input format. For a wadl2java plugin to work you need to have WADL file with syntax similar to shown below.
<application xmlns="http://research.sun.com/wadl/2006/10">
<doc xmlns:jersey="http://jersey.dev.java.net/"
jersey:generatedBy="Jersey: 1.0-ea-SNAPSHOT 10/02/2008 12:17 PM"/>
<resources base="http://localhost:9998/storage/">
<resource path="/containers">
<method name="GET" id="getContainers">
<response>
<representation mediaType="application/xml"/>
</response>
</method>
<!-- Next methods ->
</resource>
</resources>
</application>
I guess only way for you is to contact atlassian to provide at valid WADL file if the support, else you might need to use top down approach and implement the syntax as shown in the link you shared

Here is some additional info,
1) go to your specific server version api docs url.
eg:- https://docs.atlassian.com/software/jira/docs/api/REST/7.12.3/
2) Append "jira-rest-plugin.wadl" to the end and press enter
This downloads the wadl for the specific version you want
3) Signup for free in Apimatic.io and login
4) Use the transformer to upload the wadl and specify the output format (Swagger openapi v2.0 or 3.0, or postman, etc.)
5) THis will generate and download the swagger.json

Related

Wildfly exploded war hot deployment

I have a web application deployed as exploded war using wildfly. What I want to get is
Changes in jsp files are automatically reflected, without redeploying the app
Changes in .class files enforce an app redeployment.
At the moment I am in a situation in which either I can get one option or the other, but not both at the same time (meaning that either every jsp change forces a new deployment or that .class files do not force a new deployment).
Current configuration of wildfly (using version 8.1.0) is
<deployment-scanner
path="deployments"
relative-to="jboss.server.base.dir"
scan-enabled="true"
scan-interval="1000"
auto-deploy-exploded="true"
runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"
/>
...
<servlet-container name="default">
<jsp-config development="true"/>
</servlet-container>
Also, something I have found is that no matter what I set in the deployment-scanner config, once the server is up and running, if I go to the wildfly web console, the parameter auto-deploy-war is marked as true and auto-deploy-exploded is marked as false, even the scan-interval is always set to 5000 ms, which makes me think that the deployment scanner config is somehow being ignored.
I am kind of lost here quite frankly, it has to be possible for wildfly to reload the app if the change is a .class file and not do it if it is a jsp.
Have you tried JRebel? following my blog entries would help also.
http://www.nailedtothex.org/roller/kyle/entry/evaluating-jrebel-for-wildfly-and
http://www.nailedtothex.org/roller/kyle/entry/exploded-deployment-for-wildfly-on
Manik Hot deploy is an open source Maven Plugin that simplifies your web development. The plugin provides both deployment modes - the auto-deployment and also the hot-deployment. It can be easily configured in a maven project by adding the plugin to the pom.xml
....
<build>
<plugins>
.....
<!-- Manik Hotdploy -->
<plugin>
<groupId>org.imixs.maven</groupId>
<artifactId>manik-hotdeploy-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- List Source and Target folders for Autodeploy and Hotdeploy -->
<autodeployments>
<deployment>
<!-- wildcard deployment -->
<source>target/*.{war,ear,jar}</source>
<target>/opt/wildfly/standalone/deployments/</target>
<unpack>true</unpack>
</deployment>
</autodeployments>
<hotdeployments>
<deployment>
<source>src/main/webapp</source>
<target>/opt/wildfly/standalone//deployments/my-app.war</target>
</deployment>
</hotdeployments>
</configuration>
</plugin>
.....
</plugins>
</build>
....

Need some information on jdeb plugin control file

I am facing a problem with jdeb plugin.I have to modify the jdeb plugin (integrated with maven)such that the name of the debian file created shall have a different name then the current name and the control file generated should have the modified name.Now i am able to modify the current name but i am still getting the old package name in my control file.
Please find my plugin written below.
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>0.11-nklasens-1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jdeb</goal>
</goals>
<configuration>
<deb>${project.build.directory}/ABC_${version}.deb</deb>
<timestamped>true</timestamped>
<controlInfo>
<priority>${debian.priority}</priority>
<section>${debian.section}</section>
<architecture>${debian.architecture}</architecture>
<description>${debian.description}</description>
<maintainer>${debian.maintainer}</maintainer>
</controlInfo>
<dataSet>
<data>
<src>${project.build.directory}/ABC.war</src>
<type>file</type>
<destName>ABC.war</destName>
<mapper>
<type>perm</type>
<prefix>/srv/tomcat/webapps</prefix>
<user>tomcat</user>
<group>tomcat</group>
<filemode>644</filemode>
</mapper>
</data>
</dataSet>
</configuration>
</execution>
</executions>
</plugin>
got the answer after doing some experiment
The answer is add below tags under tag
<packageName>ABC</packageName>
<version>${version}</version>

Is there any way to trigger the Maven Appengine Devserver to auto-refresh static files?

The most recent version of the maven plugin has enabled updating of code every 5s, which is a great improvement. But unless I am configuring this wrong, it doesn't seem to pick up static file changes such as work in progress Javascript connecting to the appengine code.
Is there any way to alter this behavior or do I just need to wait for a new release?
Automatic updates cannot be done using appending devserver alone right now. Strictly speaking, we need to wait.
But you can achieve the effect of seamless html/js/css/etc update, hot java code replacement, etc. with the configuration below.
Configure Apache httpd or Nginx to serve static code directly from your war-source and route to app engine for servlets. In my case, all the html are directly accessible from webapp directory and servlets are called via /sim/. Using nginx and 7070 port, my working nginx config looks like:
server {
listen 7070;
root /home/pchauhan/Projects/my-company/my-mvn-gae-project/my-mvn-gae-project-war/src/main/webapp;
location /sim/ {
proxy_pass http://localhost:8080/sim/;
}
}
Use this documentation of nginx, for more configurations.
Configure Eclipse and GAE separately.
Now, you can directly make changes to source and get them on refresh, both for html (via nginx) and servlets (via devserver).
Add this webapp folder to your Chrome Dev Tools, Sources Workspace and life will be easier. Small changes can directly be saved from chrome to src via ctrl
Please note, that while this is great, you should test your app once solely on 8080 (devserver port) before uploading, just in case there is a bug in maven config and target is not being created/served correctly.
Alternate Idea for syncing: If you do not want to use nginx/httpd for some reason, you can add target...webapp to chrome workspace, work directly there for seamless updt and then use lsyncd to sync target back to src. I haven't tried it yet, but looks feasible, albeit a bit risky.
So far, best way i found was configuring below entries in pom.xml. This will build automatically your static files and reflects on the page.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="target.webapp.dir"
value="${project.build.directory}/${project.build.finalName}" />
<property name="src.webapp.dir" value="${basedir}/src/main/webapp" />
<sync verbose="true" todir="${target.webapp.dir}"
includeEmptyDirs="true">
<fileset dir="${src.webapp.dir}" />
<preserveintarget>
<include name="WEB-INF/lib/**" />
<include name="WEB-INF/classes/**" />
<include name="WEB-INF/appengine-generated/**" />
</preserveintarget>
</sync>
<!-- <sync verbose="true" todir="${target.webapp.dir}/WEB-INF/classes">
<fileset dir="${basedir}/target/classes" /> </sync> -->
</target>
</configuration>
</execution>
</executions>
</plugin>
And another entry after
<pluginManagement>
<plugins>
<!-- This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.6,)</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
This is working fine. As soon as any static files changed and saved, it got reflected on the page.
Like PoojaC20, I have also not been able to get this working with devserver alone but I ended up with a different workaround which I thought I'd share in case others found it helpful.
I now host my development static files outside of the GAE devserver by using grunt-serve. This allows a large number of advantages including:
Automatic page refresh when static files have changed - don't even need to press the refresh button.
Automatic conversion of advanced CSS such as LESS
Automatic conversion of javascript-compileable languages such as CoffeeScript
Mechanism for minification and CDN-ification when development is done.
The most profound implication of the above is that I have needed to move away from session based authentication to OAuth or OpenID Connect based authentication systems and to make all of my web service calls CORS compatible. This is some work, but it too has one very profound advantage:
Once your web sever has moved to OpenID Connect based authentication, it can now connect identically to native (e.g. mobile) client or web based clients!

undefined element declaration 'xs:schema'

I am completely new to web service stuff.
I have to write rest web service client for a web service. The web service runs fine on SoapUI. WSDL file for the URL is provided to me. But when I add the wsdl file in my Eclipse project, it gives compilation error
src-resolve.4.2: Error resolving component 'xs:schema'. It was detected that 'xs:schema' is in namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document 'file:///E:/Ashish%20Workspace/HATStoLSAMS%20Webservice/HATS2LSAMSWS/WebContent/WEB-INF/wsdl/CorpsiteService.svc.wsdl'. If this is the incorrect namespace, perhaps the prefix of 'xs:schema' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:///E:/Ashish%20Workspace/HATStoLSAMS%20Webservice/HATS2LSAMSWS/WebContent/WEB-INF/wsdl/CorpsiteService.svc.wsdl'.
I googled a lot to get rid of these error but nothing worked.
If I ignore the errors and try creating stubs using wsimport as well as wsdl2java commands
it gives error
[ERROR] undefined element declaration 'xs:schema'
line 1 of http://chec.local/STAR.WCF/CorpsiteService.svc?singlewsdl
I am using below command to generate stubs
wsimport -d e:\test -s E:\wssrc http://chec.local/STAR.WCF/CorpsiteService.svc?singlewsdl -wsdllocation "../../../../../WEB-INF/wsdl/CorpsiteService.svc.wsdl"
I am stuck at this point and have been struggling on to this the whole day.
Any help regarding this would be really helpful
The solution to this appears to be supply alternate bindings for xs:schema as described in https://metro.java.net/2.1/guide/Dealing_with_schemas_that_are_not_referenced.html
Specifically, for the http://www.w3.org/2001/XMLSchema which is often imported into the namespace xs, there is some additional work that needs to be done.
The command would be: wsimport -b http://www.w3.org/2001/XMLSchema.xsd -b customization.xjb something.wsdl
customization.xjb linked from the above is at https://www.java.net//blog/kohsuke/archive/20070228/xsd.xjb or copied from below
This customization exists to handle some naming conflicts that might arise from using the schema Schema (which is imported as the same name space in multiple schemas).
customization.xjb
<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
version="2.0">
<globalBindings>
<xjc:simple />
</globalBindings>
<bindings scd="~xsd:complexType">
<class name="ComplexTypeType"/>
</bindings>
<bindings scd="~xsd:simpleType">
<class name="SimpleTypeType"/>
</bindings>
<bindings scd="~xsd:group">
<class name="GroupType"/>
</bindings>
<bindings scd="~xsd:attributeGroup">
<class name="AttributeGroupType"/>
</bindings>
<bindings scd="~xsd:element">
<class name="ElementType"/>
</bindings>
<bindings scd="~xsd:attribute">
<class name="attributeType"/>
</bindings>
</bindings>
I have tried this with these files and the associated -b parameters to wsimport and have gotten (apparently) past this error (and on to other ones). That said, I'm not 100% certain that my new errors are not in part caused by this (and thus this wouldn't be a complete answer). Without the actual wsdl causing the problem, one can only take a reasonable guess as to solving the problem (and on to the next one).
If you are using maven-jaxb2-plugin instead -b provide needed URL as additional schema in schemas:
<schema>
<url>https://example.com/WebService.asmx?WSDL</url>
</schema>
<schema>
<url>http://www.w3.org/2001/XMLSchema.xsd</url>
</schema>
You can even save it in resources so it is picked up automatically
I was facing same issue, resolved by just adding one line into maven plugin
<args>
<arg>-b</arg>
<arg>http://www.w3.org/2001/XMLSchema.xsd</arg>
</args>
My maven plugin is given below
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>periodictableaccessws</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
<args>
<arg>-b</arg>
<arg>http://www.w3.org/2001/XMLSchema.xsd</arg>
</args>
<wsdlFiles>
<wsdlFile>doosdaas.wsdl</wsdlFile>
</wsdlFiles>
<packageName>com.dss.doosdaas</packageName>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalDTD=all</vmArg>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
<!-- <bindingDirectory>${basedir}/src/main/resources/jaxb</bindingDirectory>
<bindingFiles>
<bindingFile>jaxb_binding.xjb</bindingFile>
</bindingFiles>-->
</configuration>
</execution>
</executions>
</plugin>
I face this kind of error when I had to consume some of UE Taxations Customs web services. In previous projects I had used the solution proposed by user289086
But for recents projects I had used another solution also based in bindings but shorter, where I use the Wrapper-style rules described here Using JAXB Data Binding.
1- Create a binding file with the following content and add it to META-INF folder:
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
</jaxws:bindings>
2- Create Web service reference from wsdl using wsimport(in my case I use the Netbeans IDE WS Client Assistant that use wsimport in the background) for the following service for example:
UE CheckTinService
Note: First maybe the process of wsimport could be raise and error or not, but the difference of adding or not the previous binding is easy to check.
3- Add the binding reference to the corresponding jaxws-maven-plugin execution in the .pom file. For the example it stays like this:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>ec.europa.eu/taxation_customs/tin/checkTinService.wsdl</wsdlFile>
</wsdlFiles>
<packageName></packageName>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
<wsdlLocation>https://ec.europa.eu/taxation_customs/tin/checkTinService.wsdl</wsdlLocation>
<staleFile>${project.build.directory}/jaxws/stale/checkTinService.stale</staleFile>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/META-INF/TaxationCustomsWsImportBindings.xml</bindingFile>
</bindingFiles>
</configuration>
<id>wsimport-generate-checkTinService</id>
<phase>generate-sources</phase>
</execution>
</executions>
...
You can see the exactly configuration for using the binding file created before:
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/META-INF/TaxationCustomsWsImportBindings.xml</bindingFile>
</bindingFiles>
4- Finally turn to refresh de WS Reference and the changes will be applied to the process of wsimport.

Supporting i18n in GWT

Till now, our web application supports only English. Now we have to provide support for Italian as well. There is GWT module for some functionality. To support the Italian language I have added below line in the file "APP_Module.gwt.xml"
<extend-property name="locale" values="it"/>
I have also placed "XXX_it.properties" file under the source code where the properties file for en is kept.
Setting the locale in the jsp by following line:
<meta name="gwt:property" content="locale=${locale}">
Now, the issue is how to compile the code. I am debugging the application but it is not hitting the client code of GWT presented under WEB-INF/src.
I am very new to GWT. Please suggest how can I compile the code or there is no need of compilation. It will automatically take the changes done in "APP_Module.gwt.xml" and there is some other issue. How can I see logs of GWT?
To add support for locales to GWT application, you need to do the following in your xxx.gwt.xml:
under <module> add this to include the support:
<inherits name="com.google.gwt.i18n.I18N" />
and this to configure it:
<extend-property name="locale" values="en,it"/>
<set-property-fallback name="locale" value="en"/>
Add all your property files under some package like this:
src/main/resources/foo/bar/client/i18n/MyMessages.properties
src/main/resources/foo/bar/client/i18n/MyMessages_it.properties
Then you need to tell GWT to compile them into classes. This is example from a pom.xml file (if you don't use maven, you will have to use a different way, but you still need to configure it).
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.3.1.google</version>
<executions>
<execution>
<goals>
<goal>i18n</goal>
<goal>generateAsync</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<i18nMessagesBundles>
<resourceBundle>foo.bar.client.i18n.MyMessages</resourceBundle>
</i18nMessagesBundles>
</configuration>
</plugin>
Then you need to recompile the code. In maven mvn compile. And that's all, you will have your messages in generated sources folder ready to use.
For seeing the logs of gwt you can use gradlew gwt also you can use it to compile the code too.

Categories