service.setModuleLoadPath(moduleLoadPath.toString());
service.setModuleLoadPath(moduleLoadPath);
	public void generate() throws IOException, SAXException,			ProcessingException {		ContentHandler includeContentHandler;		if (inputSource == null)			throw new ProcessingException("No input source");		Request request = ObjectModelHelper.getRequest(objectModel);		Response response = ObjectModelHelper.getResponse(objectModel);		Context context = ObjectModelHelper.getContext(objectModel);		Session session = request.getSession(createSession);				final String servletPath = request.getServletPath();		final String pathInfo = request.getPathInfo();		StringBuffer moduleLoadPathBuffer = new StringBuffer(servletPath);		if (pathInfo != null) {			moduleLoadPathBuffer.append(pathInfo);		}		int p = moduleLoadPathBuffer.lastIndexOf("/");		if (p != Constants.STRING_NOT_FOUND) {			moduleLoadPathBuffer.delete(p, moduleLoadPathBuffer.length());  		}		final URI moduleLoadPath = new File(context.getRealPath(moduleLoadPathBuffer.toString())).toURI();		XmldbURI baseUri = collectionURI;		if(pathInfo!=null) {			baseUri = baseUri.append(request.getPathInfo());		}				// check if user and password can be read from the session		if (session != null && request.isRequestedSessionIdValid()) {            String actualUser = getSessionAttribute(session, "user");            String actualPass = getSessionAttribute(session, "password");			user = actualUser == null ? null : String.valueOf(actualUser);			password = actualPass == null ? null : String.valueOf(actualPass);		}		if (user == null)			user = defaultUser;		if (password == null)			password = defaultPassword;		try {			Collection collection = DatabaseManager.getCollection(					collectionURI.toString(), user, password);			if (collection == null) {				if (getLogger().isErrorEnabled())					getLogger().error(							"Collection " + collectionURI + " not found");				throw new ProcessingException("Collection " + collectionURI						+ " not found");			}			XQueryService service = (XQueryService) collection.getService(					"XQueryService", "1.0");			service.setProperty(Serializer.GENERATE_DOC_EVENTS, "false");			service.setProperty(EXistOutputKeys.EXPAND_XINCLUDES,					expandXIncludes ? "yes" : "no");			service.setProperty("base-uri", baseUri.toString());			//service.setNamespace(RequestModule.PREFIX, RequestModule.NAMESPACE_URI);			service.setModuleLoadPath(moduleLoadPath.toString());			if(!((CollectionImpl)collection).isRemoteCollection()) {				HttpServletRequest httpRequest = (HttpServletRequest) objectModel						.get(HttpEnvironment.HTTP_REQUEST_OBJECT);				service.declareVariable(RequestModule.PREFIX + ":request", new CocoonRequestWrapper(request, httpRequest));				service.declareVariable(ResponseModule.PREFIX + ":response", new CocoonResponseWrapper(response));				if(session != null)					service.declareVariable(SessionModule.PREFIX + ":session",new CocoonSessionWrapper(session));				includeContentHandler = this.contentHandler;			} else {				includeContentHandler = new IncludeXMLConsumer(this.contentHandler);			}			declareParameters(service);						// String uri = inputSource.getURI();			log(request, service, this);						ResourceSet result = service.execute(new CocoonSource(inputSource, true));			XMLResource resource;			this.contentHandler.startDocument();			for (long i = 0; i < result.getSize(); i++) {				resource = (XMLResource) result.getResource(i);				resource.getContentAsSAX(includeContentHandler);			}			this.contentHandler.endDocument();		} catch (XMLDBException e) {			throw new ProcessingException("XMLDBException occurred: "					+ e.getMessage(), e);		}	}