AEM 6.4 - Java sling servlet does not work with uber 6.4 jar, but does with uber 6.3 | Community
Skip to main content
brendanf9753525
New Participant
May 10, 2018
Solved

AEM 6.4 - Java sling servlet does not work with uber 6.4 jar, but does with uber 6.3

  • May 10, 2018
  • 14 replies
  • 10872 views

Hey all,

I am seeing a really weird issue with a fresh install of AEM 6.4. I have a Java sling servlet registered at a path of /bin/feed. This servlet crashes and does not load everytime I try to visit it.

Observing the logs gives me this error.

10.05.2018 14:59:24.876 *ERROR* [FelixDispatchQueue] org.apache.sling.servlets.resolver FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory returned null. (Component: com.amsurg.core.servlets.RSSXMLServlet (3142)))

org.osgi.framework.ServiceException: Service factory returned null. (Component: com.amsurg.core.servlets.RSSXMLServlet (3142))

It's pretty vague and I've seen some fixes for it with previous versions of AEM, but nothing concrete for 6.4 yet. The weird thing is, if I build and upload my package with the 6.4 uber-jar, I see the error 10/10 times. However when I compile it with the 6.3 uber-jar, it doesn't have any issues. That doesn't seem to be correct to me since I am using AEM 6.4.

Does anyone have any ideas or other things I can check for as to why this would not work? I have several other servlets registering in the same way and they are loaded just fine, so its a problem with this one + the uber 6.4 jar.

Thanks

Brendan

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

Do you use the "new" OSGI annotations and have you updated your imports accordingly? On Using OSGi annotations (>= AEM6.2) - Experience Delivers  Feike has done a good job and listed all relevant things to consider.

Jörg

14 replies

brendanf9753525
New Participant
May 15, 2018

Thank you Jorg! That was it, I needed to add those OSGI dependencies and update my bundles.

It is loading and looks good now.

joerghoh
joerghohAccepted solution
Employee
May 14, 2018

Do you use the "new" OSGI annotations and have you updated your imports accordingly? On Using OSGi annotations (>= AEM6.2) - Experience Delivers  Feike has done a good job and listed all relevant things to consider.

Jörg

brendanf9753525
New Participant
May 14, 2018

I checked and it is not generated in there. All the rest of the servlets have them but that one is missing. So it looks like it is not being added to the package.

What do you think the cause of this could be? It does not seem to like my new annotations.

joerghoh
Employee
May 14, 2018

Then you should check in the target/classes/OSGI-INF if there are xml files generated for these servlets in question.

Jörg

brendanf9753525
New Participant
May 14, 2018

Sure thing Jorg, I'll look at those once we can get this ironed out. Our bundle is named amsurg.ui.apps.

It's weird, my bundle is loaded and started and showing the correct version. I even have some other servlets that are included in there, but they use the old annotations. I included that below. It's almost like all of the servlets are being loaded and started except for the one I'm trying to play with now. It just isn't included at all. No build errors or anything like that.

@SlingServlet(paths = "/bin/amsurg/marketoNewsletterSignupServlet", methods = "POST", metatype = true)

joerghoh
Employee
May 14, 2018

You have some complaints about content package importer issues, you should fix them as well. Although these have nothing to do with your reported issue.

11.05.2018 10:05:10.547 *ERROR* [qtp1956172325-1916] org.apache.jackrabbit.vault.fs.io.Importer E /apps/amsurg/components/content/SCCN/midblock-info (org.xml.sax.SAXParseException; systemId: file:///C:/aem/jcr_root/apps/amsurg/components/content/SCCN/midblock-info/.content.xml; lineNumber: 6; columnNumber: 2; XML document structures must start and end within the same entity.)

Regarding your issue: Can you check the created content package and validate that your bundle is contained in the content package? The log excerpt you posted makes me think that there is no bundle contained (or at least not getting picked up for whatever reason). What's the name of your content package file?

Jörg

brendanf9753525
New Participant
May 14, 2018

I tried on a fresh install and it still cannot find my servlet

smacdonald2008
New Participant
May 14, 2018

Try on a fresh instance - this will tell us if the issue is with your instance or something in your steps.

brendanf9753525
New Participant
May 14, 2018

Sorry about that, I was trying a bunch of different paths. Nothing seems to be registering with that annotation. It doesn't register with /bin/amsurg/feed, /bin/amsurg, or something like /bin/foo

arunpatidar
New Participant
May 12, 2018

from logs you are accessing /bin/feed

11.05.2018 10:05:18.878 *INFO* [0:0:0:0:0:0:0:1 [1526054718868] GET /bin/feed HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Resource /bin/feed not found

but your code has different path.

try to access with /bin/amsurg/feed

Arun Patidar