Month: July 2016

Tomcat gets stuck during start up?

It takes more than 5 minutes for your tomcat to startup.  You think it’s your application’s program. But when you download a clean Tomcat (of the same version) can run it without dropping in any of your applications, it still gets stuck.  It may be caused by this: https://wiki.apache.org/tomcat/HowTo/FasterStartUp#Entropy_Source According to my just wasted 2 …

Tomcat gets stuck during start up? Read More »

Call Java compiler programatically

You don’t need to add any dependency private static void doCompile(File sourceDir) throws SomeException { System.out.println(“Compiling started”); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); DiagnosticCollector diagnostics = new DiagnosticCollector(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null); Collection files = FileUtils.listFiles(sourceDir, new String[] { “java” }, true); Iterable compilationUnits = fileManager.getJavaFileObjectsFromFiles(files); List compilerOptions = Arrays.asList(“-source”, “1.6”, “-target”, “1.6”); JavaCompiler.CompilationTask task …

Call Java compiler programatically Read More »

Propagate data change from RDBMS to Solr

Basically, you will use solr’s DataImportHandler to do the importing. Hit http://solr-server:port/solr/db/dataimport?command=full-import to do a full import. Hit http://solr-server:port/solr/dataimport?command=delta-import to do a delta import So, what’s the delta? This is configured in some data-config.xml: deltaQuery=”select id from item where last_modified > ‘${dih.last_index_time}'” So it requires the table on your database must have a column called …

Propagate data change from RDBMS to Solr Read More »

G1 v.s. CMS

G1 also aims at "low pause", and it can work well on large heaps(over 4G) .   CMS, on the other hand, are not designed for large heaps. And CMS requires more configuration. 

Enable https for your nginx-hosted website with a CA-signed certificate

1. Exchange a Certificate Signing Request for certificate files openssl req -new -newkey rsa:2048 -nodes -keyout private.key -out my.csr Then submit my.csr file to your CA. You will then get certificate files from it.   * The private.key will be used for decryption during SSL/TLS session establishment between a server and a client. 2. Combine …

Enable https for your nginx-hosted website with a CA-signed certificate Read More »

Why I am not a fan of Hibernate

Rich Domain Model + Lazy-loading cause problems Hiberntate encourages rich domain model over table model, that is,  A.b instead of A.bId You must enable lazy-loading, otherwise there will be performance issues If you are not in a hibernate session, A.b will be invalid ("Partial Materialization" problem) To make user you are in a hibernate session, …

Why I am not a fan of Hibernate Read More »