portal.sanitizeHtml and contentLib.publish error Enonic 6.15.5


Enonic version: 6.15.5
OS: Win10 64x

Hello there Enonic Dicuss community.

I am upgrading my enonic version and i’d migrate an entire project based on enonic 6.4 yo enonic 6.15 and it seems to work well but the console is showing two errors.

TypeError: contentLib.publish is not a function. This error apperas when I refresh my site after the session expires
TypeError: portal.sanitizeHtml is not a function. This error appear while im trying to create some content from my site.

I think that that error could be related with the libraries that Im calling or how Im doing the calls. Bellow Im sharing this information. If more information is needed let me know.

This is the configuration of my build.gradle
plugins {
id ‘java’
id ‘com.enonic.xp.app’ version ‘1.2.0’

xp {
version = xpVersion

app {
name = project.ext.appName
displayName = project.ext.displayName
vendorName = ‘Enonic AS’
vendorUrl = ‘http://enonic.com
systemVersion = “${xpVersion}”

dependencies {
compile “javax.servlet:javax.servlet-api:3.0.1”
compile “com.enonic.xp:core-api:${xpVersion}”
compile “com.enonic.xp:portal-api:${xpVersion}”
include “com.enonic.xp:lib-content:${xpVersion}”
include “com.enonic.xp:lib-portal:${xpVersion}”
include “com.enonic.xp:lib-thymeleaf:${xpVersion}”
//include “com.enonic.xp:lib-xslt:${xpVersion}”
//include “com.enonic.xp:lib-mustache:${xpVersion}”
include “com.enonic.xp:lib-i18n:${xpVersion}”
include “com.enonic.xp:lib-auth:${xpVersion}”
//include “com.enonic.xp:lib-cache:${xpVersion}”
//include “com.enonic.xp:lib-context:${xpVersion}”
//include “com.enonic.xp:lib-http-client:${xpVersion}”
//include “com.enonic.xp:lib-io:${xpVersion}”
include “com.enonic.xp:lib-mail:${xpVersion}”
compile “org.apache.poi:poi:3.9”
compile “org.apache.poi:poi-ooxml:3.9”
compile ‘com.google.apis:google-api-services-analytics:v3-rev159-1.25.0’
compile ‘com.google.api-client:google-api-client:1.27.0’
include “com.enonic.xp:lib-websocket:${xpVersion}”
include “com.enonic.lib:util:1.0.0”
include ‘com.enonic.lib:menu:1.2.0’
include ‘com.squareup.okhttp:okhttp:2.5.0’
include “com.enonic.lib:lib-http-client:1.0.0”
include “com.enonic.xp:lib-io:${xpVersion}”
include ‘com.enonic.lib:geoip:1.0.0’

repositories {

This is how I call the lib
var portal = require(’/lib/xp/portal’);
var contentLib = require(’/lib/xp/content’);

This is where im calling the function sanitizeHtml

var createHubCategory = contentLib.create({
name: portal.sanitizeHtml(name).replace(/([.*+/?^=:${}()|[]/\])/g, “”) + dateNow,
parentPath: portal.getSite()._path + ‘/consultorio-data/consultorio-categoria’,
displayName: portal.sanitizeHtml(name),

Hope that you could bring to me some orientation.

Thank you-



The likely culprit is that one or more of your dependencies itself has a dependency to an older version of lib-content and lib-portal which overrides the version that you get from the ${xpVersion} variable.

If you run:
gradlew.bat dependencies
inside your project, Gradle should print out a complete dependency tree so that you can troubleshoot.

My guess is that you need to update either com.enonic.lib:util or com.enonic.lib:menu to a newer version. lib-util is currently at version 1.3.1 and lib-menu is currently at version 2.0.1


Thanks for your answer. by the time I run the command gradlew.bat dependencies the console throw this error. java.lang.NoClassDefFoundError: org/

Iguess that i have a big proble with my gradle setup. I have the 4.10.2 version. any advice regarding this.

thanks in advance.



Follow bhj’s advice on upgrading the lib-util and lib-menu libraries. They had know issues in past versions with this.


Hello there thanks in advance for your replies. Here we have more context regarding this case.

The mentioned error has appeared because I have a project working pretty well on v6.4.2 and then I decided to try to upgrade it to v6.15.5
My question considering this is: Does it possible to do that by just installing the Enonic server v6.15.5, importing my project and blobs structure from a back up created and exported with Enonic v6.4.2 toolbox and then modify all the dependencies and libraries calls as stipulated on the documentation?
This upgrade process could be achieved in that way? Or is there any other way to do that? Or is not possible to do this because many errors will appear.

Please let me know your thoughts about this.


Hmm… if I understand you correctly, you seem to be describing the normal upgrade procedure, so it should work fine. If you’re lucky, the old build of your app for 6.4.2 might even work on 6.15.5 without any changes. But you should of course test this in a safe environment before trying out in your production environment, as there have been a number of minor changes (usually bug fixes of some sort) that may require you to make changes in your app. One of the most notable changes was when Enonic XP 6.7 required Java 1.8.92 or above, but that will probably not affect your actual app.

To see the changes that may be required when upgrading from 6.4.2 to 6.15.5, start by reading the changes from 6.4 to 6.5:
…and do the same research for later versions, by replacing “6.5” in the URL above with each newer feature release (6.6, 6.7, … , 6.15).

You should be able to go directly from 6.4.x to 6.15.x without needing to upgrade to any of the versions in between.