Hi there,
Just developing a plugin which checks that the user has agreed to some T&Cs before using CS, I am stumbling over differen problems, which have been reported before but not really resolved. Let's start with the first one:
It is more or less the same as reported here: http://www.jivesoftware.com/jivespace/thread/42027
The stack trace is:
17:47:52,703 [Task Engine Worker 2] ERROR com.jivesoftware.base.plugin.PluginManager - com.jivesoftware.base.plugin.PluginConfigurationException: Exactly one plugin of class de.dlh.plugins.tac.TermsAndConditionsPlugin must be specified in spring.xml
com.jivesoftware.base.plugin.PluginException: com.jivesoftware.base.plugin.PluginConfigurationException: Exactly one plugin of class de.dlh.plugins.tac.TermsAndConditionsPlugin must be specified in spring.xml
at com.jivesoftware.base.plugin.PluginManagerImpl.loadPlugin(PluginManagerImpl.java:688)
at com.jivesoftware.base.plugin.PluginManagerImpl$1.run(PluginManagerImpl.java:198)
at com.jivesoftware.util.task.TaskEngine$TaskEngineWorker.run(TaskEngine.java:392)
Caused by: com.jivesoftware.base.plugin.PluginConfigurationException: Exactly one plugin of class de.dlh.plugins.tac.TermsAndConditionsPlugin must be specified in spring.xml
at com.jivesoftware.base.plugin.configurators.SpringConfigurator.configure(SpringConfigurator.java:52)
at com.jivesoftware.base.plugin.PluginManagerImpl.loadPlugin(PluginManagerImpl.java:640)
... 2 more
I have followed the instructions and tried to do "the same" as it is done within the feedblog plugin (which works so far and does not(!) throw this exception).
I have attached my spring.xml, the plugin.xml and the plugin class.
Also the complete plugin jar (which is not complete at all and contains some other stuff, too!), which should help to reproduce this locally, if the given XMLs are not enough.
Removing the class entry from the plugin.xml "works" so far, but this is quite annoying in my eyes, as doing "the same" as being told in the how-to should lead to success...
Thanks in advance
Detlev
Hey Detlev,
I spent the last 15-20 minutes or so debugging through this plugin but it appears to work correctly for me from the JAR that you've provided. I do not get the PluginManager error but I do see some unrelated database errors:
06:45:23,443 [Task Engine Worker 4] ERROR com.jivesoftware - upgrade.database.failure
org.postgresql.util.PSQLException: ERROR: syntax error at or near "("
Can you confirm that this plugin is not already installed or maybe there is some duplicae reference with this same name? If you can debug through this to see whats going on from your end, all of the loading is done in the SpringConfigurator:
if (!(plugin instanceof DummyPlugin)) {
String[] strings = ctx.getBeanFactory().getBeanNamesForType(plugin.getClass());
if (strings.length != 1) {
throw new PluginConfigurationException(String.format(
"Exactly one plugin of class %s must be specified in spring.xml",
plugin.getClass().getName()));
}
ctx.getBeanFactory().configureBean(metaData.getPlugin(), strings[0]);
}
Hope that helps.
-Todd
Hi Todd,
I have the problem that my local test env is not really debuggable (100% CPU "forever" when starting TC).
Anyhow, I have modified the class:
throw new PluginConfigurationException(String.format("Exactly one plugin of class %s must be specified in spring.xml, but there are: " + strings.length, [...]
And the result is as expected:
16:19:18,937 [Task Engine Worker 2] ERROR com.jivesoftware.base.plugin.PluginManager - Error loading plugin
com.jivesoftware.base.plugin.PluginConfigurationException: Exactly one plugin of class de.dlh.plugins.tac.TermsAndConditionsPlugin must be specified in spring.xml, but there are: 0
at com.jivesoftware.base.plugin.configurators.SpringConfigurator.configure(SpringConfigurator.java:37)
at com.jivesoftware.base.plugin.PluginManagerImpl.loadPlugin(PluginManagerImpl.java:640)
at com.jivesoftware.base.plugin.PluginManagerImpl$1.run(PluginManagerImpl.java:198)
at com.jivesoftware.util.task.TaskEngine$TaskEngineWorker.run(TaskEngine.java:392)
Also see the thread I have referred to, the same has been observed there!
Best regards
Detlev
PS: The DB error I don't have (but I'm using MySQL).
Hmm, that is very strange. This is not the same behavior that I am seeing locally. Are there any other errors related to this plugin outside of this one? Maybe something related to the loading of the plugin or spring.xml? From this error that you've posted its either not matching the name of the class correctly or the spring.xml in your plugin failed to load. I am leaning more towards the spring.xml not loading, but I am really not sure how this couldn't load.
-Todd
Hi Todd,
> that is very strange
That it seems to be... ;-)
> Are there any other errors related to this plugin outside of this one?
There is a classloading issue later, the real hard problem, see http://www.jivesoftware.com/jivespace/thread/46017 - but in the meantime I fear that that problem is just a consequence from this one here...
Nevertheless, there are no other errors before I am calling the corresponding struts action "checkTermsConds".
I have modified the Springs ClassUtils class, method isAssignable(Class lhsType, Class rhsType), which now prints out "HEY-HO" + some information about the classes and their classloaders. I have attached the full log of a server start (without calling the action; when calling the action, one can see that the interface of the manager class has a different classloader then the implementing class). You'll also see a raised log level for org.springframework.beans.factory.xml.
> its either not matching the name of the class correctly
This can be rules out, as you can see from plugin.xml and spring.xml which had been attached to the original message.
> or the spring.xml in your plugin failed to load
This can be ruled out, too (see attached log), but (also see referred thread): Maybe this depends on some kind of race condition.
Best regards
Detlev
Hey Detlev,
I followed up with some people internally to see if they had any ideas. They had mentioned that they ran into it before but they weren't sure exactly why it happened. However, they did find a way around it. You just need to do something like this:
1. Remove the <class>plugin</class> from your plugin.xml
2. Then define your plugin class like this:
public class TermsAndConditionsPlugin implements Plugin {
public TermsAndConditionsPlugin(TACManager tacManager) {
this.tacManager = tacManager;
this.init();
}
private TACManager tacManager;
public void setTacManager(TACManager tacManager) {
System.out.println("HEY-HO: tacManager has been set within TermsAndConditionsPlugin");
this.tacManager = tacManager;
}
public TermsAndConditionsPlugin() {
System.out.println("HEY-HO: TermsAndConditionsPlugin created by " + this.getClass().getClassLoader().toString());
}
public void init() {
// TODO Auto-generated method stub
}
public void destroy() {
// TODO Auto-generated method stub
}
}
Apparently the plugin constructor takes spring dependencies as parameters. Hope that helps!
-Todd
Hi Todd,
One additional info: It seems that already this issue is due to a classloading problem. I have extended the SpringConfiguration class:
if (!(plugin instanceof DummyPlugin)) {
BeanDefinition beanDef = ctx.getBeanFactory().getBeanDefinition("termsAndConditionsPlugin");
System.out.println("SPRING_CONFIGURATOR -- " + beanDef.getBeanClassName() + " LOADED BY " + beanDef.getClass().getClassLoader());
System.out.println("NOW LOOKING FOR -- " + ((Object) (plugin)).getClass().getName() + " LOADED BY " + ((Object) (plugin)).getClass().getClassLoader());
...
... and the outcome is, as expected / feared:
HEY-HO: TermsAndConditionsPlugin created by java.net.URLClassLoader@9d9155
SPRING_CONFIGURATOR -- de.dlh.plugins.tac.TermsAndConditionsPlugin LOADED BY WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@d70d7a
NOW LOOKING FOR -- de.dlh.plugins.tac.TermsAndConditionsPlugin LOADED BY java.net.URLClassLoader@9d9155
17:57:24,234 [Task Engine Worker 2] ERROR com.jivesoftware.base.plugin.PluginManager - Error loading plugin
com.jivesoftware.base.plugin.PluginConfigurationException: Exactly one plugin of class de.dlh.plugins.tac.TermsAndConditionsPlugin must be specified in spring.xml, but there are: 0
at com.jivesoftware.base.plugin.configurators.SpringConfigurator.configure(SpringConfigurator.java:41)
at com.jivesoftware.base.plugin.PluginManagerImpl.loadPlugin(PluginManagerImpl.java:640)
at com.jivesoftware.base.plugin.PluginManagerImpl$1.run(PluginManagerImpl.java:198)
at com.jivesoftware.util.task.TaskEngine$TaskEngineWorker.run(TaskEngine.java:392)
Best regards
Detlev
PS: At least, fixing this might bring good chances to fix the second one at the same time... :-|
Please let me know if the suggested approach above also solves the other issue. Thanks!
-Todd
Hi Todd,
Hm, we are running in circles. The "workaround" you provided has been given in the referred thread, too (and a bit more correct).
If you want the constructor to get used, you have to alter the spring.xml to
<bean id="termsAndConditionsPlugin" class="de.dlh.plugins.tac.TermsAndConditionsPlugin">
<constructor-arg>
<ref bean="tacManager"/>
</constructor-arg>
</bean>
instead of using the property tag (otherwise the default constructor gets used).
Nevertheless, I have done this, but the outcome is the same as if I just would delete the class entry from the plugin.xml and use the property tag. When calling the action, I get:
HEY-HO: lhsType = de.dlh.plugins.tac.db.TACManager -- rhsType = de.dlh.plugins.tac.db.TACManagerImpl
HEY-HO: lhsType loaded by: java.net.URLClassLoader@94de98
HEY-HO: rhsType loaded by: java.net.URLClassLoader@134c0a6
HEY-HO: lhsType.isAssignableFrom(rhsType): false
and the system error on the UI and the stack trace (provided in the other thread).
So, I don't think that this kind of workaround really helps in our situation, I fear that the root cause for both issues is a classloading issue, as said, and I hope that tracking this down also brings down the second one.
Best regards
Detlev
Hey Detlev,
This would almost certainly have to be an environmental (not code based) issue since I am not able to reproduce this issue on my local machine. Can you give me a little more information about your environment? OS, Database, App server, JVM version? I wonder if this might be a JVM bug or something odd like that since it seems to be a very isolated issue (only seen 3 people ever run into it). Hopefully we can get everything sorted out.
-Todd
Hi Todd,
> OS, Database, App server, JVM version?
WinXP Prof, MySQL 5.1, Tomcat 6.0.18, SUN JDK 1.6.0_13.
Best regards
Detlev
Thanks Detlev. I'll try to set up a similar environment to see if I can replicate this issue. I'll update you as soon as I have some more information.
-Todd
Hey Detlev,
The following block of code has been pointed out to me by one of our devs:
public void run() {
// waits until context is inialized.
while (!JiveApplication.isContextInitialized()) {
try {
Thread.sleep(500);
}
catch (InterruptedException e) {}
}
// Load plugins that need loaded
for (PluginDbBean bean : pluginBeans) {
File pluginDir = new File(pluginDirectory, bean.getName());
try {
loadPlugin(pluginDir, bean);
}
catch (PluginException e) {
log.error(e.getMessage(), e);
}
}
loadDevPlugins();
}
Basically, this will try to load all plugins from the database and then try to load any plugins specified with the pluginDirs option. This means that if the plugin already exists in the database then it would be possible for this to try and load the same plugin twice. Please try running this on a clean database (or just empty out the jivePlugin table). Let me know if that works. Thanks!
-Todd
Hey Detlev,
I think Will (from support) has figured out the real problem here. He was able to reproduce this issue on his Windows machine with the plugin you've provided. The issue is your plugin name has upper and lowercase letters which will not work (we lowercase the path names automatically). So try editing your plugin.xml and changing TermsAndConditions to termsandconditions and re-reploy the JAR. Let me know if that works. Thanks!
-Todd
Jive combines the most powerful features of collaboration software, community software,
social networking software & social media monitoring into the leading SBS solution.
© Copyright 2000–2010 Jive Software. All rights reserved.
915 SW Stark St., Suite 400, Portland, OR 97205
Sales: 877-495-3700 | General: 503-295-3700
Privacy Policy | Sitemap | Jobs | Contact Us