I am working on a webapp that is deployed in Weblogic. After a few re-deployments PermGen ran out of space so I had to conclude that the webapp has a class loader leak...
I am using Yourkit to investigate that leak, but find myself stuck as I don't even know which class loader is leaking: when I do a memory dump and open it, Yourkit shows me dozens (more exactly: 289) of class loader instances. From the name I can guess that some of them are not the ones, but that still leaves many possibilities.
I tried to compare the list of class loaders before / after using the application (is it a valid approach?), but it does not help because most class loaders are instances of the same couple of classes, so I don't know which instance is the one I am interested in.
The class loaders classes reported by Yourkit are:
sun.misc.Launcher$AppClassLoader
weblogic.utils.classloaders.GenericClassLoader
weblogic.utils.classloaders.ChangeAwareClassLoader
java.net.URLClassLoader sun.misc.Launcher$ExtClassLoader
weblogic.servlet.jsp.JspClassLoader
weblogic.diagnostics.query.QueryCompiler
sun.reflect.DelegatingClassLoader
javax.management.remote.rmi.NoCallStackClassLoader
If you know already which of these is used by Weblogic to load the classes of a webapp, that would already help as I did not find it in Weblogic documentation.
And can anyone suggest a methodology to find the particular class loader instance?
I finally resorted to look at the list of loaded classes for each instance of GenericClassLoader and ChangeAwareClassLoader (as they seemed to be the likeliest ones) and checked if they had my own classes (filtering on package).
The webapp class loader is an instance of ChangeAwareClassLoader.
Related
I have two Orchard Modules.
Both have implementations of IAppSettings , which is defined in an external dll, and referenced in the modules via nuget package (So I cannot use IDependency ).
I wire these up using an Autofac Module class in each module.
Unfortunately this leads to "last registration wins" and both modules will use the last registered implementation, even though the "expected" result would be that each uses their own.
To be clear, each module is developed by a separate team, who don't co-ordinate with each other, but do use the same guidelines for module creation. The example above is just one instance of this occurring, but it is fair to assume there would be more.
How might I go about ensuring that each team can register their own dependencies for their modules, without constantly having to check with the authors of other modules?
There is one Autofac container per tenant, not per (Orchard) modules. You see the implications of this.
However this couldn't be much differently since interaction between modules would be seriously hindered if dependencies would be scoped to extensions.
Also one of the points of DI is that you can override the implementation: this is also desired here, since if you implement a dependency in Module A, then also in Module B (where Module B depends on Module A) then Module B can override the default implementation. This is a good thing.
Instead of wanting to require specific implementations for your interfaces what kind of defeats DI you could implement the strategy pattern for example. But if you tell more details I could help more.
I've been creating a couple of classes (in different modules) for puppet. Both, separately, require maven. So both classes have something like the following:
class { "maven::maven":
version => "3.0.5"
}
(using the https://forge.puppetlabs.com/maestrodev/maven module from puppet forge)
But, if I have one node that has both of my classes, puppet complains because class 'maven::maven' is declared twice. I feel like each of my classes should be free to declare all of the things it needs. If a node has more than one class both of which require maven, then I don't see the problem.
So, my question is: was the author of that maven module wrong to use a class, should he have used a define instead? (because you can use/call/whatever a define multiple times). It appears that if he had used a define I would be able to have the block of code as many times as I like, so if he was right to use a class, why?
Thanks.
I think the rationale behind this is best explained in John Arundel's Puppet 3 Beginner's Guide:
So if you're wondering which to use, consider:
Will you need to have multiple instances of this on the same node
(for example, a website)? If so, use a definition.
Could this
cause conflicts with other instances of the same thing on this node
(for example, a web server)? If so, use a class.
If you're passing in parameters to a class, there is a possibility of a conflict, the problem being that it is not clear which sets of parameters will get used.
If your first module required maven with 3.0.5 but your second module required maven with 3.0.6, puppet would not know which one to use.
The puppet module, in making it a class and not a resource/defined type, does not handle the resolution as well, because it was probably intended for a single install.
Puppet currently only supports re-using class declarations without parameters, ie. include maven::maven.
Finally, declaring dependencies on other modules in your own module is a tricky thing, that I do not know how to fully resolve yet.
Initial info: I have a groovy app (let's call it Runner) which is capable of running anything implementing certain interface (let's call it Runnable). And I have a pool of Runnables (groovy scripts) which should be visible to this app at the init stage and which app will call (through the interface and passing an object as a param).
Task: What I need is a way to load and call all the Runnables from the Runner.
Requirements: It's tricky, as scripts may not follow certain package structure and can be placed on the same machine as Runner but virtually in any place. They can also be named differently (open discussion for mandatory java alike naming: class name == file name) and can be skipped for now (though if there's gonna be advice on that it's cool!).
NOTES: I imagine it possible through having a config file in which scripts are configured (absolute path is provided) and to load them using this stuff and either cast Object to Runnable interface and trigger what I need or to invokeMethod(...). But have no idea if it can be done easier (there should be a way, cause it looks all too clumsy). I also cant think of a way to handle file naming issue and multiple classes in one file issue.
P.S.: Such long description might cause misunderstanding so please comment on vague parts.
I think you need to know all classes implementing an interface. Find Java classes implementing an interface may be of interest to you.
The option to have a config file in which script's absolute paths are written is good and proved to be a working solution. You'll have to deal with class loading of whatever is not visible in the app class loader. In particular you'll have to deal with annotation based POJO serialization problems. Singleton of Runnable loader is a good practice.
I've been having a frustrating time trying to sort out the logging in my project. In particular, one of the 3rd party libraries we use had one class, com.foo.bar.baz.java, that ignored any configuration in the properties file for the com.foo.bar package, instead following the application-wide properties.
Eventually using %c in the pattern layout I learned that Log4J was logging it as Windows rather than its package.
What could be causing this? It's proving remarkably Google-proof.
Don't forget that while the use of the fully qualified name of the class is the usual convention, it's not a requirement!
The author's quite at liberty to use whatever string they want as the Logger name and it sounds as if in this case, they've gone for a component based name.
There could be a lot of things causing it. Can you post your log configuration file? Do you have a gui project? Are you (or the 3rd party library) attempting to log to gui components?
Are you able to view the log4j configuration files of your 3rd party library?
To address your question of what could be causing this, on the surface, it sounds like they have created a custom logging implementation that is overriding your settings. There are lots of ways to achieve that.
For example, our application at work runs on Tomcat and there's a <logging> section in the server-config.xml file that allows one to specify a custom logging target for the server.
As another example, I've been bitten dozens of times by rogue commons-logging.properties files which can change the entire functionality of all logging, application wide, just by modifying a few properties. Further, those files specify a priority flag and if any property file is found on the classpath with a higher priority than the one in your project, it takes precedence!
Overall, there are lots of potential problems here. To be of more assistance, I would need a bit more information.
Is there any tool to quickly create RPC classes for GWT that extends RemoteService, the Async version and the RemoteServiceServlet derived class.
The only input should be some functions list and all the wrapper code should be generated.
I hope you got my question.
The Gwt Plugin for eclipse takes care of a lot of the boiler-plate code, including those that you have mentioned.
http://code.google.com/eclipse