Need some information on jdeb plugin control file - java

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>

Related

Duplicate NS in SOAP Message

Ive got a problem with my xml SOAP message - using java 1.8, Websphere 8.5.5.17, for generating class from wsdl Ive used jaxws-maven-plugin.
When I received SOAP message via WAS to my Java application, something duplicate my ns3 prefix (sometimes another), and unmarshaling to type Object is not work :(
<ns3:document xmlns:ns4="http://service.gggg.com/common/CommonMessage/v01" xmlns:ns3="http://service.gggg.com/RDS/datamodel/LAA/common/v01">
<ns3:outputChannels>
<ns3:archiveType>None</ns3:archiveType>
<ns3:publishingType>Signature</ns3:publishingType>
<ns3:printType>None</ns3:printType></ns3:document>
ns3 prefix is correctly defined upper and element "document" is anyType. The problem is in the inner atribute of document element -> the second definiton of xmlns:ns3, when I overide it manualy together with ns of childs it works.
<ns3:document xmlns:ns4="http://service.gggg.com/common/CommonMessage/v01" xmlns:ns9="http://service.gggg.com/RDS/datamodel/LAA/common/v01">
<ns9:outputChannels>
<ns9:archiveType>None</ns9:archiveType>
<ns9:publishingType>Signature</ns9:publishingType>
<ns9:printType>None</ns9:printType></ns3:document>
Ive just tried jaxb NamespacePrefixMapper, namespaces set in jaxb bindings, manualy overiding in Interceptor SOAPElement, add prefix namespace in package-info.java and a lot lot lot of more but without happy end :(
maven
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<genJWS>false</genJWS>
<extension>true</extension>
<wsdlFiles>
<wsdlFile>
${project.basedir}/src/main/resources/wsdl/ServiceWSDL.wsdl
</wsdlFile>
</wsdlFiles>
<target>2.0</target>
<xadditionalHeaders>true</xadditionalHeaders>
<bindingFiles>
<bindingFile>${project.basedir}/src/main/resources/jaxb/bindings.xml</bindingFile>
<bindingFile>${project.basedir}/src/jaxws/binding.xml</bindingFile>
</bindingFiles>
</configuration>
</execution>
</executions>
</plugin>
binding.xml
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle></jaxws:bindings>
bindings.xml
<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
<jaxb:bindings>
<jaxb:globalBindings generateElementProperty="false" fixedAttributeAsConstantProperty="true"
choiceContentProperty="true"/>
</jaxb:bindings></jaxb:bindings>
Can someone help me ?
THX!

How to generate Java client for Jira WADL?

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

Maven concat files specific files in a directory

I have a directory with unknown depth and folder names.
>A
-> AB
--> configuration.xml
--> ABC
---> configuration.xml
-> AD
--> configuration.xml
-> allconfigurations.xml
I need a maven plugin to concat all the configuration.xml files and create allconfigurations.xml file in the root. Unfortunately folder names and depth is unknown. It would be great to accomplish it within the pom.xml file without needing any other files.
just a quick google for you: the maven-shade-plugin with the XmlAppendingTransformer could help.
sample config is here
While struggling I realized that the real problem is to put a header and footer for the compiled allconfigurations.xml file, since each configuration.xml file is a fragment and when I concat all of them together resulting xml is not a valid xml.
here is the case;
an xml file is something like:
<Configuration xmlns="abc">
...
<connectionTimeoutInMs>240000</connectionTimeoutInMs>
<socketTimeoutInMs>240000</socketTimeoutInMs>
<persist>false</persist>
<internal>false</internal>
...
</Configuration>
and putting many of them is not valid thus result xml must be something like;
<AllConfigurations xmlns="abc">
...
<Configuration xmlns="abc">
...
</Configuration >
...
<AllConfigurations xmlns="abc">
so the first and last lines must be added to the result.
here is the solution I came up with;
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>default-cli</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<!--<phase>process-resources</phase>-->
<!--<phase>compile</phase>-->
<configuration>
<target>
<concat destfile="${project.basedir}/.../allConfigurations.xml"
force="yes">
<fileset dir="${project.basedir}/...">
<include name="xmlHeaderForConfiguration"></include>
</fileset>
<fileset dir="${project.basedir}/...">
<include name="**/configuration.xml"></include>
</fileset>
<fileset dir="${project.basedir}/...">
<include name="xmlFooterForConfiguration"></include>
</fileset>
</concat>
</target>
</configuration>
</execution>
</executions>
</plugin>
where xmlHeaderForConfiguration is a file with content; <AllConfigurations xmlns="abc"> and xmlHeaderForConfiguration has </AllConfigurations>

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.

Filtering a Spring XML file from a dependent project

I have a project MyProject which has a dependency on configuration in another project, BaseProject. Inside BaseProject I have dependencies to many different projects like ErrorLogging, PerformanceLogging, etc... I want to be able to build the top level project (MyProject) and have it filter all the spring xml files in those projects that it has as dependencies. I'm not having any luck. I can see the beans but they are not being filtered. Some of the beans are being filtered with default filters defined in their own poms but non are using the filters from MyProject.
MyProject - This contains the filter files and imports the config from the other projects.
BaseProject - Has spring beans defined which require filtering.
ErrorLogging - Has spring beans defined which require filtering.
When I run a package from MyProject all the spring files are correctly extracted into the jar file but they still contain the property placeholder values ${error.logging.host} for example... The beans in MyProject are correctly filtered. The alternative to this is to define the beans in MyProject but there are about 10 of these projects which use BaseProject and it's beans and I do not want to have to redefine them across 10 seperate projects.
If anyone could shed any light on this issue it'd be great. Thanks
Edit :
To make this clearer, I have a spring beans xml definition inside of the project ErrorLogging called errors-config.xml which defines beans for connecting to databases. This just has place holders for the connection details which should be provided by the filter.properties file that is inside of MyProject.
errors-config.xml is imported as a resource into baseproject-config.xml which sits inside of the BaseProject. Base project and it's config file are imported to MyProject.
I then build MyProject using Maven and I would like the property placeholders inside of errors-config.xml to be replaced with the values in the filter.properties in MyProject. MyProject can successfully filter it's own files but not those of ErrorsLogging project. ErrorsLogging seems to pick up filters from it's own src/main/resources folder instead of that of MyProject.
You can achieve that by unpacking all the dependencies, filtering and packing again, the whole process depends on the structure of your project, for a basic configuration this may suffices:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-dependencies</id>
<!--unpack all the dependencies to the target of this project-->
<phase>initialize</phase>
<inherited>false</inherited>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>${pom.groupId}</includeGroupIds>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/${artifactId}</outputDirectory>
<includes>**/*.properties,**/*.xml</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>${config.maven.plattform.resources}/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>zip</id>
<phase>package</phase>
<inherited>true</inherited>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
This should work as long as you have correctly defined the correct filtering of the resources (which takes places later and also uses the maven-resources-plugin).
You could use the PropertyOverrideConfigurer to override the initial properties.
For example, if you have the folowing datasource definition in errors-config.xml :
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${hibernate.driverClassName}" />
<property name="jdbcUrl" value="${hibernate.url}" />
<property name="user" value="${hibernate.username}" />
<property name="password" value="${hibernate.password}" />
</bean>
You can override the database connection properties in the MyProject context like this :
<bean id="propertyOverideConfigurer" class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="locations">
<list>
<value>filter.properties</value>
</list>
</property>
</bean>
And in the filter.properties file you need to specify the bean names and properties you wish to override :
datasource.driverClass = oracle.jdbc.driver.OracleDriver
datasource.jdbcUrl = jdbc:oracle:thin:#localhost:1521:xe
datasource.user = username
datasource.password = password
Hope this helps.

Categories