Olá, estou seguindo o tutorial do MDArte
O banco "SuportePais" deveria ter sido criado além das tabelas "Pais" e "UnidadeFederativa" quando executasse o maven do diretório do projeto?
Fiz a alteração dos arquivos para o PostgresSQL: "project.properties" no direório do projeto e "progress-ds.xml" no diretório "C:\jboss-4.2.0.GA\server\default\deploy" do JBoss. Foram geradas as tabelas referidas acima, mas o banco não foi criado na instância do PostgresSQL. O JBoss precisa estar no ar?
Os arquivos "schema-create.sql" e "schema-drop.sql" estão com os scripts para criação e exclusão das tabelas, mas não tem nada sobre o banco. É isso mesmo?
Grato,
Autor: CARLOS PEREIRA
2424 comentários
Total time: 4 seconds
Finished at: Sun Apr 15 13:26:56 BRT 2012 Mas mesmo assim continuo sem ver o banco e as tabelas criadas no PostgresSQL 8.4.
A biblioteca postgresql-8.4-701.jdbc4.jar deve estar localizada no diretório /server/default/lib/ do seu JBoss.
Coloque o usuário do banco em dataSource.user.
Coloque a senha do usuário do banco em dataSource.password.
Crie a schema suportepais e dê permissão de acesso ao usuário do banco que você usará.
deployExploded=false # The datasource for the application dataSource.name=MYSQLDS dataSource=java:/${dataSource.name} # Properties for management of the database schema,
# ignore if you setup/drop your schema manually dataSource.driver.jar=${env.JBOSS_HOME}/server/default/lib/mysql-connector-java-5.1.7-bin.jar dataSource.driver.class=com.mysql.jdbc.Driver dataSource.url=jdbc:mysql://127.0.0.1/SuportePaisBD dataSource.user=root dataSource.password=root dataSource.sql.init=core/target/schema-create.sql dataSource.sql.drop=core/target/schema-drop.sql dataSource.sql.load=core/target/db/create-dummy-load.sql # What schema related goals should do when an error occurs. dataSource.sql.onError=continue # Change this to generate to the correct MDA database mappings
# For MySql use: MySQL
# For Hypersonic use: HypersonicSql
# For Oracle9i use: Oracle9i sql.mappings=HypersonicSql # For MySql use: org.hibernate.dialect.MySQLDialect
# For Hypersonic use: org.hibernate.dialect.HSQLDialect
# For Oracle9i use: org.hibernate.dialect.Oracle9Dialect hibernate.db.dialect=org.hibernate.dialect.MySQLDialect jboss.config=default defaultHibernateGeneratorClass=sequence mysql-ds.xml: <datasources> <local-tx-datasource> <jndi-name>MYSQLDS</jndi-name> <connection-url>jdbc:mysql://127.0.0.1/SuportePaisBD</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>root</user-name>
<password>root</password>
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
</exception-sorter-class-name>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> <metadata>
<type-mapping>mySQL</type-mapping>
</metadata> </local-tx-datasource>
</datasources>
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0.2 BUILD SUCCESSFUL
Total time: 1 seconds
Finished at: Thu Apr 19 13:49:49 BRT 2012 C:\ProjetoMDA\SuportePais\core> C:\ProjetoMDA\SuportePais\core\cd>maven create-schema
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0.2 BUILD SUCCESSFUL
Total time: 3 seconds
Finished at: Thu Apr 19 13:50:50 BRT 2012 C:\ProjetoMDA\SuportePais\core\cd>
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:j="jelly:core">
<goal name="install">
<maven:maven
descriptor="${basedir}/cd/project.xml"
goals="jar:install"/>
<maven:maven
descriptor="${basedir}/cs/project.xml"
goals="install"/>
</goal>
<goal name="deploy">
<maven:maven
descriptor="${basedir}/cd/project.xml"
goals="deploy"/>
<maven:maven
descriptor="${basedir}/cs/project.xml"
goals="deploy"/>
</goal>
<goal name="lib">
<maven:maven
descriptor="${basedir}/cd/project.xml"
goals="lib"/>
<maven:maven
descriptor="${basedir}/cs/project.xml"
goals="lib"/>
</goal>
<goal name="undeploy">
<maven:maven
descriptor="${basedir}/cd/project.xml"
goals="undeploy"/>
<maven:maven
descriptor="${basedir}/cs/project.xml"
goals="undeploy"/>
</goal>
</project> C:\ProjetoMDA\SuportePais\core\cd <project default="jar:install"
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:j="jelly:core"> <ant:property environment="env"/>
<j:set var="libDirectory" value="${env.JBOSS_HOME}/server/${jboss.config}/lib"/>
<goal name="libaux"> <j:forEach var="dep" items="${pom.dependencies}">
<j:if test= "${dep.type == 'jar'}">
<j:if test= "${dep.groupId != pom.groupId}">
<j:if test= "${dep.getProperty('jar.manifest.classpath') == 'true'}">
<ant:copy todir="${libDirectory}">
<fileset dir="${user.home}/.maven/repository/${dep.groupId}/jars/">
<include name="${dep.artifact}"/>
</fileset>
</ant:copy>
</j:if>
</j:if>
</j:if>
</j:forEach>
</goal>
<ant:property environment="env"/> <j:set var="deployDirectory" value="${env.JBOSS_HOME}/server/${jboss.config}/deploy"/>
<goal name="deploy" prereqs="undeploy">
<ant:copy file="${user.home}/.maven/repository/${pom.groupId}/jars/${pom.artifactId}-${pom.CurrentVersion}.jar"
tofile="${deployDirectory}/${pom.artifactId}-${pom.CurrentVersion}.jar"/>
</goal> <goal name="undeploy">
<ant:delete includeEmptyDirs="true">
<ant:fileset dir="${deployDirectory}">
<ant:include name="${pom.artifactId}*.jar"/>
</ant:fileset>
</ant:delete>
</goal>
<preGoal name="jar:jar"> <ant:path id="schema.classpath">
<ant:path refid="maven.dependency.classpath"/>
<ant:path location="${maven.build.dest}"/>
</ant:path> <ant:mkdir dir="${hibernate.schema.output.dir}"/> <ant:fileset id="hibernate.mapping.files" dir="${maven.build.dest}">
<ant:include name="**/*.hbm.xml"/>
</ant:fileset> <ant:pathconvert refid="hibernate.mapping.files" property="hibernate.mappings" pathsep=" "/> <ant:java classname="org.hibernate.tool.hbm2ddl.SchemaExport" fork="true">
<ant:arg value="--output=${hibernate.schema.output.dir}/schema-create.sql"/>
<ant:arg value="--text"/>
<ant:arg value="--quiet"/>
<ant:arg value="--delimiter=;"/>
<ant:arg value="--format"/>
<ant:arg line="${hibernate.mappings}"/>
<ant:jvmarg value="-Dhibernate.dialect=${hibernate.db.dialect}"/>
<ant:classpath refid="schema.classpath" />
</ant:java> <ant:replaceregexp file="${hibernate.schema.output.dir}/schema-create.sql"
match="^(alter table .* drop constraint|drop table)"
replace="-- SKIP \1"
flags="i"
byline="true"/> <ant:java classname="org.hibernate.tool.hbm2ddl.SchemaExport" fork="true">
<ant:arg value="--output=${hibernate.schema.output.dir}/schema-drop.sql"/>
<ant:arg value="--text"/>
<ant:arg value="--quiet"/>
<ant:arg value="--delimiter=;"/>
<ant:arg value="--format"/>
<ant:arg value="--drop"/>
<ant:arg line="${hibernate.mappings}"/>
<ant:jvmarg value="-Dhibernate.dialect=${hibernate.db.dialect}"/>
<ant:classpath refid="schema.classpath" />
</ant:java> </preGoal>
<j:set var="libDirectory" value="${env.JBOSS_HOME}/server/${jboss.config}/lib"/>
<goal name="libaux"> <j:forEach var="dep" items="${pom.dependencies}">
<j:if test= "${dep.type == 'jar'}">
<j:if test= "${dep.groupId != pom.groupId}">
<j:if test= "${dep.getProperty('jar.manifest.classpath') == 'true'}">
<ant:copy todir="${libDirectory}">
<fileset dir="${user.home}/.maven/repository/${dep.groupId}/jars/">
<include name="${dep.artifact}"/>
</fileset>
</ant:copy>
</j:if>
</j:if>
</j:if>
</j:forEach>
</goal> <goal name="earInstall">
<j:set var="earDirectory" value="C:\ProjetoMDA/../../target/ear"/>
<j:forEach var="dep" items="${pom.dependencies}">
<j:if test= "${dep.type == 'jar'}">
<j:if test= "${dep.groupId != pom.groupId}">
<j:if test= "${dep.getProperty('jar.manifest.classpath') == 'true'}">
<ant:copy todir="${earDirectory}">
<fileset dir="${maven.repo.local}/${dep.groupId}/jars/">
<include name="${dep.artifact}"/>
<exclude name="*commons-logging*"/>
</fileset>
</ant:copy>
</j:if>
</j:if>
</j:if>
</j:forEach> <ant:copy
file="${maven.repo.local}/${pom.groupId}/jars/${pom.artifactId}-${pom.CurrentVersion}.jar"
tofile="${earDirectory}/${pom.artifactId}-${pom.CurrentVersion}.jar"/>
</goal> </project>
__ __
| \/ |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
|_| |_\__,_|\_/\___|_||_| v. 1.0.2 build:start: create-schema:
execute-script:
[sql] Executing file: C:\ProjetoMDA\SuportePais\core\cd\target\schema-create.sql
[sql] 0 of 0 SQL statements executed successfully
BUILD SUCCESSFUL
Total time: 1 seconds
Finished at: Thu Apr 19 16:50:42 BRT 2012 C:\ProjetoMDA\SuportePais>
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:j="jelly:core"
xmlns:util="jelly:util"
xmlns:i="jelly:interaction"> <ant:property environment="env"/> <!-- ==================================================================
Builds everything and installs it into the local Maven repository
================================================================== -->
<goal name="install">
<maven:maven
descriptor="mda/project.xml"
goals="pom:install"/>
<maven:maven
descriptor="common/project.xml"
goals="jar:install"/>
<maven:maven
descriptor="core/project.xml"
goals="install"/>
<maven:maven
descriptor="web/project.xml"
goals="install"/>
</goal> <goal name="lib">
<j:set var="goal" value="libaux"/>
<attainGoal name="multiproject:goal"/>
<attainGoal name="libaux"/>
</goal>
<goal name="libaux">
</goal> <!-- ==================================================================
Cleans Everything
================================================================== -->
<goal name="clean">
<attainGoal name="multiproject:clean"/>
<!-- get rid of all the log files -->
<ant:delete>
<ant:fileset dir=".">
<ant:include name="**/*.log*"/>
<ant:exclude name="maven.log"/>
<ant:exclude name="**/*andromda*.log"/>
</ant:fileset>
</ant:delete>
</goal> <!-- ==================================================================
Cleans Everything and deletes all implementation classes
================================================================== -->
<goal name="nuke">
<i:ask question="This will also clean out all implementation classes, are you sure (y/n) ?"
answer="nukeit"/>
<j:choose>
<j:when test="${nukeit eq 'y'}">
<ant:echo>Nuking source code...</ant:echo>
<attainGoal name="clean"/>
<ant:delete>
<fileset dir="common/src/java">
<include name="**/*Impl.java"/>
</fileset>
<fileset dir="core/src/java">
<include name="**/*Impl.java"/>
</fileset>
<fileset dir="web/src/java">
<include name="**/*Impl.java"/>
</fileset>
</ant:delete>
<ant:echo>Finished nuke.</ant:echo>
</j:when>
<j:otherwise>
<ant:echo>Nuke was canceled by user.</ant:echo>
</j:otherwise>
</j:choose>
</goal>
<!-- ==================================================================
Deploy the Application
================================================================== -->
<goal name="deploy">
<maven:maven
descriptor="common/project.xml"
goals="deploy"/>
<maven:maven
descriptor="core/project.xml"
goals="deploy"/>
<maven:maven
descriptor="web/project.xml"
goals="deploy"/>
</goal> <!-- ==================================================================
Undeploy the Application
================================================================== -->
<goal name="undeploy">
<maven:maven
descriptor="common/project.xml"
goals="undeploy"/>
<maven:maven
descriptor="core/project.xml"
goals="undeploy"/>
<maven:maven
descriptor="web/project.xml"
goals="undeploy"/>
</goal> <!-- ==================================================================
Builds the Web component
================================================================== -->
<goal name="web">
<maven:maven
descriptor="web/project.xml"
goals="install"/>
</goal> <!-- ==================================================================
Builds the Core component
================================================================== -->
<goal name="core">
<maven:maven
descriptor="core/project.xml"
goals="install"/>
</goal> <!-- ==================================================================
Builds the Common component
================================================================== -->
<goal name="common">
<maven:maven
descriptor="common/project.xml"
goals="jar:install"/>
</goal> <!-- ==================================================================
Runs the MDA component
================================================================== -->
<goal name="mda">
<maven:maven
descriptor="mda/project.xml"
goals="pom:install"/>
</goal> <!-- ==================================================================
Starts the AndroMDA server
================================================================== -->
<goal name="start-andromda-server">
<maven:maven
descriptor="mda/project.xml"
goals="andromda:start-server"/>
</goal> <!-- ==================================================================
Stops the AndroMDA server
================================================================== -->
<goal name="stop-andromda-server">
<maven:maven
descriptor="mda/project.xml"
goals="andromda:stop-server"/>
</goal> <!-- ============================================================
Initializes the database schema for this application
============================================================ -->
<goal name="create-schema">
<j:set var="script" value="${dataSource.sql.init}"/>
<attainGoal name="execute-script"/>
</goal> <!-- ============================================================
Drops the database schema for this application
============================================================ -->
<goal name="drop-schema">
<j:set var="script" value="${dataSource.sql.drop}"/>
<attainGoal name="execute-script"/>
</goal> <goal name="load-dummy-data">
<j:set var="script" value="${dataSource.sql.load}"/>
<attainGoal name="execute-script"/>
</goal> <j:set var="generatedSourceDir" value="${maven.build.dir}"/>
<ant:available
file="${maven.build.src}"
type="dir"
property="generatedSrcAvailable"/> <!-- ============================================================
Adds the generated source to the compile path for
each subproject (if any exists)
============================================================ -->
<preGoal name="java:compile">
<!-- only attempt to add the generated source to the classpath
if we have a source directory -->
<j:set var="sourceDirectory" value="${pom.build.sourceDirectory}"/>
<j:if test="${!empty sourceDirectory}">
<j:if test="${generatedSrcAvailable}">
<ant:available
file="${sourceDirectory}"
type="dir"
property="srcAvailable"/>
<j:choose>
<j:when test="${srcAvailable}">
<!-- add the paths of the generated source to the
maven compile path -->
<ant:path
id="andromda.java.gen.src"
location="${generatedSourceDir}/src"/>
<maven:addPath
id="maven.compile.src.set"
refid="andromda.java.gen.src"/>
</j:when>
<j:otherwise>
<ant:path id="maven.compile.src.set">
<!-- need to set sources present to true since
maven thinks no source exist if the directory
specified by pom.build.sourceDirectory doesn't exist -->
<j:set var="sourcesPresent" value="true"/>
<ant:pathelement location="${generatedSourceDir}/src"/>
</ant:path>
</j:otherwise>
</j:choose>
</j:if>
</j:if>
</preGoal> <!-- ============================================================
Executes the given DDL script
============================================================ -->
<goal name="execute-script">
<j:if test="${script != null}">
<util:file var="scriptFile" name="${script}"/>
<j:if test="${scriptFile.exists()}">
<ant:sql driver="${dataSource.driver.class}"
src="${scriptFile}"
url="${dataSource.url}"
userid="${dataSource.user}"
password="${dataSource.password}"
onerror="${dataSource.sql.onError}">
<ant:classpath>
<ant:pathelement location="${dataSource.driver.jar}"/>
</ant:classpath>
</ant:sql>
</j:if>
</j:if>
</goal> <!-- ============================================================
Gera arquivo EAR contendo todos os modulos
============================================================ -->
<goal name="earInstall">
<j:set var="targetDirectory" value="C:\ProjetoMDA/target"/>
<j:set var="earDirectory" value="C:\ProjetoMDA/target/ear"/>
<!-- apaga arquivos previamente gerados -->
<util:available file="${targetDirectory}/${pom.artifactId}.ear">
<ant:delete file="${targetDirectory}/${pom.artifactId}.ear"/>
</util:available>
<util:available file="${earDirectory}">
<ant:delete dir="${earDirectory}"/>
</util:available>
<!-- cria diretorios -->
<ant:mkdir dir="${targetDirectory}"/>
<ant:mkdir dir="${earDirectory}"/>
<ant:mkdir dir="${earDirectory}/META-INF"/>
<ant:mkdir dir="${earDirectory}/temp"/>
<maven:reactor
includes="common/project.xml,core/cd/project.xml,core/cs/*/project.xml,web/*/project.xml"
banner="Building EAR"
goals="earInstall"
basedir="C:\ProjetoMDA"/>
<ant:concat destfile="${earDirectory}/temp/temp-meio.xml" binary="true">
<ant:fileset dir="${earDirectory}/temp" includes="*"/>
</ant:concat>
<!-- cria arquivo application.xml -->
<j:file name="${earDirectory}/temp/temp-inicio.xml"
outputMode="xml"
omitXmlDeclaration="true"
escapeText="false"
trim="false"><![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd"> <application>
<display-name>${pom.artifactId}</display-name>
]]></j:file> <j:file name="${earDirectory}/temp/temp-fim.xml"
outputMode="xml"
omitXmlDeclaration="true"
escapeText="false"
trim="false"><![CDATA[
</application>]]></j:file> <ant:concat destfile="${earDirectory}/META-INF/application.xml" binary="true">
<ant:filelist dir="${earDirectory}/temp" files="temp-inicio.xml,temp-meio.xml,temp-fim.xml"/>
</ant:concat> <!-- gera arquivo de configuracao do jboss para isolamento de classes -->
<j:file name="${earDirectory}/META-INF/jboss-app.xml"
outputMode="xml"
omitXmlDeclaration="true"
escapeText="false"
trim="false"><![CDATA[<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE jboss-app PUBLIC '-//JBoss//DTD J2EE Application 1.3V2//EN' 'http://www.jboss.org/j2ee/dtd/jboss-app_3_2.dtd'> <jboss-app>
<loader-repository>
jboss.loader:loader=${pom.artifactId}.ear
<loader-repository-config>
java2ParentDelegation=false
</loader-repository-config>
</loader-repository>
</jboss-app>
]]></j:file>
<ant:delete dir="${earDirectory}/temp"/>
<ant:zip compress="false" basedir="${earDirectory}" destfile="${targetDirectory}/${pom.artifactId}.ear"/>
</goal> </project>