"Unexpected error running Liquibase: Unknown Reason" liquibase 3.3.5 and grails war file - grails

This is the command I am running:
java -jar /root/liquibase/liquibase.jar \
--driver=com.mysql.jdbc.Driver \
--logLevel=debug \
--changeLogFile=migrations/changelog.xml \
--classpath=/usr/share/tomcat7/lib/mysql.jar:/var/lib/tomcat7/webapps/myApp.war \
--url="jdbc:mysql://127.0.0.1:3306/mydb" \
--username=myuser \
--password=mypass \
--contexts=MYCONTEXT \
update
this fails with the following unhelpful error message:
Unexpected error running Liquibase: Unknown Reason
SEVERE 9/9/15 2:23 PM: liquibase: Unknown Reason
java.lang.AbstractMethodError
at liquibase.database.DatabaseFactory.register(DatabaseFactory.java:87)
at liquibase.database.DatabaseFactory.<init>(DatabaseFactory.java:29)
at liquibase.database.DatabaseFactory.getInstance(DatabaseFactory.java:40)
at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:50)
at liquibase.integration.commandline.Main.doMigration(Main.java:884)
at liquibase.integration.commandline.Main.run(Main.java:175)
at liquibase.integration.commandline.Main.main(Main.java:94)
I have no idea where to look. I have verified that the jars and wars are correct, i.e.
ls /root/liquibase/liquibase.jar
ls /usr/share/tomcat7/lib/mysql.jar
ls /var/lib/tomcat7/webapps/revolve.war
All list the corresponding file.
Any ideas?
the war exploded looks like this:
WEB-INF\classes\migrations\
changelog.xml
lots_of_other_changes.xml
WEB-INF\classes\migrations\sql
lots of sql files
I have tired lots of variations, including:
--changeLogFile=WEB-INF/classes/migrations/changelog.xml \
the changelogs work find if I run them on my local pc outside of a war file, although I do have to cd into the directory where the main changelog.xml file is first, otherwise it does not work.
The main changelog looks like this:
<databaseChangeLog
:
<include file="baseline.xml"/>
<include file="something.xml"/>
and these included files have things like this:
<changeSet id="something" author="me">
<comment>something</comment>
<sqlFile path="sql//something//new_things.sql" />
</changeSet>
NOTE:
using the grails in-application auto-updater feature with the data-migration 1.4.0 plug wont work, as it is hard coded to use liquibase version 2.0.5 which has major bugs.
using liquibase 3.4+ is not currently an option due to incompatibility.
If I try the command without including the war file location, I correctly get an error saying could not find the changelog file expected, and it creates the DATABASECHANGELOCK table in the db (so that side is ok)
No matter what I change changeLogFile ot, it always gives this error, even something completely wrong.
We dont want to go through the pain of generating diff sql, and running that sql.
I suspect the issue is to do with the relative paths of the includes in the change sets.
I also tried changing all the
<include file="something.xml"/>
to
<include file="something.xml" relativeToChangelogFile="true" />
and
<sqlFile path="sql//something//new_things.sql" />
to
<sqlFile relativeToChangelogFile="true" path="sql//something//new_things.sql" />
But this made no difference - same error. I tried exploding the war and running it on the exploded files - this works, but is not what we want (as there is no way to explode the war on the production machines - they dont have the jar command, and if we deploy the war to live servers, without the DB changes first, the live system will fail)

I don't know about Grails, but I'm immediately noticing those doubled-slashes in your paths. I would expect them to cause problems.
Are you perhaps thinking of the need to quote Windows-style backslashes? Where you see things like: C:\\path\\to\\file.dat.
But you don't need to do that for Unix-style slashes (or forward-slashes, if you will). (And if you did you'd still have to quote them with backslashes, like this: \/path\/to\/file.dat -- but don't do that.)

I have the same situation: using LiquiBase with a Grails application. I had to fall back to liquibase-core-2.0.5.jar, which is embedded in the Grails User Library. I could not figure out how to exclude the jar. Unfortunately, this version of LiquiBase is considered very buggy.

Related

What is this build.xml doing?

I am learning build.xml and am confused by the following code:
<macrodef name="a-test">
<attribute name="port" default="${PORT}"/> #1
<junit printsummary=...
<env key="PORT" value="#{port}" /> #2
...
when I run java with commandLine including -DPORT=8080 and then in java code I get port value 8080 by calling
String port = System.getenv(PORT).
What is the above build.xml doing? So far I know $ is to represent a property while # is to represent an attribute. Besides, the above code is the only place where PORT and port appear. What happens here so that port value are finally obtained in java code? Thanks.
The other question, what is the difference btw. using "env key" and using "sysproperty"? according to http://etutorials.org/Programming/Java+extreme+programming/Chapter+3.+Ant/3.6+Passing+Arguments+to+a+Buildfile/
sysproperty can be use to parse argument -D to java code, while env key is used to do the same thing right? Thanks.
Is there any detailed document about build.xml? the one I google from internet describer things so briefly.
What you see is macrodef in ant. There will be another place in build.xml(or other build.xml) where this is called by like
<a-test port=<value> ..

Openbravo ant build fails

I am trying to setup openbravo on eclipse environment with the above URL.
Development stack setup is done successfully. (ANT, Java, Postgresql)
At the openbravo source directory when i apply the command
ant install.source
Build failure due to errors -
/home/pos/sourcecode_openbravo/Openbravo-3.0MP21/build.xml:480: The following error occurred while executing this line:
480 <ant dir="${base.src}" target="compile.complete.development" inheritAll="true" inheritRefs="true" />
/home/pos/sourcecode_openbravo/Openbravo-3.0MP21/src/build.xml:874: The following error occurred while executing this line:
874 <jvmarg line="${env.CATALINA_OPTS}" />
/home/pos/sourcecode_openbravo/Openbravo-3.0MP21/src/build.xml:880: Directory
880 <jvmarg value="-Djava.io.tmpdir=${env.CATALINA_BASE}/temp" />
/var/lib/tomcat6/webapps/openbravo/WEB-INF/lib creation was not successful for an unknown reason
Any help would be appreciated. Thanks.
Sounds like a permission problem.
See the related section 'Permission issues' in openbravo wiki
EDIT
for the remaining issues, i believe the properties base.src, CATALINA_OPTS and CATALINA_BASE are not set properly. Check this via :
<echo>
$${base.src} => ${base.src}
$${env.CATALINA_OPTS} => ${env.CATALINA_OPTS}
$${env.CATALINA_BASE} => ${env.CATALINA_BASE}
</echo>
or simply output all available properties use :
<echoproperties/>
also consider, before using ${env.whatever} you need to use :
<property environment="env"/>
before !
/var/lib/tomcat6/webapps/openbravo/WEB-INF/lib creation was not successful for an unknown reason
Give the permission to webapps folder
sudo chmod -R 777 /var/lib/tomcat6/webapps/
/var/lib/tomcat6/webapps/openbravo/WEB-INF/lib creation was not
successful for an unknown reason
it seem permission problem. It is important to always us the correct user account to start / stop tomcat!
Conceptually there are two user accounts involved in working with Openbravo:
command-line user used to work with files & compile Openbravo
user account used by Apache Tomcat service
There are several overlapping areas in which one of the accounts needs to access and modify files from the other account in both directions.
To avoid any problems Openbravo strongly recommends to run Apache Tomcat services with the same user account which is used on command line. As that way the above topic will be perfectly solved easily.
source: http://wiki.openbravo.com/wiki/Installation/Custom/Apache_Tomcat

Jaxb binding file being ignored

I having a bit of trouble building JAXB bindings fora set of schemas and its driving me a bit batty. Here is the schema in question (it is just one of may schema in this particular build):
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xml="http://www.w3.org/XML/1998/namespace" targetNamespace="http://www.w3.org/XML/1998/namespace">
<attribute name="lang" type="language">
<annotation>
<documentation>In due course, we should install the relevant ISO 2- and 3-letter
codes as the enumerated possible values . . .</documentation>
</annotation>
</attribute>
<attribute name="space" default="preserve">
<simpleType>
<restriction base="NCName">
<enumeration value="default"/>
<enumeration value="preserve"/>
</restriction>
</simpleType>
</attribute>
<attributeGroup name="specialAttrs">
<attribute ref="xml:lang"/>
<attribute ref="xml:space"/>
</attributeGroup>
xjc is claiming that the attributes declared above are already declared elsewhere:
parsing a schema...
[ERROR] 'lang' is already defined
line 26 of file:../../gml/3.1.1/smil/xml-mod.xsd
[ERROR] (related to above error) the first definition appears here
line 88 of http://www.w3.org/2001/03/xml.xsd
[ERROR] 'space' is already defined
line 34 of file:../../gml/3.1.1/smil/xml-mod.xsd
[ERROR] (related to above error) the first definition appears here
line 95 of http://www.w3.org/2001/03/xml.xsd
[ERROR] 'specialAttrs' is already defined
line 39 of file:../../gml/3.1.1/smil/xml-mod.xsd
[ERROR] (related to above error) the first definition appears here
line 111 of http://www.w3.org/2001/03/xml.xsd
Failed to parse a schema.
Doing a bit of research would lead me to believe that the problem is that I need a binding file to resolve the duplicate attributes....and I have one :
<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc">
<jaxb:bindings schemaLocation="../../gml/3.1.1/smil/xml-mod.xsd" node="/xs:schema">
<jaxb:bindings node="//xs:attribute[#name='lang']">
<jaxb:property name="langAttribute"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:attribute[#name='space']">
<jaxb:property name="spaceAttribute"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:attributeGroup[#name='specialAttrs']">
<jaxb:property name="specialAttrsAttribute"/>
</jaxb:bindings>
</jaxb:bindings>
Yet the problem persists. The error message with or without the bindings file is the same. I know the file is being used , because if I mess up the xpath for the node selector I get an error message. It's like xjc knows the bindings file is there but ignores it.
Here's the command line that fails to build the bindings:
C:\tools\jaxb-ri-20110512\bin\xjc -episode ..\..\..\common.ogc -d ..\..\..\src -p com.ogc.bindings -b ..\..\..\bindings.xsd -catalog ..\..\..\ogc.cat -extension sosAll.xsd
I have tried this with both the jdk6 native jaxb (2.0) and jaxb 2.2.4 (I installed the jaxb-api.jar in the endorsed directory)
XJC (bundled with JDK), ignores binding file, if the path to the binding file or the XSD / WSDL is too long.
Issue observed and confirmed on Oracle 64 bit JDK 1.6.0.45, on Windows 7 ultimate and on Linux, XJC (bundled with JDK), ignores binding file, if the path to the binding file is too long.
I did NOT have the time to do detail research on the issue; I solved my problem by simply shortening the svn checkout path. It was the most bizarre issue - I could not reproduce the problem on my Windows 8 Laptop and on Linux, but on a Windows 7 workstation, build kept on failing. I identified this issue by confirming that other then path, there is NO difference between Windows 8 LAPTOP, where the build works, vs. Windows 7 Ultimate where the path is a bit long (6 characters -> /trunk).
Problem was solved without any code, configuration, xml schema or binding file change. Posting here so that others who may run into this, have a bit of easier time then me.
i believe this is an issue with namespace collision, you dont have a namespace defined for your schema elements and it seems you are using names for your attributes that are in conflict with the ones defined in xml's schema (xml.xsd)

CVS error - CVS exited with error code 1

I am seeing this error for quite sometime now.
I am running ant build on CYGWIN which inturn runs on WindowsXP.
The resolution(bad one) I found was to delete my gcct/first directory and run ant build again (which runs from another directory). It runs successfully but if I modify some code under gcct/first, I do not want to delete it because of this error.
I did see this link. The resolution here does not apply to me since I do not have .cvspass defined anywhere in the build.xml.
C:\svn\CEL_v3681\buildCore.xml:1883: cvs exited with error code 1
Command line was [Executing 'cvs' with arguments:
'checkout'
'-A'
'-rfirst_v2_126'
'gcct/first'
The ' characters around the executable and arguments are
not part of the command.
environment:
ALLUSERSPROFILE=C:\Documents and Settings\All Users
ANT_HOME=C:/Apps/Apache/apache-ant-1.7.0
APPDATA=C:\Documents and Settings\shankarc\Application Data
CLASSPATH=./;C:/Program Files/Java/jre1.5.0_07/lib/ext/QTJava.zip
COMMONPROGRAMFILES=C:\Program Files\Common Files
COMPUTERNAME=NYKPWM2035798
COMSPEC=C:\WINNT\system32\cmd.exe
CUSTPROF=Roaming700Live
CVSROOT=:pserver:shankarc#amcvs2.lehman.com:/home/eqcvs/cmte
CVS_RSH=/bin/ssh
FP_NO_HOST_CHECK=NO
HOME=C:\Apps\CYGWIN\home\shankarc
HOMEDRIVE=F:
HOMEPATH=\
HOSTNAME=nykpwm2035798
IDEA_PROPERTIES=C:\Documents and Settings\shankarc\idea.properties
INFOPATH=/usr/local/info:/usr/share/info:/usr/info:
JAVA_HOME=C:/Program Files/Java/jdk1.6.0_21/
JDK_HOME=C:\Program Files\Java\jdk1.6.0_21\
LOGONSERVER=\\NYKPSM00069
MANPATH=/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/man
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
PATH=C:\Apps\CYGWIN\usr\local\bin;C:\Apps\CYGWIN\bin;C:\Apps\CYGWIN\bin;C:\Apps\CYGWIN\usr\X11R6\bin;C:\Apps\Apache\apache-ant-1.7.0\bin;C:\Program Files\Java\jdk1.6.0_21\bin\;C:\Apps\CYGWIN\bin;C:\Program Files\VisualSVN Server\bin;C:\Program Files\Sudowin\Clients\Console;C:\Program Files\Fortify Software\Fortify 360 v2.5.0\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.PSC1
PRINTER=\\NYKPSM04020\NYKLPR1301-03-03C05
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 6, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0f06
PROFGROUP=FONP
PROGRAMFILES=C:\Program Files
PROMPT=$P$G
PWD=/cygdrive/c/svn/CEL_v3681/gcct/cel
QHOME=c:\q
QTJAVA=C:\Program Files\Java\jre1.5.0_07\lib\ext\QTJava.zip
SESSIONNAME=Console
SHLVL=1
SITECODE=NYK
SITEIDENT=NYK
SVN_ASP_DOT_NET_HACK=1
SYSTEMDRIVE=C:
SYSTEMROOT=C:\WINNT
TEMP=C:\TEMP
TERM=cygwin
TMP=C:\TEMP
UATDATA=C:\WINNT\system32\CCM\UATData\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77
USER=shankarc
USERDNSDOMAIN=INTRANET.BARCAPINT.COM
USERDOMAIN=INTRANET
USERNAME=shankarc
USERPROFILE=C:\Documents and Settings\shankarc
WINDIR=C:\WINNT
CVS_PASSFILE=C:\Apps\CYGWIN\home\shankarc\.cvspass]
Total time: 58 seconds
How I resolve this?
I had the same issue and found that even though I was not using .cvspass I did have a build property of cvs.pass set which needed to be reset to OVERRIDE to function depending on how you set up your cvs access (though it looked similar from your post). This needed to be changed in build.properties and .build.properties. Hope this helps!

liquibase future rollback error with sqlFile tag: File not found

I've added the future-rollback tag to my ant script. What i want to do (and I think future-rollback is what Im looking for) is to generate an sql rollback script, but without executing it (rollback script must be delivered with sql scripts is the requirement from my client).
My changelog file has many changesets, some of which contain the <sqlFile> tag.
For example:
<databaseChangeLog ...>
<include file="latest/somesqlprocedure.xml" relativeToChangelogFile="true"/>
</databaseChangelog...>
Where the latest/somesqlprocedure.xml has an sqlFile tag.
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<sqlFile path="${changelog.dir}/latest/myprocedure.sql" splitStatements="false" />
</changeSet>
</databaseChangeLog>
When I run the ant script, I get the following error
liquibase.exception.ChangeLogParseException:
Invalid Migration File: <sqlfile
path=${changelog.dir}/latest/myprocedure.sql>
- Could not find file
Does anyone has an idea of whats going on ?
This is a snippet of the build.xml file
<target name="db-future-rollback" depends="init">
<rollbackFutureDatabase
changeLogFile="${db.changelog.file}"
driver="${database.driver}"
url="${database.url}"
username="${database.username}"
password="${database.password}"
outputfile="${database.rollback.dir}"
promptOnNonLocalDatabase="${prompt.user.if.not.local.database}"
classpathref="project.classpath"
>
</rollbackFutureDatabase>
</target>
Thanks in advance.
The problem may be coming from using an absolute path in your sqlFile, rather than a classpath-relative path. The classpath relative path was what was originally supported in liquibase and is still better tested. The absolute path option was added recently, and the futureRollbackSql code may have not been patched to support it.
Can you try the sqlFile using a relative path?
As a side note, the relative path option is generally better because the filename is used in the databasechangelog table to note which changeSets have ran. If you use an absolute path, the entire path is stored and if you try to re-run the changelog from a different path (or running against the same database from a different machine), liquibase will think it is a different changeSet and try to re-run it.

Resources