Improvement of building process
We have one big project. And as all big projects it’s build takes long time – it is the problem, because it is wasting time 🙁 First some words about project architecture. It is based on Java EE 5 (we use EJB, JPA, JMS, etc.) and we use GWT for building rich user interface. Also, for static pages, we use Magnolia CMS. And as result building of it is not quick. After some analysis I found obvious. At the same…
Integrating JAX-WS into Magnolia CMS

Got a task today to add support of JAX-WS into our Magnolia based project. Hell. I took me 30 minutes to add support for JAX-RS(Jersey). But it took about four hours to do this for JAX-WS. The first step is quite trivial we need to create web service itself:package com.softteco.ws; import javax.jws.WebMethod;import javax.jws.WebParam;import javax.jws.WebService; @WebService(serviceName=”PingService”)public class PingService { @WebMethod(operationName=”ping”) public String ping(@WebParam(name=”s”) String data) { return data; }}The second step is also quite trivial. You’ll need to add one more listener into your web.xml….
Internationalization of the Magnolia Freemarker templates

To extend the contents of Magnolia CMS – we have created several custom paragraphs. Once we need a localization for these paragraphs – we’ve tried a usual approach used in STK. So we’ve written something like${i18n[‘custom.goToTop’]}in the FreeMarker template and got the following error immediately:freemarker.core.InvalidReferenceException: Expression i18n is undefined on … What the hell, our template is similar to the STK paragraphs? Later it appeared that we’re missing one important property in the paragraph metadata called i18nBasename. Exactly this parameter…
Designing Magnolia e-mail templates

Mailing functionality is rather natural for any application. You often need to send e-mails about registration or order confirmation. This post describes a way which has been used to design e-mail templates for Magnolia CMS. It provides a nice module to work with the e-mails. You can easily register a template and send it via the following code:Map<String, String> parameters = …;final Context context = MgnlContext.getInstance();final MgnlMailFactory factory = MailModule.getInstance().getFactory();final MgnlMailHandler handler = factory.getEmailHandler();final MgnlEmail email = factory.getEmailFromTemplate(“orderConfirmation”, parameters);email.setToList(to);email.setBodyFromResourceFile();MgnlContext.setInstance(context);handler.prepareAndSendMail(email);We use FreeMarker…
Uploading files in Magnolia CMS
We need to have an upload functionality in our web application based on Magnolia CMS. So I’ve created a small servlet which uses commons-upload library from Apache. So the code looked like: FileItemFactory factory = new DiskFileItemFactory();ServletFileUpload upload = new ServletFileUpload(factory);List items = upload.parseRequest(request); However the list of items was empty. Trying to understand where does my file goes – I’ve started debugging the library and it appears that MalformedStreamException(“Stream ended unexpectedly”) is thrown internally. However it’s silently skipped and…
Integrating Magnolia CMS and custom application security
We have an application integrated into Magnolia CMS. and it’s quite natural to have a single way of handling security. Both Magnolia and our application use JAAS for authentication. However magnolia uses JCR repository to store security data, while our application uses database. Since we didn’t want to cause some possible side effects in Magnolia – the following model was applied: users and a limited set of roles is synchronized between application and Magnolia. Let’s look at how it looks…
Working with JCR in Magnolia-CMS
Magnolia CMS is popular Java-based CMS, but unfortunately there is not enough documentation regarding it. For example, I decide to store and load some data into built-in JCR repository and I did not find guide for it. Thus I decided to create this post. So my goal is use JCR as storage for my custom data. I want to store data into it and load data. So let’s start. First I’d to get Content and then add same entities into…
Transaction in not-transactional environment
Some days ago I had problem strange problem in JavaEE application on Glassfish application server. Let’s I explain it. I have two JPA entities Person and Address, which are linked via @ManyToOne relation. And I have service-method (in Stateless bean) – it updates Person and liked Address. The problem was that TopLink did not delete Address entities in this service-method. First I thought that it deals with TopLink and its configuration, but later I found that entities are deleted after…
GWT and Magnolia Integration
I like GWT and I like Magnolia. What do you think about link them? GWT will be responsible for dynamic pages. Such page will provide rich user interface with a lot of JavaScript and AJAX. Thus search engines will not index these pages, but it is not problem – Magnolia will be responsible for such pages. Also Magnolia provides some useful features like mail service, file uploading mechanism, etc. So let’s link them. Create GWT application First, we need to…
Magnolia on Glassfish
By default magnolia-cms is working on Tomcat, but it is easy to run it on Glassfish v2. You only need to deploy magnolia in glassfish and after that add default JAAS login configuration into login.conf, which is place in conf directory of your domain:
1 2 3 4 5 6 7 8 | magnolia { info.magnolia.jaas.sp.jcr.JCRAuthenticationModule requisite; info.magnolia.jaas.sp.jcr.JCRAuthorizationModule required; }; Jackrabbit { org.apache.jackrabbit.core.security.SimpleLoginModule required; }; |
Also check that “Default Principal To Role Mapping” flag is not checked for your domain (you’ll find it on Configuration -> Security page of glassfish Admin Console).