Agustus 25, 2015
By
Firman
I created webapp using maven and it behaved oddly. Whenever there is web.xml file, then annotations will be ignored. So if you have servlets not registered in web.xml but annotated, http requests won't be forwarded to them. Annotations are only scanned if you remove the web.xml. After hours of digging, I found out the root cause of the problem is because maven creates the most ancient version of web.xml which is version 2.3.
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
You need to have web.xml version 3 to make web.xml takes precedence over annotations while still having the servlet container scan for annotations.
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
I am unaware of any earlier version of web.xml that behaves like version 3.
Agustus 22, 2015
By
Firman
When running a Java app using maven and you need to debug it, simply pass debugging option as Maven option and then connect to it using remote debug from IDE.
MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y" mvn jetty:run
Juli 25, 2015
By
Firman
WAS for Developers (the full version, not the liberty version) turns out to be not quite straightforward to install on Centos using only the command line (since my Centos installation is a minimal one). So I decided to wriote down my experience installing it.
Preparing Centos:
- yum install "Development Tools"
- If your Centos is 64 bit, you need to install some 32 bit libraries to make IBM Installation Manager works... yum provides \*/libgcc_s.so.1 then pick from the list the package for 32 bit and yum install it.
- Open 9080 and 9060 (the former application port, latter management port of WAS). firewall-cmd --zone=public --add-port=9080/tcp --permanent. Do that for 9060 too and then firewall-cmd --reload.
Installation of WAS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE agent-input [
<!ENTITY home "USERHOMEDIR">
]>
<!--The "acceptLicense" attribute has been deprecated. Use "-acceptLicense" command line option to accept license agreements.-->
<agent-input acceptLicense="true">
<server>
<repository location="/code/was" />
</server>
<profile id="IBM WebSphere Application Server V8.5" installLocation="/code/IBM/WebSphere/AppServer" />
<install modify="false">
<offering id="com.ibm.websphere.DEVELOPERSILAN.v85" profile="IBM WebSphere Application Server V8.5" features="core.feature,ejbdeploy,thinclient,embeddablecontainer,com.ibm.sdk.6_64bit" installFixes="none" />
</install>
<preference name="com.ibm.cic.common.core.preferences.eclipseCache" value="/code/IBM/IMShared" />
<preference name="com.ibm.cic.common.core.preferences.connectTimeout" value="30" />
<preference name="com.ibm.cic.common.core.preferences.readTimeout" value="45" />
<preference name="com.ibm.cic.common.core.preferences.downloadAutoRetryCount" value="0" />
<preference name="offering.service.repositories.areUsed" value="true" />
<preference name="com.ibm.cic.common.core.preferences.ssl.nonsecureMode" value="false" />
<preference name="com.ibm.cic.common.core.preferences.http.disablePreemptiveAuthentication" value="false" />
<preference name="http.ntlm.auth.kind" value="NTLM" />
<preference name="http.ntlm.auth.enableIntegrated.win32" value="true" />
<preference name="com.ibm.cic.common.core.preferences.preserveDownloadedArtifacts" value="true" />
<preference name="com.ibm.cic.common.core.preferences.keepFetchedFiles" value="false" />
<preference name="PassportAdvantageIsEnabled" value="false" />
<preference name="com.ibm.cic.common.core.preferences.searchForUpdates" value="false" />
<preference name="com.ibm.cic.agent.ui.displayInternalVersion" value="false" />
<preference name="com.ibm.cic.common.sharedUI.showErrorLog" value="true" />
<preference name="com.ibm.cic.common.sharedUI.showWarningLog" value="true" />
<preference name="com.ibm.cic.common.sharedUI.showNoteLog" value="true" />
</agent-input>
Juli 23, 2015
By
Firman
To enable Eclipse to connect to the internet through proxy:
- set proxy settings in General -> Network Connections. Set for both HTTP and HTTPS BUT leave SOCKS empty!
- Active provider: manual
Juli 13, 2015
By
Firman
For a full database export/import use
exp user@DB FULL=Y FILE=PATH_TO_DUMPFILE
imp user@DB FULL=Y FILE=PATH_TO_DUMPFILE
The user must have EXP_FULL_DATABASE resp IMP_FULL_DATABASE role (or something equivalent, like DBA). DB is your database (e.g. XE, if you have expreess edition)
Juni 03, 2015
By
Firman
Moving from Eclipse to IntelliJ was painful mainly because of the keyboard shortcuts that made me so productive in Eclipse have to be relearnt.
1. Moving between occurence.
In Eclipse, this is achieved by placing caret over a class name or an instance, then Ctrl+. or Ctrl+,
In IntelliJ, place the caret on the class name or instance name and press Ctrl+Shift+F7 to mark. Then move to the next/prev occurence by F3 or Shift+F3. To open pop-up window showing all occurences of a certain instance: Ctrl+Alt+F7. After done navigating, press Esc.
2. Showing type hierarchy.
In Eclipse, Ctrl+T.
In IntelliJ,
Ctrl+Alt+U
3. Go to definition
In Eclipse, F3
In IntelliJ, Ctrl+B
4. List all members of a class
In Eclipse, Ctrl+O
In IntelliJ, Ctrl+F12
Go to Class, to quickly open any class in the editor: Ctrl+N
To open any file, not just classes: Ctrl+Shift+N
Comment/Uncomment current line or selection: Ctrl+/ and Ctrl+Shift+/Rename refactoring to rename any identifier. Can look in comments, text files and across different languages too: Shift+F6all purpose shortcut is Ctrl+Shift+AGo to next/prev open tab: Alt+Left/Right
Go to last viewed open tab: Ctrl+Alt+Left/Right.
Go to implementation Ctrl+Alt+B
Go to super class Ctrl+U
More coming up as I discover them