Kohei Nozaki's blog 

Disabling SpamAssassin on James


Posted on Friday Feb 06, 2015 at 03:00PM in Technology


I’m using revision number 1657019 in the SVN trunk of James3. I see an error in james-server.log at every receiving of emails as follows:

INFO  14:41:51,912 | james.mailetcontext | Error communicating with spamd on localhost:783 Exception: java.net.ConnectException: Connection refused

It seems like that James is trying to connect to local SpamAssassin instance, but I have no SpamAssassin instance on my server yet so I simply deleted following definition from mailetcontainer.xml.

<mailet notmatch="SenderHostIsLocal" class="SpamAssassin">
  <spamdHost>localhost</spamdHost>
  <spamdPort>783</spamdPort>
</mailet>

Now the exception disappeared.


Defining aliases on James


Posted on Friday Feb 06, 2015 at 02:47PM in Technology


I’m using James3 in SVN trunk revision number 1657019.

Adding a user to recipient rewrite table

This forwards a address postmaster@example.com to kyle@example.com:

./james-cli.sh -p 9999 -h localhost addaddressmapping postmaster example.com kyle@example.com

Defining postmaster address

James replaces a particular address postmaster by PostmasterAlias according to XML definition on some environment, so we need to set correct email address to it. in $JAMES_HOME/mailetcontainer.xml as follows:

<mailetcontainer enableJmx="true">

    <!-- MailAddress used for PostMaster -->
        <context>
            <postmaster>kyle@example.com</postmaster>
        </context>
...


Updating and Configuring Derby shipped with James


Posted on Friday Feb 06, 2015 at 02:30PM in Technology


Put latest Derby jars

I used derby.jar and derbynet.jar of 10.11.1.1 to accept network connections. put these jars you needed into $JAMES_HOME/lib.

Define that jars to wrapper.conf

Comment out following line in $JAMES_HOME/conf/wrapper.conf:

#wrapper.java.classpath.94=%REPO_DIR%/derby-10.9.1.0.jar

Then put following line:

wrapper.java.classpath.94=%REPO_DIR%/derby.jar

Make Derby to accept network connections

Add following line to $JAMES_HOME/conf/wrapper.conf.

wrapper.java.classpath.131=%REPO_DIR%/derbynet.jar

Also additional system properties are needed:

wrapper.java.additional.15=-Dderby.drda.startNetworkServer=true
wrapper.java.additional.16=-Dderby.drda.portNumber=11527

Config derby.log

I prefer to place derby.log into $JAMES_HOME/log, and append log to exist one.

wrapper.java.additional.17=-Dderby.stream.error.file=../log/derby.log
wrapper.java.additional.18=-Dderby.infolog.append=true

Define shutdown hook of Derby

Lob streaming is not supported

Currently OpenJPA, James’s JPA provider, is not supported lob streaming for Derby. James stored mail data in lob so If you frequently use larger mails, consider using other databases instead of Derby.


Profiling remote JVM over SSH with VisualVM


Posted on Friday Feb 06, 2015 at 01:31PM in Technology


UPDATE October 2015: This procedure requires a VisualVM distribution that can be obtained from https://visualvm.java.net . At least, It will work with VisualVM 1.3.8. May doesn’t work with VisualVM which has been installed as a part of JDK distribution. I have experienced VisualVM which comes with JDK8u60 doesn’t work.

First I tried that creating a tunnel like ssh remote.example.org -L 19999:localhost:9999 and connecting VisualVM to localhost:19999, but it didn’t worked. intead, creating a socks tunnel like ssh remote.example.com -D 1080 and connecting VisualVM to localhost:9999 via socks proxy is worked. detailed procedure is following:

  1. Create ssh socks tunnel

  2. Set manual proxy in VisualVM’s preferences

  3. Right-click Local

  4. Add JMX connection

  5. Enter localhost:9999 to text box

  6. Click OK

  7. Double-click newly added JMX icon

Make sure that destination JVM has started with following system properties:

-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=false


Remote debugging of standalone application with IntelliJ IDEA


Posted on Friday Feb 06, 2015 at 11:08AM in Technology


Environment

  • IntelliJ IDEA 14.0.3

  • Oracle JDK 8u20

  • OS X 10.9

Procedure

  1. Open/create/import a project of the target application in IntelliJ IDEA

  2. Attach additional sources such as dependencies if you need it. it can be attached from Project Structure ⇒ Libraries.

  3. Set breakpoints as you desired

  4. Open Edit Configurations…​

  5. Click + button

  6. Click Remote

  7. Look Configuration tab and copy the fragment in Command line arguments for running remote JVM as follows:

    -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
  8. Click OK

  9. Launch target application with preceding argument which copied

  10. Click insect icon on upper-right