quarta-feira, 17 de junho de 2015

Liferay - jBoss Web Console url and Management Realm user

It's possible to do all of the configurations you need in jBoss through the XML, and other, configuration files. But you have a cleaner way to do it - jBoss Web Console.

First things first, what is the Web Console Url?

It depends on your standalone.conf file ( it's localized in your jBoss directory in the \standalone\configuration path ). Open the file and check for the same line that is highlighted in the next figure:




Mine is at the port 9990. Open a new tab with the url localhost:port.

Now one of two things may happen:

1. You have already a user to access the management console.
2. You don't have any user configured yet.

If your at point 2, keep reading.




As explained in the Welcome page, open a command line and access the bin folder in your jboss directory. Run the add-user.bat file.

Now choose the first option Management User as you want a user to access the management web console.
 



For the realm you can keep ManagementRealm or set a new one.
Set the user and password.

Now you've a management user!



 When you access the Web Console url again you'll be asked to authenticate. Do it so




In the console you can do many things, like:

- Check datasources
- Change  environment properties
- Manage applications

And that's it!

jBoss/Liferay - Manual undeploy an application

If you're using your Liferay instance with a jBoss instance as the application server, it's possible to make a manual undeploy if needed.

To do so, follow the next steps:

1. Access [jBoss installation folder] \standalone\deployments.
2. Search for the YourApplicationName.war.dodeploy file.
3. Rename the file to YourApplicationName.war.undeploy or delete it so that the application is unninstalled from the server.

And that's it!


Liferay - Change Site Name

If you ever wanted to change your Site Name but the changes are not applied, don't worry! I've got the solution.

And it's a very simple one. Follow these steps:

1. Access the liferay database ( if you don't know the name of it you can edit the standalone.conf file and check in the datasource section ).

2. Find the table Account_.

3. Edit the Name column and set the desired name.

And that's all!

quarta-feira, 20 de maio de 2015

Liferay - Application WAR is blacklisted

Sometimes when you deploy an application WAR file into your jBoss Server, it can get blacklisted. The reasons for this can be many, like:

1. You've copied the file into the deploy folder but it took to long to paste all the archive before de deploy process started. If you repeat this again and again the your application will get blacklisted.

2. Your WAR application archive is corrupted. Make sure you can open it. If you don't then your file is corrupted and jboss will not be able to deploy it.

To solve this just restart the server and try to deploy it again.

sexta-feira, 15 de maio de 2015

Liferay - Can't import LDAP users because of special characters

If you use the default LDAP configuration for Liferay 6.2, then you're in for a problem when it starts to import the users.

It is usual for the users in a LDAP server to have all sort of characters but the default configuration of Liferay doesn't allow all of them.

To get this fixed you'll have to add this property to your liferay configuration:

users.screen.name.validator = com.liferay.portal.security.auth.LiberalScreenNameValidator 


Then restart your server.

quinta-feira, 14 de maio de 2015

Liferay - Not updating dependencies or resources

When you've deployed a new version of your application in a jboss server, its possible that, sometimes, you have a problem with non updated dependencies or javascript/stylesheets resources.

This happens because the jboss server saves the data from the previous installed version of your application. 

To solve this stop the server, access the standalone/temp folder and delete the folders: auth, vfs, work.

Then start the server.

terça-feira, 5 de maio de 2015

Liferay - How to change your application server encoding?


 If you ever have any kind of problems regarding encoding in your application, it can well be a problem in the configuration of your application server.

If you're using jBoss, then follow the next steps:

 1. Open your ide and click two times in the server instance in the Servers tab.


2. Open Launch Configuration

 



3. Choose Common tab and there you'll have an Encoding area. Choose the type of encoding you need. Save it et voilá!


segunda-feira, 4 de maio de 2015

Liferay - Home Page, Landing Page and Logout Page.

When you're developing a project to a client, it can be required that you define the first page as the login page of your application. To do so, edit the portal.ext.properties file and add the next lines: 
#*******DEFAULT LANDING PAGE*******#
default.landing.page.path=path
default.logout.page.path=path

#******HOME PAGE*******#
company.default.home.url=path

The default.landing.page.path is the page where you'll be redirected after you've logged in into liferay.
The default.logout.page.path is the page where you'll be redirected after you've logged out off liferay or your application.
The company.default.home.url is the page where you'll be redirected after you access your base hostname, like localhost:8080.

Restart your application server so your changes take effect.

quarta-feira, 8 de abril de 2015

Liferay - Create endpoints in jBoss 7.1.1

Just like a properties file, the advantage of using JNDI in an application server is evident. You can define your application to read certain bindings only by name. If you ever have to change the application server, you'll only have to define the same bindings again - no application changes will be needed.

In jBoss 7.1.1 it's pretty straight forward to create bindings.

Acess your standalone configuration file (standalone.xml) and look for the

        <subsystem xmlns="urn:jboss:domain:naming:1.1">


tag.

There you'll define two differente tags:

- a Simple tag, where you define you property as key/value
- a Lookup tag, that will be used to map your property to a more user-friendly name. That name will be exposed in the JNDI context and accessible in your java classes.

Here is an example:
        
<subsystem xmlns="urn:jboss:domain:naming:1.1">
 <bindings>
  <simple name="java:jboss/applicationmode" type="java.lang.String" value="DEMO"></simple>
  <lookup name="property/applicationmode" lookup="java:jboss/applicationmode"/> 
 </bindings>
</subsystem>

And then, in your java class, instatiate InitialContext and get the property by its exposed name:

InitialContext ctx = new InitialContext();

String applicationEnv = (String) ctx.lookup("property/applicationenvironment");

quinta-feira, 26 de fevereiro de 2015

Can't see portlet hook changes

When you create a Hook liferay plugin and deploy it to you application server, you will not see the changes right away.

What to do?

Restart the application server.

Can't log in on liferay (jBoss)

If you can't log in on liferay there's something really quick you can do to solve your problem. Delete the file:
portal-setup-wizard.properties
from your liferay home directory. Deleting this file will ensure that Liferay will present the wizard setup again when you restart the application server.

 NOTE: If you don't where it is your liferay home, check the portal-ext.properties file and property liferay.home. If you still can't get it, look for the Deploy folder, which is in the same location of the properties file.

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.