|
21 | 21 |
|
22 | 22 |
|
23 | 23 | import java.io.File; |
| 24 | +import java.io.OutputStream; |
| 25 | +import java.lang.reflect.Method; |
24 | 26 | import java.net.MalformedURLException; |
25 | 27 | import java.net.URL; |
26 | 28 | import java.util.ArrayList; |
27 | 29 | import java.util.List; |
28 | | - |
29 | | -import javax.servlet.ServletException; |
| 30 | +import java.util.Map; |
30 | 31 |
|
31 | 32 | import lucee.commons.io.res.Resource; |
32 | 33 | import lucee.loader.engine.CFMLEngine; |
@@ -166,7 +167,7 @@ public void onTextMessage(WebSocket websocket, String text) throws Exception { |
166 | 167 | } |
167 | 168 | } |
168 | 169 | super.onTextMessage(websocket, text); |
169 | | - |
| 170 | + |
170 | 171 | } |
171 | 172 | catch(Exception e) { |
172 | 173 | e.printStackTrace(); |
@@ -279,14 +280,33 @@ private PageContext createPageContext() throws PageException { |
279 | 280 | File contextRoot; |
280 | 281 | if(res instanceof File) contextRoot=(File) res; |
281 | 282 | else contextRoot=new File(res.getAbsolutePath()); |
282 | | - |
| 283 | + |
| 284 | + // Use reflection to call createPageContext to avoid javax/jakarta Cookie[] signature issues |
283 | 285 | try { |
284 | | - return engine.createPageContext(contextRoot, url.getHost(), url.getPath(), "", null, null, null, null, null, -1, true); |
285 | | - } catch (ServletException e) { |
| 286 | + Method method = findCreatePageContextMethod(engine.getClass()); |
| 287 | + if (method == null) { |
| 288 | + throw new RuntimeException("Could not find createPageContext method on CFMLEngine"); |
| 289 | + } |
| 290 | + return (PageContext) method.invoke(engine, contextRoot, url.getHost(), url.getPath(), "", null, null, null, null, null, -1L, true); |
| 291 | + } catch (Exception e) { |
286 | 292 | throw caster.toPageException(e); |
287 | 293 | } |
288 | 294 | } |
289 | 295 |
|
| 296 | + private static Method createPageContextMethod = null; |
| 297 | + |
| 298 | + private Method findCreatePageContextMethod(Class<?> clazz) { |
| 299 | + if (createPageContextMethod != null) return createPageContextMethod; |
| 300 | + |
| 301 | + for (Method m : clazz.getMethods()) { |
| 302 | + if ("createPageContext".equals(m.getName()) && m.getParameterCount() == 11) { |
| 303 | + createPageContextMethod = m; |
| 304 | + return m; |
| 305 | + } |
| 306 | + } |
| 307 | + return null; |
| 308 | + } |
| 309 | + |
290 | 310 | private void releasePageContext(PageContext pc) throws PageException { |
291 | 311 | if(pc==null) return; |
292 | 312 | engine.releasePageContext(pc, true); |
|
0 commit comments