-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 All,
On 2/4/20 3:33 PM, Christopher Schultz wrote: > I just upgraded an application from commons-beanutils-1.9.3 to > commons-beanutils-1.9.4 that is using Velocity 1.7 and Tools 2.0 > and I'm getting this error on startup: > > Caused by: org.apache.velocity.tools.config.NullKeyException: Key > is null for tool whose class is 'null' at > org.apache.velocity.tools.config.ToolConfiguration.validate(ToolConfig ur > > ation.java:348) I think I've figured this out. The ToolConfiguration class has two sets of properties: public void setClass(Class); // Write-only public void getClassname(String); // Write public String getClassname(); // Read In my tools.xml, I had the following XML: <tools> <toolbox scope="application"> <tool class="org.apache.velocity.tools.generic.AlternatorTool" /> [...] </toolbox> </tools> In commons-beanutils up through 1.9.3, it would happily convert the "class" XML attribute into an instance of java.lang.Class representing the Class named in the string, and call setClass(Class) which ... just sets the class name: public void setClass(Class clazz) { setClassname(clazz.getName()); } In commons-beanutils-1.9.4, it doesn't want to allow you to set a Class property anymore. I didn't follow all the code in commons-beanutils all the way down, but I was able to finally see that it wasn't finding "class" as a settable property on the ToolConfiguration class for whatever reason (probably a blacklist of property names). The obvious solution is just to use the "classname" attribute instead of the "class" attribute and everything is fine: <tools> <toolbox scope="application"> <tool classname="org.apache.velocity.tools.generic.AlternatorTool" / > [...] </toolbox> </tools> And now I get what I'm expecting: FactoryConfiguration from 4 sources with 2 toolboxes: Toolbox 'application' with 1 properties [scope -auto-> application; ] and 15 tools: Tool 'alternator' => org.apache.velocity.tools.generic.AlternatorTool with 1 properties [classname -auto-> org.apache.velocity.tools.generic.AlternatorTool; ] [...] I hope that helps someone else with this same problem, because I was seriously worried about what I was going to do, here :) I'm going to post a message to the users@ list summarizing this just in case it happens to anyone else. - -chris -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl46/18ACgkQHPApP6U8 pFggDBAAswWW93jo2wV895n/K6uGIlYIQLojgsvUs7/OMUOy2uElaQvlTQqBdLwJ JVue4eEDqbVSKXMPW73Jwisq44YvltiPcNFnQCxJzUKnVZDborvmgLgv3puIeD+y yx16iBL1QUQ5z0aSE7K9TxhLpWpgp5N0/CmQonbGzrIkAnbCimZnuxrUrMKjQ2Ip /oUCrdKKbypjrSbqVwR1K24HoGcA9S+pPPTAaWUEbrgFq5GpbzWFhTwOVinBWa87 8nWSqbE2ilIjPKvWH2IvLCTB59raPAywYp3RBVI2TUaBWWfO94LFuhdI3AgmRgde p42I0ms7Q4fbAAUraHkKqKjaL2F39UcnMXhskqqHrjf08B6YFecto01eOhWuySDG /L22MTp6Hy7W15rcPS5mewU2YaM5p/PXu3NzyiQGqArQ81BaZq31Wwz9kagNneLu 0PNVQWjOeQ/k0mtSuStk/Sc2uYIAhsFWU3B6BnrapomrL474g+AN8rFpFqH6lsOo RQHDBnbcXAx2hOq7VjEUj2HL2PqIYZIsD9c+JZ6k2FdQDeRr0702atHHfgDE9VVo QAaC148exVl3SHgsuLQXVViQSMWfuPqWLiu6eThRnox3HEs/VDqGJEi+DQ5icmP6 dvNlmfdowwT1jrAdhPAbuLgYS18zPofOaLBOUbMV9dCQePf+oVk= =8z81 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org