Kohei Nozaki's blog 

Backup of a database server on VMware Fusion


Posted on Sunday Jan 25, 2015 at 06:05PM in Technology


There are some opinion about AutoProtect enables backup of a virtual machine with Time Machine, but I decided that I will backup my virtual machine as a regular file after shutdown. because there are some opinion that sometimes snapshots bring corruption of databases. they said that there’s possibility of occurrence of unsaved state during taking snapshots and I don’t want to corrupt my database.

But I don’t know what is difference between database servers and daily use computer? is there no possibility of serious corruption of something in daily use computers? has potentially snapshots some wrong design? is it unnecessary to force quiescing for daily use computer? doesn’t it bring crucial problems like data corruption on databases?

Googling with vmware snapshot database consistency gave me many interesting articles or discussions.

As to the procedure about backup after shutdown, following URL would be good to read:

How to mount Time Capsule from command line:


Using multiple instances of WildFly on shared home directory


Posted 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.

tar zxvf ~/Downloads/wildfly-8.2.0.Final.tar.gz

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.

  1. Open Edit Configurations…​ on the drop down list in upper right corner

  2. Add Local JBoss Server instance

  3. Press Configure…​

  4. Press + button in upper left corner of the window

  5. Enter /Users/kyle/servers/wildfly-8.2.0.Final and press OK twice

  6. Put -Djboss.server.base.dir=/Users/kyle/servers/wildfly-8.2.0.Final/standalone-1 to VM options

  7. Put 100 to Port offset

  8. 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


Progress of reading 2 #packt5dollar - thoughts about build tool


Posted 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


Posted 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:

  1. Just find and install JRebel plugin from plugin installation window of IntelliJ IDEA

  2. After restart, enter your activation key (get yours from https://my.jrebel.com/) in Help ⇒ JRebel Activation window

  3. 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>
  4. 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)

  5. 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


Posted 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">
    <!--  -->
    ...