26 June 2015

Windows: software to add (updated)

Current list of software I'm running:

  • MS Office
  • Firefox, with extensions
    • AdBlock Plus
    • RESTClient
      • v2.0.3 hangs with "Accept: application/json" request that return an empty body
    • IE Tab V2
    • Quickjava (disable all kinds of web page content) 
    • SearchWP 
    • Print Pages to PDF
    • User Agent Switcher
  • Q-Dir: multi pane tabbed file manager
  • GreenShot screencapture tool
  • IntelliJ IDEA (€), Netbeans, Eclipse (for the Memory Analyzer Tool)
  • Google Drive
  • Enterprise Architect UML modeling (€) 
  • IZarc compressor (warning: by default also installs Nitro PDF)
  • notepad++
  • winscp, putty
  • Paint.Net 
  • Foxit PDF reader, for its easy editing and annotations
    •  select rectangular text regions
    • Contains a PDF printer, allowing you to print portions of a document to a pdf file (losing selectable text)
    • Free version contains an advertisement bar which you can disable in file > preferences > general, application startup panel
  • WinHTTrack offline browser
  • Cygwin Unix tools

8 June 2015

Hybris omnichannel commerce performance tips

Nice Hybris performance/design post.
Given that the original blog is inactive I'm copying and structuring some of the content below:

  • Data structure / DB
    • Indexing – Add DB indexes according to your model customization. (High priority) You would like to drop unused indexes also, so that DB should not waste it’s time. (Medium priority) 
    • Ensure your custom types defined into items xml are persisting data into its own table rather than piggy banking on generic table. (High priority) 
    • Any relation-end that does not need to be ordered should have this attribute set to false. A common mistake is that developers cut-and-paste type and relation definitions in items.xml files which may result in unintentionally setting relation ends to be ordered.(High Priority
    • If no deployment table is defined for a many-to-many relation, a generic join table is used to store relations and is not optimal for performance. So ensure you define rel table for your custom many to many relationships.
    • Avoid defining collection types. To maintain data integrity, always use a relation.
  • Front end webserver
    • Leverage web server modules for browser caching and compression. Don’t forget disabling unused apache modules. (Low priority)
    • Ensure Hybris app servers are not serving static content. (High priority) Use CDN for static media/pages delivery. This may reduce 90% load from your infrastructure. If above not possible then simply ensure web server layer fronting hybris serving static media or scale externally.
    •  Perform SSL termination at load balancer/web server. Don’t trouble hybris app servers for SSL handshake. (Medium priority)
  • Ensure only required extensions are deployed on front end hybris servers and avoid deploying any back office extension on front end. This is good for security and performance. (Medium priority)
  • Log/audit
    • Ensure loggers configuration is not too verbose in production. (Low)
    •  Cron job logs. Hmc does not have pagination and this kills your hmc when you open a job with thousands of log files. (Medium Priority)
    • Avoid creating history records if possible or purge them on regular interval. Creating a history record by using auditing service might be fancy but can become a big performance overhead very quickly. Imagine creating an audit record for each stock level change. (Medium Priority)
  • Catalogs
    • Avoid maintaining/developing catalog version aware types. If cannot then avoid making them part of catalog sync. e.g price  - Touching price daily for every product may result into full cat sync. Either maintain prices with online version only or at the time of create/update update both version. This way you can remove price item type from catalog sync.
    • If hybris is not your PIM and you have some other system where merchandising team perform preview before publishing a product then you really don’t need multiple catalog version in hybris. Here you can save lots of overhead from hybris. (High priority)
  • Stock service
    • Ensure you are not checking stock on loading of product detail page, category listing pages or add/remove event on basket page. Do this check only on add item into basket, submission of basket page and just before taking payment (i.e. you need to reserve stock here). (High priority)
    • Ensure hybris stock service is used to check stock status and no logic is written on Stock Model directly. (High priority)
  • Ensure JALO and web app session time out are configured to same value. (High priority)
  • Clustering
    • 4 load balanced hybris app servers should be more than sufficient for a decent load, if solution is designed correctly.  
    • TCP/UDP clustering configuration doesn’t matter much for 4 app server cluster. But prefer sticking with default UDP settings. Hybris works well for either case until you have some serious networking issue. Use udpsniff to validate packets (Low priority)
  • Set the minimum and maximum heap sizes for the JVM to the same value. 8GB should be more than sufficient. More memory means longer GC pause and GC pause means all threads on halt.
  • Search
    • Ensure solution is designed properly. You should be really very smart here.
    • Run Solr in standalone mode with one master server. Perform delta Index frequently 10-15 mins.  Prefer two-phase mode so that your site should not stuck while indexing happening behind the scene. Run full index update once in a week or only when you perform schema change. (High Priority)
    • Use Solr as much as you can. Because this way you can save DB calls. Hybris is very chatty with DB because of it’s cache refreshment and lazy loading concept. I really hate this part of hybris but now used to live with this and identified ways to avoid implementing DB centric solution. E.g. you can use solr to render category listing pages, you can index price and stock data and use this data as much as you can. Whole objective touch DB when it is really necessary. (High priority)
    • < Disable Quick Search in hmc on the front-end and back-end hybris application servers. (Low priority)
  • Use Out Of the Box functionality whenever possible
    • Order Invoice generation/re-generation in pdf format.
    •  Purging/archive items older than 30 days: you can configure this manually through hmc or write an impex.
  • Ensure you use hybris WCMS Navigation node design for Mega menu construction so that you should not end-up preparing nested category hierarchy with every hit. 

25 February 2015

NetBeans hints (updated)

Your first NetBeans project
  1. On the start page click the Learn & Discover tab
  2. Under Demo's and Tutorials select Java SE applications
  3. Start the Java Quick Start Tutorial 
NetBeans 7.4 Developer Guide
If you're searching how to do someting in netbeans just type it in the ... search box, it will not only search in your project,  but also in the online help.
Keyboard shortcuts
  • view, search & change shortcuts: tools => options => keymap
    • You can set the keymap to a profile from another IDE (Eclipse, IntelliJ...) here as well.
  • help => keyboard shortcuts card. The pdf that is shown, lives in
  • Some additional useful shortcuts:
    • Go to
      • to definition: CTRL click
        • to implementation: CTRL ALT click
    • Edit
      • Code completion
        • autocomplete popup (+ javadoc): CTRL SPACE
        • javadoc inline popup: CTRL SHIFT SPACE
          • ALT F1 to see in browse
          • Netbeans bundles plenty of javadoc you can browse supplied javadoc for your project libraries from help>Javadoc references
        • complete to recently typed word: CTRL k
      • Add semicolon at end of line:  CTRL ;
      • Add new line below + go there: SHIFT ENTER
    • View
      • fold/unfold code: CTRL –/+
      • members/herarchy of current selection: CTRL/ALT SHIFT F12
Running code
  • After you ran a program, and corrected some errors Rerun using the >> buttons.

  • The lighter double arrows below allow you to rerun with different parameters. You can change the arguments you run with in the Ant properties window.
  • Similar options are available for (individual) tests.
    • You can also launch an individual test by  positioning the cursor in the method and selecting "Run focused test" from the right click menu. 

Netbeans comes with plenty of sample projects for you to explore

HTTP Monitor

In the properties of your Server you can enable  the HTTP monitor.
When the server receives an HTTP request, NetBeans will show a window with all request (but not all response) details. (You may have to undeploy/redeploy your webapp for the monitor to show up).
Additionally,  if you use the internal browser (or the NetBeans Chrome plugin) you can use Window > Web > Network Monitor (NetBeans >= 7.4). It is does not show all client side traffic but is targeted at in-page initiated traffic (REST, websockets) and failed requests.

26 January 2015

18 January 2015

Glassfish missing DataSource: Table/View XXX does not exist

I have a little old webapp connecting to a DB using a glassfish ConnectionPool.
This used to run fine but on a more recent glassfish (4.0) I do net get a good datasource from Glassfish, resulting in a Table/View <name> does not exist error message (the message is a general symptom for a failed DB connection, which can have many other reasons).
The problem exists if I configure the DataSource in web.xml and also if I inject it using @Resource.
The solution is to explicitly map the application reference to the JNDI name in WEB-INF/glassfish-web.xml:


If you don't, Glassfish returns a ConnectionPoolDataSource. Some people corrected this by refering in their web.xml to the ConnectionPoolDataSource, but the solution above will work both for web.xml and Resource injection.

servlets / JSP links (updated)

9 January 2015

Java EE web technology version history (updated)

JSR numbers are included as links.
Servers are webcontainers.Take care, web containers do not include JSF. You have to add it yourself or use an enterprise application server. Enterprise application servers are included in the
complete Java EE version overview.

Java EEservletJSP     ELJSTLJSF    MVCServer       What’s new

jetty 1
ServletContext, RequestDispatcher
tomcat 3.3
jetty 3
53 2.3
53 1.2
tomcat 4.1
jetty 4
154 2.4
152 2.0
52 1.1
tomcat 5.5
jetty 5
245 2.1
127 1.2
tomcat 6
jetty 6
315 3.0
314 2.0
tomcat 7
jetty 8
asynchronous servlets, EL method calls, more...
340 3.1
 341 3.0

344 2.2

tomcat 8
jetty 9.1
HTML 5, non blocking (Listener) servlet IO
369 4.0

371 1.0tomcat 9 (future)HTTP/2