openmeetings-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitry Zamula <club.brant...@gmail.com>
Subject Re: Fix build process bug
Date Fri, 20 Apr 2012 14:59:04 GMT
I have implemented parameter "--drop" and create a patch:
https://issues.apache.org/jira/browse/OPENMEETINGS-194

Checking the old data in the database during the installation and the key
"--force" not yet implemented. Some problems with injection of
EntityManager - I will deal at the weekend.

2012/4/19 Maxim Solodovnik <solomax666@gmail.com>

> Or even better
>
> 1) by default installation will not start if DB has data
> 2) optional parameter --force will run installation anyway
> 3) optional parameter --drop will drop database before install
>
> 4) additional check to suppress web installer if DB exist can be added
>
> On Thu, Apr 19, 2012 at 15:28, Maxim Solodovnik <solomax666@gmail.com
> >wrote:
>
> > I would add separate option.
> > And probably additional check if DB contains data before install
> >
> > 2012/4/19 seba.wagner@gmail.com <seba.wagner@gmail.com>
> >
> > Just one note: It is no good idea to drop the db silently during
> >> installation.
> >>
> >> A user might simply think: "Hey a new version, lets unzip, alter the
> >> persistence.xml file and re-install"
> >> If you guys now implement a hook that automatically drops the previous
> db
> >> the user will loose all his data without even a notice or confirmation.
> >> Of course we can write in our docs a big marker like "do not do this"
> >> however the data is gone and we might receive a lot of emails from
> >> frustrated users.
> >>
> >> So having a parameter in the install to optionally drop or truncate a
> >> previous DB is good but making this the default behaviour and silently
> >> drop
> >> the db while installing is not a good idea.
> >> Our current update process is: You export a backup, install in a blank
> >> database and re-import the backup again.
> >>
> >> Sebastian
> >>
> >> 2012/4/19 Maxim Solodovnik <solomax666@gmail.com>
> >>
> >> > I'm currently in the process of writing command line admin able to
> >> > install/backup/restore OM (cleanup unused files is in progress)
> >> >
> >> > drop database can be added as an option to it (since Mapping Tool can
> be
> >> > directly called from comman line admin I hope there will be no issues
> >> with
> >> > DB url)
> >> >
> >> > please take a look at "package org.openmeetings.cli".
> >> >
> >> > It already has code for DB patching
> >> > this code code can be generalized to get DB url.
> >> >
> >> > hope this will help.
> >> >
> >> > 2012/4/19 Dmitry Zamula <club.brantner@gmail.com>
> >> >
> >> > > Yes, guys, this is my fault. Initially, I assumed that build and
> >> install
> >> > > related. Maxim in the past letters has already said that it is not,
> >> but
> >> > > somehow I did not realize the importance of this.
> >> > > Today I will deal with the installation process. Now the basic idea
> -
> >> > > before you install to remove all tables.
> >> > >
> >> > > 2012/4/18 Maxim Solodovnik <solomax666@gmail.com>
> >> > >
> >> > > > Installation and build are different processes.
> >> > > > Build did not creates any tables (except for junky tests).
> >> > > > Double installation after manual removing guards against it is
up
> to
> >> > > > user.(IMHO)
> >> > > > As well as we are not tracking situations when user manually
edits
> >> DB.
> >> > > > On Apr 18, 2012 11:46 PM, "Alexei Fedotov" <
> >> alexei.fedotov@gmail.com>
> >> > > > wrote:
> >> > > >
> >> > > > > I miss the point - how fixing a build file would fix the
> problem.
> >> > > > >
> >> > > > > Extra entries appear in runtime. Imagine someone would call
> >> installer
> >> > > > twice
> >> > > > > in a row (that can be done by deleting some file in between
> >> without
> >> > > > > invoking tbe build file)
> >> > > > >
> >> > > > > That's why I suggested making menu entries unique, so the
second
> >> > insert
> >> > > > > would update the table row, or dropping the tables right
before
> >> > > insering
> >> > > > in
> >> > > > > the web application.
> >> > > > > 18.04.2012 19:31 пользователь "Dmitry Zamula"
<
> >> > club.brantner@gmail.com
> >> > > >
> >> > > > > написал:
> >> > > > >
> >> > > > > > Here is my "ugly-solution":
> >> > > > > >
> >> > > > > > <target name="refresh">
> >> > > > > >    <taskdef name="tablerefresh"
> >> > > > > > classname="org.apache.openjpa.jdbc.ant.MappingToolTask">
> >> > > > > >      <classpath refid="jpa.enhancement.classpath"
/>
> >> > > > > >    </taskdef>
> >> > > > > >
> >> > > > > >    <replaceregexp
> file="${dist.persistence.dir}/persistence.xml"
> >> > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> match="(org.apache.commons.dbcp.BasicDataSource)([\s\S]*)(DriverClassName=)([a-zA-Z.]*[^,\s]*)"
> >> > > > > > replace="\4\2\3\4"/>
> >> > > > > >
> >> > > > > >    <tablerefresh schemaAction="drop">
> >> > > > > >      <config
> >> > propertiesFile="${dist.persistence.dir}/persistence.xml"
> >> > > > />
> >> > > > > >    </tablerefresh>
> >> > > > > >
> >> > > > > >    <replaceregexp
> file="${dist.persistence.dir}/persistence.xml"
> >> > > > > > match="ConnectionDriverName&quot; value=&quot;[a-zA-Z.]*"
> >> > > > > > replace="ConnectionDriverName&quot;
> >> > > > > > value=&quot;org.apache.commons.dbcp.BasicDataSource"/>
> >> > > > > >    <echo message="Table refreshing complete." />
> >> > > > > > </target>
> >> > > > > >
> >> > > > > > I tested it, it works (drops all tables). Only in the
case of
> >> > oracle
> >> > > > > > persistence.xml, it should add the line <property
name =
> >> > > > > > "openjpa.ConnectionDriverName" ...
> >> > > > > >
> >> > > > > > 2012/4/18 Alexei Fedotov <alexei.fedotov@gmail.com>
> >> > > > > >
> >> > > > > > > Hello Dmitry,
> >> > > > > > >
> >> > > > > > > Answering questions sequentially, without paying
attention
> to
> >> > your
> >> > > > > later
> >> > > > > > > progress. Discard answers if they come late.
> >> > > > > > >
> >> > > > > > > Why ant cannot find file persistence.xml?
> >> > > > > > >
> >> > > > > > > Ant is controversal. IMHO.
> >> > > > > > >
> >> > > > > > > Some values are assigned dynamicly, others are
> pre-calculated
> >> > > before
> >> > > > > the
> >> > > > > > > build process starts.
> >> > > > > > >
> >> > > > > > > This includes file tree. Ant believes it could
match most
> >> > > > dependencies
> >> > > > > > > including copied files before the build process
starts. This
> >> does
> >> > > not
> >> > > > > > live
> >> > > > > > > well with most custom tasks (if they have side
effects) and
> >> > > external
> >> > > > > > tools
> >> > > > > > > which copy or modify files.
> >> > > > > > >
> >> > > > > > > This also includes checking if the file located
by tge path
> in
> >> > the
> >> > > > > > property
> >> > > > > > > exists.
> >> > > > > > >
> >> > > > > > > This sometimes gives the problems you describe.
> >> > > > > > > 18.04.2012 13:30 пользователь "Dmitry
Zamula" <
> >> > > > club.brantner@gmail.com
> >> > > > > >
> >> > > > > > > написал:
> >> > > > > > >
> >> > > > > > > > Command-line version of MappingTool did not
give an
> >> answers. In
> >> > > > > digging
> >> > > > > > > the
> >> > > > > > > > source code, I found that, in any case, AntClassLoader.
> >> Bearing
> >> > > in
> >> > > > > mind
> >> > > > > > > > that change a property "openjpa.ConnectionDriverName"
from
> >> > > > > > > > "org.apache.commons.dbcp.BasicDataSource"
to
> >> > > > "com.mysql.jdbc.Driver"
> >> > > > > > > helps,
> >> > > > > > > > I came to the conclusion that the problem
is not in
> >> > classcoader,
> >> > > > and
> >> > > > > to
> >> > > > > > > use
> >> > > > > > > > the driver.
> >> > > > > > > > I asked this situation in OpenJPA mailing
list, but not
> yet
> >> > > > received
> >> > > > > a
> >> > > > > > > > reply (unfortunately, the discussion on the
OpenJPA
> mailing
> >> > list
> >> > > > are
> >> > > > > > not
> >> > > > > > > so
> >> > > > > > > > rapidly as in Openmeetings).
> >> > > > > > > >
> >> > > > > > > > I have not quite elegant solution to this
problem. I could
> >> use
> >> > > > > ant-task
> >> > > > > > > > "ReplaceRegExp" and write a regexp, which
changes the line
> >> > > > > > > > org.apache.commons.dbcp.BasicDataSource on
the right
> driver
> >> > (from
> >> > > > > > > > openjpa.ConnectionProperties), and at the
end of the
> >> > ant-target,
> >> > > > gets
> >> > > > > > all
> >> > > > > > > > it was.
> >> > > > > > > > Despite the "ugliness" of the decision, I
would still
> finish
> >> > the
> >> > > > > task,
> >> > > > > > > and
> >> > > > > > > > put a patch that is required to participate
in GSoC.
> >> > > > > > > >
> >> > > > > > > > 2012/4/15 Maxim Solodovnik <solomax666@gmail.com>
> >> > > > > > > >
> >> > > > > > > > > I also think so.
> >> > > > > > > > > According to the Google and MappingTool
sources it's
> using
> >> > some
> >> > > > non
> >> > > > > > > > > standard classloader. I tried to bypass
it, but wasn't
> >> > succeed
> >> > > > > (need
> >> > > > > > > more
> >> > > > > > > > > time).
> >> > > > > > > > >
> >> > > > > > > > > Maybe running command -line version
of MappingTool can
> >> give
> >> > > more
> >> > > > > > > > > information?
> >> > > > > > > > > On Apr 15, 2012 1:48 AM, "Dmitry Zamula"
<
> >> > > > club.brantner@gmail.com>
> >> > > > > > > > wrote:
> >> > > > > > > > >
> >> > > > > > > > > > The problem was in persistent.xml
(I tested only with
> >> > mysql).
> >> > > > > First
> >> > > > > > > of
> >> > > > > > > > > all,
> >> > > > > > > > > > there was no <property name="openjpa.ConnectionURL"
> >> > > > value="..."/>
> >> > > > > > > (url
> >> > > > > > > > > was
> >> > > > > > > > > > inside the property name =
> >> "openjpa.ConnectionProperties").
> >> > > > > > > > > > But the main problem - MappingToolTask
can not use a
> >> > > connection
> >> > > > > > from
> >> > > > > > > > > pool.
> >> > > > > > > > > > With <property name="openjpa.ConnectionDriverName"
> >> > > > > > > > > > value="com.mysql.jdbc.Driver"/>
it works, but value =
> >> > > > > > > > > > "org.apache.commons.dbcp.BasicDataSource"
does not
> work.
> >> > > > > Classpath
> >> > > > > > > > > contains
> >> > > > > > > > > > all required libraries.
> >> > > > > > > > > > I think this is a bug in openjpa.
> >> > > > > > > > > >
> >> > > > > > > > > > 2012/4/14 Maxim Solodovnik <solomax666@gmail.com>
> >> > > > > > > > > >
> >> > > > > > > > > > > OK
> >> > > > > > > > > > > tried that.
> >> > > > > > > > > > >
> >> > > > > > > > > > > We are using openjpa 2.2.0
> >> > > > > > > > > > > Here is documentation from
it:
> >> > > > > > > > > > >
> >> > > > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > >
> >> > > > > > > >
> >> > > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> http://openjpa.apache.org/builds/2.2.0/apache-openjpa/docs/ref_guide_integration.html#ref_guide_integration_mappingtool
> >> > > > > > > > > > >
> >> > > > > > > > > > > I slightly modified your code
and was able to
> >> reproduce
> >> > > your
> >> > > > > > > result:
> >> > > > > > > > > > > A connection could not be
obtained for driver class
> >> > > > > > > > > > > "org.apache.commons.dbcp.BasicDataSource"
and URL
> >> "null".
> >> > > > > > > > > > >
> >> > > > > > > > > > > But
> >> > > > > > > > > > > according to my stacktace
to lowest exception is:
> >> > > > > > > > > > > Caused by: java.lang.IllegalArgumentException:
> >> > > > > > > > > > > java.lang.ClassNotFoundException:
> >> > > > > > > > > org.apache.commons.dbcp.BasicDataSource
> >> > > > > > > > > > > at serp.util.Strings.toClass(Strings.java:164)
> >> > > > > > > > > > > at serp.util.Strings.toClass(Strings.java:108)
> >> > > > > > > > > > > at
> >> > > > > > > > > > >
> >> > > > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > >
> >> > > > > > > >
> >> > > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:211)
> >> > > > > > > > > > > at
> >> > > > > > > > > > >
> >> > > > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > >
> >> > > > > > > >
> >> > > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> org.apache.openjpa.lib.conf.Configurations.newInstance(Configurations.java:170)
> >> > > > > > > > > > > at
> >> > > > > > > > > > >
> >> > > > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > >
> >> > > > > > > >
> >> > > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:114)
> >> > > > > > > > > > >
> >> > > > > > > > > > >
> >> > > > > > > > > > > This means there is something
wrong with MappingTool
> >> > > > > > > > > > classpath/classloader
> >> > > > > > > > > > >
> >> > > > > > > > > > > Unfortunately I have no time
right now to dig this.
> >> > > > > > > > > > > Currently I simply drop database
before running
> >> install.
> >> > > > > > > > > > >
> >> > > > > > > > > > > please NOTE it is not necessary
to run install every
> >> time
> >> > > you
> >> > > > > > > rebuild
> >> > > > > > > > > OM,
> >> > > > > > > > > > > it works as expected without
reinstalling. (the only
> >> > > > exception
> >> > > > > is
> >> > > > > > > > > > changing
> >> > > > > > > > > > > primary key on table, which
is not often)
> >> > > > > > > > > > >
> >> > > > > > > > > > > 2012/4/13 Dmitry Zamula <club.brantner@gmail.com>
> >> > > > > > > > > > >
> >> > > > > > > > > > > > Ok, thank you. I used
this documentation, and may
> >> be it
> >> > > > will
> >> > > > > be
> >> > > > > > > > > > > interesting
> >> > > > > > > > > > > > to you:
> >> > > > > > > > > > > >
> >> > > > > > > > > > > >
> >> > > > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > >
> >> > > > > > > >
> >> > > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> http://openjpa.apache.org/builds/1.0.2/apache-openjpa-1.0.2/docs/manual/ref_guide_mapping.html#ref_guide_mapping_mappingtool
> >> > > > > > > > > > > >
> >> > > > > > > > > > > > 2012/4/13 Maxim Solodovnik
<solomax666@gmail.com>
> >> > > > > > > > > > > >
> >> > > > > > > > > > > > > I'll try to read
documentation regarding this
> task
> >> > > later
> >> > > > > > today,
> >> > > > > > > > > never
> >> > > > > > > > > > > use
> >> > > > > > > > > > > > > it before
> >> > > > > > > > > > > > > On Apr 13, 2012
3:02 PM, "Dmitry Zamula" <
> >> > > > > > > > club.brantner@gmail.com>
> >> > > > > > > > > > > > wrote:
> >> > > > > > > > > > > > >
> >> > > > > > > > > > > > > > Yes, but now
in ${dist.persistence.dir} I
> >> already
> >> > > have
> >> > > > a
> >> > > > > > > > > > > > persistence.xml.
> >> > > > > > > > > > > > > > And MappingToolTask
does not see it.
> >> > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > 2012/4/13 Maxim
Solodovnik <
> >> solomax666@gmail.com>
> >> > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > > Persistence.xml
is copied to its location by
> >> one
> >> > of
> >> > > > the
> >> > > > > > ant
> >> > > > > > > > > > tasks.
> >> > > > > > > > > > > > You
> >> > > > > > > > > > > > > > need
> >> > > > > > > > > > > > > > > to add
dependency to this task (have no
> >> sources
> >> > > right
> >> > > > > > now,
> >> > > > > > > > can
> >> > > > > > > > > > tell
> >> > > > > > > > > > > > > exact
> >> > > > > > > > > > > > > > > task name
later today)
> >> > > > > > > > > > > > > > >  On Apr
13, 2012 2:23 PM, "Dmitry Zamula" <
> >> > > > > > > > > > club.brantner@gmail.com
> >> > > > > > > > > > > >
> >> > > > > > > > > > > > > > wrote:
> >> > > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > > > Hello!
> >> > > > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > > > I
want to fix bug - after a few builds of
> >> the
> >> > > > system,
> >> > > > > > > there
> >> > > > > > > > > is
> >> > > > > > > > > > a
> >> > > > > > > > > > > > > > > > duplicate
information in database(in
> >> > particular,
> >> > > > this
> >> > > > > > > > affects
> >> > > > > > > > > > the
> >> > > > > > > > > > > > > > > interface
> >> > > > > > > > > > > > > > > > -
double buttons, menus, etc.). I wrote
> new
> >> > > target
> >> > > > in
> >> > > > > > > > > > build.xml:
> >> > > > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > > > <target
name="refresh">
> >> > > > > > > > > > > > > > > > 
  <taskdef name="tablerefresh"
> >> > > > > > > > > > > > > > > >
> >> > > > > > classname="org.apache.openjpa.jdbc.ant.MappingToolTask">
> >> > > > > > > > > > > > > > > > 
    <classpath
> >> > refid="jpa.enhancement.classpath"
> >> > > > />
> >> > > > > > > > > > > > > > > > 
  </taskdef>
> >> > > > > > > > > > > > > > > > 
  <tablerefresh schemaAction="refresh">
> >> > > > > > > > > > > > > > > > 
    <config
> >> > > > > > > > > > > >
> >> > propertiesFile="${dist.persistence.dir}/persistence.xml"
> >> > > > > > > > > > > > > > />
> >> > > > > > > > > > > > > > > > 
  </tablerefresh>
> >> > > > > > > > > > > > > > > > 
  <echo message="Table refreshing
> >> complete."
> >> > />
> >> > > > > > > > > > > > > > > > </target>
> >> > > > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > > > But,
MappingToolTask cant find
> >> persistence.xml
> >> > > > > (Error:
> >> > > > > > A
> >> > > > > > > > > > > connection
> >> > > > > > > > > > > > > > could
> >> > > > > > > > > > > > > > > > not
be obtained for driver class
> >> > > > > > > > > > > > > > > "org.apache.commons.dbcp.BasicDataSource"
> >> > > > > > > > > > > > > > > > and
URL "null").
> >> > > > > > > > > > > > > > > > Does
anyone have any ideas why this is
> >> > happening?
> >> > > > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > >
> >> > > > > > > > > > > > > >
> >> > > > > > > > > > > > > >
> >> > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > --
> >> > > > > > > > > > > > > >
> >> > > > _________________________________________________________
> >> > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > С уважением,
> >> > > > > > > > > > > > > >
> >> > > > > > > > > > > > > > Замула
Дмитрий
> >> > > > > > > > > > > > > >
> >> > > > > > > > > > > > >
> >> > > > > > > > > > > >
> >> > > > > > > > > > > >
> >> > > > > > > > > > > >
> >> > > > > > > > > > > > --
> >> > > > > > > > > > > >
> >> > _________________________________________________________
> >> > > > > > > > > > > >
> >> > > > > > > > > > > > С уважением,
> >> > > > > > > > > > > >
> >> > > > > > > > > > > > Замула Дмитрий
> >> > > > > > > > > > > >
> >> > > > > > > > > > >
> >> > > > > > > > > > >
> >> > > > > > > > > > >
> >> > > > > > > > > > > --
> >> > > > > > > > > > > WBR
> >> > > > > > > > > > > Maxim aka solomax
> >> > > > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > > >
> >> > > > > > > > > > --
> >> > > > > > > > > >
> >> _________________________________________________________
> >> > > > > > > > > >
> >> > > > > > > > > > С уважением,
> >> > > > > > > > > >
> >> > > > > > > > > > Замула Дмитрий
> >> > > > > > > > > >
> >> > > > > > > > >
> >> > > > > > > >
> >> > > > > > > >
> >> > > > > > > >
> >> > > > > > > > --
> >> > > > > > > > _________________________________________________________
> >> > > > > > > >
> >> > > > > > > > С уважением,
> >> > > > > > > >
> >> > > > > > > > Замула Дмитрий
> >> > > > > > > >
> >> > > > > > >
> >> > > > > >
> >> > > > > >
> >> > > > > >
> >> > > > > > --
> >> > > > > > _________________________________________________________
> >> > > > > >
> >> > > > > > С уважением,
> >> > > > > >
> >> > > > > > Замула Дмитрий
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > > --
> >> > > _________________________________________________________
> >> > >
> >> > > С уважением,
> >> > >
> >> > > Замула Дмитрий
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> > WBR
> >> > Maxim aka solomax
> >> >
> >>
> >>
> >>
> >> --
> >> Sebastian Wagner
> >> https://twitter.com/#!/dead_lock
> >> http://www.openmeetings.de
> >> http://www.webbase-design.de
> >> http://www.wagner-sebastian.com
> >> seba.wagner@gmail.com
> >>
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>



-- 
_________________________________________________________

С уважением,

Замула Дмитрий

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message