Skip to main content

Posts

How to Access Spring Application Context from JSR-168 Portlet Step 1 : Make sure you have spring-webmvc-portlet.jar in your project classpath Step 2 : Make sure you defined your spring files in web.xml like this <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:applicationContext-dao.xml classpath:applicationContext-services.xml classpath:applicationContext-schedule.xml classpath:applicationContext-ajax.xml </param-value> </context-param> Optional <servlet> <servlet-name>context</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> Step 3 : Access like this. PortletContext pc = this.getPortletContext(); ApplicationContext context = Portle...

Basic Log4j tutorial

Step 1 : create file log4j.properties in $project_home/src/ log4j.appender.portlet = org.apache.log4j.FileAppender # log file will be in tomcat/logs/ log4j.appender.portlet.File = ${catalina.home}/logs/privatemessage.log log4j.appender.portlet.Append = false log4j.appender.portlet.layout = org.apache.log4j.PatternLayout log4j.appender.portlet.layout.ConversionPattern = %d{ABSOLUTE} [%t] %-5p %-30.30c{2} %x - %m %n # only log errors log4j.rootCategory=WARN, portlet # log trace messages from this package and sub packages log4j.logger.com.cisco.project=TRACE Step 2 : add these lines to web.xml <context-param> <param-name>log4jConfigLocation</param-name> <param-value>classpath:log4j.properties</param-value> </context-param> Step 3 : Use logger in your java classes, before add log4j library to your project classpath // add imports import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; // define priv...

Liferay 5.2.3 Solr Integration

Liferay Solr Integration Environment: Liferay 5.2.3 or 5.2.5 Solr 1.4 solr-web-5.2.3.1.war Follow these steps Step 1: Add the below line to catalina.sh or catalina.bat, i.e setting the $SOLR_HOME dir (/content/liferay/data/solr) set JAVA_OPTS=%JAVA_OPTS% -Dsolr.solr.home="C:\solr1" Step 2: Copy conf directory from solr downloaded (apache-solr-1.4.0\example\solr\conf) to the $SOLR_HOME (/content/liferay/data/solr) from step 1 Step 3: Replace $SOLR_HOME/conf/schema.xml with solr-web-5.2.3.1/WEB-INF/conf/schema.xml Step 4: Edit $SOLR_HOME/conf/solrconfig.xml change this line with appropriate dir ... to /content/liferay/data/solr/data/ Step 5: Restart Step 6: deploy your solr-web from control panel or deploy dir, also you can download that from here solr-web-5.2.3.1 Step 7: run reindex in liferay control panel->server administration Step 8: Restart

Liferay Jackrabbit Oracle integration

Follow these steps to integrate Liferay, Jackrabbit, and Oracle. Step 1 : Copy the below lines into portal-ext.properties dl.hook.impl=com.liferay.documentlibrary.util.JCRHook jcr.initialize.on.startup=true jcr.workspace.name=liferay jcr.node.documentlibrary=documentlibrary jcr.jackrabbit.repository.root=${liferay.home}/data/jackrabbit jcr.jackrabbit.config.file.path=${jcr.jackrabbit.repository.root}/repository.xml jcr.jackrabbit.repository.home=${jcr.jackrabbit.repository.root}/home jcr.jackrabbit.credentials.username=none jcr.jackrabbit.credentials.password=none Step 2 : Replace the content of liferay-installation/data/jackrabbit/repository.xml with below xml text and then restart <?xml version="1.0"?> <Repository> <!--<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"> <param name="path" value="${rep.home}/repository" /> </FileSystem>--> <!-- Data...

SCEA 5 Step 1

I have prepared from the following materials EJB in Action GOF Design patterns J2EE Design patterns JEE 5 tutorial from Sun.com JavaPassion.com (EJB, JAX-WS) Real exam was different than what I've learned from the above books, SCEA 5 exam was challenging, its an Enterprise Architect Certification so the focus was on solving architectural problems (Scalability, Availability, Maintainability, Picking right technology, & Patterns) So the above materials covered 60-70% of the objectives, rest of the questions I had to answer from my experience, and most of the answer choices were pretty close. Example However i can't post the real question so I'm providing this from my own Question: Pick the right technology for sending XML based reliable message to another system. A: JMS B: JAX-WS C: RMI D: Stateless bean as you can see A, B, C are all correct i.e. we can send an XML message to another system reliably My Advice: However I would cross all those choice which...

Singleton pattern revisited in Java

Lets look at one the simple implementation of Singleton pattern in Java public class A { public static A a; private A () {} public static A getInstance() { if ( a == null ) { a = new A(); } return a; } } I'm arguing there is a major flaw in the implementation of getInstance() method, most of the old authors have simply translated all pattern implementation into Java from C++, remember Java Class-loaders work differently from C++. The above class is never loaded until we call A.getInstance() once, so what is the point of writing that thread safe, or validation code its all waste and we are simply introducing rubbish, simple implement Singleton pattern this way public class A { public static A a = new A(); private A () {} public static A getInstance() { return a; } }

Does IE6 has any benefits?

I don't like Microsoft like any other open source lover. Though my question is on greatest nightmare IE6, does it have any benefits? I was lucky enough to think one IE6 creates more jobs (i.e UI developer & QA). hahhahah...... Please comment if you know any other IE6 benefit so i can update this post.