ClassCastException when calling a CQ Service

Issue

You configured a custom CQ Service placed in /classes/.../serviceclass. If you try to access this CQ Service from a JSP script (by ServiceManager.getService(), you get a ClassCastException.

Solution

To make sure that your class is loaded from the same classloader put your class file (including the package directory hierarchy) into a jar file. Then, copy it to /system/bin.new/lib. The com.day.cq.bootstrap.BootClassLoader loads your class. The service manager as well as the JSP system use the com.day.cq.bootstrap.BootClassLoader.

註解:

Make sure that your class isn't in /classes/... or still in the class cache (/system/works/classes) from an earlier compilation in cqde. Then, restart.

Additional information

The ClassCastException occurs when the service manager and the JSP system don't use the same classloader. Therefore, your class isn't the same for the service manager and the JSP system.

 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 日邁阿密海灘和線上