Foren

Facing a problem with findByXXX() methods in liferay plugins

thumbnail
guru murthy, geändert vor 12 Jahren.

Facing a problem with findByXXX() methods in liferay plugins

Regular Member Beiträge: 208 Beitrittsdatum: 12.08.11 Neueste Beiträge
Hi All ,

Right now I am working with liferay V5.1.2 . The database is MySQL , OS is ubuntu .

I am able to create a finder methods using service builder ( service.xml ) in plugins portlets but when i use those finder methods in JSP's like [Entity]Util.findByXXX(value) then i get the below exception .

javax.servlet.ServletException: com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: FROM package.Entity WHERE groupId = ?


I get the above only when i use finder methods . If anybody know the answer for this please share it .

Not only for finder methods , it's showing error for countXXX() methods also.
Caught unexpected exception java.lang.IllegalArgumentException
com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: SELECT COUNT(*) FROM package.Entity WHERE Name = ?


Thanks in advance .
G.Gurumurthy
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Liferay Legend Beiträge: 14915 Beitrittsdatum: 02.09.06 Neueste Beiträge
It means you're not passing the argument to the finder to call it correctly (or possibly passing a null).

Try passing real arguments to the finder methods.
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
As David said, you're probably not passing the right parameters. If you need further assistance, you'll probably have to paste your code so we'll be able to look at it.
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Liferay Legend Beiträge: 14915 Beitrittsdatum: 02.09.06 Neueste Beiträge
Jeez, Hitoshi, how can I ever catch up to your post count if you keep replying to my posts emoticon
thumbnail
guru murthy, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member Beiträge: 208 Beitrittsdatum: 12.08.11 Neueste Beiträge
Hi ,

As you said , I am sending the code related to my work , please go through it .
This is my service.xml in plugins V5.1.2

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 5.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_5_1_0.dtd">

<service-builder package-path="com.roles" >

<namespace>Group</namespace>

<entity name="Roles" local-service="true" remote-service="false" >
<!-- PK fields -->
<column name="roleId" type="Integer" primary="true" id-type="increment" />

<!-- Normal columns -->
<column name="Name" type="String" />
<column name="ParentRoleId" type="Integer" />
<column name="groupId" type="Long" />
<column name="RoleType" type="Integer" />
<column name="Description" type="String" />

<finder name="RoleName" return-type="Roles">
<finder-column name="Name" />
</finder>
<finder name="Group" return-type="Collection">
<finder-column name="groupId" />
</finder>
<finder return-type="Collection" name="ParentRoleId">
<finder-column name="ParentRoleId" />
</finder>

</entity>

<entity name="Roles_Types" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="Id" type="Integer" primary="true" id-type="increment"/>
<!-- Normal columns -->
<column name="RoleType" type="String"/>
<column name="Description" type="String" />
</entity>

<entity name="Roles_Staff" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="Id" type="Integer" primary="true" id-type="increment"/>
<!-- Normal columns -->
<column name="RoleId" type="Integer"/>
<column name="UserId" type="String" />
</entity>

<entity name="Roles_Semester" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="Id" type="Integer" primary="true" id-type="increment"/>
<!-- Normal columns -->
<column name="RoleId" type="Integer"/>
<column name="SemesterId" type="Integer" />
</entity>

</service-builder>


after this I wrote some code in the JSP just like below


<%
ThemeDisplay themeDispaly=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDispaly.getLayout().getGroup();
Long groupId = group.getGroupId();

RolesUtil.findByGroup(groupId);
%>


This is what i did in my JSP but it showing the below problem when i hit the JSP.


Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/roles/UpdateRole.jsp at line 79

76: <option value="-1"> &lt;-- select --&gt; </option>
77: <%
78: List<Roles> roles1=null;
79: roles1=RolesUtil.findByGroup(groupId);
80: for(Roles objRoles:roles1){
81: %>
82: <option value="<%=objRoles.getPrimaryKey()%> "><b><%=objRoles.getName() %></b></option>


Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:535)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:472)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
at org.apache.jsp.jsp.roles.rolesView_jsp._jspService(rolesView_jsp.java:403)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
... 144 more
Caused by: javax.servlet.ServletException: com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: FROM com.roles.model.Roles WHERE groupId = ?
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
at org.apache.jsp.jsp.roles.UpdateRole_jsp._jspService(UpdateRole_jsp.java:1065)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
... 157 more
Caused by: com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: FROM com.roles.model.Roles WHERE groupId = ?
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.processException(BasePersistenceImpl.java:78)
at com.roles.service.persistence.RolesPersistenceImpl.findByGroup(RolesPersistenceImpl.java:391)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy549.findByGroup(Unknown Source)
at com.roles.service.persistence.RolesUtil.findByGroup(RolesUtil.java:88)
at org.apache.jsp.jsp.roles.UpdateRole_jsp._jspService(UpdateRole_jsp.java:563)
... 160 more
Caused by: java.lang.IllegalArgumentException: No positional parameters in query: FROM com.roles.model.Roles WHERE groupId = ?
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:332)
at org.hibernate.impl.AbstractQueryImpl.setLong(AbstractQueryImpl.java:489)
at com.liferay.portal.dao.orm.hibernate.QueryImpl.setLong(QueryImpl.java:115)
at com.liferay.portal.kernel.dao.orm.QueryPos.add(QueryPos.java:96)
at com.roles.service.persistence.RolesPersistenceImpl.findByGroup(RolesPersistenceImpl.java:379)
... 175 more

thumbnail
Raja Nagendra Kumar, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Expert Beiträge: 484 Beitrittsdatum: 02.03.06 Neueste Beiträge
Are u calling the method with null values.. or check if the DB schema is intact or got changed later to Service Creation..
thumbnail
guru murthy, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member Beiträge: 208 Beitrittsdatum: 12.08.11 Neueste Beiträge
Hi Raja ,

I am getting organization / community id through themeDisplay in My JSP , so it won't be null . I passed that groupId to finder method .

Regards ...
G.Gurumurthy
thumbnail
Ketan Savaliya, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member Beiträge: 117 Beitrittsdatum: 03.03.11 Neueste Beiträge

hi,

your code,
<%
ThemeDisplay themeDispaly=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDispaly.getLayout().getGroup();
Long groupId = group.getGroupId();

RolesUtil.findByGroup(groupId);
%>



insted of passing this way of group id, pass themeDisplay.getScopeGroupId();

hope so it will help you,

Thankx & Regards
Ketan savaliya
thumbnail
guru murthy, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member Beiträge: 208 Beitrittsdatum: 12.08.11 Neueste Beiträge
Hi Ketan ,

can you tell me the difference between group.getGroupId() and themeDisplay.getScopeGroupId()
thumbnail
guru murthy, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member Beiträge: 208 Beitrittsdatum: 12.08.11 Neueste Beiträge
Ketan Savaliya:

hi,

your code,
<%
ThemeDisplay themeDispaly=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDispaly.getLayout().getGroup();
Long groupId = group.getGroupId();

RolesUtil.findByGroup(groupId);
%>



insted of passing this way of group id, pass themeDisplay.getScopeGroupId();

hope so it will help you,

Thankx & Regards
Ketan savaliya



Hi Ketan ,

I got the goup id also when i call Long groupId = group.getGroupId(); , so there is no problem with it .
thumbnail
guru murthy, geändert vor 12 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member Beiträge: 208 Beitrittsdatum: 12.08.11 Neueste Beiträge
Hi All ,

Still I have a problem with service builder tool in plugins V5.1.2 . I am showing the main exceptions which are came early .

1) As per findByGroupId(groupId) , the following error occurred .

javax.servlet.ServletException: com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: FROM com.roles.model.Roles WHERE GroupId = ?


2) As per countByName(name) also same issue

Caught unexpected exception java.lang.IllegalArgumentException
com.liferay.portal.SystemException: java.lang.IllegalArgumentException: No positional parameters in query: SELECT COUNT(*) FROM com.roles.model.Roles WHERE Name = ?


3) next one is creating a object to [Entity]Impl class and calling the setXXX() methods of [Entity]Impl object . after that I called add[Entity]() method to store details in Database but i got below issue.

Caught ORMException
com.liferay.portal.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: Unknown entity: com.roles.model.impl.[Entity]Impl


By looking those issues , i thought there is a service builder tool problem in liferay plugins (version : 5.1.2 ) with the combination of MySQL 5.1.49 , Ubuntu 10.10 - the Maverick Meerkat, Tomcat 6.0 . If not , Let me know how to resolve these issues .

Thanks in advance ...
G.Gurumurthy ,
Ryan Griffith, geändert vor 11 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

New Member Beiträge: 4 Beitrittsdatum: 22.02.12 Neueste Beiträge
This has been dead for awhile, but did you ever get this figured out? I'm running into the same issue with v5.2.
thumbnail
Gurumurthy Godlaveeti, geändert vor 11 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

Regular Member Beiträge: 208 Beitrittsdatum: 12.08.11 Neueste Beiträge
HI Ryan ,

I had a problem with this scenario when I worked . Actually I used Wrapper classes in service.xml file so it is generated service layer classes and [Entity]Util.java have findByXXX() methods . you can observe the parameters data type of each findByXXX() method . All findByXXX() methods parameters data type are primitive data type only .

findByXXX(int primaryId);


But for all findByXXX() methods , i passed Wrapper class objects as parameters so i got ORMException and some other . I resolved those by passing primitive data types to findByXXX() or countByXXX() methods . After i did this changes , there was no issue again .

So did you do the same mistake , if so then make the changes and finish it . if it is not the issue then please provide all information regarding bug .

Thanks ,
G.Gurumurthy .
Ryan Griffith, geändert vor 11 Jahren.

RE: Facing a problem with findByXXX() methods in liferay plugins

New Member Beiträge: 4 Beitrittsdatum: 22.02.12 Neueste Beiträge
Gurumurthy Godlaveeti:

But for all findByXXX() methods , i passed Wrapper class objects as parameters so i got ORMException and some other . I resolved those by passing primitive data types to findByXXX() or countByXXX() methods . After i did this changes , there was no issue again .


Just making sure I follow you, I should use something like type="boolean" vs type="Boolean" in my services.xml file?