Foros de discusión

Portlet is temporarily unavailable.

Shikhar Saran Srivastava, modificado hace 8 años.

Portlet is temporarily unavailable.

New Member Mensajes: 17 Fecha de incorporación: 20/09/15 Mensajes recientes
I'm using liferay-ce-ga5 and I have made a portlet in a liferay developer studio,in my portlet there is a .jsp file and Registration.java file I'm sending the form values from .jsp file to .java file & when i try to run this portlet this is showing me error Registration is temporarily unavailable.How i fix this error.
My view.jsp file is:

<%
/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>


<portlet:defineobjects />

This is the <b>Registration New</b> portlet.<br>



<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>




<form>
Name: <input type="text" name="LAST_NAMES"><br>
Job: <input type="text" name="JOB_TITLES">
<input type="submit">
</form>




&lt;%@ page import = "com.test.Registration"%&gt;  <!-- //importing java class -->
&lt;% 
Registration hm = new Registration();  /*  creating reference for my java class */
String name = request.getParameter("LAST_NAMES"); 
String job = request.getParameter("JOB_TITLES");
Registration.addUser(name, 5242242, job, 1);   /* calling java method */
%&gt;


And my Registration.java code is:

package com.test;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;

import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;

import com.liferay.portal.model.Contact;
import com.liferay.portal.model.ContactModel;
import com.liferay.portal.model.Country;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.GroupConstants;
import com.liferay.portal.model.GroupModel;
import com.liferay.portal.model.Layout;
import com.liferay.portal.model.LayoutConstants;
import com.liferay.portal.model.LayoutTypePortlet;
import com.liferay.portal.model.Portlet;
import com.liferay.portal.model.PortletConstants;
import com.liferay.portal.model.PortletPreferences;
import com.liferay.portal.model.Region;
import com.liferay.portal.model.User;
import com.liferay.portal.service.AddressLocalServiceUtil;
import com.liferay.portal.service.CountryServiceUtil;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.LayoutLocalServiceUtil;
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
import com.liferay.portal.service.PortletLocalServiceUtil;
import com.liferay.portal.service.RegionServiceUtil;
import com.liferay.portal.service.ResourceLocalServiceUtil;
import com.liferay.portal.service.RoleLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.service.permission.PortletPermissionUtil;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portal.util.PortletKeys;
import com.liferay.portlet.PortletPreferencesFactoryUtil;
import com.liferay.portlet.journal.NoSuchArticleException;
import com.liferay.portlet.journal.model.JournalArticle;

import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil;
import com.liferay.portlet.social.model.SocialRequest;
import com.liferay.portlet.social.model.SocialRequestConstants;
import com.liferay.portlet.social.service.SocialRequestLocalServiceUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;

import java.util.List;




/**
 * Portlet implementation class Registration
 */
public class Registration extends MVCPortlet {

	private static String password;
	private static ContactModel receiverUser;
	private static String name;
	private static String friendlyURL;
	private static boolean privateLayout;
	private static String layoutTemplateId;
	private static String portletId;
	private static Object group;
	private static Object title;
	private static String columnId;
	private static String[] ar;

	// add a new user to the DB, using random fake data,
	// and set up their profile pages, and add
	// them to the right sites, friend a couple of other random users.
	public synchronized static User addUser(String firstName, int companyId,
	                                        String themeId, int profileFlag)
	    throws Exception {

	    String lastName = firstName;
	    String job = themeId;
	    Group guestGroup = GroupLocalServiceUtil.getGroup(
	        companyId, GroupConstants.GUEST);

	    long[] groupIds;
	    try {
	        // see if there's a demo sales group, and add the user to the
	        // group if so
	        Group salesGroup = GroupLocalServiceUtil.getGroup(
	            companyId, "Company A");
	        groupIds = new long[]{guestGroup.getGroupId(),
	            salesGroup.getGroupId()};
	    } catch (Exception ex) {
	        groupIds = new long[]{guestGroup.getGroupId()};
	    }
	    ServiceContext serviceContext = new ServiceContext();

	    long[] roleIds;
	    try {
	        // see if we're using social office, and add SO's role to the new
	        // user if so
	        roleIds = new long[]{RoleLocalServiceUtil.getRole(companyId,
	            "Social Office User").getRoleId()};
	        serviceContext.setScopeGroupId(guestGroup.getGroupId());
	    } catch (Exception ignored) {
	        roleIds = new long[]{};
	    }
	    User user = UserLocalServiceUtil.addUser(UserLocalServiceUtil
	        .getDefaultUserId(companyId), companyId, false,
	        firstName,
	        firstName,
	        false, firstName.toLowerCase(), firstName.toLowerCase() +
	        "@liferay.com", 0, "",
	        LocaleUtil.getDefault(), firstName,
	        "", lastName, 0, 0, true, 8, 15, 1974, job, groupIds,
	        new long[]{}, roleIds, new long[]{},
	        false, serviceContext);

	    assignAddressTo(user);
	    setFirstLogin(firstName, user);
	    assignRandomFriends(user);


	    if (profileFlag==1) {
	        setupUserProfile(companyId, themeId, guestGroup, user);
	    }
	    return user;

	}
	
	
	private static String getRndStr(String LAST_NAMES) {
		return ar[(int) (Math.random() * (double) ar.length)];
	}


	private static void setupUserProfile(long companyId, String themeId,
			Group guestGroup, User user) throws Exception {
		Group group = user.getGroup();
	    if (themeId != null &amp;&amp; !themeId.isEmpty()) {
	        LayoutSetLocalServiceUtil.updateLookAndFeel(
	            group.getGroupId(), false, themeId, "01", "",
	            false);
	    }

	    // Profile layout

	    Layout layout = addLayout(
	        group, user.getFullName(), false, "/profile", "2_columns_ii");
	    JournalArticle cloudArticle, assetListArticle;

	    try {
	        cloudArticle = JournalArticleLocalServiceUtil.getLatestArticle
	            (guestGroup.getGroupId(),
	            SocialDriverConstants.CLOUD_ARTICLE_ID);
	    } catch (NoSuchArticleException ex) {
	        cloudArticle = addArticle("/cloud-structure.xml",
	            "/cloud-template.vm", "cloud-article.xml",
	            UserLocalServiceUtil.getDefaultUserId(companyId),
	            guestGroup.getGroupId(),
	            SocialDriverConstants.CLOUD_ARTICLE_ID);
	    }

	    try {
	        assetListArticle = JournalArticleLocalServiceUtil
	            .getLatestArticle(guestGroup.getGroupId(),
	            SocialDriverConstants.ASSETLIST_ARTICLE_ID);
	    } catch (NoSuchArticleException ex) {
	        assetListArticle = addArticle("/assetlist-structure.xml",
	            "/assetlist-template.vm", "assetlist-article.xml",
	            UserLocalServiceUtil.getDefaultUserId(companyId),
	            guestGroup.getGroupId(),
	            SocialDriverConstants.ASSETLIST_ARTICLE_ID);
	    }
	    try {
	        JournalArticleLocalServiceUtil.getLatestArticle(guestGroup
	            .getGroupId(),
	            SocialDriverConstants.EXPERTSLIST_ARTICLE_ID);
	    } catch (NoSuchArticleException ex) {
	        addArticle("/experts-structure.xml", "/experts-template.vm",
	            "experts-article.xml",
	            UserLocalServiceUtil.getDefaultUserId(companyId),
	            guestGroup.getGroupId(),
	            SocialDriverConstants.EXPERTSLIST_ARTICLE_ID);
	    }

	    addPortletId(layout, "1_WAR_socialnetworkingportlet", "column-1");
	    addPortletId(layout, PortletKeys.REQUESTS, "column-1");
	    String portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT,
	        "column-1");
	    configureJournalContent(
	        layout, guestGroup, portletId, cloudArticle.getArticleId());
	    configurePortletTitle(layout, portletId, "Expertise");
	    addPortletBorder(layout, portletId);

	    addPortletBorder(layout, addPortletId(layout,
	        "2_WAR_socialnetworkingportlet", "column-1"));

	    addPortletBorder(layout, addPortletId(layout, PortletKeys.ACTIVITIES,
	        "column-2"));
	    addPortletBorder(layout, addPortletId(layout,
	        "3_WAR_socialnetworkingportlet", "column-2"));

	    // Expertise layout

	    layout = addLayout(group, "Expertise", false, "/expertise",
	        "2_columns_ii");

	    addPortletId(layout, "1_WAR_socialnetworkingportlet", "column-1");
	    addPortletId(layout, PortletKeys.REQUESTS, "column-1");
	    portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT,
	        "column-1");
	    configureJournalContent(
	        layout, guestGroup, portletId, cloudArticle.getArticleId());
	    configurePortletTitle(layout, portletId, "Expertise");
	    addPortletBorder(layout, portletId);

	    portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT,
	        "column-2");
	    configureJournalContent(
	        layout, guestGroup, portletId, assetListArticle.getArticleId());
	    configurePortletTitle(layout, portletId, user.getFirstName() + "'s " +
	        "Contributions");
	    addPortletBorder(layout, portletId);

	    // Social layout

	    layout = addLayout(group, "Social", false, "/social", "2_columns_ii");

	    addPortletId(layout, "1_WAR_socialnetworkingportlet", "column-1");
	    addPortletId(layout, PortletKeys.REQUESTS, "column-1");
	    addPortletBorder(layout, addPortletId(layout,
	        "2_WAR_socialnetworkingportlet", "column-1"));
	    addPortletBorder(layout, addPortletId(layout, PortletKeys.ACTIVITIES,
	        "column-2"));
	    addPortletBorder(layout, addPortletId(layout,
	        "3_WAR_socialnetworkingportlet", "column-2"));

	    // Blog layout

	    layout = addLayout(group, "Blog", false, "/blog", "2_columns_ii");

	    addPortletBorder(layout, addPortletId(layout,
	        PortletKeys.RECENT_BLOGGERS, "column-1"));
	    addPortletBorder(layout, addPortletId(layout, PortletKeys.BLOGS,
	        "column-2"));

	    // Workspace layout

	    layout = addLayout(
	        group, "Workspace", false, "/workspace", "2_columns_i");

	    addPortletBorder(layout, addPortletId(layout,
	        PortletKeys.RECENT_DOCUMENTS, "column-1"));
	    addPortletBorder(layout, addPortletId(layout,
	        PortletKeys.DOCUMENT_LIBRARY, "column-2"));

	    addPortletId(layout, PortletKeys.CALENDAR, "column-2");
		
	}



	private static JournalArticle addArticle(String string, String string2,
			String string3, long defaultUserId, long groupId,
			String CLOUD_ARTICLE_ID) throws Exception{
		
		return null;
	}


	private static String addPortletId(Layout layout, String string,
			String string2) throws Exception {
		LayoutTypePortlet layoutTypePortlet =
				                           (LayoutTypePortlet)layout.getLayoutType();
				   
				                    portletId = layoutTypePortlet.addPortletId(
				                           0, portletId, columnId, -1, false);
				  
				                   updateLayout(layout);
				  
				                   addResourcePermissions(layout, portletId);
				  
			                   return portletId;
		
		
	}


	private static void addResourcePermissions(Layout layout, String portletId2) throws Exception {
		Portlet portlet = PortletLocalServiceUtil.getPortletById(
                layout.getCompanyId(), portletId);

        PortalUtil.addPortletDefaultResource(
                layout.getCompanyId(), layout, portlet);
		
	}


	private static void updateLayout(Layout layout) throws Exception {
		LayoutLocalServiceUtil.updateLayout(
                layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(),
                layout.getTypeSettings());
		
	}


	public static void addPortletBorder(Layout layout, String portletId2)
		    throws Exception {

		    PortletPreferences portletSetup =
		        (PortletPreferences) PortletPreferencesFactoryUtil.getLayoutPortletSetup(
			    layout, portletId2);

		    ((javax.portlet.PortletPreferences) portletSetup).setValue(
		        "portletSetupShowBorders", String.valueOf(Boolean.TRUE));

		    ((javax.portlet.PortletPreferences) portletSetup).store();
		}



	private static void configurePortletTitle(Layout layout, String portletId2,
			String string) throws Exception {
		 PortletPreferences portletSetup =
			        (PortletPreferences) PortletPreferencesFactoryUtil.getLayoutPortletSetup(
		    layout, portletId);

			    ((javax.portlet.PortletPreferences) portletSetup).setValue("portletSetupUseCustomTitle", String.valueOf(Boolean.TRUE));
			    ((javax.portlet.PortletPreferences) portletSetup).setValue("portletSetupTitle_en_US", (String) title);

			    ((javax.portlet.PortletPreferences) portletSetup).store();
		
	}


	private static void configureJournalContent(Layout layout,
			Group guestGroup, String portletId2, String articleId) throws Exception {
		PortletPreferences portletSetup =
		        (PortletPreferences) PortletPreferencesFactoryUtil.getLayoutPortletSetup(
		    layout, portletId);

		    if (group == null) {
		        ((javax.portlet.PortletPreferences) portletSetup).setValue("groupId", String.valueOf(layout.getGroupId()));
		    } else {
		        ((javax.portlet.PortletPreferences) portletSetup).setValue("groupId", String.valueOf(((GroupModel) group).getGroupId()));
		    }
		    ((javax.portlet.PortletPreferences) portletSetup).setValue("articleId", articleId);

		    ((javax.portlet.PortletPreferences) portletSetup).store();
		
	}


	private static Layout addLayout(Group group, String string, boolean b,
			String string2, String string3) throws Exception {
		
		ServiceContext serviceContext = new ServiceContext();

	    Layout layout = LayoutLocalServiceUtil.addLayout(
	        group.getCreatorUserId(), group.getGroupId(), privateLayout,
	        LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, name, StringPool.BLANK,
	        StringPool.BLANK, LayoutConstants.TYPE_PORTLET, false, friendlyURL,
	        serviceContext);

	    LayoutTypePortlet layoutTypePortlet =
	        (LayoutTypePortlet) layout.getLayoutType();

	    layoutTypePortlet.setLayoutTemplateId(0, layoutTemplateId, false);

	    addResources(layout, PortletKeys.DOCKBAR);

	    return layout;
	}


	private static void addResources(Layout layout, String dockbar) throws Exception {
		String rootPortletId = PortletConstants.getRootPortletId(portletId);

	    String portletPrimaryKey = PortletPermissionUtil.getPrimaryKey(
	        layout.getPlid(), portletId);

	    ResourceLocalServiceUtil.addResources(
	        layout.getCompanyId(), layout.getGroupId(), 0, rootPortletId,
	        portletPrimaryKey, true, true, true);
		
	}


	private static void assignRandomFriends(User user) throws Exception {
		int userCount = UserLocalServiceUtil.getUsersCount();
	    int friendCount = (int) (Math.random() * (double) userCount);
	    for (int i = 0; i &lt; friendCount; i++) {
	        int frienduser = (int) (Math.random() * (double) userCount);
	        User randUser = UserLocalServiceUtil.getUsers(frienduser,
	            frienduser + 1).get(0);
	        if (randUser.getUserId() == user.getUserId()) continue;
	        if (randUser.isDefaultUser()) continue;
	        boolean confirm = (Math.random() &gt; .4);
	        addSocialRequest(user, randUser, confirm);
	    }
		
	}

	private static void addSocialRequest(User user, User randUser,
			boolean confirm) throws Exception {
		SocialRequest socialRequest = SocialRequestLocalServiceUtil.addRequest(
		        user.getUserId(), 0, User.class.getName(), user.getUserId(),
		        1, StringPool.BLANK,
		        receiverUser.getUserId());

		    if (confirm) {
		        SocialRequestLocalServiceUtil.updateRequest(
		            socialRequest.getRequestId(),
		            SocialRequestConstants.STATUS_CONFIRM, new ThemeDisplay());
		    }
		
	}

	private static void setFirstLogin(String firstName, User user) throws Exception {
	    UserLocalServiceUtil.updatePortrait(user.getUserId(),
	            getPortraitBytes());

	        UserLocalServiceUtil.updateLastLogin(
	            user.getUserId(), user.getLoginIP());
	        UserLocalServiceUtil.updateAgreedToTermsOfUse(user.getUserId(), true);
	        UserLocalServiceUtil.updatePassword(user.getUserId(),
	            password.toLowerCase(), password.toLowerCase(),
	            false, true);
	        UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false);


	        String[] questions = StringUtil.split(
	            PropsUtil.get("users.reminder.queries.questions"));

	        String question = questions[0];
	        String answer = "1234";

	        UserLocalServiceUtil.updateReminderQuery(
	            user.getUserId(), question, answer);
}
		
		

	private static byte[] getPortraitBytes() throws Exception {
		
		String id = SocialDriverConstants.GRAVATAR_IDS[(int) (Math.random() *
		        (double) SocialDriverConstants.GRAVATAR_IDS.length)];
		    String urlS = "http://2.gravatar.com/avatar/" + id + "?s=80&amp;d=identicon";
		    URL url = new URL(urlS);
		    ByteArrayOutputStream bos = new ByteArrayOutputStream();
		    InputStream in = url.openStream();
		    byte[] buf = new byte[2048];
		    int bytesRead;
		    while ((bytesRead = in.read(buf)) != -1) {
		        bos.write(buf, 0, bytesRead);
		    }
		    in.close();
		    return bos.toByteArray();
	}

	
	
	@SuppressWarnings("deprecation")
	private static void assignAddressTo(User user) throws SystemException, PortalException {
		    String street = "123 Anystreet";
		    String city = "Doesnt Matter";
		    String zip = "12342";
		    List<country> countrys = CountryServiceUtil.getCountries();
		    Country country = countrys.get((int) (Math.random() * (double)
		        countrys.size()));
		    double rnd = Math.random();
		    if (rnd &lt; .1) {
		        country = CountryServiceUtil.getCountryByName("United States");
		    } else if (rnd &lt; .2) {
		        country = CountryServiceUtil.getCountryByName("Japan");
		    }
		    List<region> regions = RegionServiceUtil.getRegions(country
		        .getCountryId());
		    long regionId = 0;
		    if (regions != null &amp;&amp; !regions.isEmpty()) {
		        regionId = regions.get((int) (Math.random() * (double) regions
		            .size())).getRegionId();
		    }

		    AddressLocalServiceUtil.addAddress(user.getUserId(),
		        Contact.class.getName(), user.getContactId(),
		        street, "", "", city, zip, regionId, country.getCountryId(),
		        11002, true, true);

		
	}
	
	
}
</region></country>
thumbnail
David H Nebinger, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Shikhar Saran Srivastava:
How i fix this error.


Look in the log files, see what the reported exception is and fix it.
Shikhar Saran Srivastava, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

New Member Mensajes: 17 Fecha de incorporación: 20/09/15 Mensajes recientes
I'm getting following error in the log file:

Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /view.jsp at line 38

35: String name = request.getParameter("LAST_NAMES"); 
36: String Job = request.getParameter("JOB_TITLES");
37: Registration hm = new Registration(); 
38: Registration.addUser(name, 5242242, Job, true);   /* calling java method */
39: %&gt;
40:


my Registration class is static so i have call this function in a static way but can;t sove the problem,please tell what to do?
thumbnail
Andrew Jardine, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Best to provide the full stack trace for the error, but if you class is static then you shouldn't be doing a new Registration();
Shikhar Saran Srivastava, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

New Member Mensajes: 17 Fecha de incorporación: 20/09/15 Mensajes recientes
I have tried to remove that instantiation part but it doesn't help.
My addUser function is:

public synchronized static User addUser(String firstName, long companyId,
	                                        String themeId, boolean profileFlag)
	    throws Exception {

	    String lastName = getRndStr(SocialDriverConstants.LAST_NAMES);
	    String job = getRndStr(SocialDriverConstants.JOB_TITLES);
	    Group guestGroup = GroupLocalServiceUtil.getGroup(
	        companyId, GroupConstants.GUEST);

	    long[] groupIds;
	    try {
	        // see if there's a demo sales group, and add the user to the
	        // group if so
	        Group salesGroup = GroupLocalServiceUtil.getGroup(
	            companyId, "Company A");
	        groupIds = new long[]{guestGroup.getGroupId(),
	            salesGroup.getGroupId()};
	    } catch (Exception ex) {
	        groupIds = new long[]{guestGroup.getGroupId()};
	    }
	    ServiceContext serviceContext = new ServiceContext();

	    long[] roleIds;
	    try {
	        // see if we're using social office, and add SO's role to the new
	        // user if so
	        roleIds = new long[]{RoleLocalServiceUtil.getRole(companyId,
	            "Social Office User").getRoleId()};
	        serviceContext.setScopeGroupId(guestGroup.getGroupId());
	    } catch (Exception e) {
	        roleIds = new long[]{};
	    }
	    User user = UserLocalServiceUtil.addUser(UserLocalServiceUtil
	        .getDefaultUserId(companyId), companyId, false,
	        firstName,
	        firstName,
	        false, firstName.toLowerCase(), firstName.toLowerCase() +
	        "@liferay.com", 0, "",
	        LocaleUtil.getDefault(), firstName,
	        "", lastName, 0, 0, true, 8, 15, 1974, job, groupIds,
	        new long[]{}, roleIds, new long[]{},
	        false, serviceContext);

	    assignAddressTo(user);
	    setFirstLogin(firstName, user);
	    assignRandomFriends(user);


	    if (profileFlag) {
	        setupUserProfile(companyId, themeId, guestGroup, user);
	    }
	    return user;

	}
thumbnail
David H Nebinger, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
This doesn't tell you anything about what the problem is.

Was it class not found? Was it no such method? Seriously your problem seems to be a lack of any java knowledge, not lack of Liferay knowledge.

If you know that you have to invoke statically, why are you instantiating an instance on line 37?
Shikhar Saran Srivastava, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

New Member Mensajes: 17 Fecha de incorporación: 20/09/15 Mensajes recientes
I have tried to remove that instantiation part but it doesn't help.
My addUser function is:

	public synchronized static User addUser(String firstName, long companyId,
	                                        String themeId, boolean profileFlag)
	    throws Exception {

	    String lastName = getRndStr(SocialDriverConstants.LAST_NAMES);
	    String job = getRndStr(SocialDriverConstants.JOB_TITLES);
	    Group guestGroup = GroupLocalServiceUtil.getGroup(
	        companyId, GroupConstants.GUEST);

	    long[] groupIds;
	    try {
	        // see if there's a demo sales group, and add the user to the
	        // group if so
	        Group salesGroup = GroupLocalServiceUtil.getGroup(
	            companyId, "Company A");
	        groupIds = new long[]{guestGroup.getGroupId(),
	            salesGroup.getGroupId()};
	    } catch (Exception ex) {
	        groupIds = new long[]{guestGroup.getGroupId()};
	    }
	    ServiceContext serviceContext = new ServiceContext();

	    long[] roleIds;
	    try {
	        // see if we're using social office, and add SO's role to the new
	        // user if so
	        roleIds = new long[]{RoleLocalServiceUtil.getRole(companyId,
	            "Social Office User").getRoleId()};
	        serviceContext.setScopeGroupId(guestGroup.getGroupId());
	    } catch (Exception e) {
	        roleIds = new long[]{};
	    }
	    User user = UserLocalServiceUtil.addUser(UserLocalServiceUtil
	        .getDefaultUserId(companyId), companyId, false,
	        firstName,
	        firstName,
	        false, firstName.toLowerCase(), firstName.toLowerCase() +
	        "@liferay.com", 0, "",
	        LocaleUtil.getDefault(), firstName,
	        "", lastName, 0, 0, true, 8, 15, 1974, job, groupIds,
	        new long[]{}, roleIds, new long[]{},
	        false, serviceContext);

	    assignAddressTo(user);
	    setFirstLogin(firstName, user);
	    assignRandomFriends(user);


	    if (profileFlag) {
	        setupUserProfile(companyId, themeId, guestGroup, user);
	    }
	    return user;

	}
thumbnail
Andrew Jardine, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Ok -- but can you provide the FULL stacktrace? not just the error message but the fukk trace that includes the cause section?
Shikhar Saran Srivastava, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

New Member Mensajes: 17 Fecha de incorporación: 20/09/15 Mensajes recientes
In my log file the stack-trace is:

09:13:16,511 ERROR [RuntimePageImpl-2][PortletServlet:116] javax.portlet.PortletException: org.apache.jasper.JasperException: An exception occurred processing JSP page /view.jsp at line 32

29: &lt;% 
30: String name = request.getParameter("LAST_NAMES"); 
31: String Job = request.getParameter("JOB_TITLES");
32: Registration.addUser(name, 5242242, Job, true);   /* calling java method */
33: %&gt;
34: 


Stacktrace:
javax.portlet.PortletException: org.apache.jasper.JasperException: An exception occurred processing JSP page /view.jsp at line 32

29: &lt;% 
30: String name = request.getParameter("LAST_NAMES"); 
31: String Job = request.getParameter("JOB_TITLES");
32: Registration.addUser(name, 5242242, Job, true);   /* calling java method */
33: %&gt;
34: 


Stacktrace:
	at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:117)
	at com.liferay.util.bridges.mvc.MVCPortlet.include(MVCPortlet.java:362)
	at com.liferay.util.bridges.mvc.MVCPortlet.include(MVCPortlet.java:378)
	at com.liferay.util.bridges.mvc.MVCPortlet.doView(MVCPortlet.java:144)
	at com.liferay.portal.kernel.portlet.LiferayPortlet.doDispatch(LiferayPortlet.java:235)
	at com.liferay.util.bridges.mvc.MVCPortlet.doDispatch(MVCPortlet.java:314)
	at javax.portlet.GenericPortlet.render(GenericPortlet.java:262)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:103)
	at com.liferay.portlet.ScriptDataPortletFilter.doFilter(ScriptDataPortletFilter.java:55)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
	at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
	at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:112)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:604)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:543)
	at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:583)
	at com.liferay.portlet.InvokerPortletImpl.invokeRender(InvokerPortletImpl.java:656)
	at com.liferay.portlet.InvokerPortletImpl.render(InvokerPortletImpl.java:362)
	at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(render_005fportlet_jsp.java:1239)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at com.liferay.portal.servlet.DirectRequestDispatcher.include(DirectRequestDispatcher.java:57)
	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.doDispatch(ClassLoaderRequestDispatcherWrapper.java:78)
	at com.liferay.portal.servlet.ClassLoaderRequestDispatcherWrapper.include(ClassLoaderRequestDispatcherWrapper.java:53)
	at com.liferay.portlet.PortletContainerImpl._doRender(PortletContainerImpl.java:638)
	at com.liferay.portlet.PortletContainerImpl.render(PortletContainerImpl.java:135)
	at com.liferay.portlet.SecurityPortletContainerWrapper.render(SecurityPortletContainerWrapper.java:141)
	at com.liferay.portlet.RestrictPortletContainerWrapper.render(RestrictPortletContainerWrapper.java:126)
	at com.liferay.portal.kernel.portlet.PortletContainerUtil.render(PortletContainerUtil.java:156)
	at com.liferay.portal.layoutconfiguration.util.PortletRenderer._render(PortletRenderer.java:125)
	at com.liferay.portal.layoutconfiguration.util.PortletRenderer.access$4(PortletRenderer.java:107)
	at com.liferay.portal.layoutconfiguration.util.PortletRenderer$PortletRendererCallable.doCall(PortletRenderer.java:180)
	at com.liferay.portal.layoutconfiguration.util.PortletRenderer$PortletRendererCallable.doCall(PortletRenderer.java:1)
	at com.liferay.portal.kernel.executor.CopyThreadLocalCallable.call(CopyThreadLocalCallable.java:69)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:682)
	at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:593)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /view.jsp at line 32

29: &lt;% 
30: String name = request.getParameter("LAST_NAMES"); 
31: String Job = request.getParameter("JOB_TITLES");
32: Registration.addUser(name, 5242242, Job, true);   /* calling java method */
33: %&gt;
34: 


Stacktrace:
	at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:575)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:604)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:543)
	at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:331)
	at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:112)
	... 44 more
Caused by: java.lang.NullPointerException
	at com.test.Registration.getRndStr(Registration.java:132)
	at com.test.Registration.addUser(Registration.java:79)
	at org.apache.jsp.view_jsp._jspService(view_jsp.java:148)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
	... 58 more
09:13:16,514 ERROR [RuntimePageImpl-2][render_portlet_jsp:132] null
java.lang.NullPointerException
	at com.test.Registration.getRndStr(Registration.java:132)
	at com.test.Registration.addUser(Registration.java:79)
	at org.apache.jsp.view_jsp._jspService(view_jsp.java:148)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:604)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:543)
	at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:331)
	at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:112)
thumbnail
Andrew Jardine, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Based on the stacktrace it looks like the actual issue is on line 132 in your Registration class.


at com.test.Registration.getRndStr(Registration.java:132)


Looking at the class you originally posted, that method looks like this (assuming you have not changed it)


  private static String getRndStr(String LAST_NAMES) {
       return ar[(int) (Math.random() * (double) ar.length)];
   }


.. I would assume if this is still the method that ar has a value of null and it is ar.length that is causing the issue. I thought at first that it might be LAST_NAMES that was null (since in the JSP you have a request.getParameter("LAST_NAMES"); but I don't see the paramter actually being used, so I think that just leaves ar.length.
thumbnail
David H Nebinger, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Yeah, ar has to be null.

If it were merely an empty array, then there'd be an array index out of bounds exception.
Shikhar Saran Srivastava, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

New Member Mensajes: 17 Fecha de incorporación: 20/09/15 Mensajes recientes
I have attached my portlet can you please import and check because i have fixed all logs errors but it is giving me so much exceptions.
thumbnail
David H Nebinger, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
A lar file is totally worthless. it contains nothing, no errors, no portlet, nothing.
thumbnail
Andrew Jardine, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
I'm sure what David means is emoticon....

Rather than "exporting the portlet" and sending that to us, can you please provide the WAR file that is being built. If you are using maven then a


mvn clean package 


command will ensure that the latest is bundled up. This will likely be placed in your /target folder. If you are using the SDK (ANT) then running the WAR target will produce the war file and by default places it in the $SDK_HOME/dist directory.
Shikhar Saran Srivastava, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

New Member Mensajes: 17 Fecha de incorporación: 20/09/15 Mensajes recientes
I have attached my portlet can you please import and check because i have fixed all logs errors but it is giving me so much exceptions.
thumbnail
Bijan Vakili, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Expert Mensajes: 375 Fecha de incorporación: 10/03/09 Mensajes recientes
Hello,
As David said, check out the logs. I'll add a few points beside your question:


Read the Portlet Spec or a summary. dev.liferay.com has learning paths for you.
thumbnail
Andrew Jardine, modificado hace 8 años.

RE: Portlet is temporarily unavailable.

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
I would also recommend removing html, head and body tags from your view.jsp. These are already added by your theme (portal_normal.ftl/vm) file.