Trying to delete a page throws Page does not exist

Issue

When you try to delete a page programmatically, you receive an error similar to the following:

10:09:38 *ERROR* delivery: Unhandled Exception: javax.servlet.ServletException: Page '/content/playground/en/test' does not exist.javax.servlet.ServletException: Page '/content/playground/en/test' does not exist. 10:09:38 at com.day.jasper40.runtime.JspRuntimeLibrary.handlePageException(JspRuntimeLibrary.java:891) 10:09:38 at apps.daytest.templates.test.start$jsp._jspService(start$jsp.java:134) 10:09:38 at com.day.jasper40.runtime.HttpJspBase.service(HttpJspBase.java:107) 10:09:38 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) 10:09:38 at com.day.cq.jsp.JspHandler.doCallInternal(JspHandler.java:342)

You used code similar to the following:

if(pageToDelete.exists())

{

try

{ pageToDelete.startTransaction();

pageToDelete.delete(false);

pageToDelete.commit();

}catch(Exception e) {

pageToDelete.rollback(); }

}

Solution

Remove the transaction code. For example:

if(pageToDelete.exists()) { try { pageToDelete.delete(false); }catch(Exception e) { log.error(e.getMessage(), e); } }

Additional information

It's not necessary to use any transaction code for deleting a page.

 Adobe

更快、更輕鬆地獲得協助

新的使用者?

Adobe MAX 2024

Adobe MAX
創意大會

10 月 14 至 16 日邁阿密海灘和線上

Adobe MAX

創意大會

10 月 14 至 16 日邁阿密海灘和線上

Adobe MAX 2024

Adobe MAX
創意大會

10 月 14 至 16 日邁阿密海灘和線上

Adobe MAX

創意大會

10 月 14 至 16 日邁阿密海灘和線上