[izpack-users] ClassCastException with custom listeners

Steve Dodge steve at robododge.com
Sat Jun 2 00:38:09 CEST 2007


Hello Klaus,

Your response has been very helpful.  I my environment, I have IzPack  
compilation integrated with Maven.  This configuration forces me to  
use the standalone compiler.    I was able to overcome the  
ClassCastExeption by creating VelocityInstallerListerner.jar and  
VelocityCompilerListener.jar and adding them to the standalone- 
compiler.jar in /bin/customActions/

There is one interesting thing I noticed during compilation now.  I  
see a message stating that the VelocityInstallerListener.jar is being  
added.  But I don't see a similar message for the compilerListener.   
I'm assuming this is because the IzPack compiler just uses the  
compilerListner during compile time and its done, no need to add  
it.   Taking that  observation one step further, it becomes apparent  
that using the "jar" attribute on the listener configuration doesn't  
distinguish between Compiler vs. Installer listeners, thus it adds  
both to the collection of installer listeners, resulting in a  
ClassCast later on.  It would be much better if the functionality  
worked properly when using the "jar" attribute.  This is better  
because modifying the contents of the standalone-compiler.jar is not  
a portable approach.

Thanks for your help,
Steve




On May 24, 2007, at 3:28 AM, Bartz, Klaus wrote:

> Hi Steve,
> the simplest way to create custom actions is to add your listener
> to the ant script of IzPack (%IZ_HOME%\src\build.xml).
> See target build.listeners.
>
> There is a name convention for listener. Rename your listener to
> CompileListener -> VelocityCompilerListener
> VelocityListener -> VelocityInstallerListener
> and may be the VelocityUninstallerListener
>
> The CompilerListener should only exist at compile time, not at
> install time. In the moment I do not know why it is active in your
> installation.
> Passive is clear because you add the classes to your install.jar (see
> below).
> CompilerListener.class is contained in the standalone compiler.
>
> Do not add panel or custom action jars with <jar> in install.xml, else
> put the jar files into the standalone compiler, or into the IzPack
> installation
> if you use the "normal" compiler. Both in the sub dir bin 
> \customActions
> (bin\panels for panels). If you use the <jar> element, you put the
> contents of
> the jar into the install.jar, not the jar file self into the compiler
> (where
> a compiler listener have to be).
> May be it works also with the attribute "jar" of element "listener". I
> never
> used it because I never need it.
>
> Try the packaging ("compile") with the "normal" compiler.
>
> If you use build.xml, ervery listener will be packed in a jar file.
> Be aware that you have to declare all needed classes in the ant call;
> may be see the tag
> <build-installer-listener name="RegistryInstallerListener">
>
> Do not add so much jars into your install.xml. I think you need
> <jar src="lib/ant-1.6.5.jar"/>
> <jar src="lib/ant-launcher-1.6.5.jar"/>
> <jar src="lib/velocity-1.5.jar"/>
>
> and not more.
>
> Cheers
>
> Klaus
>
>> -----Original Message-----
>> From: izpack-users-bounces at lists.berlios.de
>> [mailto:izpack-users-bounces at lists.berlios.de] On Behalf Of
>> Steve Dodge
>> Sent: Thursday, May 24, 2007 4:41 AM
>> To: izpack-users at lists.berlios.de
>> Subject: Re: [izpack-users] ClassCastException with custom listeners
>>
>>
>> Hello,
>>
>> I'm thinking that my explanation is too complicated.  Let me
>> simplify.  I've created a compiler listener and installer listener.
>> I've added those to my install.xml.  Since I'm using the standalone-
>> compiler, I set  the "jar" attribute.  The compiler listener runs as
>> expected, but when the installer is running, it gets a
>> ClassCastException because my compiler listener is
>> incorrectly placed
>> in the collection of InstallerListener objects.
>>
>> Thanks,
>> Steve
>>
>>
>>
>> On May 21, 2007, at 10:40 AM, Steve Dodge wrote:
>>
>>> I've built a compile listener and an installer listener.  Using
>>> IzPack 3.10.1.   The compile listener added a filename to the of a
>>> Velocity template to the additionalData map.  The Installer
>> listener
>>> checks during afterFile() if the name of the file matches a
>> Velocity
>>> template, and applies the template if so.  I am also using the
>>> standalone-compiler.jar. My install.xml has the following.
>>>
>>>    <listeners>
>>>     <listener
>>>        compiler="nm.trw.utils.listener.CompileListener"
>>>        installer="nm.trw.utils.listener.VelocityListener"
>>>        jar="lib/tekPackListeners.jar"
>>>        />
>>>
>>>     <listener installer="AntActionInstallerListener"
>>>                uninstaller="AntActionUninstallerListener"/>
>>>     </listeners>
>>>
>>> Using debug output, I verify the compile listener is being called
>>> correctly during compile time as it searches for <addititionalData>
>>> tags within the <fileset> and parses the data correctly. During
>>> install, when the install panel is showing the progress
>> bar, I get the
>>> following exception:
>>>
>>> java.lang.ClassCastException: nm.trw.utils.listener.CompileListener
>>>          at com.izforge.izpack.installer.Unpacker.getCustomActions
>>> (Unpacker.java:1139)
>>>          at com.izforge.izpack.installer.Unpacker.run(Unpacker.java:
>>> 295)
>>>          at java.lang.Thread.run(Thread.java:613)
>>>
>>> Looking at the code for Unpacker, it seems the CompileListener was
>>> improperly placed in the collection of InstallerListeners, thus
>>> ClassCastException.
>>>
>>> Here are the <jars> that I had to add to make it work.
>>> <jar src="lib/tekPackListeners.jar"/>
>>> <jar src="lib/izevent-3.10.1.jar"/>
>>> <jar src="lib/compiler-3.10.1.jar"/><!-- this one has to be here,
>>> izevent isn't enough,  otherwise ClassNotFoundException for
>>> CompilerListener interface <jar src="lib/ant-1.6.5.jar"/>
>>> <jar src="lib/ant-launcher-1.6.5.jar"/>
>>> <jar src="lib/velocity-1.5.jar"/>
>>>
>>> I think I'm missing something in the installation here.
>>>
>>> Thanks,
>>> Steve
>>>
>>>
>>>
>>>
>>>
>>>
>>> Am I missing something in the setup here?  I cannot figure out how
>>> CompileListener makes it way into the
>>>
>>>
>>>
>>> _______________________________________________
>>> izpack-users mailing list
>>> izpack-users at lists.berlios.de
>>> https://lists.berlios.de/mailman/listinfo/izpack-users
>>
>> _______________________________________________
>> izpack-users mailing list
>> izpack-users at lists.berlios.de
>> https://lists.berlios.de/mailman/listinfo/izpack-users
>>
> _______________________________________________
> izpack-users mailing list
> izpack-users at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/izpack-users




More information about the izpack-users mailing list