@@ -46,8 +46,44 @@ public Playwright createPlaywright() {
46
46
47
47
try {
48
48
// Use this class's classloader (LaunchedClassLoader in Spring Boot)
49
- Thread .currentThread ().setContextClassLoader (this .getClass ().getClassLoader ());
50
- return Playwright .create ();
49
+ ClassLoader newCL = this .getClass ().getClassLoader ();
50
+ log .info ("Switching to ClassLoader: {} [{}]" , newCL .getClass ().getSimpleName (), newCL .toString ());
51
+ Thread .currentThread ().setContextClassLoader (newCL );
52
+
53
+ log .info ("About to call Playwright.create()..." );
54
+ Playwright playwright = Playwright .create ();
55
+ log .info ("Playwright.create() successful! Instance: {}" , playwright .getClass ().getName ());
56
+
57
+ // Check what was actually downloaded after creation
58
+ log .info ("=== Post-Creation Directory Check ===" );
59
+ String browserPath = System .getProperty ("playwright.browsers.path" );
60
+ String tempDir = System .getProperty ("playwright.driver.tmpdir" );
61
+
62
+ try {
63
+ Path browsersPath = Paths .get (browserPath );
64
+ if (Files .exists (browsersPath )) {
65
+ log .info ("Browsers directory content:" );
66
+ Files .walk (browsersPath , 2 ).forEach (path -> {
67
+ if (!path .equals (browsersPath )) {
68
+ log .info (" - {}" , browsersPath .relativize (path ));
69
+ }
70
+ });
71
+ }
72
+
73
+ // Check temp directory for playwright files
74
+ Path tempPath = Paths .get (tempDir );
75
+ if (Files .exists (tempPath )) {
76
+ Files .list (tempPath )
77
+ .filter (path -> path .getFileName ().toString ().contains ("playwright" ))
78
+ .forEach (path -> log .info ("Temp playwright file: {}" , path ));
79
+ }
80
+ }
81
+ catch (Exception e ) {
82
+ log .warn ("Could not list post-creation directories: {}" , e .getMessage ());
83
+ }
84
+ log .info ("=====================================" );
85
+
86
+ return playwright ;
51
87
}
52
88
finally {
53
89
// Always restore original class loader
@@ -64,6 +100,25 @@ public Playwright createPlaywright() {
64
100
* Set up environment properties for Spring Boot
65
101
*/
66
102
private void setupSpringBootEnvironment () {
103
+ // Print detailed class loader information
104
+ ClassLoader currentCL = Thread .currentThread ().getContextClassLoader ();
105
+ ClassLoader thisCL = this .getClass ().getClassLoader ();
106
+
107
+ log .info ("=== Playwright Class Loader Analysis ===" );
108
+ log .info ("Current thread context ClassLoader: {} [{}]" , currentCL .getClass ().getSimpleName (),
109
+ currentCL .toString ());
110
+ log .info ("This class ClassLoader: {} [{}]" , thisCL .getClass ().getSimpleName (), thisCL .toString ());
111
+
112
+ // Print classpath information
113
+ String classPath = System .getProperty ("java.class.path" );
114
+ log .info ("Java classpath: {}" , classPath );
115
+
116
+ // Print loader path if exists
117
+ String loaderPath = System .getProperty ("loader.path" );
118
+ if (loaderPath != null ) {
119
+ log .info ("Spring Boot loader.path: {}" , loaderPath );
120
+ }
121
+
67
122
// Set browser path
68
123
String browserPath = System .getProperty ("user.home" ) + "/.cache/ms-playwright" ;
69
124
System .setProperty ("playwright.browsers.path" , browserPath );
@@ -85,6 +140,37 @@ private void setupSpringBootEnvironment() {
85
140
log .info ("Spring Boot Playwright environment configured:" );
86
141
log .info (" - Browser path: {}" , browserPath );
87
142
log .info (" - Temp directory: {}" , tempDir );
143
+
144
+ // Print all Playwright-related system properties
145
+ log .info ("=== Playwright Runtime Directories ===" );
146
+ log .info (" - playwright.browsers.path: {}" , System .getProperty ("playwright.browsers.path" ));
147
+ log .info (" - playwright.driver.tmpdir: {}" , System .getProperty ("playwright.driver.tmpdir" ));
148
+ log .info (" - PLAYWRIGHT_BROWSERS_PATH env: {}" , System .getenv ("PLAYWRIGHT_BROWSERS_PATH" ));
149
+ log .info (" - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: {}" , System .getProperty ("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD" ));
150
+
151
+ // Check actual directories
152
+ String [] checkPaths = { browserPath , browserPath + "/chromium-*" , browserPath + "/firefox-*" ,
153
+ browserPath + "/webkit-*" , tempDir + "/playwright-java-*" };
154
+
155
+ for (String path : checkPaths ) {
156
+ try {
157
+ Path p = Paths .get (path .replace ("*" , "" ));
158
+ if (Files .exists (p )) {
159
+ log .info (" ✓ Directory exists: {}" , path );
160
+ if (Files .isDirectory (p )) {
161
+ Files .list (p ).forEach (subPath -> log .info (" - {}" , subPath .getFileName ()));
162
+ }
163
+ }
164
+ else {
165
+ log .info (" ✗ Directory not found: {}" , path );
166
+ }
167
+ }
168
+ catch (Exception e ) {
169
+ log .warn (" ? Could not check path {}: {}" , path , e .getMessage ());
170
+ }
171
+ }
172
+
173
+ log .info ("==========================================" );
88
174
}
89
175
90
176
/**
0 commit comments