Hello!
I've been working through an issue on our site and unsure what I am doing wrong in my Java. What we need to do is return the JSON from a url and then loop through those to display within a component. I have created a Service to grab those and then brought in my service to retrieve the data, but I seemingly get a Resource error when trying to test it? Here is my service and screenshots of the models and the htl. Please let me know if you can help me identify this issue!!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @SocialTaylor - Glad that we figured out that the issue is with bundle.
If your version of bundle is not updated, then check if the code package is successfully installed in crx/packmgr. If yes, then try to re-install the package and look for any possible errors in the logs.
Additionally, you can deploy the bundle alone manually via /system/console/bundles page.
On the versioning
===================
For local development, you can always have -SNAPSHOT version, and AEM will override the -SNAPSHOT jar each time you deploy.
For deployment to higher environments - If you are using Cloud Manager, it will take care of creating a valid version number for each build based on timestamp as per below screenshot and you don't need to manage the version in pom.
version in pom.xml - will be generated by Cloud Manger, without any action from your end.
If you still want to manage versioning of your builds, you can opt for maven release plugin and below are some useful links.
http://maven.apache.org/maven-release/maven-release-plugin/
https://www.initialyze.com/blog/2020/04/cutting-releases-for-your-aem-projects-using-maven/
https://github.com/Adobe-Marketing-Cloud/aem-sample-we-retail-commons/blob/master/pom.xml
Thanks,
Fani
Hello,
The log file describe the error coming from file layoutloanofficers_html.java at line 39
Now, to find the file go to /crx-quickstart/launchpad/felix and search for your class file layoutloanofficers_html.java (sightly java file) using below shell command
find . -name "layoutloanofficers_html.java"
then start debugging from there.
hope it will help!!
Hello,
its AEM installed folder structure which you should access from your server (not as url) and then run shell or similar command mentioned above.
Thanks!!
Hi @SocialTaylor,
In the Model, try @Inject instead of @OSGiService for the services to get injected.
Hope this helps!
Thanks,
Kiran Vedantam.
Tried giving this a go and it seems to still be giving me the same error. Not sure if it has to do with the sling model or the htl at this point.
Hi @SocialTaylor - Can you confirm if your bundle containing the Model is deployed and active?
Hey @Fanindra_Surat !
I believer you are onto the correct issue. When I went to my bundles in the AEM console, I do not see either my service nor my model there, as you can see in my screenshot below.
Earlier as I was working on this, it made my update my package-info.java from '1.0' to '1.1.0' for both of those after I removed '-SNAPSHOT' from the version of all of my POM.xml files to start proper versioning. How do I go about telling it to bump those up from 1.0.0 to 1.1.0? And, was that the correct way to go about versioning in my POM.xml files? I don't know a lot about setting up projects in AEM, but we were told removing the '-SNAPSHOTS' were needed for our builds when publishing to the cloud haha.
Thank you so much for your help!!!
Taylor
Hi @SocialTaylor - Glad that we figured out that the issue is with bundle.
If your version of bundle is not updated, then check if the code package is successfully installed in crx/packmgr. If yes, then try to re-install the package and look for any possible errors in the logs.
Additionally, you can deploy the bundle alone manually via /system/console/bundles page.
On the versioning
===================
For local development, you can always have -SNAPSHOT version, and AEM will override the -SNAPSHOT jar each time you deploy.
For deployment to higher environments - If you are using Cloud Manager, it will take care of creating a valid version number for each build based on timestamp as per below screenshot and you don't need to manage the version in pom.
version in pom.xml - will be generated by Cloud Manger, without any action from your end.
If you still want to manage versioning of your builds, you can opt for maven release plugin and below are some useful links.
http://maven.apache.org/maven-release/maven-release-plugin/
https://www.initialyze.com/blog/2020/04/cutting-releases-for-your-aem-projects-using-maven/
https://github.com/Adobe-Marketing-Cloud/aem-sample-we-retail-commons/blob/master/pom.xml
Thanks,
Fani
Hey @Fanindra_Surat !
That did seem to be the issue for my model! The only issue now is I'm still unable to get the JSON using the service I created. Unsure if that is an issue with how I am returning that JSON or not. Any thoughts?
Taylor
Hey @SocialTaylor - I would say, we may need to confirm if the json to object mapping in your service layer is happening properly. For that, you can add few loggers after the object mapping and print the values from your pojos.
If this test is as expected, we can get to the Sightly rendering part of the flow.
Thanks,
Fani
Hi,
Can you check whether your model folder is added in pom.xml under
Sling-Model-Packages ?
Views
Likes
Replies