I am trying to get the Moqui 1.4.1 release up and running but using Postgres as the database platform. Here are the platform details.
Ubuntu 12.04
Postgres 9.4 using JDBC driver postgresql-9.3-1102.jdbc41.jar (sitting in /runtime/lib. Hope that's the right place)
Firstly, I can't find MoquiDefaultConf.xml anywhere so I assume this is only applicable to development?
Under runtime/conf, I have MoquiDevConf.xml, MoquiDevTestConf.xml, MoquiProductionConf.xml, MoquiStagingConf.xml. In all four, I have added the following entity-facade entry.
<entity-facade crypt-pass="MoquiDefaultPassword:CHANGEME">
<!--
<datasource group-name="transactional" database-conf-name="postgresql" schema-name="">
<inline-jdbc jdbc-uri="jdbc:postgresql://127.0.0.1:5432/MoquiDEFAULT?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8" jdbc-username="moqui" jdbc-password="moqui" pool-minsize="2" pool-maxsize="50"/>
</datasource>
-->
<datasource group-name="transactional" database-conf-name="postgres" schema-name="public">
<!--
<inline-jdbc pool-minsize="5" pool-maxsize="50">
<xa-properties user="moqui" password="moqui" serverName="localhost" portNumber="5432"
databaseName="MoquiDEFAULT"/>
</inline-jdbc>
-->
<inline-jdbc jdbc-uri="jdbc:postgresql://127.0.0.1:5432/MoquiDEFAULT"
jdbc-username="moqui" jdbc-password="moqui"
pool-minsize="2" pool-maxsize="50"/>
</datasource>
</entity-facade>
<!-- end snippet -->
The Problem:
When I run gradle load, the load target
creates a bunch of derby databases which I don't understand given that it is now configured for Postgres.
The tables enumeration_type and enumeration are created in Postgres.
Then the process gets stuck.
Here is the output at the point.
> --- 12304 [main] INFO org.moqui.impl.entity.EntityDbMeta
Created table [ENUMERATION_TYPE] for entity [moqui.basic.EnumerationType]
> --- 12788 [main] INFO org.moqui.impl.entity.EntityDbMeta
Created table [ENUMERATION] for entity [moqui.basic.Enumeration]
> --- 611953 [-task-scheduler] WARN Bitronix.tm.BitronixTransaction
transaction timed out: a Bitronix Transaction with GTRID [3132372E302E312E3100000000002E270D00000001], status=MARKED_ROLLBACK, 1 resource(s) enlisted (started Thu Jan 01 02:50:24 SAST 1970)
So Bitronix isn't happy about something.
If I terminate the load and restart, then it creates the next table geo and then gets stuck again although this time, it doesn't show the Bitronix warning.
> --- 12268 [main] INFO org.moqui.impl.entity.EntityDbMeta
Created table [GEO] for entity [moqui.basic.Geo]
Help appreciated.
Additional info in response to answers:
I downloaded this for the purposes of assessing functionality so I just want to run the application not extend it. As you've pointed out, this only has the pre-built WAR file in it. However, if I browse the contents of the WAR file, I find no MoquiDefaultConf.xml file. In fact, the only XML file in the whole WAR file is web.xml.
Upon discovering this, and after reading the chapter in the book regarding setup, I googled MoquiDefaultConf.xml and found the file on github. I then copied the datasource element out of that and simply pasted that into the entity-facade of ALL the listed Moqui*Conf.xml to make sure it got picked up....which it finally did but with the halting issue. I tried both inline jdbc options; once with the one with the xa-properties tag and once with the one without.
Sorry. I am from a Microsoft background so this is all a bit foreign to me , but in my defence I was technically capable of getting OFBiz up and running by fumbling around like this.
UPDATE:
OK. Progress.
Turns out I was running Postgres 9.1 not 9.4 (Oops. Linux noob) with postgresql-9.3-1102.jdbc4.jar driver. Not sure if that was contributing to the halting but I upgraded to Postgres 9.4 with postgresql-9.3-1102.jdbc41.jar driver, and the halting was still happening.
David, you correctly pointed out the missing startup-add-missing and runtime-add-missing attributes. The reason this happened was because I had initially tried to cobble the datasource element together from OFBiz equivalent, and when I eventually found the MoquiDefaultConf.xml online, I only copied the inline-jdbc elements into the datasource elements I used from OFBiz and didn't copy the whole datasource element. Silly. Anyway, after adding the datasource element to ONLY the MoquiDevConf.xml and "gradle load"ing, 91 tables were created in Postgres so the build completed successfully....well sort of.
A derby database called MoquiDEFAULT is still created in the derby folder in the db folder. I can confirm that the webapp is talking to Postgres because I created an entry in the Example grid and it appeared in the example table in Postgres. I don't know enough about the internals to know if queries are duplicating on the derby database.
Lastly, after using a process of elimination, I determined that the build was using MoquiDevConfig.xml and not MoquiProductionConf.xml. I.e. when I put the datasource in only the MoquiProductionConf.xml entity-facade element, it has no effect and creates tables only in derby (well...over 100 .dat files) and none in Postgres. This is confusing given that MoquiInit.properties only ever references MoquiProductionConf.xml. I can confirm that building using MoquiDevConfig.xml generates about 20 fewer .dat files than does MoquiProductionConf.xml. I don't know enough about Gradle build files to know what to change.
MoquiDevConf.xml
<?xml version="1.0" encoding="UTF-8" ?>
<tools enable-elasticsearch="true" enable-camel="false"/>
<cache-list>
<!-- Development Mode - don't use these for production, load testing, etc.
Cleared by default every 20 seconds from when loaded into cache. -->
<cache name="entity.definition" expire-time-idle="30"/>
<!-- longer timeout since this basically looks through all files to check for new or moved entity defs -->
<cache name="entity.location" expire-time-idle="300"/>
<cache name="entity.data.feed.info" expire-time-idle="30"/>
<cache name="service.location" expire-time-idle="5"/>
<cache name="service.java.class" expire-time-idle="5"/>
<cache name="kie.component.releaseId" expire-time-idle="5"/>
<cache name="screen.location" expire-time-idle="5"/>
<cache name="screen.template.mode" expire-time-idle="5"/>
<cache name="screen.template.location" expire-time-idle="5"/>
<cache name="resource.xml-actions.location" expire-time-idle="5"/>
<cache name="resource.groovy.location" expire-time-idle="5"/>
<!-- longer timeout because these are cached by the expression text itself, so changed text is a new entry -->
<cache name="resource.groovy.expression" expire-time-idle="600"/>
<cache name="resource.javascript.location" expire-time-idle="5"/>
<cache name="resource.ftl.location" expire-time-idle="5"/>
<cache name="resource.gstring.location" expire-time-idle="5"/>
<cache name="resource.wiki.location" expire-time-idle="5"/>
<cache name="resource.markdown.location" expire-time-idle="5"/>
<cache name="resource.text.location" expire-time-idle="5"/>
<cache name="resource.reference.location" expire-time-idle="5"/>
<cache name="l10n.message" expire-time-idle="600"/>
</cache-list>
<server-stats stats-skip-condition="ec.web?.request?.pathInfo?.startsWith('/rpc') || ec.web?.request?.pathInfo?.startsWith('/status')">
<!-- For development, track everything! It'll run slow through... -->
<artifact-stats type="screen" persist-bin="true" persist-hit="true"/>
<artifact-stats type="screen-content" persist-bin="true" persist-hit="true"/>
<artifact-stats type="transition" persist-bin="true" persist-hit="true"/>
<artifact-stats type="service" persist-bin="true" persist-hit="true"/>
<artifact-stats type="service" sub-type="entity-auto" persist-bin="true" persist-hit="false"/>
<artifact-stats type="service" sub-type="entity-implicit" persist-bin="true" persist-hit="false"/>
<artifact-stats type="entity" persist-bin="true"/>
</server-stats>
<webapp-list>
<webapp name="webroot" http-port="8080" https-enabled="false">
<root-screen host=".*" location="component://webroot/screen/webroot.xml"/>
</webapp>
</webapp-list>
<screen-facade boundary-comments="true">
<!-- The default conf file has a macro location defined for html already, but this is an example of how to
refer to a file to override the default macros. -->
<screen-text-output type="html" mime-type="text/html"
macro-template-location="template/screen-macro/ScreenHtmlMacros.ftl"/>
</screen-facade>
<entity-facade crypt-pass="MoquiDefaultPassword:CHANGEME">
<datasource group-name="transactional" database-conf-name="postgres" schema-name="public" startup-add-missing="true" runtime-add-missing="false">
<inline-jdbc pool-minsize="5" pool-maxsize="50">
<xa-properties user="moqui" password="moqui" serverName="localhost" portNumber="5432"
databaseName="MoquiDEFAULT"/>
</inline-jdbc>
<!-- <inline-jdbc jdbc-uri="jdbc:postgresql://127.0.0.1/MoquiDEFAULT"
jdbc-username="moqui" jdbc-password="moqui" pool-minsize="2" pool-maxsize="50"/> -->
</datasource>
</entity-facade>
<repository-list>
<!-- <repository name="main" location="http://localhost:8081/rmi" type="rmi" workspace="default"
username="admin" password="admin"/> -->
</repository-list>
<component-list>
<!-- This loads the tools component over top of the default one, which will result in a warning but works
fine. Use something like this to refer to components in a JCR repository. -->
<component name="tools" location="component/tools"/>
</component-list>
The MoquiDefaultConf.xml file is in the pre-built executable war file if you downloaded the binary release, though you can see it here in the source repo:
https://github.com/moqui/moqui/blob/master/framework/src/main/resources/MoquiDefaultConf.xml
In there you will see an example configuration for Postgres:
<datasource group-name="transactional" database-conf-name="postgres" schema-name="public" startup-add-missing="true" runtime-add-missing="false">
<inline-jdbc pool-minsize="5" pool-maxsize="50">
<xa-properties user="moqui" password="moqui" serverName="localhost" portNumber="5432"
databaseName="MoquiDEFAULT"/>
</inline-jdbc>
<!-- <inline-jdbc jdbc-uri="jdbc:postgresql://127.0.0.1/MoquiDEFAULT"
jdbc-username="moqui" jdbc-password="moqui" pool-minsize="2" pool-maxsize="50"/> -->
</datasource>
Note especially these two attributes on the datasource element: startup-add-missing="true" runtime-add-missing="false". Postgres does not support creating tables on the fly, so they all have to be created before the system gets running instead of the default mode which is to create tables only as they are needed (when the first write is done).
The MoquiDefaultConf.xml file also has a definition for the "tenantcommon" entity group, pointing it to Derby:
<datasource group-name="tenantcommon" database-conf-name="derby" schema-name="MOQUI">
<inline-jdbc pool-minsize="2" pool-maxsize="10">
<xa-properties databaseName="${moqui.runtime}/db/derby/MoquiDEFAULT" createDatabase="create"/>
</inline-jdbc>
</datasource>
To put those entities in Postgres as well you'll need to add a similar definition to the Moqui Conf XML file used at runtime.
Use this config inside entity-facade tag in MoquiDevConf.xml or MoquiProductionConf.xml
<datasource group-name="transactional" database-conf-name="postgres" schema-name="public" startup-add-missing="true" runtime-add-missing="false">
<inline-jdbc jdbc-uri="jdbc:postgresql://localhost/dbname" jdbc-username="postgres" jdbc-password="pass"/>
</datasource>
Related
I have application running in Websphere Liberty and uses DB2 in Z/oS. I have set the db2 driver proerties in DB2JCCConfiguration.properties .How can make sure that the server has picked up properties I have set .I am not sure how to verify the trace to see if the properties are applied to server
To configure a datasource (for any backend DB) with Liberty, you can add configuration like this to your server.xml:
<featureManager>
<feature>jdbc-4.2</feature>
</featureManager>
<library id="driver-library">
<fileset dir="/path/to/driver/dir" includes="*.jar"/>
</library>
<dataSource id="DefaultDataSource" jndiName="jdbc/myDB">
<jdbcDriver libraryRef="driver-library"/>
<properties.db2.jcc serverName="example.db.hostname.com" portNumber="50000"
databaseName="myDB"
user="exampleUser"
password="examplePassword"
currentSchema="xyz"
fullyMaterializeInputStreams="true"/>
</dataSource>
To test if your configuration is correct and that your Liberty server can connect to your DB2 database, add the following configuration:
<featureManager>
<feature>appSecurity-3.0</feature>
<feature>restConnector-2.0</feature>
<feature>jdbc-4.2</feature>
</featureManager>
<!-- Any security mechanism can be used, <quickStartSecurity> is the simplest -->
<quickStartSecurity userName="admin" userPassword="admin"/>
And then go to: https://localhost:9443/ibm/api/validation/dataSource/DefaultDataSource
(this assumes your <dataSource> id is DefaultDataSource)
For more info, see this cheat sheet: https://aguibert.github.io/openliberty-cheat-sheet/#_ibm_db2
I have added system-properties tag in standalone-full.xml, but its not working in standalone mode. However, if I add the same tag in domain.xml it's working for domain mode.
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:2.2">
<extensions>
....
</extensions>
<system-properties>
<property name="java.util.Arrays.useLegacyMergeSort" value="true"/>
</system-properties>
</server>
According to this article on jBoss General configuration concepts
System property values can be set in a number of places in domain.xml, host.xml and standalone.xml.
Then what about standalone-full.xml?
I don't want to set it through command line and not even in java code.
In standalone it's probably too late to set it in the configuration files. You'll need to add it to the standalone.conf or standalone.conf.bat in the JAVA_OPTS environment variable. A global property like that needs to be set before anything else attempts to use java.util.Arrays.
If you have started the Wildfly server with standalone-full.xml instead of standalone.xml(the default) than this should be reflected in the start of the server:
standalone.sh -b <hostIP> -c standalone-full.xml -Dorg...
Then this will have effect on first start.
If you change something in this config file, you will need to reload Wildfly(configuration) from jboss cli:
[standalone#localhost:9990 /] :reload
For Wildfly 10 it's working nontheless. I was able to read the property for an instance started with the standalone-full.xml containing some properties.
The manual must be outdated then I guess? Because even Wildfly itself inserts a new property in the standalone-full.xml when using the Wildfly admin webinterface: http://localhost:9990 > Configuration > System Properties (Wildfly will add the property of course to the xml config which was used to start the instance). That's enough proof for me.
I am following these exercises for learning Liberty.
I am having an issue in he Lab 3 - Module 2.2 Liberty and JPA (DB2) .
After setting all the JDBC and Data Source details, i restart the server and i do not see the two lines that mention the dataSource and jdbd driver.
[AUDIT] J2CA8004I : The dataSource DB2Connection is avilable as jdbc/DB2Connection.
[AUDIT] J2CA8000I : The jdbcDriver my JDBCDriver is available.
How can i know if the jpa and jdb features ae correctly set?
This is the server.xml
<!-- Enable features -->
<featureManager onError="WARN">
<feature>jsp-2.2</feature>
<feature>jpa-2.0</feature>
<feature>jdbc-4.0</feature>
</featureManager>
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
httpPort="9080"
httpsPort="9443" />
<jdbcDriver id="myJDBCDriver">
<library name="DB2Lib">
<fileset dir="C:\wlp\db2jdbc" includes="db2jcc4.jar, db2jcc_license_cu.jar"></fileset>
</library>
</jdbcDriver>
<dataSource jndiName="jdbc/DB2Connection" id="DB2Connection"
jdbcDriverRef="myJDBCDriver">
<properties.db2.jcc databaseName="SAMPLE" serverName="igacloud" password="{xor}FhgeOz1tPj08" user="db2admin"></properties.db2.jcc>
</dataSource>
Unlike Classic WebSphere, which has a "test connection" capability in its admin console (datasource panel), there is no equivalent means with WebSphere Liberty yet. Have you tried testing the connection with a simple "Hello World" JPA application?
The CWWKF0012I message is simply confirming what features have been enabled - some features depend on other features and automatically enables them, which is why you see more features than defined in your server.xml.
I have a small test in which I am trying to chalk out the time taken by Infinispan in a local cache and then in a local cache with a write behind.
Surprisingly, the time taken in a local cache to put 8M entries is around 27 sec and to do a get it is 1 millisec. That is good. However, as soon as I enable the write behind the does not even end in 30 minutes. I am sure there is something which is terribly wrong with the configuration.
I have used 5.3.0 Final and 5.2.7 final.
The configurations are pasted here
<namedCache name="LocalWithWriteBehind">
<loaders shared="false">
<loader class="org.infinispan.loaders.file.FileCacheStore"
fetchPersistentState="true" ignoreModifications="false"
purgeOnStartup="false">
<properties>
<property name="location" value="${java.io.tmpdir}" />
</properties>
<!-- write-behind configuration starts here -->
<async enabled="true" threadPoolSize="500" />
<!-- write-behind configuration ends here -->
</loader>
</loaders>
</namedCache>
If you would like to see the Scala App, see the code here http://pastebin.com/PSiJFFiZ
The file cache store before Infinispan 6.0 was very slow. Please upgrade to Infinispan 6.0.0.Final, and enable the single file cache store as indicated here.
Can I dump a properties file somewhere in one of the JBoss 6 directories, and pick it up from the classpath?
Or even better, does anybody know the mechanism behind a configuration file like $JBOSS_HOME/server/default/deploy/jboss-logging.xml? Changes to this file seem to trigger an event, so that a running instance can process the modifications (without having to bounce the AS).
A possibility is to configure SystemPropertiesService in ./conf/jboss-service.xml.
This allows you to configure system properties in-place, or load them from a properties file:
<server>
<mbean code="org.jboss.varia.property.SystemPropertiesService"
name="jboss.util:type=Service,name=SystemProperties">
<!-- Load properties from each of the given comma seperated URLs -->
<attribute name="URLList">
http://somehost/some-location.properties,
./conf/somelocal.properties
</attribute>
<!-- Set propertuies using the properties file style. -->
<attribute name="Properties">
property1=This is the value of my property
property2=This is the value of my other property
</attribute>
</mbean>
</server>
For more details, refer to: http://docs.jboss.org/jbossas/admindevel326/html/ch10.html
They have made this even easier in JBoss EAP 6 (AS 7).
Pass Property File as Startup Parameter
This can be added within the main start up script or passed as parameter
./standalone.sh --properties=/Users/john.galt/dev/config/ds/jboss.properties
If these properties are read, they will be rendered in the server log as the first statement.
3:58:41,633 DEBUG [org.jboss.as.config] (MSC service thread 1-6) Configured system properties:
DSsettings.password = password
DSsettings.user-name = admin
DSsettings.connection-url = jdbc:oracle:fat:#activedb:1521:DEV
[Standalone] =
awt.nativeDoubleBuffering = true
NOTE: As these settings are logged in server log, ensure no clear text passwords are in the property files in production
Use passed in system properties
You could use these system properties with following syntax.
Example Usage in a data source file
<xa-datasource jndi-name="java:jboss/ds" pool-name="cPool" jta="true" enabled="true" use-ccm="true">
<xa-datasource-property name="URL">
${DSsettings.connection_url}
</xa-datasource-property>
<driver>oracle</driver>
...
<security>
<user-name>${DSsettings.user-name}</user-name>
<password>${DSsettings.password}</password>
</security>
...
</xa-datasource>
In JBoss 6 use: ./deploy/properties-service.xml
On JBoss AS7 properties-service.xml no longer exist, the below is the solution:
http://www.mastertheboss.com/jboss-server/jboss-configuration/how-to-inject-system-properties-into-jboss