[izpack-user] About Rollback of Installation

130 views
Skip to first unread message

jyoti gore

unread,
Apr 13, 2010, 3:20:35 AM4/13/10
to us...@izpack.codehaus.org
Hello,
I am searching to rollback my installation after getting some error while running executable file.
 
 
Thanks,
Jyo
 
 
 

René Krell

unread,
Apr 14, 2010, 4:10:21 AM4/14/10
to us...@izpack.codehaus.org
Hi Jyo,

For rollback, you get to mention a couple of things:
- recover files you copied over "file", "singlefile", "fileset"
- recover system files you somehow touched by a script from the installation
(for instance using patching on system config files)
- re-register or unregister system services (Unix + Windows)
- recover registry entries (Windows)
- recover a database which might be also elsewhere on another server

It is important to know what in particular you want to recover and what your
application requires to give a more concrete answer.

With the current release, you can for instance add an Ant installation
listener and implement this with an additional Ant script given as resource to
the installation. If you know a little bit of Ant, this should be easy and you
should be able to to any combination of the above variants. In this case, you
might try start your executable from the Ant script with order afterpacks or
afterpack, putting it into a try-catch (antcontrib) block and do the rollback
actions in the catch part.
There is also an BSF scripting installer and uninstaller listener which you
can use to include rollback scripts.
See http://izpack.org/documentation/custom-actions.html

In future, for IzPack 5.0 there will be an additional possibility to
automatically rename files according to a globmapper pattern with the
"renameTo" attribute for the "file", "singlefile" and "fileset" elements,
which you can give a certain prefix or suffix. This will it make easier to
recover actually overwritten files. But this is still in incubation phase.

Rene

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


jyoti gore

unread,
Apr 14, 2010, 5:04:25 AM4/14/10
to us...@izpack.codehaus.org
Hello Rene,
I am installing my java application as follows
- all files and folders are copied to the given Installaton Path.
- In install.xml file executable tag of pack is as follows to execute install.bat:

<

packs><pack>

.....<executable os="windows" keep="true" stage="postinstall" failure="abort"   targetfile="$INSTALL_PATH/install.bat"> <args> <argvalue="$INSTALL_PATH" /> </args>   </executable>

</pack></packs>

- In install.bat file I am actually  running java file which connects to database server and registers my application to it ,but if error will come while inserting into database the installer gives popup like "Installation not complete" and after clicking on Ok is goes to next panel ,it's not aborting installer even if I've given failure="abort".

- so whenever error will come I want to abort the installation and remove copied files,folders.

- I am attaching install.xml with this mail.

 
Thank you.
 
Regards,
Jyo.

 
install.xml

René Krell

unread,
Apr 14, 2010, 5:23:38 AM4/14/10
to us...@izpack.codehaus.org
I see two issues here. You must decide, if you want a real rollback or only
aborting:

1. Rollback of changes on a failure
Here you have to implement something in a script.
In your case, you have to check the return code of some commands in
install.bat and make some decisions based on it, rolling back directly in
install.bat using system commands. IMHO, at the moment there's no way to
launch something additionally on failure.
Personally, I would prefer to implement an Ant listener for your custom
actions instead of install.bat, which gives you a better control, and which is
more "near" to Java.

2. Installer not aborting on failure
The failing abort is given by your install.bat, which probably exits with
%errorlevel%==0 due to some reason. Please check it for instance by running it
from a terminal and checking the errorlevel manually. For being able to
recognize failures in a batch script it's necessary to have a return code not
equal to 0.

jyoti gore

unread,
Apr 14, 2010, 6:21:49 AM4/14/10
to us...@izpack.codehaus.org
In install.bat file I am simply having command to run java file :
java" -cp .;lib/terminal.jar com.skandsoft.setu.terminal.install.Install
 
- Internally Install.java having main method which connects to database and inserts My application's information into the database and at the time of insertion ConstraintViolationException is coming .
-  i know ConstraintViolationException will come but after this error i want to abort installation.Installer not aborting installation it goes to next panel.
 
- while running it from a terminal  i m getting this error :
 
14 Apr 2010 15:26:25,547 - INFO com.skandsoft.setu.terminal.install.Install - Property File path config/terminal.properties
14 Apr 2010 15:26:25,687 - WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: null
14 Apr 2010 15:26:25,687 - ERROR org.hibernate.util.JDBCExceptionReporter - Batch entry 0 insert into public.data_point (data_point_name, data_point_ip, data_point_port, data_point_active, data_point_host_name, data_point_id) values (jyoti1, 192.168.0.60, 7002, 1, jyoti1, 2) was aborted.  Call getNextException to see the cause.
14 Apr 2010 15:26:25,687 - WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 23505
14 Apr 2010 15:26:25,687 - ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: duplicate key violates unique constraint "host_and_port_sholud_be_unique"
14 Apr 2010 15:26:25,703 - ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at com.skandsoft.setu.terminal.install.Install.install(Unknown Source)
        at com.skandsoft.setu.terminal.install.Install.main(Unknown Source)
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into public.data_point (data_point_name, data_point_ip, data_point_port, data_point_active, data_
point_host_name, data_point_id) values (jyoti1, 192.168.0.60, 7002, 1, jyoti1, 2) was aborted.  Call getNextException to see the cause.
        at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2534)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1317)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:350)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2596)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
        ... 9 more
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
 

- actually I m not able to decide which error code its returning.

- after this error i want to abort installation and remove copied files and folders to installation path.

 

Thanks in advance.

regards,

Jyo.



René Krell

unread,
Apr 14, 2010, 6:35:09 AM4/14/10
to us...@izpack.codehaus.org
Hi Jyo,

On Wednesday 14 April 2010 11:04:25 you wrote:

> - In install.bat file I am actually running java file which connects to
> database server and registers my application to it ,but if error will come
> while inserting into database the installer gives popup like "Installation
> not complete" and after clicking on Ok is goes to next panel ,it's not
> aborting installer even if I've given failure="abort".

I made a code review and there is in fact an issue with the installer on
failure="abort". There is only called emitError, which means informing the
user but not blocking the <Next> button. It should emit an error and block the
next button, instead.

Can you file an issue with a short description on the Jira bugtracker, please?
We will solve this hopefully in the next release. I f you want to solve it by
yourself in the code, just poke me and I'll tell you where :-)

René

Julien Ponge

unread,
Apr 14, 2010, 11:29:02 AM4/14/10
to us...@izpack.codehaus.org
FYI JIRA @Codehaus is down for maintenance, but should be back next day or so...

--
http://izpack.org/
http://jpz-log.info/
http://julien.ponge.info/

Reply all
Reply to author
Forward
0 new messages