@@ -570,28 +570,26 @@ public static long getMaxIdleTimeout(ConfigWeb cw, Object session, long defaultV
570570 }
571571
572572 /**
573- * Get ServletContext from ConfigWeb using reflection to avoid javax/jakarta linking issues
573+ * Get ServletContext from ConfigWeb using plain java.lang.reflect to avoid
574+ * javax/jakarta linking issues AND to avoid Lucee's ClassUtil which ASM-reads
575+ * bytecode via the class's classloader — that fails after cfadmin restart /
576+ * bundle reload because the old classloader is stopped (LDEV-6221).
574577 */
575578 public static Object getServletContext (ConfigWeb cw ) {
576579 try {
577- CFMLEngine eng = CFMLEngineFactory .getInstance ();
578- return eng .getClassUtil ().callMethod (cw , eng .getCastUtil ().toKey ("getServletContext" ), new Object [] {});
580+ return cw .getClass ().getMethod ("getServletContext" ).invoke (cw );
579581 }
580- catch (PageException e ) {
582+ catch (ReflectiveOperationException e ) {
581583 throw new RuntimeException ("Failed to get ServletContext from ConfigWeb" , e );
582584 }
583585 }
584586
585- /**
586- * Get real path from ServletContext using reflection
587- */
588587 public static String getServletContextRealPath (ConfigWeb cw , String path ) {
589588 try {
590589 Object sc = getServletContext (cw );
591- CFMLEngine eng = CFMLEngineFactory .getInstance ();
592- return (String ) eng .getClassUtil ().callMethod (sc , eng .getCastUtil ().toKey ("getRealPath" ), new Object [] { path });
590+ return (String ) sc .getClass ().getMethod ("getRealPath" , String .class ).invoke (sc , path );
593591 }
594- catch (PageException e ) {
592+ catch (ReflectiveOperationException e ) {
595593 throw new RuntimeException ("Failed to get real path from ServletContext" , e );
596594 }
597595 }
@@ -602,20 +600,15 @@ public static String getServletContextRealPath(ConfigWeb cw, String path) {
602600 public static boolean isCliServletContext (ConfigWeb cw ) {
603601 Object sc = getServletContext (cw );
604602 if (sc == null ) return true ;
605- ClassUtil util = CFMLEngineFactory .getInstance ().getClassUtil ();
606- return util .isInstaneOf (sc .getClass (), "lucee.cli.servlet.ServletContextImpl" );
603+ return "lucee.cli.servlet.ServletContextImpl" .equals (sc .getClass ().getName ());
607604 }
608605
609- /**
610- * Get attribute from ServletContext using reflection
611- */
612606 public static Object getServletContextAttribute (ConfigWeb cw , String name ) {
613607 try {
614608 Object sc = getServletContext (cw );
615- CFMLEngine eng = CFMLEngineFactory .getInstance ();
616- return eng .getClassUtil ().callMethod (sc , eng .getCastUtil ().toKey ("getAttribute" ), new Object [] { name });
609+ return sc .getClass ().getMethod ("getAttribute" , String .class ).invoke (sc , name );
617610 }
618- catch (PageException e ) {
611+ catch (ReflectiveOperationException e ) {
619612 throw new RuntimeException ("Failed to get attribute [" + name + "] from ServletContext" , e );
620613 }
621614 }
0 commit comments