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
111 Views Asked by Subhomoy Sikdar At
2
There are 2 best solutions below
Related Questions in TOMCAT
- Best way to pass an environment variable to several config files
- Openshift context path
- KeyStore file is not found in jar, although present in jar
- phpseclib of how to get PID and kill
- Unable to connect database of lamp instance from servlet running on tomcat instance of google cloud
- Spring and Tomcat: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
- How can I get a custom header from the client in Tomcat?
- why lost Mysql connection pool after a period?
- Eclipse Java EE + Bitnami Tomcat Stack
- Service not starting using Spring-boot during integration tests
- Image not loading in web page and says 404 error
- Maven Tomcat plugin - 404 WebServlet not found
- How to deploy a spring boot MVC application in traditional tomcat webapps folder?
- Tomcat Manager is not accessible in multi-domain configuration
- JSP return Jasper Exceptions on my friend's pc's when it works on mine
Related Questions in CLASSLOADER
- Get full path of a package situated in source folder from junit
- ClassLoader: Treating a class as a resource - safe or implementation detail?
- Eclipse/Java can't start any project
- Can java string literals be garbage collected?. If Yes, how to prove it?
- Java override class to Load project Class instead Jar class
- Javamail ClassCastException when sending multipart messages
- How to use PowerMock with Arquillian?
- How do I install a servlet in a tomcat container and have it loaded into each web app's context?
- How do I print the current classpath for a Jenkins plugin?
- UrlClassLoader scope
- The autoloader expected class tobe defined in file
- ClassNotFoundException when load class with Class.forName
- Rome 0.9 does not work correctly when module classloader order : parent last
- Confusing ClassNotFoundException when instantiating JAXBContext with packageName and Classloader
- ClassNotFoundException on android blank activity
Related Questions in WEB-INF
- Using property files in Web Applications
- debug java web application packaged as war file in eclipse
- Spring not accessing JSP inside /WEB-INF/jsp/ folder
- RequestDispatcher.forward() to resource under "/WEB-INF" doesn't work in WebSphere
- App Engine doesn't find WEB-INF in WAR created by sbt
- Spring/Resin configuration problem
- Access resource file from JSP
- how to create files under /WEB-INF/
- redirection with jsf - from a page in web to a page in WEB-INF
- How get WEB-INF folder path in java JAX-WS app
- Which XHTML files do I need to put in /WEB-INF and which not?
- Eclipse deploys content of WebContent folder to WEB-INF folder.
- migrating data from tomcat .dbx files
- where .jsp files put in web project
- How do I share security-constraint between .wars?
Related Questions in CONTEXTCLASSLOADER
- ClassLoader.getResourceAsStream() confusion
- How can I safely solve this Java context classloader problem?
- How to prevent loading class from jar
- How do I have different web applications share same classloader?
- Java ClassLoader getResources not working with Launcher$AppClassLoader
- Parent-Child Classloader Class Resolution
- Instantiating a tomcat WEB-INF\class\myclass from tomcat lib using classloader
- Using Esper within OSGi framework
- Crazy ClassLoader question
- Classloader specific properties
- Why can't java use thread context classloader when a method is literally called?
- Loading classes using Spring inside an eclipse OSGi container does not seem to work. Fix?
- Android: after Gradle update to 6.7.1 ClassLoader in JUnit test no longer lists all resources
- Cannot add web application to built-in Tomcat of @SpringBootApplication with main-thread's context class loader
- How does the class loader loads an instance of extended class which is declared inside a method? (java.lang.NoClassDefFoundError)
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)
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?
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.