I am trying to load a class present in a war file in tomcat from a class in a jar in tomcat lib. I am doing this using Class.forname("myclass") but the application is throwing class not found exception. i guess this is because the webapp will have its own class loader. can someone suggest how to fix this
Instantiating a tomcat WEB-INF\class\myclass from tomcat lib using classloader
112 views Asked by Subhomoy Sikdar At
2
There are 2 answers
Related Questions in TOMCAT
- Unable to compile the class for JSP in tomcat 8.5.95
- detect catalina.out log path from a running tomcat on non-Windows
- Tomcat 9.0.80 with Open JDK (JRE only) v16.0.2 crashing/unresponsive several times a day with load: Thread Count hits Max and All Threads are Busy
- JAX-RS webapp deployed to Tomcat returns HTTP 404 error while it works fine in Eclipse
- Illegal access: this web application instance has been stopped already. Could not load [org.apache.logging.log4j.message.SimpleMessage]
- File Upload Handling: Inconsistent HTTP Response Codes for Different File Sizes with Exception in Tomcat
- Don't get any public folder when deployment in svelte kit app
- Accessing solr web interface behind reverse proxy returns "Content Encoding Error"
- java.lang.UnsatisfiedLinkError: org.apache.tomcat.jni.SSL.renegotiatePending(J)I
- Cannot decrypt the password in application.yml properly if war file in the tomcat/webapps
- how to deploy mock json data api's(json-server) and angular 17 application in apache tomcat server 9 version
- version compatibility issue between spring boot, struts2-core and tomcat-embed-jasper in web application
- Is there any possibility to use JTA with Spring Framework 6 and Tomcat or Payara?
- Eclipse issue with publishing to Tomcat server
- null in Camunda variables
Related Questions in CLASSLOADER
- Unable to load Subject segmentation service of com.google.android.gms
- How to use your own Bouncy Castle version in an application deployed on JBoss EAP 7.4
- Loading Jar into classpath which is not defined in pom.xml
- Override classes present in Spring Boot fat jar with classes in external jar present in loader.path
- How to get SystemClassLoader URLs in JDK17 gracefully?
- Maven plugin: common dependency in plugin and project, create dependency class object in plugin from class in project
- Getting 404 when accessing classes annotated with @Path in {war}/WEB-INF/classes in Jetty 9
- Translet class loaded, but unable to create translet instance
- jvm classloading issue (defineClass1)
- How to dynamically load a jar in runtime (Not for reflection)
- TomEE - How does ClassLoader load from 3 webapps
- Spring boot jar loading
- how to load JPA Entities and Repositories in sprint boot app from external folder/jar
- loading constraint violation when resolving method "javax/imageio/metadata/IIOMetadata.getAsTree(Ljava/lang/String;)Lorg/w3c/dom/Node
- Generate custom java code like lombok at compile time
Related Questions in WEB-INF
- how to block web-inf from http GET - wildfly 20 exploded
- Define the parameter babelfy.key in babelfy.properties in the config folder
- Java and spring boot: Can you automatically generate dependencies in eclipse or another program?
- What is the best practice of the directory Structure Of Java Web Application
- Missing WEB-INF folder in Maven Java Project
- Cannot call JavaScript function located in a different file and folder from HTML file for Select Option
- What do i need to do in IntelliJ so that my dependencies specified in the pom.xml are automatically added to the ..WEB-INF/lib folder?
- How to Restrict access to web-inf folder from accessing outside without using security-constraint
- Access to web-inf from deployed jar
- URL-Redirecting on host_name in browser in tomcat9 using classes/project/servlet
- Error Caused by: java.io.FileNotFoundException for file under src/main/resources/config/env/dev2 in SpringBoot 2.0 application
- Cannot show image outside WEB-INF folder
- Spring-Boot using JSP's from dependent jar
- How to secure a sun-jaxws java web service inside the webapp xml config files
- How to solve a JAR conflict in Tomcat web app required for a plugin that has a dependency on a class already in WEB-INF/lib?
Related Questions in CONTEXTCLASSLOADER
- java.lang.StackOverflowError when java.lang.ClassLoader.loadClass(ClassLoader.java:569)
- Android: after Gradle update to 6.7.1 ClassLoader in JUnit test no longer lists all resources
- Oracle leaks threads on when closing Hibernate Sessions with Oracle JDBC driver
- CompilingClassLoader fun, any ideas how child class loads from different classloader in this case?
- How does the class loader loads an instance of extended class which is declared inside a method? (java.lang.NoClassDefFoundError)
- getSystemResource() vs getResource() with relevant ClassLoader
- Java ClassLoader getResources not working with Launcher$AppClassLoader
- Parallel stream doesn't set Thread.contextClassLoader after tomcat upgrade
- Calling `defineClass` on ClassLoader results in "No matching method found"
- Cannot add web application to built-in Tomcat of @SpringBootApplication with main-thread's context class loader
- How can I get the name of caller class when the app goes from activityA to activityB?
- Tomcat 7 - JAAS realm cannot access web app class files
- Using Esper within OSGi framework
- Instantiating a tomcat WEB-INF\class\myclass from tomcat lib using classloader
- Can Thread.setContextClassLoader set a different ClassLoader than returned by getCCL?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
This is by design - you can't do that. With the hierarchical classloaders that tomcat is using, you don't have a chance to load a class that's contained a webapp from a class loaded from the global classpath unless you build your own classloading mechanism - which I wouldn't recommend.
I'd rather like to know what problem you're trying to solve with this solution attempt. I can't think of any underlying problem where this would be the right solution for.