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 Wed, 18 Apr 2012 15:31:07 GMT
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
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > _________________________________________________________
> > > >
> > > > С уважением,
> > > >
> > > > Замула Дмитрий
> > > >
> > >
> >
> >
> >
> > --
> > _________________________________________________________
> >
> > С уважением,
> >
> > Замула Дмитрий
> >
>



-- 
_________________________________________________________

С уважением,

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

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