Fórum

Getting exception when i am clicking on save button of create account page

thumbnail
Rajeev Kumar, modificado 8 Anos atrás.

Getting exception when i am clicking on save button of create account page

Junior Member Postagens: 25 Data de Entrada: 15/05/14 Postagens Recentes
Hi Team,
I am getting below exception when i am clicking on save button of create account page. please any one help me for this problem. also i sharing simple code below.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.struts.BaseStrutsPortletAction;
import com.liferay.portal.kernel.struts.StrutsPortletAction;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.Address;
import com.liferay.portal.model.Contact;
import com.liferay.portal.model.EmailAddress;
import com.liferay.portal.model.Phone;
import com.liferay.portal.model.User;
import com.liferay.portal.service.AddressLocalServiceUtil;
import com.liferay.portal.service.PhoneLocalServiceUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.service.ServiceContextFactory;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.portlet.usersadmin.util.UsersAdminUtil;


import java.util.Date;
import java.util.List;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

public class CustomCreateAccountAction extends BaseStrutsPortletAction {

public CustomCreateAccountAction() {

}

@Override
public void processAction(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {

System.out.println("Process Action" + originalStrutsPortletAction);
String screenName = ParamUtil.getString(actionRequest, "screenName");
String firstName = ParamUtil.getString(actionRequest, "firstName");
String lastName = ParamUtil.getString(actionRequest, "lastName");
String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
String emailAddress = ParamUtil
.getString(actionRequest, "emailAddress");
long userId = CounterLocalServiceUtil.increment(User.class.getName());
User user = UserLocalServiceUtil.createUser(userId);
user.setFirstName(firstName);
user.setLastName(lastName);
user.setEmailAddress(emailAddress);
user.setScreenName(screenName);
user.setJobTitle(jobTitle);
user = UserLocalServiceUtil.addUser(user);

System.out.println("Hi This Is Current User" + " " + user);

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

ServiceContext serviceContext = ServiceContextFactory.getInstance(
User.class.getName(), actionRequest);
boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
int birthdayMonth = ParamUtil
.getInteger(actionRequest, "birthdayMonth");
int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
List<Address> addresses = UsersAdminUtil.getAddresses(actionRequest);
List<EmailAddress> emailAddresses = UsersAdminUtil
.getEmailAddresses(actionRequest);
List<Phone> phones = UsersAdminUtil.getPhones(actionRequest);
String street1 = ParamUtil.getString(actionRequest, "Street1");
String street2 = ParamUtil.getString(actionRequest, "Street2");
String street3 = ParamUtil.getString(actionRequest, "Street3");
String zip = ParamUtil.getString(actionRequest, "PostalCode");
String city = ParamUtil.getString(actionRequest, "City");

long addressId = CounterLocalServiceUtil.increment(Address.class
.getName());

Address address = AddressLocalServiceUtil.createAddress(addressId);
address.setCompanyId(themeDisplay.getCompanyId());
address.setUserId(themeDisplay.getUserId());
address.setClassName(Contact.class.getName());
address.setClassPK(user.getContactId());
address.setPrimary(true);
address.setMailing(false);
address.setCreateDate(new Date());
address.setModifiedDate(new Date());
address.setStreet1(street1);
address.setStreet2(street2);
address.setStreet3(street3);
address.setZip(zip);
address.setCity(city);
AddressLocalServiceUtil.addAddress(address);
System.out.println("Hi this is Current Address" + " " + address);

String contactNumber = ParamUtil.getString(actionRequest,
"contactnumber");

long phone_id = CounterLocalServiceUtil
.increment(Phone.class.getName());

Phone phone = PhoneLocalServiceUtil.createPhone(phone_id);
phone.setCompanyId(user.getCompanyId());
phone.setClassName(Contact.class.getName());
phone.setClassPK(user.getContactId());
phone.setNumber(contactNumber);
phone = PhoneLocalServiceUtil.addPhone(phone);

String restaurantName = ParamUtil.getString(actionRequest,
"restaurant_name");
String franchiseName = ParamUtil.getString(actionRequest,
"franchise_name");
int restaurantNumber = ParamUtil.getInteger(actionRequest,
"restaurant_number");
String locationOfTheRestaurant = ParamUtil.getString(actionRequest,
"location_of_the_restaurant");
String organization = ParamUtil
.getString(actionRequest, "organization");
String role = ParamUtil.getString(actionRequest, "role");
String market = ParamUtil.getString(actionRequest, "market");



originalStrutsPortletAction.processAction(portletConfig, actionRequest,
actionResponse);
}

@Override
public String render(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig,

RenderRequest renderRequest, RenderResponse renderResponse)

throws Exception {

System.out
.println("inside the render action while creating the account");

String ret = originalStrutsPortletAction.render(null, portletConfig,
renderRequest, renderResponse);

renderRequest.setAttribute(WebKeys.PORTLET_DECORATE, Boolean.TRUE);

return ret;

}

}


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
... 157 more
Caused by: java.sql.BatchUpdateException: Duplicate entry '0' for key 'IX_5ADBE171'
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2054)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1135)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 165 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '0' for key 'IX_5ADBE171'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1040)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2794)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2006)
... 169 more
09:43:37,349 ERROR [http-bio-8080-exec-3][render_portlet_jsp:132] null
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '0' for key 'IX_5ADBE171'
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1040)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2794)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2006)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1135)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
inside the render action while creating the account
Process Actioncom.liferay.portal.struts.StrutsPortletActionAdapter@58c15c14
09:49:51,374 ERROR [http-bio-8080-exec-5][JDBCExceptionReporter:82] Duplicate entry '0' for key 'IX_5ADBE171'
09:49:51,523 ERROR [http-bio-8080-exec-5][DefaultTransactionExecutor:93] Application exception overridden by commit exception
org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; SQL [insert into User_ (uuid_, 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, userId) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:637)
at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:793)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:664)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.processCommit(DefaultTransactionExecutor.java:82)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:70)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
at $Proxy103.addUser(Unknown Source)
at com.liferay.portal.service.UserLocalServiceUtil.addUser(UserLocalServiceUtil.java:54)
at com.abc.org.CustomCreateAccountAction.processAction(CustomCreateAccountAction.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:67)
at $Proxy537.processAction(Unknown Source)
at com.liferay.portal.struts.PortletActionAdapter.processAction(PortletActionAdapter.java:55)
at com.liferay.portal.struts.PortletRequestProcessor.process(PortletRequestProcessor.java:166)
at com.liferay.portlet.StrutsPortlet.processAction(StrutsPortlet.java:216)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:71)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:597)
at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:628)
at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:308)
at com.liferay.portlet.PortletContainerImpl._doProcessAction(PortletContainerImpl.java:402)
at com.liferay.portlet.PortletContainerImpl.processAction(PortletContainerImpl.java:110)
at com.liferay.portlet.SecurityPortletContainerWrapper.processAction(SecurityPortletContainerWrapper.java:109)
at com.liferay.portlet.RestrictPortletContainerWrapper.processAction(RestrictPortletContainerWrapper.java:75)
at com.liferay.portal.kernel.portlet.PortletContainerUtil.processAction(PortletContainerUtil.java:115)
at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:378)
at com.liferay.portal.action.LayoutAction.doExecute(LayoutAction.java:200)
at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:95)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:178)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:549)
at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:526)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:293)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:359)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:293)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:243)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:267)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:226)
at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:185)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:185)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Regards,
Rajeev Kumar
thumbnail
Vishal Kumar, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Regular Member Postagens: 198 Data de Entrada: 12/12/12 Postagens Recentes
Try this one..

long primaryKeyId = CounterLocalServiceUtil.increment(ClassName.class.getName());

XYZDetails XYZDetails = XYZDetailsLocalServiceUtil.createXYZDetails(primaryKeyId);
thumbnail
Rajeev Kumar, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Junior Member Postagens: 25 Data de Entrada: 15/05/14 Postagens Recentes
Hi Vishal,
Thanks for your supports, but still i am getting same exception. Below is my code snippets.

public void processAction(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {


originalStrutsPortletAction.processAction(portletConfig, actionRequest,
actionResponse);

System.out.println("Process Action" + originalStrutsPortletAction);
String screenName = ParamUtil.getString(actionRequest, "screenName");
String firstName = ParamUtil.getString(actionRequest, "firstName");
String lastName = ParamUtil.getString(actionRequest, "lastName");
String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
String emailAddress = ParamUtil
.getString(actionRequest, "emailAddress");


long userId = CounterLocalServiceUtil.increment(User.class.getName());
User user = UserLocalServiceUtil.createUser(userId);

user.setFirstName(firstName);
user.setLastName(lastName);
user.setEmailAddress(emailAddress);
user.setScreenName(screenName);
user.setJobTitle(jobTitle);
user = UserLocalServiceUtil.addUser(user);


System.out.println("Hi This Is Current User" + " " + user);
}
}

Regards,
Rajeev Kumar
thumbnail
Vishal Kumar, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Regular Member Postagens: 198 Data de Entrada: 12/12/12 Postagens Recentes
Hi Rajeev,

Please find the sample code below:


public void newUser(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException, SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
long companyId = themeDisplay.getCompanyId();
long idContact = CounterLocalServiceUtil.increment(Contact.class.getName());
String greeting="Welcome Admin";
long id = CounterLocalServiceUtil.increment(User.class.getName());
user = UserLocalServiceUtil.createUser(id);
user.setCompanyId(companyId);
user.setPassword(password1);
String screenName="admin"+id;
user.setScreenName(screenName);
user.setEmailAddress(emailAddress);
user.setFacebookId(facebookId);
user.setOpenId(openId);
user.setGreeting(greeting);
//user.setFirstName(firstName);
user.setFirstName("Site Admin");
//user.setLastName(lastName);
user.setJobTitle(jobTitle);
user.setCreateDate(new Date ());
user.setContactId(idContact);
user.setPasswordReset(true);
user.setPasswordEncrypted(false);
user.setPasswordModifiedDate(new Date());
user.setCreateDate(new Date());
user.setModifiedDate(new Date());
user.setLanguageId(themeDisplay.getLanguageId());
user.setTimeZoneId(themeDisplay.getTimeZone().getDisplayName());
UserLocalServiceUtil.addUser(user);

/
//Insert Contact for a user
//long idContact = CounterLocalServiceUtil.increment(Contact.class.getName());
Contact contact = ContactLocalServiceUtil.createContact(idContact);
contact.setCompanyId(companyId);
contact.setCreateDate(new Date());
contact.setUserName(screenName);
contact.setUserId(user.getUserId());
contact.setModifiedDate(new Date());
contact.setFirstName("contact-"+contact.getContactId());
contact.setLastName("contact-"+contact.getContactId());
contact.setMiddleName("contact-"+contact.getContactId());
contact.setPrefixId(prefixId);
contact.setSuffixId(suffixId);
contact.setJobTitle(jobTitle+contact.getContactId());
contact.setBirthday(new Date());
ContactLocalServiceUtil.addContact(contact);

}
thumbnail
Vishal Kumar, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Regular Member Postagens: 198 Data de Entrada: 12/12/12 Postagens Recentes
Are you using struts portlet?
thumbnail
Rajeev Kumar, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Junior Member Postagens: 25 Data de Entrada: 15/05/14 Postagens Recentes
Yes Vishal , I am useing struts portlet hooks.
Thanks a lot vishal for your help.

Regards,
Rajeev Kumar
thumbnail
Vishal Kumar, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Regular Member Postagens: 198 Data de Entrada: 12/12/12 Postagens Recentes
user = UserLocalServiceUtil.addUser(user);

Change this to UserLocalServiceUtil.updateUser(user) and give a try.
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Rajeev Kumar:
Hi Vishal,
Thanks for your supports, but still i am getting same exception. Below is my code snippets.

public void processAction(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {


originalStrutsPortletAction.processAction(portletConfig, actionRequest,
actionResponse);


Is the original struts portlet action per chance the existing Liferay create account action?

Your exception is on a duplicate column value, probably an email address or screen name, likely caused by invoking the original create account action (which still creates the account, btw) followed by your subsequent UserLocalServiceUtil.addUser() method to add the same user again.
thumbnail
Rajeev Kumar, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Junior Member Postagens: 25 Data de Entrada: 15/05/14 Postagens Recentes
Hi David,
Thanks for your guidelines, but could you please provide me solid solutions for this requirement because i am doing hit and trial and not achieving the requirement.

Regards,
Rajeev Kumar
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
What requirement? There was no discussion about the requirement or what exactly you're trying to do.

The only thing I can gleem is that you have to do something special when you create an account and have created a JSP hook and struts action hook to override what the login portlet normally does when creating users.

However you inappropriately called the login portlet's struts action which creates the user. Then your code gets invoked which tries to add the user again using the same keys and fails.

You have two choices:

1. keep the call to the original in place and change your code to fetch the new user, make changes, then update the user.
2. drop the call to the original and implement all of the code to add the new user yourself.

But you cannot continue with the mix you have now.
thumbnail
Dominique Ebert, modificado 8 Anos atrás.

RE: Getting exception when i am clicking on save button of create account

Junior Member Postagens: 29 Data de Entrada: 01/02/13 Postagens Recentes
Hi Rajeev,

your getting an duplicate entry exception (constraint violation) right here:

Caused by: java.sql.BatchUpdateException: Duplicate entry '0' for key 'IX_5ADBE171'

So you could maybe check out what columns are affected by the IX_5ADBE171 constraint and then evaluate where and why your code tries to insert a 0 into that particular column.

And also consider what David suggested, maybe you are trying to insert a user twice, by firing the original struts action.

regards