terça-feira, 20 de janeiro de 2015

Failed to load or instantiate TagExtraInfo class: com.ibm.ws.portletcontainer.tags.DefineObjectsTag

Failed to load or instantiate TagExtraInfo class: com.ibm.ws.portletcontainer.tags.DefineObjectsTag

Migrating a portlet application from Websphere Portal to Liferay can bring some problems. One of the problems that i faced has to do with the taglibs used in JSP. 
To be able to use the tag




you have to set the include for the portlet taglib, like this:
<%@taglib uri="http://java.sun.com/portlet" prefix="portlet" %>



In Websphere that taglib location is in the class:
com.ibm.ws.portletcontainer.tags



If you try to run the application, you'll have the error:
 Failed to load or instantiate TagExtraInfo class: com.ibm.ws.portletcontainer.tags.DefineObjectsTag

because Liferay can't find that class. 

How to fix it?

Edit the applications web.xml file, and add

http://java.sun.com/portlet_2_0
/WEB-INF/tld/liferay-portlet.tld



 
Note that you have to have the tld file in the location you provide.
And that's it.

quinta-feira, 15 de janeiro de 2015

Liferay - How to fix the Not updating theme because version 6.2.1 is newer than version 6.2.0.1 error

Not updating theme because version 6.2.1 is newer than version 6.2.0.1

When you're developing a Theme plugin, sometimes your changes won't reflect in the browser. Maybe is cache, maybe not. When cache is not the root of your problems, you may be facing the next error:

"Not updating theme because version 6.2.1 is newer than version 6.2.0.1."

As the message states it happens because the application version installed is newer than the one you're trying to install.

And when do this happen? It took me sometime to get this but think i got it:

1. Create a Theme Plugin with SDK and ready to run in Liferay version 6.2.1.
2. Generate the Theme WAR and install it in a Liferay version 6.1.1.
3. Create a Theme Plugin with the same name as 1 and deploy it to Liferay.

How can i solve it?

Delete the theme installed from the WAR.
Create a new theme plugin using the SDK that works with Liferay version 6.1.1 and deploy.

Et voilá, you'll never have the same problem again. 

Don't forget to change the compatibility attribute in the liferay-look-and-feel.xml file. Set it accordingly to your liferay version.

quarta-feira, 14 de janeiro de 2015

Liferay - How to fix the You do not have the roles required to access this portlet message

How to fix the You do not have the roles required to access this portlet message

There will be times where you want to configure the visualization permissions for a portlet.

To do so, you authenticate yourself and access the Configuration area in right top corner of the portlet.


This is the list of edit options of the portlet.


There you'll want to remove the View choice from the Guest role.

This is the portlet permissions listed by role.


You save and think: "Done!"

But it isn't.

When you access the page with the portlet you have just configured, you'll see this warning:

This image shows the message You do not have the roles required to access this portlet.


To remove this warning, you must access the portal-ext.properties

and add (or edit) the next line:


layout.show.portlet.access.denied=false

Restart the server and you're done!

Liferay - How to Get User Data

How to Get User Data

To access authenticated user data you can use the ThemeDisplay class.

All you have to do is instantiate the class like this:


ThemeDisplay themeDisplay = (ThemeDisplay)renderRequest .getAttribute(WebKeys.THEME_DISPLAY);


With the ThemeDisplay object you can then get an instance of the User class:

User user = themeDisplay.getUser();


Now you can access all of these User attributes:

//     uuid
//     userId
//     companyId
//     createDate
//     modifiedDate
//     defaultUser
//     contactId
//     password
//     passwordEncrypted
//     passwordReset
//     passwordModifiedDate
//     digest
//     reminderQueryQuestion
//     reminderQueryAnswer
//     graceLoginCount
//     screenName
//     emailAddress
//     facebookId
//     ldapServerId
//     openId
//     portraitId
//     languageId
//     timeZoneId
//     greeting
//     comments
//     firstName
//     middleName
//     lastName
//     jobTitle
//     loginDate
//     loginIP
//     lastLoginDate
//     lastLoginIP
//     lastFailedLoginDate
//     failedLoginAttempts
//     lockout
//     lockoutDate
//     agreedToTermsOfUse
//     emailAddressVerified
//     status


Have fun!

Liferay - Portal Developer Properties

While developing applications in Liferay, be it a Hook, a Theme or a Portlet, you can activate the portal developer mode to ease your task.

If you're using Tomcat you should edit the setenv file (setenv.sh in Linux or setenv.bat in Window).

Look for the CATALINA_OPTS line and add this option to JVM:

-Dexternal-properties=portal-developer.properties


Then you should edit the portal-developer.properties

(located at Tomcat/webapps/ROOT/WEB-INF/classes) 

In this file you have a lot of properties that you change but i use it mainly for this three:

theme.css.fast.load
theme.images.fast.load
javascript.fast.load

You can set cache off for css,images and javascript by simply set this properties to false. This is great if your testing updates in JSP, CSS or Javascript and want to see the changes right away.

Restart your application server.


Welcome

Web developers know they can rely on Google when they're at a dead end. You know, with only a simple search, you will eventually find a solution in the form of a life saver as Stack Overflow and Code Ranch. 
Liferay Central will agroup some of the most common, and not so common, solutions for many JAVA and CMS related problems, mostly Liferay.
You're welcome to come and stay!

Liferay IDE - How to fix the Ide could not find portal root error

How to fix the Ide could not find portal root error

When you create a liferay plugin with maven build, in the Hook Plugin wizard trying to Add JSP will show a error message:

"ide could not find portal root"

This is because using Maven, instead of Ant, the build will not use the build.username.properties and therefore it will not read the app.server.tomcat.portal.dir attribute with the portal root directory.

How can i fix it?

 To fix this you need to edit the project pom.xml and set the appServerPortalDir attribute value to the portal root directory. For example: C:\cms\liferay\tomcat-7.0.42\webapps\ROOT

sexta-feira, 9 de janeiro de 2015

How to fix the PermGen Out of Memory Error

How to fix the PermGen Out of Memory Error

The PermGen Out of Memory Error is a very common memory leak error in any application running in an JVM instance.

First of all, what is the PermGen in a JVM?

PermGen stands for permanent generation and it is the memory area used for storing class and method objects. By default most application as a low value configured for the maximum permGen space size, as low as 256m.

Sometimes, when a large number of classes are loaded you’ll have a PermGen Out of Memory error, making the application becoming slower to respond till it does not responds at all.

How can i fix it?

Luckily this one is easy to solve. Access the launch configuration of your application server and look for the VM arguments. You’ll find a parameter that defines the maximum size for PermGen:

-Xmx1024m -XX:MaxPermSize=256m

Change it to:

-Xmx1024m -XX:MaxPermSize=512m

Save and restart the server.