Integrating Liferay Developer Studio with JBoss Application Server 7.1

Liferay Developer Studio comes bundled with Tomcat server. Tomcat is usually useful to get things up and running however not so suitable for resource intensive applications. JBoss is usually is good choice for most requirements. The following are the instructions on how to integrate JBoss with Liferay.

  1. Download Liferay JBoss bundle from the liferay website and save it on your local drive. I saved liferay-portal-jboss-6.2-ee-sp7-20140807114015311.zip to my local drive.
  2. Unzip this file to a folder of your choice. I unzipped it to C:\work\liferay-portal\liferay-portal-6.2-ee-sp7. This will your JBOSS_BUNDLE_HOME.
  3. Start the JBoss Server.
  4. If you navigate to http://localhost:8080/, you will see a message indicating that you dont have the Liferay License.
  5. Refer to section in my previous blog post on updating license.
  6. You also need to connect to the same database that you set up with Liferay Developer Studio. To connect to the existing database:
    1. Create a new file called portal-ext.properties in JBOSS_BUNDLE_HOME.
    2. Add the following properties to the file and restart your JBoss Application Server.
jdbc.default.driverClassName=net.sourceforge.jtds.jdbc.Driver
jdbc.default.url=jdbc:jtds:sqlserver://localhost:1433/service_portal
jdbc.default.username=xxxxxx
jdbc.default.password=xxxxxx
  1. Create a new file called portal-setup-wizard.properties in JBOSS_BUNDLE_HOME, add the following lines and save it.
    1. admin.email.from.address={your admin user email address}
    2. admin.email.from.name=Admin User
    3. liferay.home=C:/work/liferay-portal/liferay-portal-6.2-ee-sp7
    4. setup.wizard.enabled=false
  2. Create a new file called build.(your username}.properties in {LIFERAY_HOME}\liferay-developer-studio\liferay-plugins-sdk-6.2 and add the following lines and save it.
app.server.type = jboss
app.server.jboss.dir = ${app.server.parent.dir}/jboss-7.1.1
app.server.jboss.lib.global.dir = ${app.server.jboss.dir}/modules/com/liferay/portal/main
app.server.jboss.portal.dir = ${app.server.jboss.dir}/standalone/deployments/ROOT.war
app.server.jboss.deploy.dir = ${app.server.jboss.dir}/standalone/deployments
app.server.parent.dir = C:/work/liferay-portal/liferay-portal-6.2-ee-sp7
  1. Restart your application server. You should automatically be navigated to the Portal Login page.

Liferay: How to Setup Liferay 6.2 EE Developer Environment

Installing Liferey Developer Studio

  • Navigate to https://www.liferay.com/get-ee-trial/downloads/developer-studio.
  • In the Downloads section, select ‘Windows 64 Bit Bundle’ and click on download.
  • Create a folder on your machine where you want to setup your liferay environment. I have C:\work\liferay\
  • Unzip the downloaded file into the folder you created for liferay development.
  • Open Liferay Developer Studio by clicking on developer studio icon inside your unzipped folder.
  • You will be asked to specify a workspace (I specified, C:\work\liferay\workspace).
  • Start your Tomcat Server.

Updating Licence

  • Once your server has started up, navigate to http://localhost:8080. You will be automatically navigated to the page telling you that the server is not registered. To register the licence:
  • Clear both data and licence folders at LIFERAY_HOME\liferay-develoeper-studio\liferay-portal-6.2-ee-sp5\
  • Place your licence.xml in the deploy directory.
  • Restart your Tomcat Application Server.
  • You should see Liferay configuration page at http://localhost:8080

Configuring Liferay Admin User

Under the Administrator User Section:

  • Enter First Name: admin
  • Enter Last Name: user
  • Email: Enter your email address eg; rampal.abhi@gmail.com

Configure Database

Liferay comes packaged with Hypersonic database. It is recommended that you configure it to use a proper DBMS like Oracle, MySQL or SQL Server.
The following will detail the steps to connect to SQL Server.

  • Please create a new database on SQL Server and give it a sensible name, I called it liferay_portal.
  • On localhost:8080, under the database section, click on change hyperlink, this should open up a database configuration section.
  • Under Database Type dropdown select: SQL Server.
  • Under Database URL enter: jdbc:jtds:sqlserver://localhost/liferay_portal
  • Under JDBC driver class name enter: net.sourceforge.jtds.jdbc.Driver
  • Under username enter your database admin username.
  • Under password enter your database password.
  • Click Finish Configuration.

If you encounter a java connection refused exception when trying to connect to the database, please follow the following steps to resolve it.

  • Create a file called portal-ext.properties
  • Enter the following details in portal-ext.properties

jdbc.default.driverClassName=net.sourceforge.jtds.jdbc.Driver

jdbc.default.url=jdbc:jtds:sqlserver://localhost:1433/service_portal

jdbc.default.username=[your database username]

jdbc.default.password=[your database password]

  • Saved the file at LIFERAY_HOME\liferay-developer-studio\liferay-portal-6.2-ee-sp5
  • Open SQL Server Configuration Manager
  • In the left hand side menu, in the tree structure, select SQL Server Network Configuration -> Protocols for MSSQLSERVER
  • Right click on TCP/IP and enable it (if not enabled).
  • Double click on TCP/IP, this should open TCP/IP popup.
  • Open IP Addresses tab.
  • In the tab, you’ll notice a number of IP addresses listed in each section.
  • In the section where you see IP address 127.0.0.1, make sure IP is active and enabled and port is 1433.
  • Save your changes.
  • Restart the Liferay Tomcat server, you shouldn’t see any errors now.

Silicon Valley – Auckland Edition

There’s been talk by Auckland Council to transform Auckland into a technology innovation mecca in the Asia Pacific Region. Specifically, the proposal is to transform the Wynyard Quarter precinct into a mini Silicon Valley much like the actual Silicon Valley in San Francisco Bay Area in the US. It’s good to see the government recognizing the importance knowledge driven technological innovation as a source of economic growth in New Zealand. However, I feel that the government might be overlooking what really makes Silicon Valley an innovation powerhouse and its definitely not the technology parks. In fact, most companies in the valley are famously started in suburban garages or university dorm rooms. I’m not saying don’t develop technology parks, by all means, please do and get the IBMs, the HPs, the Microsofts to move in there but its going to have a limited impact on the startup scene in Auckland. To forge a culture of innovation you have to make Auckland an attractive place for young smart people from around the world to move to live and work.

The easiest thing the administration can do to attract highly mobile young bright people is to develop world class universities. Our top universities are always crying out for funding and what they receive easily dwarfs in comparison to their American and European counterparts. Once you attract top geeks from around the world to your universities, eventually some percentage of them would fuel into the local economy and even smaller percentage would try to build companies and still a smaller percentage would be successful. This will start a feedback loop, smart people would attract other smart people and eventually you would have thriving innovation centre. Secondly, you have to make Auckland a city where venture capital is easily available for startup founders. While local government can and does help with capital but ultimately this would come from the ex founders who cashed in on their successful gigs and are hungry for more. Again, this comes back to the feedback loop which is started by the pouring money into the local university system.

This is roughly the model on which startup hubs all over the world are based on. Below are some that stand out, would be nice to see people adding Auckland to that list!

Silicon Valley, US – Stanford University, University of California – Berkeley
Boston, US – Harvard University, MIT
New York, US – Columbia University, Cornell University
Waterloo/Toronto, Canada – University of Waterloo, University of Toronto
London, UK – Kings College, Imperial College, University College, London Business School, Oxbridge
Singapore – Nanyang Technological University, National University of Singapore
Tel Aviv, Israel – Tel Aviv University
Bangalore, India – Indian Institute of Science, IITs (from all over India)
Auckland, NZ – University of Auckland, Massey University??

Thoughts on the Wheedle Fiasco

Anyone who works in technology in New Zealand is probably aware of the Wheedle.co.nz and listselltrade.co.nz fiascos from the past few weeks. Social Media has been abuzz with people complaining about the substandard user interfaces, security loopholes, faulty hyperlinks etc. I really admire the audacity of founders to launch products in the NZ online e-commerce market where TradeMe is the undisputed king by market share. The long list of startups that have failed in the process of competing with TradeMe is enough to put any potential founder off from even trying. Sadly, the audacity to compete with TradeMe wasn’t matched with a crafty execution. One cannot help but wonder why both companies failed so spectacularly, why their game was over so quickly, where did they go wrong? Looking closely, some things stand out.

First Impressions
In the web and mobile apps business first impressions are hugely important. They make or break your product. When you’re someone like Wheedle, taking on TradeMe, your site shouldn’t look like a poor cousin of TradeMe. User experience on your site is your first point of attack on grabbing the customer’s attention. The colour combinations, the fonts, the logos and buttons should be begging the customer to click. You’ve already lost the battle if your site looks unfinished and painfully similar to the big brother in the market. Remember, users are going to use your application because they think it will offer something different, something better, something that they’ve been waiting for and has finally arrived, something that really connects with them! If your site looks too similar then you’re already losing your customers. Both Wheedle and ListSellTrade should have invested more in the UI of their respective apps.

Security
When you build an e-commerce application security is right up there with a great user-interface in the list of things you have to get right. For your first release you don’t have to exhaustively spend resources on security. You just have to get the basics right. Make sure your site doesn’t have any of the ‘OWASP top ten list of the 10 most dangerous security flaws’ and unlike Wheedle, please do not send users their passwords in plain text! Even a little suspicion that confidential information is not secure on your app will drive consumers away.

Outsourcing
There is two types of outsourcing. The first, where you outsource because you cannot find people with a specific skill set in your country. For someone trying to innovate, trying to carve out a niche in the market such outsourcing is essential. Then there is the other type, the one where firms that are not really in the innovation business, that are just developing mediocre products and want to achieve that as cheaply as possible. While I personally have some reservations on this as a long term business mode, it seems to have worked for some companies (and others have miserably failed e.g. 2 Degrees). However, here is something to ponder – do you know of any company that launched a successful product, challenged the status quo, made leaps into a new market with a product that was outsourced to cheap overseas developers. I haven’t. Facebook, Google, Amazon, Yelp, Groupon and locally, Orion Health, Xero, MCom, INRO, Telogis and even TradeMe, founders didn’t just come up with an idea and outsourced the development work to India. Entrepreneurship and new product development is more about the execution of idea rather than the idea itself. When you outsource the development of your product you lose control over the execution and poor execution only paves way to failure. Wheedle made a major mistake of outsourcing the software development team to India.

Quiet roll outs
Part of the reason why Wheedle so spectacularly failed is because they created too much hype building up to the launch day. TV, radio, Social Media, they were everywhere. When they did eventually launch and failed subsequently, they got a lot negative press that they could have done without. A smarter way would have been to quietly launch their product, grow it organically, fix all the issues that are reported along the way and then finally go all guns blazing into TV and Social Media campaigns in order to market the product.

Software Development > Marketing Campaign
No Marketing campaign can ever make up for a shoddy product.

Android: download and decompress GZIP file on the fly

Code snippet below shows a neat way of downloading and decompressing a GZIP file on the fly. This saves from having to programmatically download the file first and then decompressing it. I have used this for downloading and unzipping a GZIP file that contained an XML document.

protected String doInBackground(String... sUrl) {
	try {
		URL url = new URL(sUrl[0]);
		URLConnection connection = url.openConnection();
		InputStream stream = connection.getInputStream();
		stream = new GZIPInputStream(stream);
		InputSource is = new InputSource(stream);
		InputStream input = new BufferedInputStream(is.getByteStream());
		OutputStream output = new FileOutputStream("Path to the file");
		byte data[] = new byte[2097152];
		long total = 0;
		int count;
		
		while ((count = input.read(data)) != -1) {
			total += count;
			output.write(data, 0, count);
		}

		output.flush();
		output.close();
		input.close();
	} catch (BufferOverflowException e) {
		e.printStackTrace();
	} catch (IOException e) {
		e.printStackTrace();
		return null;
	}
}

PDF Document word-split using Flying Saucer/XHTML Renderer

I thought I’d write a post on some bizarre behavior I recently encountered with the Java 5 SAX Parser. This might help people who are using Flying Saucer for PDF generation.

We were reported a bug where the PDF documents generated by a web application we developed, occasionally, had words split across two lines. We tried hard to establish a pattern on when the split happened but after trying out many different scenarios and much deliberation we came to the conclusion that the split was random and no real pattern could be followed to replicate it. It was so hard to replicate that, at times, it would take the tester a whole day to find an example split in the generated PDF documents.

The web application uses Flying Saucer/XHTML Renderer to render PDF from an XHTML document. Flying Saucer is the most widely used PDF renderer in the Java technology stack and therefore it’s quite bizarre to encounter such a problem. Doing some googling also revealed that no one else had encountered a similar problem and for most people Flying Saucer worked like a breeze. This meant that after exhausting all other options of looking for the bug in our code, we were left with no other option than looking through the Flying Saucer code to look for the potential bug.

The web application uses the combination Spring MVC and Apache Tiles to generate XHTML document to represent the format and content of the PDF to be generated. The application was running on IBM Websphere server and used the default websphere Java 6 SAX parser to convert the XHTML document into W3C DOM. Through our investigation it was found that in the DOM, the split words were represented by multiple text nodes. So for example, if performance was to split into ‘perfor’ and ‘mance’ in the PDF, in the DOM, ‘perfor’ and ‘mance’ were parts of the different text nodes. Flying Saucer, the PDF renderer, treats each text node separately, which caused text to break in the middle of words.

We still don’t know why the SAX Parser arbitrarily creates two text nodes to represent one word. An obvious solution to the problem was to use a different parser and using a different parser did seem to solve the problem. However, normalising the document, i.e. combining multiple text nodes and therefore removing the possibility of having a word being represented by multiple text nodes seemed a much easier option since there was already a method available in the Java API to normalise the document and just calling this method fixed our problem.

This seems to have solved the problem with no more word-splits reported to date.
We still don’t know why the SAX parser created multiple text nodes to represent one word.