Expand my Community achievements bar.

SOLVED

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

Avatar

Level 5

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");

    }

 

 

 

 

 

 

}

1 Accepted Solution

Avatar

Correct answer by
Level 10

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. 

View solution in original post

5 Replies

Avatar

Employee

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

Avatar

Correct answer by
Level 10

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. 

Avatar

Level 10

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. 

Avatar

Level 5

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.

Avatar

Level 5

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