Expand my Community achievements bar.

SOLVED

Jcr calls seems not working and cannot add nodes to aem using ResourceFactory

Avatar

Level 4

I was trying out tutorial Adobe Experience Manager Help | Persisting Adobe Experience Manager 6.4 JCR data using a Custom Form...

I was able to create the form and submit the data and obtain the same under the post.POST.jsp file but I think the java method addEmployeeData is not working since there are no new employee nodes being added. Is there any way to find whether the java call is working or not?

How can I know whether my instance is trying to add jcr nodes or not?

Is there any log service associated with this bundle and where it is stored. Is there any other way to test and execute the program?

If I want to change the Java code associated with the bundle how can I do that after the bundle is deployed in the server without using maven?

I would urgently require a quick debug for this issue and my java code is exactly same as per the tutorial. I would really appreciate if somebody can help me out with this. Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 4

Actually now I have given the user permission to every node in JCR and it is now working! Thanks a lot for saving my time! Meanwhile I think there are no issues with the jsp file. Also I would suggest to update the article with two things:

1. Permission

Give permission for all the contents of jcr to the created user.

2. Actually it doesn't seem to work when we use the FormContainer that was created as part of the article, since there is no Advanced options available. I suggest using the default Form components in the form container. I have used them inorder to compensate the missing advanced tab in the container. Attaching my screenshot here for community reference.

1690006_pastedImage_0.png

So my suggestion is to use all the default form components instead of using the created form components.

Thanks a lot smacdonald2008​ You are awesome!

View solution in original post

14 Replies

Avatar

Level 10

THis works - as you can see the video at the end of the article. To see if your Java is being invoked - first make sure that the OSGi bundle is in active state.

Also - did you create a system user and perform the SLING MAPPING as discussed in the article? If not - this example will not work.

Also - to change the Java logic - you need to change the code in ECLIPSE and then re-compile the bundle using MAVEN. There is simply no other way to recompile a bundle without using MAVEN (even the Eclipse DEV TOOL uses Maven) .

Avatar

Level 10

YOu can also create a custom log file that is based on Java packages. See this article for more details - Scott's Digital Community: Creating a custom log file for an Adobe Experience Manager project

So you can make a custom log for this project by following the above article. Replace the JAVA packages in this article with the Java packages in your Java program.

Avatar

Level 4

Thanks for your support.

OSGI Bundle is in active state and Sling mapping was done with the system user created. What are the possible ways to check whether the function call through jsp was successful or returned any errors?

So far my execution seems fine but no new nodes are added to the repository.

Is there any additional way to invoke the javascript without using editable templates as specified in the article?

Also kindly help me to find a solution.

Avatar

Level 4

Actually there are several logger statements in the article java code, where does they actually gets written. Where can I check them in the messages?

Avatar

Level 10

You can view the default log file for the project -

ALOG.png

Avatar

Level 10

Also - does your system user have the correct permissions to interact with that part of the JCR? For testing - i typically mark off all rows so there is no permission issues.

Avatar

Level 4

yes I had given all permissions for employee node.

1689987_pastedImage_0.png

as you could verify here.

Avatar

Level 10

Try clicking the top row in permissions. Give the system user all permissions to rule that out.

Avatar

Level 4

And I wonder I can't see a single line of logs in the specified log. The log is blank

1689988_pastedImage_0.png

does this indicate something.

So there is no way to find if my Java method was invoked ?

Avatar

Level 10

Yeah  - this seems to suggest that your code was never invoked. Show me your post.POST.JSP!

Avatar

Level 4

<%@include file="/libs/fd/af/components/guidesglobal.jsp" %>

<%@include file="/libs/foundation/global.jsp"%>

<%@page import="com.day.cq.wcm.foundation.forms.FormsHelper,

             org.apache.sling.api.resource.ResourceUtil,

             org.apache.sling.api.resource.ValueMap" %>

<%@taglib prefix="sling"

                uri="http://sling.apache.org/taglibs/sling/1.0" %>

<%@taglib prefix="cq"

                uri="http://www.day.com/taglibs/cq/1.0"

%>

<cq:defineObjects/>

<sling:defineObjects/>

<%

     String formName = request.getParameter("formName");

     String formPosition = request.getParameter("formPosition");

      String formOffice = request.getParameter("formOffice");

     String formAge = request.getParameter("formAge");

     String formDate = request.getParameter("formDate");

     String formSalary = request.getParameter("formSal"); 

out.println("Success");

out.println(formName);

out.println(formPosition);

   com.adobe.persist.core.EmployeeInter data = sling.getService(com.adobe.persist.core.EmployeeInter.class);

out.println(data);

data.addEmployeeData(formOffice, formAge,formPosition, formName, formSalary, formDate);

%>

Actually it is same as in the tutorial!

Avatar

Level 10

Just tested this. As you can see it works.

Try giving that System USER all permissions.

Avatar

Level 10

Show me the SLing Mapping Configuration that you did too.

Avatar

Correct answer by
Level 4

Actually now I have given the user permission to every node in JCR and it is now working! Thanks a lot for saving my time! Meanwhile I think there are no issues with the jsp file. Also I would suggest to update the article with two things:

1. Permission

Give permission for all the contents of jcr to the created user.

2. Actually it doesn't seem to work when we use the FormContainer that was created as part of the article, since there is no Advanced options available. I suggest using the default Form components in the form container. I have used them inorder to compensate the missing advanced tab in the container. Attaching my screenshot here for community reference.

1690006_pastedImage_0.png

So my suggestion is to use all the default form components instead of using the created form components.

Thanks a lot smacdonald2008​ You are awesome!