classloader

Reload class file in tomcat

好久不见. 提交于 2019-12-08 06:11:11
问题 I am creating a class file at run time. I want to replace the existing class file with the updated one in the class loader. It is similar to hot swapping (e.g. JRebel) which avoids server restart and redeployment. I found context.xml approach for tomcat for context reloading. But it is not very useful in case of production environment. Can we register class with ClassLoader at runtime? Please suggest if any alternative is there to reload class at runtime. I am using following code to retrieve

Java load properties file correctly

╄→尐↘猪︶ㄣ 提交于 2019-12-08 04:48:36
问题 I have the following project structure: ProjectName/src/java/com/main/Main.java And I have a properties file in the following folder: ProjectName/config/settings.properties Now I tried to load the properties file in the Main.java with: InputStream input = Main.class.getResourceAsStream("/config/settings.properties"); Properties prop = System.getProperties(); prop.load(input); But this does not work. How is it the right way to do it? Edit: I got the following error: Exception in thread "main"

Issue while extending PatternLayout in log4j

℡╲_俬逩灬. 提交于 2019-12-08 03:40:04
问题 I created a new class NewLinePatternLayout.java which extends PatternLayout.java of log4j. Below is my log4j.properties. log4j.rootLogger=INFO, R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=${catalina.home}/logs/tomcat.log log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=com.myCompany.utils.NewLinePatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n I am getting an error as below: log4j:ERROR The

Adding second conf folder to JBoss 5.1.0

ぃ、小莉子 提交于 2019-12-08 03:34:48
问题 We have a slightly modified JBoss 5.1.0 configuration, where we have added a new folder called <JBOSS_HOME>/myconf to the classpath. Here is the pertinent bit of conf/jboss-service.xml : <server> <classpath codebase="${jboss.server.lib.url}" archives="*"/> <classpath codebase="${jboss.common.lib.url}" archives="*"/> <classpath codebase="myconf" archives="*"/> ... </server> The idea being that application-specific configuration files can go into <JBOSS_HOME>/myconf while JBoss-specific

Is there a Tomcat-like classloader that can be used standalone?

空扰寡人 提交于 2019-12-08 02:53:14
问题 I'm working with a Java sort-of-application-server (Smartfox) which can run multiple applications ("extensions") but has a very inconvenient classpath setup to go along with it, along with issues when trying to use SLF4J. To work around that I'd like to wrap my applications in their own classloaders. Such a containing classloader should be much like Tomcat's, in that it Can load classes from a directory containing JARs. Prefers classes from its own classpath over those from the parent Is

Explanation of class loading in an EAR for non-requested but dependent class

社会主义新天地 提交于 2019-12-08 00:51:43
问题 I'm trying to track down a problem I'm having in WAS 6.1 with AXIS 1 and Commons Logging. My EAR is set to parent last. In the ear is commons-logging, Axis and a client jar that uses Axis. The classes in the client jar are called from a WAR. The WAR calls the client, which calls the axis jar, which needs commons-logging. But it does not appear as if the EAR is loading commons-logging from itself. It looks like commons-logging is coming from WebSphere. Then another class in the WAR directly

EAR and WAR class loader

妖精的绣舞 提交于 2019-12-08 00:24:00
问题 I'm very confused about the JBoss class loader. Can any one describe in details how the class loader works, exactly? I only have to do one thing... If a WAR doesn't find a class with its own classloader, he delegates the search to its parent classloader which must be the EAR's. What changes should I have to do in my application for the above? Please reply as soon as possible. Thank you. 回答1: In continuation of our discussion in the comments, I noticed the following JBoss feature request.

I am getting an “exception in thread ”main“ java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver”

Deadly 提交于 2019-12-07 21:41:51
问题 I have added selenium-standalone.jar & selenium-java.jar but still I am getting the following exception when running the basic program, Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriver (wrong name: org/openqa/selenium/Webdriver) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass

How to preload classes in Java?

妖精的绣舞 提交于 2019-12-07 20:52:06
问题 The first opening of a new JInternalFrame in my Swing interface takes some time. According to the profiler, most of this time is spent in the Classloader.loadClass() method. I understand that it loads classes dynamically when needed and indeed the next time I open the same frame, it is much faster. This application has a login screen, and then a time with an empty desktoppane before the user opens one of those internal frames. I figure that since I have some "down time", I could use it to

Different behavior of ClassLoader.getSystemClassLoader().getResource() in servlet container and test environment

陌路散爱 提交于 2019-12-07 16:57:47
问题 I have a web application my requirement is to read some files and process it and persist the file content in database when the application starts. class MyUtil{ /** *Read the files */ public static void readFiles(){ File file = new File(ClassLoader.getSystemClassLoader().getResource("MyFile").toURI()); //NullPointerException // ClassLoader.getSystemClassLoader().getResource("MyFile") is giving null in servlet.init() method. if (file.isDirectory()) { //Read all the files and persist. } } }