My springboot application builds into a WAR file (using Jenkins). I want to automate the remote deployment to Websphere 9.
I have read around and it seems there is no maven plugin for deployment to websphere 9 but ant support is pretty good. So, I'm using maven ant plugin to help running those ant tasks. I started with attempt to list the applications installed, just to see if it works. However I'm running into an exception related to localization:
[ERROR] C:\DEV\ant-was-deploy.xml:81:
java.util.MissingResourceException: Can't find bundle for base name
com.ibm.ws.profile.resourcebundle.WSProfileResourceBundle, locale
en_US
My ant-was-deploy.xml is referenced from pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>id123</id>
<phase>clean</phase>
<configuration>
<locales>es</locales>
<target>
<ant antfile="${basedir}/ant-was-deploy.xml">
<target name="listApps"/>
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
ant-was-deploy.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="websphere" default="listApps" basedir="." >
<target name="listApps" >
<taskdef name="wsListApps" classname="com.ibm.websphere.ant.tasks.ListApplications" classpath="${wasHome.dir}/plugins/com.ibm.ws.runtime.jar" />
<wsListApps
profileName="AppServ01"
wasHome="C:\\opt\\IBM\\WebSphere\\AppServer"
/>
</target>
</project>
I think the error comes from com.ibm.ws.runtime.jar. Inside it has WSProfileResourceBundle.class and WSProfileResourceBundle_en.class but not WSProfileResourceBundle_en_US.class (name is just an assumption - I have copied the bundle with this name inside the jar but it didn't work).
I also tried to set the locale for the entire plugin but it seems that localization for this plugin is not implemented properly (no impact in my case - I set the locale to 'es' but still got the error for en_US).
I also tried to pass system parameters to maven command: mvn clean -Duser.language=fr -Duser.country=FR
It didn't work either.
So, my question is if there is a way to change the locale before the ant script? If I can set it to 'en' probably it will find the right resource bundle.
I'm fairly new to Websphere, if there is another solution to automate the remote deployment to websphere 9 I would be happy to hear it. I would rather not use scripts on target server or Jenkins plugin but if there is no other way ...
I just had the same issue. In my case, i was using an AppServer name (AppSrv1 instead of AppSrv01) that did not exist anymore, in my maven settings.xml.
The right server name solved the issue.
Related
In my ServletFilter, I want to use specific jetty API exposed in the HttpServletRequest implementation.
I launched it like that:
final Request jettyRequest = Request.getBaseRequest(request)
If I want to avoid ClassNotFoundException, I must add the jetty-server artifact to my maven dependencies. But if I do that, getBaseRequest returns null because 'request instanceof Request' returns false instead of true.
This is certainly due to conflict between jetty and application classloaders because both of them have loaded 'org.eclipse.jetty.server.Request' class. I tried several configurations, but I was not able to make the Request class exposed to my webapp without adding the dependency in WEB-INF/lib, which causes the classpath issue.
My application is launched with "mvn jetty:run-forked" and configured like this:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<webAppSourceDirectory>${project.build.directory}/${project.name}</webAppSourceDirectory>
<systemProperties>
<force>true</force>
</systemProperties>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
<jettyXml>../jetty.xml,../jetty-ssl.xml,../jetty-https.xml</jettyXml>
<jvmArgs>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/alpn/alpn-boot/${alpn-version}/alpn-boot-${alpn-version}.jar</jvmArgs>
</configuration>
</plugin>
Any help will be appreciated!
I fixed the issue by adding a WebAppContext configuration file that contains:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="parentLoaderPriority">true</Set>
</Configure>
The file must be referenced in jetty-maven-plugin like that:
<contextXml>../jetty-context.xml</contextXml>
I have this line in log4j:
log4j.appender.FILE.File=${catalina.home}/logs/debug.log
Works perfectly when I run the project from IntelliJ.
But when I try to run a TestNG test (from maven) it fails:
log4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: /logs/debug.log (No such file or directory)
I could hardcode the path and all will be good. But I don't want that solution since I can deploy on various systems where ${catalina.home} is in different place.
I develop on a mac and deploy on freebsd and centos. Tomcat is in different places all the time. I could use /var/log/myapp.log but ...
Is any way to define a common variable (available in IntelliJ and when I run the maven test) with the log file path?
Please try to use the Maven Profile which will be activated when the ${env.catalina.home} is not existed, together with the Maven Surefire Plugin:Using System Properties.
<profile>
<id>mock-catalina-home</id>
<activation>
<property>
<name>!env.catalina.home</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14</version>
<configuration>
<encoding>UTF-8</encoding>
<systemProperties>
<property>
<name>catalina.home</name>
<value>PATH_TO_CATALINA_HOME</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Please note that the PATH_TO_CATALINA_HOME can be referred by the Maven Properties as well. e.g.
<systemProperties>
<property>
<name>PATH_TO_CATALINA_HOME</name>
<value>${my.dev.catalina.home}</value>
</property>
</systemProperties>
This will help us to define the ${my.dev.catalina.home} to be various values.
I hope this may help.
In order for the log4j properties file get the correct value for ${catalina.home} when running the tests from maven, it needs to be in a file that is filtered by maven (src/main/resources is a directory for files like that). Also, the variable 'catalina.home' needs to be setup in maven. You can create a variable AKA maven property that uses an environment variable so you can define the different location for the tomcat install on each machine:
<properties>
<catalina.home>${env.catalina.home}</catalina.home>
<properties>
You can also specify the location of the log files in relation to the home directory for your user account.
In log4j this would use the following format: ${user.home}/weblogs/log4j1.log
In log4j 2, this would use the following format: ${sys:user.home}/weblogs/log4j2Rolling.log
log4j 2 can use the Java system properties, environmental variables, or Maven properties
I have a situation where we wrap a jar with JSmooth to get an suitable exe file.
This has traditionally been built by ant, and as part of our general mavenification the current, short-term solution has been to use maven-antrun-plugin to set a property and invoke ant.
Unfortunately this approach fails when building on Unix (as there is no X11 display available) and the solution is to invoke the JVM with -Djava.awt.headless=true. I would like to do this in my pom.xml but cannot identify where to do this.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<!-- create one-jar and exefy it -->
<property name="maven.project.build.finalName" value="${project.build.finalName}" />
<!-- note: fails on headless Linux for now -->
<ant />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
It is ok to fork a new JVM directly but not to rely on platform specifics.
How can I do this correctly?
As far as I know, the solution without forking JVM is to use MAVEN_OPT
export MAVEN_OPTS="-Djava.awt.headless=true"
Since -D is JVM option, you had to specify it to maven directly. You cannot (once again, from what I know) pass it as internal argument (and there isn't any configuration option that allow it)
So, using MAVEN_OPT parameter become the right way to do it.
EDIT 1:
You can have a glance here using better-maven2-antrun-plugin
http://code.google.com/p/better-maven2-antrun-plugin/wiki/Usage
EDIT 2:
Can can maybe help maven-antrun developpement providing them a way to specify those parameters, like maven-compiler-plugin. This would be the best way if you really want to use pom informations.
The ant manual has a section titled "Running Ant via Java" that shows how to do just what you want. A slightly tweaked version of their example is reproduced below:
<java
classname="org.apache.tools.ant.launch.Launcher"
fork="true"
failonerror="true"
dir="${basedir}"
taskname="headless-ant"
>
<classpath>
<pathelement location="${ant.home}/lib/ant-launcher.jar"/>
</classpath>
<arg value="-buildfile"/>
<arg file="${ant.file}"/>
<arg value="-Dbasedir=${basedir}"/>
<jvmarg value="-Djava.awt.headless=true"/>
</java>
If you put that snippet in place of the <ant> element in your snippet, it should do the trick.
I'm trying to get around the common issue of Jetty locking static files on Windows with the technique of setting useFileMappedBuffer to false in webdefault.xml. Unfortunately, every time Jetty is not picking up my customized webdefault.xml.
I'm using Apache Maven 3.0.2. I've tried using the maven-jetty-plugin (v6.1.26) and jetty-maven-plugin (v8.0.0.M2) but with no difference. I've tried running clean and rebuilding as well before running Jetty.
I've verified each time that my webdefault.xml was taken from the same version as the plugin and has the correct settings, namely, only changing this setting from true to false:
...
<init-param>
<param-name>useFileMappedBuffer</param-name>
<param-value>false</param-value>
</init-param>
...
And here's what my pom.xml Jetty plugin section looks like:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<contextPath>/</contextPath>
<webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
</configuration>
</plugin>
I've also tried altering the path to my file:
<webDefaultXml>${basedir}/src/main/resources/webdefault.xml</webDefaultXml>
Everywhere I've seen this exact solution and it sounds like it is working for others (although I found one instance where someone had my issue). The startup for jetty has this in the output:
> mvn jetty:run
...
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
...
This further makes me think it isn't being applied. All the other paths are correct in the output.
My most direct issue that I'm seeing while Jetty is running is that whenever I edit a static file (JavaScript, CSS, etc.) with IntelliJ IDEA 10, I get this error message:
Cannot save file:
D:\...\... (The requested operation cannot be performed on a file with a user-mapped section open)
After I stop Jetty then it saves just fine. This happens every time.
Any ideas what I could be doing wrong? Thanks in advance.
I found an entirely different doc for the newer Jetty plugin jetty-maven-plugin (v8.0.0.M2) and it looks like the configuration name has changed:
http://wiki.eclipse.org/Jetty/Reference/webdefault.xml#Using_the_Jetty_Maven_Plugin
<project>
...
<plugins>
<plugin>
...
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webAppConfig>
...
<defaultsDescriptor>/my/path/to/webdefault.xml</defaultsDescriptor>
</webAppConfig>
</configuration>
</plugin>
...
</plugins>
...
</project>
This now seems to work for the newer plugin. I'm still unsure why the v6 plugin does not pick up the customized config.
The only solution I found that worked with maven-jetty-plugin 6.1.24 was this:
http://false.ekta.is/2010/12/jettyrun-maven-plugin-file-locking-on-windows-a-better-way/
The Jetty documentation outlines three ways to do it (as of Jetty 9):
https://www.eclipse.org/jetty/documentation/current/troubleshooting-locked-files-on-windows.html
I successfully used the init-param method in Maven:
<!-- Running an embedded server for testing/development -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.9.v20180320</version>
<configuration>
<webApp>
<_initParams>
<org.eclipse.jetty.servlet.Default.useFileMappedBuffer>false</org.eclipse.jetty.servlet.Default.useFileMappedBuffer>
</_initParams>
</webApp>
</configuration>
</plugin>
Question partly answered in Selenium RC testing with Maven - basically stating go back to using Firefox 3.5 (but one answer suggesting that does not work). Not an option anyway - 3.6.8 is what we are using.
Anyway, any clue on how to get Maven / Selenium working with Firefox 3.6.x?
I am attempting to use:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>2.0a5</version>
</dependency>
For dependent Java classes used in the tests.
And:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.1-SNAPSHOT</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
</configuration>
</execution>
<execution>
<id>stop-selenium</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
When I run integration-test against Firefox, I get:
INFO [org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher] Preparing Firefox profile...
ERROR [org.openqa.selenium.server.BrowserSessionFactory] Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Firefox refused shutdown while preparing a profile
Caused by:
org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$FileLockRemainedException: Lock file still present! C:\DOCUME~1\XXX\LOCALS~1\Temp\customProfileDirb809d85d6d064be0bdd1a4ee68035cbb\parent.lock
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFileLockToGoAway(FirefoxChromeLauncher.java:269)
I've had a problem with firefox and Selenium RC.
The solution was to edit the selenium RC jar files. Open them up in WINRAR (or similar) and browse through the folders for
selenium-server.jar\customProfileDirCUSTFF\extensions\*
selenium-server.jar\customProfileDirCUSTFFCHROME\extensions\*
Open up the files you see called "Install.rdf"
<Description about="urn:mozilla:install-manifest">
<em:id>readystate#openqa.org</em:id>
<em:type>2</em:type>
<em:name>DocumentReadyState</em:name>
<em:version>1.0</em:version>
<em:description>Provides a mechanism to update the document readyState property</em:description>
<!-- Firefox -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1.4.1</em:minVersion>
<em:maxVersion>3.6.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>
And see where it says MaxVersion? Bump that up to say ... 4.6
Save the file and overwrite the original install.rdf in the .jar
Then... selenium is happy.
I really apologise for wating your time if this doesn't work. It was a hack that I found after a few hours / days of scrambling.
...
EDIT
...
Oh beans I just read the error message from above. Nowhere near the same issue. Yours is something to do with a lockfile or previous firefox session.
Tried a clear history/reset to factory defaults in the browser and similar?