Can't deploy servlet - keep getting constraint violation for any path | Community
Skip to main content
Level 4
October 16, 2015
Solved

Can't deploy servlet - keep getting constraint violation for any path

  • October 16, 2015
  • 5 replies
  • 1154 views

I am deploying the simplest servlet - keep getting the error when I call it from a web page using simple ajax call. (this works locally btw)

Status 

500

Message            

javax.jcr.nodetype.ConstraintViolationException: No child node definition for wcm found in node /bin

Location               invalid link: /bin/wcm/imf/SampleTest/bin/wcm/imf/SampleTest

Parent Location                /bin/wcm/imf

Path     

/bin/wcm/imf/SampleTest

 

@Component(metatype = false)

@Service

@Properties({

        @Property(name = "sling.servlet.paths", value = "/bin/wcm/imf/SampleTest"),

        @Property(name = "sling.servlet.methods", value = "GET")

})

public class SampleTestServlet extends SlingAllMethodsServlet {

 

 

 

                private final static Logger log = LoggerFactory.getLogger(SampleTestServlet.class);

 

 

 

    @Reference

    protected SlingSettingsService settingsService;

 

    @Override

    protected void doGet(SlingHttpServletRequest request,

                         SlingHttpServletResponse response) throws ServletException,

            IOException {

 

 

 

        response.getWriter().println("hi");

    }

 

 

 

 

 

 

}

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 smacdonald2008

Sounds like there dependencies on author that are not on the other server. Assume your bundle is successfully installed on Author and depends on BundleA. However BunldeA is not installed on Publisher. In this case - your bundle can be set to active on Author but not on Publisher. 

5 replies

Adobe Employee
October 16, 2015

First off, you should try to avoid registering servlets by path. This means that you aren't taking advantage of one of the key features of Apache Sling -- the ability to use resources to model your path space.

That said, it looks to me like the problem is in how your AJAX code is accessing the servlet. It appears to be making a POST request, yet your servlet is only registered to accept GET requests.

The subject line mentions deploying - are you sure that the servlet has been deployed? You can check this using the OSGi web console.

Regards,

Justin

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

Sounds like there dependencies on author that are not on the other server. Assume your bundle is successfully installed on Author and depends on BundleA. However BunldeA is not installed on Publisher. In this case - your bundle can be set to active on Author but not on Publisher. 

smacdonald2008
Level 10
October 16, 2015

If it works locally  - that means you have not deployed (or placed into an active state) your OSGi bundle that contains the servlet to AEM publish. 

Level 4
October 16, 2015

I had originially a completely working sample using proper matching GET to GET

What i noticed is, the component in system/console/components when I deploy on local, shows status "Active". I deploy the snapshot to my staging environemnt, it shows "registered" with no way to switch it on.

Why would a component only be registered and not active? I also updated it to read "immediate=true". The bundle is active as well.

Level 4
October 16, 2015

So to give more info, i use same method to deploy to local/stage

a. build the bundle locally using maven (follow all the guidelines)

b. Take the jar from bundle/target and upload it to system/console