Title: Facing NoClassDefFoundError despite jar being in classpath (dynamic compilation) · Issue #31 · trung/InMemoryJavaCompiler · GitHub
Open Graph Title: Facing NoClassDefFoundError despite jar being in classpath (dynamic compilation) · Issue #31 · trung/InMemoryJavaCompiler
X Title: Facing NoClassDefFoundError despite jar being in classpath (dynamic compilation) · Issue #31 · trung/InMemoryJavaCompiler
Description: In a tomcat server, at run time, I am reading java class files and compiling them dynamically using InMemoryJavaCompiler. Code Sample - InMemoryJavaCompiler.newInstance() .useOptions("-parameters", "-classpath", sb.toString(), "-Xlint:un...
Open Graph Description: In a tomcat server, at run time, I am reading java class files and compiling them dynamically using InMemoryJavaCompiler. Code Sample - InMemoryJavaCompiler.newInstance() .useOptions("-parameters",...
X Description: In a tomcat server, at run time, I am reading java class files and compiling them dynamically using InMemoryJavaCompiler. Code Sample - InMemoryJavaCompiler.newInstance() .useOptions("-paramet...
Opengraph URL: https://github.com/trung/InMemoryJavaCompiler/issues/31
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Facing NoClassDefFoundError despite jar being in classpath (dynamic compilation)","articleBody":"In a tomcat server, at run time, I am reading java class files and compiling them dynamically using InMemoryJavaCompiler. \r\nCode Sample -\r\n```\r\nInMemoryJavaCompiler.newInstance()\r\n .useOptions(\"-parameters\", \r\n \"-classpath\", sb.toString(), \r\n \"-Xlint:unchecked\")\r\n .compile(sourceCodeClassName,\r\n sourceCode.toString());\r\n```\r\nHere sb (Stringbuilder) indicates the jars read from WEB-INF/lib directory separated by a colon.\r\nThe code works in the following scenarios :\r\n 1. If the above compilation code is kept in a standalone class file \u0026 the relevant libraries are set in the classpath, the compilation from a bash script was successful.\r\n 2. I printed the jar files i.e. I printed sb value separately \u0026 took a copy of it. I manually ran javac -classpath \u003csourceCode.java\u003e in the terminal. The compilation was successful.\r\n\r\nThe code is not working in the following scenarios :\r\n\r\n a. When the above code snippet is added as a stand alone program in IDE(Eclipse), I faced NoClassDefFound error for the interface which the sourceCode was implementing.\r\n\r\n b. In Tomcat, the relevant jar is present in contextName/WEB-INF/lib/ and in addition to that the jar is added in -useOptions classpath. Even then, I am facing NoClassDefFound error for the the interface the sourceCode was implementing.\r\n\r\nNote : There are no duplicate copies of the jar or multiple versions of the jar present in the lib directory or the classpath value.","author":{"url":"https://github.com/LuPev","@type":"Person","name":"LuPev"},"datePublished":"2020-11-21T08:35:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/31/InMemoryJavaCompiler/issues/31"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6bb2b913-5665-7c22-4b6b-23f408f5261a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9EAC:335C42:E5B3E7:12AC14E:697E4321 |
| html-safe-nonce | 1852b3473fcf6b5d151e53be2877d29d873a2de95baca1f6b6ade6e69b6b805b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUFDOjMzNUM0MjpFNUIzRTc6MTJBQzE0RTo2OTdFNDMyMSIsInZpc2l0b3JfaWQiOiI0ODgzODM0NDQ1MzU5ODkxMjMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 146364c574a5e39904b2846a950e9eb9b1b751a164cc97e215fe5da5b660b37f |
| hovercard-subject-tag | issue:747976255 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/trung/InMemoryJavaCompiler/31/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a6a4008a3c1882e691f145c6e5dfde66074929d1acf2df12fc4a564532ab351b/trung/InMemoryJavaCompiler/issues/31 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a6a4008a3c1882e691f145c6e5dfde66074929d1acf2df12fc4a564532ab351b/trung/InMemoryJavaCompiler/issues/31 |
| og:image:alt | In a tomcat server, at run time, I am reading java class files and compiling them dynamically using InMemoryJavaCompiler. Code Sample - InMemoryJavaCompiler.newInstance() .useOptions("-parameters",... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LuPev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/trung/InMemoryJavaCompiler git https://github.com/trung/InMemoryJavaCompiler.git |
| octolytics-dimension-user_id | 24930 |
| octolytics-dimension-user_login | trung |
| octolytics-dimension-repository_id | 31716516 |
| octolytics-dimension-repository_nwo | trung/InMemoryJavaCompiler |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31716516 |
| octolytics-dimension-repository_network_root_nwo | trung/InMemoryJavaCompiler |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width