Reload Classes in JVM
Folks,
One of my java application is deployed on the server which I invoke through the batch file (Batch file not only execute my main file also set all class path etc).
It was working very much fine for last 2 to 3 months but what happened in this month is it this application start generating the reports twice and also some time it runs from old version class and sometime from new version.It seems to me something is related to JVM. Can I know how come I refresh the JVM or reload.
One more thing can you please temme the command which I should write in the batch file so that whenever batch file executes it first reload all class files.
your help will be appreciated.
Thanks
Shawn_Aslam wrote:
Okay I understand that when JVM starts it reload all the classes.
But in the class path only library files path is given not the class paths.I updated one class almost one month back and suddenly by the start of August JVM start using the old version in spite of the new. Its really strange to me. You have an impossible situation which means your assumptions are wrong. Which assumptions it is hard to say. But some examples.
1. Something reverted the code.
2. It has been running the old code all this time.
3. The class path changed when it restarted.
Today I have rename the classes to the sake of resolution. Can we manually restart or reload the JVM?Can you restart the VM? Persuming that you have permission then yes.
Similar Messages
-
Does loading too many classes into jvm slow down performance?
hi all,
does loading too many classes into jvm will slow down performance. Our application is CPU bound, if we use any framework we need to load all the classes related to that framework in JVM. Does this have any effect on the performance of the JVM.
thanks and regards,
akmaldoes loading many classes into jvm slow down performance.It will increase the time it takes for the JVM to load your application.
Our application is CPU boundThe time it takes the JVM to load your application is not likely to be an issue for you then. -
Reloading classes in WebLogic Server 6.1
Hello all,
We are developing applications for wlserver6.1 on JDK 1.3 and the development
proccess is slow due to the fact that every time that we modify a class (not servlets
or JSP´s) we have to restart the server o redeploy the application in order to
reload the new version of the class. I understand that this is because the JVM
does not support Hot Code Replace and the Server classloaders do not check for
changes in classes only in Servlets (we are running the server in development
mode).
Is there a work around for this? A custom classloader perhaps? Third party tools?
All replies welcome
Thanks
MaxThanks, that's very helpful.
In 7.0/8.1, you could use weblogic.Deployer to redeploy just the webapp
module without bouncing the rest of the app. In your common case of
changing classes which are only in the webapp, this would be very fast.
You might save yourself some time by just developing on 8.1. java
weblogic.Deployer -examples will show you how to redeploy just the
webapp. Assuming your app didn't use any new 8.1 features, then it
should run fine on 6.1 as well.
I don't honestly remember whether 6.1 offered this functionality or not.
weblogic.Deployer was not added until 7.0 so you would have to check
the weblogic.deploy command.
-- Rob
Max wrote:
To answer your questions...
1) Hardware: Pentium II, 512Mb RAM
2) Redeploy: From console by unmarking the deployed check for the webapp box applying
the changes and remarking the deployed checkbox. For this to work i must put all
my classes in web-inf i would prefer it if i could put my classes elsewhere on
the classpath. If there are other better ways to redeploy i would be gratefull
for any advice, the applications directory and weblogic.Deployer sound interesting,
is it worth me looking at these possibilities?
3) The application consists of:
- 1 web application with around 50 Servlets and 2500 JSPs
- 45 EJB´s
Unfortunately the application is not mine, i´ve been contracted to add a new module
to it and do not have control over the applications architecture. The elements
that i want to reload are typically Java classes that at the moment are inside
the web app. Ideally i´d like to be able to put them anywhere on the classpath
and reload them.
Hope that this info is of some interest to you, should need anything else let
me know
max
Rob Woollen <[email protected]> wrote:
Yes, 4 minutes is too long.
I actually own this problem for our next release so I'm pretty
interested to hear more about your situation.
In particular:
1) What hardware is this on?
2) How are you redeploying the application?
a) through the console
b) through the applications directory
c) weblogic.Deployer
d) wldeploy ant task
e) in your IDE (if so, which one?)
3) Can you give me more details on your application size? (How many
EJBs/webapps etc)
4) What are you typically changing during development? java classes,
ejb implementations, ejb interfaces, web content etc...
If you (or anyone else) wants to give this information privately, you
could email me by removing the please.noemail.com and replacing it with
bea.com
Anyway, in the current world, I usually suggest that people consider
breaking their app up into smaller sub-applications which will redeploy
faster. It's a bit of work and in no way ideal, but I don't have any
better answers, yet...
-- Rob
Max wrote:
It takes about 4 minutes to redeploy which is more or less the sameas restarting
the server. Its the only application deployed on the server but asapplications
go i think that its quite large.
max
Rob Woollen <[email protected]> wrote:
You should almost never need to restart a server during development.
However, you will need to redeploy your application to pick-up class
changes.
How slow is redeploying your application?
-- Rob
Max wrote:
Hello all,
We are developing applications for wlserver6.1 on JDK 1.3 and the
development
proccess is slow due to the fact that every time that we modify aclass
(not servlets
or JSP´s) we have to restart the server o redeploy the applicationin order to
reload the new version of the class. I understand that this is becausethe JVM
does not support Hot Code Replace and the Server classloaders do notcheck for
changes in classes only in Servlets (we are running the server in
development
mode).
Is there a work around for this? A custom classloader perhaps? Thirdparty tools?
All replies welcome
Thanks
Max -
How to reload class file for java objects in CF MX7
I'm trying to create a simple java object for use in a CFML
page. According to the topic "About ColdFusion and Java objects" in
the CF developer's guide, I can compile my java module and put the
.class file in the CFusionMX7/wwwroot/WEB-INF/classes directory and
it'll be dynamically reloaded any time CF sees a new .class file
there. But the dynamic reload isn't happening; I have to restart
the CF server to get it to pick up a new version.
I don't believe this directory is in the "general JVM
classpath"; I don't find "classes" in the Java Class Path in the CF
Administrator's System Information page. And I have all the caching
options turned off on the "Server Settings > Caching" page, if
that has any bearing on it.
Are there any known issues around this dynamic reload
capability, or maybe a more definitive way to make sure the
WEB-INF/classes directory isn't in the classpath?
Thanks,
JamesYes, I understand. But if I'm reading it correctly, what
you're saying seems to contradict the documentation
http://livedocs.adobe.com/coldfusion/7/htmldocs/00001561.htm
ColdFusion dynamically loads classes that are either .class
files in the web_root/WEB-INF/classes directory or in JAR files in
the web_root/WEB-INF/lib directory. ColdFusion checks the time
stamp on the file when it creates an object that is defined in
either directory, even when the class is already in memory. If the
file that contains the class is newer than the class in memory,
ColdFusion loads the class from that directory.
http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_18228&sliceId=1
Dynamic class reloading for Java servlets classes and
forcfobject (sic) Java classes is disabled by default in
ColdFusion MX. To enable dynamic class reloading, do the following:
Also, I seem to recall that setting worked in a prior
version. Though I would have to test it again on another machine to
be certain. -
Reloading classes on the fly?
Is there a convenient way to reload changed classes without shutting down and restarting the cluster nodes? I would like to just do cache.clear() then reload the class files and begin populating the cache with the new objects.
Thanks,
AndrewThat depends on how the classes are loaded.
You probably used the CLASSPATH environment variable to load classes into classpath.
In this case you have to restart your nodes in order for new classes to be loaded by the JVM.
To my knowledge, Coherence does not provide any separate classloading features as, for example, an application server does
where each deployed application gets its own classloader on top of the system classloader defined by CLASSPATH.
In order to provide this same functionality you have to write a separate classloader that loads the classes of the types
you load in the cache. In this case the coherence.jar etcetera are in the system classloader (CLASSPATH), while your
application classes are loaded by a custom classloader.
ConfigurablePofContext is ClassLoaderAware (http://download.oracle.com/docs/cd/E18686_01/coh.37/e18683/com/tangosol/io/ClassLoaderAware.html)
From the ConfigurablePofContext API (http://download.oracle.com/docs/cd/E18686_01/coh.37/e18683/com/tangosol/io/pof/ConfigurablePofContext.html):
"It is conceivable that the ConfigurablePofContext is loaded by the system ClassLoader (or some other relatively global ClassLoader), while the objects
deserialized by the PofContext are loaded by an application-specific ClassLoader, such as is typical within an application server. The ConfigurablePofContext
is designed to load the configuration, the POF-able object classes and the PofSerializer classes from within a specified ClassLoader context, and to pass
the ClassLoader information on to the PofSerializer instances, just in case they are not loaded from within the application's ClassLoader context.
In other words, the ConfigurablePofContext, its configuration, the PofSerializer classes and the POF-able classes can all be loaded by the same ClassLoader,
or they can all be loaded by different ClassLoaders, so long as the configuration, the POF-able classes and the PofSerializer classes can be loaded by either
the specified ClassLoader or by the ClassLoader that loaded the ConfigurablePofContext itself."
The problem is (with most classloading) how to unload the classes that are referenced in a runtime environment. This usually means, in the case of an
application server, to delete a certain deployment and redeploy again.
Hope it makes a little sense.
An example of a custom classloader and same more background on classloading can be found here: http://middlewaremagic.com/weblogic/?p=6725 -
Working with Active Classes on JVM
I would like to see an example of where one class with a simple data field, such as an integer, can be read in through the JVM and the value of that integer can be determined in a different class with no references between the two classes. The classes cannot communicate at all. The class getting the value must determine the value by accessing the data stored in the JVM heap or memory area.
Thanks for the help.I would like to see an example of where one class with
a simple data field, such as an integer, can be read
in through the JVM and the value of that integer can
be determined in a different class with no references
between the two classes. The classes cannot
communicate at all. The class getting the value must
determine the value by accessing the data stored in
the JVM heap or memory area.Nothing between the two classes?
Simple. Create a third class and it refers to the first two.
Or perhaps use the debugging api (which in a single VM means that you will need to use JNI.) -
Hi,
I'm working with two spark solaris 9 servers in cluster running sun one 6.1 web servers. The servelets/jsp applications have problems reloading a changed class. The java applications are in a storage engine connected by nfs to the servers. We Ussually work in the master server that it's similar to the slave in its java and webserver configuration. there isn't any difference beetwen the servers in the java applications enviroment. But always we compile in the master server. The changed class loads correctly and quickly (few seconds) in the master server but the slave fails to load it. For the second server we must reload all the application trought the administration server, "load configuration files".
In the server log file i can see the following lines:
WebModule[dataj_dev]: WEB2680: Exception starting filter ControllerFilter java.lang.ClassFormatError: com/huji/data/system/RegularDataSystem (Extra bytes at the end of the class file) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1717) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:983) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1431) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1301) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at com.huji.data.ControllerFilter.class$(ControllerFilter.java:34) at com.huji.data.ControllerFilter.<clinit>(ControllerFilter.java:34) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:274) at java.lang.Class.newInstance0(Class.java:308) at java.lang.Class.newInstance(Class.java:261) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:261) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:322) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:120) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3271) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3747) at com.iplanet.ias.web.WebModule.start(WebModule.java:251) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133) at org.apache.catalina.core.StandardHost.start(StandardHost.java:652) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1133) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:355) at org.apache.catalina.startup.Embedded.start(Embedded.java:995) at com.iplanet.ias.web.WebContainer.start(WebContainer.java:431) at com.iplanet.ias.web.WebContainer.startInstance(WebContainer.java:500) at com.iplanet.ias.server.J2EERunner.confPostInit(J2EERunner.java:161) [03/Sep/2007:14:41:13] failure (11314): WebModule[dataj_dev]: WEB2705: Context startup failed due to previous errors
what's wrong? why it happens?The servers don't share the same instance dir, each webserver is locally installed. They only share the content directory: java classes , html files and cgi programs. Anyway may be that the secondary server has problem loading the class from the storage. I changed the parameter dynamicreloadinterval to make a bigest delay in this server. Before this change almost in the same time both the servers tryed to load the same class. I didn't test , i hope it works.
The issue is that if this true, i should see the same fenomena with other files types, not only with classes and it doesn't happen. -
Weblogic doesn't reload classes
Hi,
I'm working with weblogic7.0 sp2 on Windows NT... When I put the updated classes
into the classes directory under WEB-INF... The latest classes are not getting
loaded until I restart the server... I've set the "set STARTMODE=false" ... But,
it works fine in windows 2000 server...
--Thanxs\sureshTry setting ProductionMode=false
as startparameter.
This should start WLS in Development Mode.
If docu is right and everything works fine
WLS should reload changed wars.
If you use exploded apps.
Try creating a File REDEPLOY and touch it to let WLS check for new class-files
Greetings
fear
Guangjun Ma <[email protected]> wrote:
>Mr/Ms Dimitri,
>you wrote: when servlet's .class files in WEB-INF/classes change, servlets
>are reloaded.
>--Could you tell me what should I do to make it work? (sorry I'm new
>to WL6.1)
>
>BTW. I am playing WL6.1 with Jarkata Struts.
-
I have wrote a container for servlet, now I need to reload a servlet from a my container.
to do this, I define:
String nameSrv = "myservlet";
URL[] urlsToLoadFrom = new URL[]{new URL("file:"+ System.getProperty("user.dir") + System.getProperty("file.separator") + "servlets"+System.getProperty("file.separator"))};
HttpServlet sv = (HttpServlet)URLClassLoader.newInstance(urlsToLoadFrom).loadClass(nameSrv).newInstance();
But, if i modify my "myservlet.java" and compile it, while my container is running, it load the old servlet and not the new.
Now, if I reload the container (stop/start JVM) it load the latest version of servlet.
How can I load the latest version of servlet, without stop and start the server (i.e. my servlet conteiner)?
thanksI have wrote a container for servlet, now I need to
reload a servlet from a my container.
to do this, I define:
String nameSrv = "myservlet";
URL[] urlsToLoadFrom = new URL[]{new URL("file:"+
System.getProperty("user.dir") +
System.getProperty("file.separator") +
"servlets"+System.getProperty("file.separator"))};
HttpServlet sv =
(HttpServlet)URLClassLoader.newInstance(urlsToLoadFrom)
loadClass(nameSrv).newInstance();
But, if i modify my "myservlet.java" and compile it,
while my container is running, it load the old servlet
and not the new.
Now, if I reload the container (stop/start JVM) it
load the latest version of servlet.
How can I load the latest version of servlet, without
stop and start the server (i.e. my servlet
conteiner)?
thanks1. Before you modify "myservlet.java"Load myservlet using your own classloader.
2. After you modify and recompile "myservlet.java", nuke the classloader that you used to load myservlet.
3. Create a new classloader that you'll use to reload myservlet.
PS: myservlet must be outside the java classpath, otherwize, cannot reload it. -
InvalidClassException: JComponent; local class incompatible - JVM Version?
Iam having trouble deserializing some old objects.
My object header is
public class SoundMatrix extends AbstractTableModel implements Serializable
So i happend to save some swing components :(
Now i got the problem of deserializing them again. What can i do to recover the data?
The serialVersionUID is the same, none has changed.
java.io.InvalidClassException: javax.swing.JComponent; local class incompatible: stream classdesc serialVersionUID = -2514362798440941654, local class serialVersionUID = -1030230214076481435
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at javax.swing.event.EventListenerList.readObject(EventListenerList.java:255)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at dk.tigermedia.Prog.main(Prog.java:119)
I guess its a JVM Versioning problem, the version may have changed over time, the application have been used.
I know the problem is, that i have serialized Swing objects- the docs even warn against this. Great :)
Can i see which version was used to make the files? Can take control over the deserializing process?
Tryed overwriting the readObject - but it dont seem to get that far.
Any help is much appreciated. Thanks.Update versions don't matter, just 1.3, 1.4, 1.5 etc.
You don't need to recompile except backwards, e.g. if you're using JDK 1.3 you need binaries produced by 1.3 or with -target 1.3. But I'd advocate writing a new mini application for this conversion task, using 1.3 or whatever the JDK version actually was when the data was serialized.
You also need to inform management about this debacle and the reasons for it. The warnings about serialization-incompatibility of Swing classes have been right there in the Javadoc since the beginning. No competent IT professional should have perpetrated this act. Make sure it doesn't happen again. -
Hi
Im running Tomcat as my localhoost when I develop JSP-solutions.
I have also recently started to write servlets which I think is a nice way to work except for one thing, when I recompile my classes I have to restart Tomcat to see the change. But there must be a way to set Tomcat to reload the classes when I hit the update button or Ctrl-F5 in my browser. Can someone help me with this?
Thanks in advance / Regards PGHave a look here; http://www.moreservlets.com/Using-Tomcat-4.html
Under section "configure tomcat", have a look the step No.5
Hope it helps. Gook luck. -
Hello,
Tomcat reloads automatically the classes when you modify them.
With J2EE, when I modify a class I have to redeploy the application to reload my new classes or my modified classes.
Somebody knows if we can reload automatically classes in J2EE ???
Thanksto redeploy WebApp classes without restarting tomcat...
- copy classes to [TOMCAT_HOME]\webapps\{YourWebApp}\WEB-INF\classes
- go to Tomcat Web Application Manager (http://host:8080/manager/html)
- select 'Reload' for your webapp
This will bin the old WebApp classloader and create a new one, using the new class versions.
Simply copying classes to the webapps directory doesn't seem to trigger this (and the new classes can't be reloaded into the existing ClassLoader).
(Win XP Pro / tomcat 4.1.18) -
How to reload classes on redeploy
I want to reload the classes of an EJB every time I redeploy it without restart the server (I use JBoss).
well actually I use two different versions of JBoss.
- At work I use Jboss 4.2.2GA, using hot deployment (files are deployed to a directory app.ear in stead of deploying an actual ear file). For this type of deployment to work, the application.xml file MUST be modified before the server will see that the application is changed
- at home I use JBoss 5.01GA and just deploy the ear file from netbeans, which works perfectly.
From what you say, I gather you are deploying just the EJB jar, not an EAR. Perhaps you should try it like that.
Also: I believe there were many problems with JBoss 5.0 that were fixed in JBoss 5.01, so I would verify the version that your host is running. -
Reloading classes in classloader
Dear All,
I want to reload the class in classloader. The classloader is not systemclassloader. Can any one help me with example to explain how to reload the class from custom classloader or give me the link where the explanation is.
regards
Saravanan V.SYou can't load a class that's already been loaded with the same classloader but you could create a new instance of your classloader and then reload the class.
-
My problem is to reload a class with the same name but
with different definitions. This is necessary if you
hove long running servers and want to replace with new class definition
without restarting Java Runtime. Old class definition
hopefully garbage collected afterwards. Anyone has information on this?Read about class loaders and take a look if you have the time for it at the source code for Tomcat or Jetty, which are two small servlet containers. They use a class loader hierarchy to enable run-time reloading.
There's a little bit in here:
http://java.sun.com/products/jndi/tutorial/beyond/misc/classloader.html
There some more in the security specs:
http://java.sun.com/j2se/1.4.2/docs/guide/security/spec/security-spec.doc5.html
This is actuall a product, but uses the same technology:
http://docs.sun.com/source/816-5777-10/jpgapxre.htm
A javaworld article:
http://www.javaworld.com/javaworld/javaqa/2003-06/01-qa-0606-load.html
An easy (and not so correct) way to look at the class loader is that it performs a chroot combined with the rebinding of several folders of the original filesystem.
Maybe you are looking for
-
ORA-01722 when opening a package in SQL Developer 1.2 with oracle 9iR1
Hi, I use SQL Developer with Oracle Database 9i release 1. When I open a package in SQL Developer 1.2 (or 1.5) for editing, I receive the error ORA-01722. The package successfully opens but this message, which pops everytime, is really annoying. I mo
-
Here's my question on Stackoverflow. http://stackoverflow.com/questions/13223428/how-to-symlink-vendor-libraries-in-dw-it-doesn t-consider-that-a-library-is-in And here I duplicate it. Please see on Stackoverflow because I'm afraid I'll not be able t
-
No accessibility for screen readers
I have a client who is blind and uses JAWS screen reader to access computer information. Several E-books were purchased and downloaded (ebooks.com) and it was found that they can not be accessed by JAWS to read the content as they are in PDF "content
-
Is it true you can't edit text in PS once you've saved it ?
I just spent an hour on the phone with tech support in India and the bottom line was: u can't save text in PS and go back and edit it once you saved it. This doesn't make any sense. They were adamant. The problem I'm having is that a portion of my sa
-
Hi Can someone advice me if I can move my SCCM 2012 R2 SQL Databases (1 CAS and 2 Primary Site Server DB's) having version SQL 2008 R2 to SQL 2012? As per this blog, looks like we can....Do I need to take any additional checks? http://blogs.technet.c