tar zxvf ~/Downloads/wildfly-8.2.0.Final.tar.gz
Using multiple instances of WildFly on shared home directory
TweetPosted on Saturday Jan 24, 2015 at 10:34AM in Technology
Sometimes I need to use multiple instances of WildFly, but it’s annoying to copy whole WildFly package for every needs. also it consumes many diskspace (it’s over 100MB per instance!). an instance means a configuration (deployed applications, registered JDBC driver, datasource, job repository of batch and so on) in this entry.
I leave this entry as a my note of a way to use multiple instances that sharing the home directory (core modules of WildFly) except configuration.
Explode the tarball of WildFly.
Copy the standalone directory for numbers that you want to use.
cd wildfly-8.2.0.Final cp -rpv standalone standalone-1 cp -rpv standalone standalone-2
Launch an instance on a specified base directory.
bin/standalone.sh -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone-1
Also -Djboss.socket.binding.port-offset=100
parameter is useful for using multiple instance at same time. it makes WildFly to apply a offset for all of number of ports to listen. for example, following instances can be running at the same time with its own configuration and same core modules:
bin/standalone.sh -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone-1 -Djboss.socket.binding.port-offset=100 bin/standalone.sh -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone-2 -Djboss.socket.binding.port-offset=200
Note that if you use port offset and when you want to use jboss-cli, you need to start jboss-cli with an additional parameter for each instances like following:
./jboss-cli.sh --controller=localhost:10090 --connect
Configuring IntelliJ IDEA.
-
Open
Edit Configurations…
on the drop down list in upper right corner -
Add Local JBoss Server instance
-
Press
Configure…
-
Press
+
button in upper left corner of the window -
Enter
/Users/kyle/servers/wildfly-8.2.0.Final
and pressOK
twice -
Put
-Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone-1
toVM options
-
Put
100
toPort offset
-
Press
OK
Now you can use same Application server
for each Run Configuration. you only need to copy original standalone directory and specify jboss.server.base.dir
and Port offset
for each projects that needed to manage separately.
Note: the size of standalone directory is around 150K. so reasonable.
kyle-no-MacBook:wildfly-8.2.0.Final kyle$ du -sh standalone 136K standalone
References
Tags: wildfly
Progress of reading 2 #packt5dollar - thoughts about build tool
TweetPosted on Friday Jan 23, 2015 at 09:51PM in Technology
I haven’t read IntelliJ IDEA Essentials yet except some parts of Run configuration but it gives me that better view of the mechanism to run an application on the application server or standalone. I read that with Mastering Apache Maven 3 at same time. I didn’t understand particulary how my application will be built and run, but these books improved my understanding drastically.
I guess that every beginner Java programmer would better to learn that how build tool and Java program works through development with simple text editor and cli of build tool before start using a modern IDE. also launching an application server and deploying their application with build tool is good for server-side programmer. it’s important to know what each tool done. I don’t know how much waste my time for stucking in various problem of automated build and deploy mechanism. this can be avoided with correct understanding of the mechanism.
I realized how Maven has many function and flexibility. the book gave me basic knowledge about it but still I have to learn more advanced topics such as real-world use case which used multi module scheme. there are more Maven books published that mentioned about more specific topic so I would read these books later.
Also I should look back that book sometimes because I might misunderstood or simply couldn’t understand at some part of the book. also there are many plugins that the book didn’t mentioned comprehensively (I know it’s impossible for only one book) so I need to learn about it on the web or another books.
Evaluating JRebel for WildFly and IntelliJ IDEA
TweetPosted on Wednesday Jan 21, 2015 at 10:41PM in Technology
I’m evaluating myJRebel which is free, for personal, non-commercial use only version of JRebel. it enables hot-deployment of classes. its quick start guide for IntelliJ IDEA is nice and easy to understand.
I used an example project which used in my past posting Exploded deployment for WildFly on development and Conditional inclusion of whole element for deployment descriptor with Maven for evaluate JRebel.
Installation is very easy. we can just follow the quick start guide. my recipe is as follows:
-
Just find and install JRebel plugin from plugin installation window of IntelliJ IDEA
-
After restart, enter your activation key (get yours from https://my.jrebel.com/) in Help ⇒ JRebel Activation window
-
Add a definition of JRebel Maven Plugin. I prefer to put definition to a profile because sometimes I make my project public on GitHub or somewhere and not everyone can use JRebel
<profile> <id>jrebel</id> <build> <plugins> <plugin> <groupId>org.zeroturnaround</groupId> <artifactId>jrebel-maven-plugin</artifactId> <version>1.1.5</version> <executions> <execution> <id>generate-rebel-xml</id> <phase>process-resources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile>
-
Enable a profile named
jrebel
in Maven Projects window (make sure to check if/WEB-INF/classes/rebel.xml
exists in the target directory after build) -
Launch your application server with a newly added Run with JRebel icon on upper-right. you would see some logging messages from JRebel in your console
After installation, I did some experiment that modifying a method of CDI managed bean which returns a constant string. it works fine, and pressing Command+F9 (Make Project) after modification is good so that JRebel can reflects changes immediately. also Update classes and resources On frame deactivation works fine but I felt some delay to reflect for about 1 or 2 seconds.
It works fine during the evaluation and it was very nice. it properly enabled server side Java development without deployment. I would apply it to my project.
Also I found a book named "Instant JRebel" (published on 2013). I haven’t read it but it might be good for beginners.
Conditional inclusion of whole element for deployment descriptor with Maven
TweetPosted on Wednesday Jan 21, 2015 at 11:26AM in Technology
Sometimes I need to tweak deployment descriptors (e.g. web.xml) for different environment (e.g. development/integration-test/production). I frequently see the case which tweaks only values of context-param, or choose appropriate one from separated files for each environment but I’m looking for a way to include or exclude whole an element using single template. I found a solution so I leave some note about that.
pom.xml
Specify <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
in plugin configuration.
<build> <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors> </configuration> </plugin> </plugins> </build>
Define variables for each environment. in my case I need to include a context-param of JSF for development environment only. if I didn’t use profile named development
when the time of build, then that context-param will be simply excluded from web.xml.
<profiles> <profile> <id>development</id> <properties> <context-params><![CDATA[ --> <context-param> <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> <param-value>0</param-value> </context-param> <!-- ]]></context-params> </properties> </profile> <profile> <id>default</id> <properties> <context-params></context-params> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> </profiles>
web.xml
Just put an expression inside XML comment syntax. it’s intended to avoid that complaining XML editor of your IDE.
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!-- ${context-params} --> ... </web-app>
Processed web.xml
If I build with mvn clean package -P development
then web.xml will be:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!-- --> <context-param> <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> <param-value>0</param-value> </context-param> <!-- --> ...
If I use mvn clean package
then web.xml will be:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <!-- --> ...
Tags: maven
Exploded deployment for WildFly on development
TweetPosted on Tuesday Jan 20, 2015 at 07:25PM in Technology
I used archive deployment for long time on development because of this problem: http://stackoverflow.com/questions/24725644/intellij-idea-artifact-xxxxwar-exploded-has-invalid-extension
Archive deployment needs redeploy for reflect updates of every resource even if I updated only static content such as html, css, xhtml and jsp. it’s very annoying but finally I found a solution to use exploded deployment with WildFly and IntelliJ IDEA for WAR application so I leave some notes about it. my environment is WildFly 8.2.0.Final and IntelliJ IDEA 14.0.2.
First, specify webappDirectory which ended with .war to pom.xml in your project so that make WildFly to stop complaining that there’s no suffix to application directory.
<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <webappDirectory>${project.build.directory}/exploded/${project.build.finalName}.war</webappDirectory> </configuration> </plugin>
According to https://youtrack.jetbrains.com/issue/IDEA-86484, this should be worked for EAR deployments:
<workDirectory>${project.build.directory}/myapp.ear</workDirectory>
Set following attributes to WildFly with jboss-cli for JSP hot-deployment:
/subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=development, value=true) /subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=check-interval, value=1) /subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=modification-test-interval, value=1) /subsystem=undertow/servlet-container=default/setting=jsp:write-attribute(name=recompile-on-fail, value=true) :reload
Set following parameters to web.xml for JSF(XHTML) hot-deployment:
<context-param> <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> <param-value>0</param-value> </context-param> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param>
REFRESH_PERIOD should be 2 (default) or something for production environment (filtering with maven might help). also it’s better to specify PROJECT_STAGE in JNDI.
Then configure your IDE.
for IntelliJ IDEA
-
Click the empty drop down list on upper right then select Edit Configurations…
-
Click "+" button on upper left then select JBoss Server ⇒ Local
-
Click "Fix" on the lower right then select an artifact which ended with "exploded"
-
Back to server tab and select desirable actions. I prefer "Update resources" for On frame deactivation because it enables that I can check modified JSP/XHTMLs with just press Command+Tab to switch to browser and reload immediately. I can trigger redeploy by hand with Command+F10 shortcut when I update some classes.
-
Now you can launch WildFly with the button on the upper right.
Refer http://jrebel.com for hot deployment of classes. it also offers free https://my.jrebel.com for personal, non-commercial use.