Browsing Category "java"

Search This Blog

Powered by Blogger.

Pages

Browsing "Older Posts"

Browsing Category "java"

JDK8 java.lang.NoClassDefFoundError: com/sun/tools/javac/code/TypeTags

By TY → Sunday, October 11, 2015

Java build fail after update to jdk8 java.lang.NoClassDefFoundError: com/sun/tools/javac/code/TypeTags

Some projects continue to build successfully while some others failed after upgrading JDK.
Looking deeper into it and comparing the projects, those that failed are projects that are using lombok. It has been a while since I have upgraded lombok version. (which was still at 0.XXX)

After downloading the latest version of lombok and rebuild, the build completes successfully!

Gmail to allow less secure app to connect

By TY →


Some of my old java application that used to be able to send out email via Gmail fails. This seems to be due to a security enhancement sometime back in Gmail.

We now need to explicitly allow less secure applications to connect to Gmail. In order to do that, we will have to


  1. Go to
    https://www.google.com/settings/security/lesssecureapps
  2. Check "Allow access for less secure apps"
Note that, this feature is not available for google account with 2-steps verifications enabled.

For more information:
https://support.google.com/accounts/answer/6010255?hl=en

Unable to build in intellij idea when using lombok

By TY →
When using lombok with intellij, there is a great lombok plugin that enable Intellij to pick up the getter setter methods within the editor. However, when trying to build within Intellij, the build will fail.

To solve this, we only need to configure Intellij to process the annotations.
Go to Settings and type in "Enable annotation processing" in the search field and click "Annotation Processors" in the result.


Then just check "Enable annotation processing"

Reference : 
http://stackoverflow.com/questions/9424364/cant-compile-project-when-im-using-lombok-under-intellij-idea

Building docker image for jdk7, tomcat7 and apache2

By TY → Monday, June 8, 2015

Generate keystore to be used for SSL

keytool -genkey -alias tomcat -keyalg RSA \
  -keypass password -storepass password -keystore .keystore

Dockerfile

FROM ubuntu:latest
MAINTAINER TYKOH 
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV DEBIAN_FRONTEND noninteractive

RUN locale-gen $LANG; echo "LANG=\"${LANG}\"" > /etc/default/locale; dpkg-reconfigure locales
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -y install git
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -y install openjdk-7-jre-headless wget unzip vim
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -y install apache2 libapache2-mod-jk
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get -y install supervisor

RUN mkdir -p /opt/tomcat
RUN cd /opt/tomcat
# note docker will auto extract tar gz files
ADD apache-tomcat-7.0.55/ /opt/tomcat/apache-tomcat-7.0.55

# Add volumes for data
VOLUME  ["/data"]


# Add supervisord stuff
ADD start-apache2.sh /start-apache2.sh
ADD run.sh /run.sh
RUN chmod 755 /*.sh
ADD supervisord-apache2.conf /etc/supervisor/conf.d/supervisord-apache2.conf

# add self sign cert for apache2
ADD .keystore /opt/tomcat/.keystore

# config to enable .htaccess
ADD apache_default /etc/apache2/sites-available/000-default.conf
RUN a2enmod rewrite
## prepare apache2 ssl
RUN a2enmod ssl
## RUN a2ensite default-ssl
RUN a2enmod jk

ADD workers.properties /etc/libapache2-mod-jk/workers.properties

ADD .keystore /opt/tomcat/.keystore
## ADD default-ssl /etc/apache2/sites-available/default-ssl.conf

EXPOSE 80 443
CMD ["/run.sh"]

Build docker image

docker build --tag=jdk7-tomcat7-ssl .

Run docker container

docker run -d -p 80:80 -p 443:443 jdk7-tomcat7-ssl
Github