You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by shikage <ch...@gmail.com> on 2013/12/20 22:25:38 UTC

Maven Project for Initial Content and Servlets/Bundle

Hi, 

I have been doing some development with Day CQ/Adobe AEM for the past
several months and consider myself to be getting the general hang of how to
setup and build projects for this system. As I understand it, it has Apache
Sling at it's core so I figured I would give this a try for some of my own
personal projects outside of work.

However, when building Maven projects for CQ the Multimodule project
archetype is generally used which creates one project for your backend code
like services, servlets, bundled classes and other Java code, and another
project for the "content" which is the files and scripts to go into the apps
folder, etc/designs folder, etc..

I have been trying to setup a project for Sling. I have been following the
steps provided through the various blog posts at
http://in-the-sling.blogspot.ca/2008/08/basic-osgi-service-for-sling.html.
They worked quite well until reaching the Servlet part. I may have made a
mistake in trying to simply add the servlet code and definitions to the same
POM that was used for the service and the initial content instead of
creating a separate project for the servlet.

So, in short, I guess my questions are: Is there a similar Multimodule
Project archetype for Sling as is used for CQ? If not, is there something in
particular I need to do to make my POM used for the initial-content and
service to allow the inclusion of a servlet? Or do I need to make a separate
Servlet project for that and build a parent project to tie the two packages
together or just install the two projects individually?

Perhaps someone can point me to a good guide for setting up eclipse for
building a bundle/package for Sling instead of for building the entire Sling
project? I am looking to just build the additional code I want to
deploy/install onto an already running Sling server.

Thanks.



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Maven-Project-for-Initial-Content-and-Servlets-Bundle-tp4029856.html
Sent from the Sling - Users mailing list archive at Nabble.com.

Re: Maven Project for Initial Content and Servlets/Bundle

Posted by shikage <ch...@gmail.com>.
Seems I managed to find a solution to the major part of my problem. In
following the directions on the site in my previous post I had used an old
version of the maven scr plug in that didn't work with the newer @Service,
@Component, etc and only the @scr.service, etc.. When I changed the version
of my src plugin in the POM the servlet and services started being
registered properly.

I have been encountering one slightly odd problem however. When attempting
to register a servlet as a resourceType instead of using a path, when I
attempt to access the servlet the output is always blank/empty. I am using
the following two lines for a simple hello world output:
response.setContentType("text/plain");
response.getWriter().write("Hello World");

I have also tried changing the second line for:
response.getOutpustream().print("Hello World");

And I have tried flushing the output buffer at the end with:
response.flushBuffer();



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Maven-Project-for-Initial-Content-and-Servlets-Bundle-tp4029856p4029862.html
Sent from the Sling - Users mailing list archive at Nabble.com.