How do I configure proxy settings for install4j-maven-plugin? - maven

I tried passing the proxy settings in via <jvmArguments> just like you do with an install4j-generated installer:
<plugin>
<groupId>org.sonatype.install4j</groupId>
<artifactId>install4j-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>compile-installers</id>
<phase>package</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<jvmArguments>
<arg>-DproxySet=true</arg>
<arg>-Dhttps.proxyHost=...</arg>
<arg>-Dhttps.proxyPort=443</arg>
<arg>-DproxyAuth=true</arg>
<arg>-DproxyAuthUser=${...}</arg>
<arg>-DproxyPassword=${...}</arg>
</jvmArguments>
...
</configuration>
</execution>
</executions>
</plugin>
but that failed.
On a machine where proxy settings are injected via the IDE, the above works, even if I intentionally pass in a wrong password or even a nonexistent proxy server, so I guess I'm Doing It Wrong(tm).

Turns out it was a misconfiguration.
Lesson to take home: If you see "connection refused", "forbidden", or any other connection failure messages, it might be the proxy or the target server talking, you don't know and the install4j-maven-plugin output does not tell you.
It would be nice if a future install4j-maven-plugin version could output that information, but currently it does not.

Related

How to fetch Swagger definition from a password-protected remote server in Maven

Rather than copy a Swagger definition from another project, I want to fetch the current version direct from Gitlab. I thought that I might be able to link to the server settings in settings.xml but that doesn't seem to work.
How do I pass the server credentials to Maven in order to access the yaml? Or is this not the right way to do it?
<execution>
<goals>
<goal>java</goal>
</goals>
<id>generate-swagger-attrstore</id>
<phase>generate-sources</phase>
<configuration>
<server>gitlab</server>
<mainClass>io.swagger.codegen.SwaggerCodegen</mainClass>
<includePluginDependencies>true</includePluginDependencies>
<arguments>
<argument>generate</argument>
<argument>-l</argument>
<argument>java</argument>
<argument>-c</argument>
<argument>${swagger.dir}/attrstore-codegen-config.json</argument>
<argument>-i</argument>
<argument>${swagger.attrstore}</argument>
<argument>-o</argument>
<argument>${basedir}</argument>
<argument>--library</argument>
<argument>okhttp-gson</argument>
</arguments>
</configuration>
</execution>

OTRS GenericTicketConnectorSOAP.wsdl can't create port and service

I'm using jax-ws maven plugin for generate obiekt from GenericTicketConnectorSOAP.wsdl every object generated without GenericTicketConnectorSOAP, service and port. My pom.xml is wrong or this wsdl isn't prepare to generate service and port ?
Thanks for help.
I cannot use wsdl to generate Java stub classes. I posted my solution here
BTW, the link to your pom does not work. Access denied.
Thanks for your solution. I found other. When I'm using axistools-maven-plugin plugin
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<configuration>
<urls>
<url>file:/${project.basedir}/otrs/Service.wsdl</url>
</urls>
<packageSpace>my.package</packageSpace>
<testCases>false</testCases>
<serverSide>false</serverSide>
</configuration>
</plugin>
everything are generating by itself(port, service itp)

Issue with stopping weblogic server using wls-maven-plugin

This is part of my pom.xml of my .ear file
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>wls-maven-plugin</artifactId>
<version>12.1.1.0</version>
<configuration>
<adminurl>${adminURL}</adminurl>
<user>${username}</user>
<password>${pswrd}</password>
<upload>true</upload>
<remote>false</remote>
<verbose>true</verbose>
<source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
<name>${project.build.finalName}</name>
<targets>${serverName}</targets>
<noExit>true</noExit>
<middlewareHome>${middlewareH}</middlewareHome>
<domainHome>${domainH}</domainHome>
</configuration>
<executions>
<execution>
<id>stopserver</id>
<phase>install</phase>
<goals>
<goal>stop-server</goal>
</goals>
<configuration>
<action>stopserver</action>
<workingDir>${stopScriptDirectory}</workingDir>
<command>stopScript.sh</command>
</configuration>
</execution>
</executions>
</plugin>
I am trying to stop the server by running the stopScript.sh
This is the error I am getting when it is trying to execute the stop-server goal:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.oracle.weblogic:wls-maven-plugin:12.1.1.0:stop-server (stopserver) on project OventusEAR2: Unable to parse configuration of mojo com.oracle.weblogic:wls-maven-plugin:12.1.1.0:stop-server for parameter command: Cannot assign configuration entry 'command' with value 'stopScript.sh' of type java.lang.String to property of type java.lang.String[]
Any ideas?
Though I am not familiar with this particular plugin, however I have seen similar issues before, I guess command parameter is expecting an array instead.
Please try replacing
<command>stopScript.sh</command>
with
<command>
<value>stopScript.sh</value>
</command>
and test again.

jaxws-maven-plugin and proxy exclusions

I use jaxws-maven-plugin to produce java from wsdl.
wsdl located in local network, but refers to some xsd in internet.
It becomes troubles in generation code with maven plugin, becouse it has lack of advanced http proxy settings.
Is there a workaround for this issue?
My config is:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<!--<httpproxy>127.0.0.1:5865</httpproxy>-->
<packageName>my.pkg</packageName>
<verbose>true</verbose>
<wsdlUrls>
<wsdlUrl>
http://10.31.7.64:13080/service.wsdl
</wsdlUrl>
</wsdlUrls>
</configuration>
</plugin>
Without proxy I got
parsing WSDL...
[ERROR] IOException thrown when processing "http://www.w3.org/2005/05/xmlmime". Exception: java.net.ConnectException: Connection refused: connect.
With proxy I got
parsing WSDL...
[ERROR] Server returned HTTP response code: 504 for URL: http://10.31.7.64:13080/service.wsdl
May be it problem of proxy, but I don't have another proxy behind corporate network.
A better approach is to use the noProxy variable of the JVM. Then your build fails when the WSDL is not available (In my case very useful for integration tests) You can add this to the jaxws-maven-plugin configuration:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>wsdltoJava</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlUrls>
<wsdlUrl>https://someService.yourcompany.net/Service/Service?wsdl</wsdlUrl>
</wsdlUrls>
<vmArgs>
<vmArg>-Dhttp.nonProxyHosts=*.yourcompany.net, 10.31.7.64</vmArg>
</vmArgs>
<keep>true</keep>
<packageName>com.yourcompany.package</packageName>
<sourceDestDir>your/target/directory</sourceDestDir>
</configuration>
</execution>
</executions>
AFAIU, when we enable the httpproxy, all request will go to that proxy, including with the <wsdlUrl>.
The server returns
HTTP response code: 504 for URL: http://10.31.7.64:13080/service.wsdl
The Status Code Definitions told us as the following: -
504 Gateway Timeout
The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server specified by the URI (e.g. HTTP, FTP, LDAP) or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.
The root cause may be the proxy does not known our address, in this case it is 10.31.7.64
IMHO please try to download the wsdl and put it to local machine. Then configured by using the wsdlFiles as the following example: -
<configuration>
<wsdlFiles>
<wsdlFile>${basedir}/path/to/wsdl</wsdlFile>
</wsdlFiles>
</configuration>
I hope this may help.

get maven to replace values based on user/build.properties

im at the point in my project where im moving data connections to the beta and production databases for testing. obviously, having the alpha database credentials stored in the source repository is fine, but the beta and production credentials, id be put in front of a firing squad for that one.
i know maven can have a {userdir}/build.properties file. this is the file i want to use to keep the db credentials out of the source repository. but i can't seem to get maven to figure out that for file x.cfg.xml it has to replace values.
so i have in one of my hibernate.cfg.xml files this line
<property name="hibernate.connection.url">#ssoBetaUrl#</property>
now how do i get maven to replace that variable with the value thats in the {userdir}/build.properties file?
edit-------------
ive been playing with the properties-maven-plugin plugin but i seem to not be able to get it to fire. i put this in my parent pom
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<id>read-properties</id>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
</execution>
</executions>
</plugin>
but when it builds, it does not fire. if im reading http://maven.apache.org/maven-1.x/reference/properties.html right it should find the build properties file in the ~/build.properties folder and go from there, but im not sure.
I think you are approaching this the wrong way around. Instead of having the build process bake the appropriate connection details into the JAR file you should instead have the program look for a configuration file at startup.
Typically, my hibernate based apps, will look for a file under %user.home&/.appname/config.properties and load DB credentials and other deployment specfic data from there. If the file is missing, a default version can be included in the JAR and copied to this location (on initial startup so you don't have to copy-paste the file to new systems) that is then edited with appropriate settings.
This way, you can use the same build to produce JAR (or WAR) files for test and production servers, the differences will be in the (presumably already deployed) configuration files. This also makes it possible to have multiple production deployments, each talking to a different database, without any complications in the build process.
You could use two plugins.
properties-maven-plugin
replacer
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>{userdir}/build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>target/**/*.*</include>
</includes>
<replacements>
<replacement>
<token>#ssoBetaUrl#</token>
<value>http://[anyURL]</value>
</replacement>
</replacements>
</configuration>
</plugin>

Resources