Entries tagged [wildfly]
Installing Apache Derby to WildFly
TweetPosted on Saturday Jan 10, 2015 at 02:29PM in Technology
This post describes how to install Apache Derby 10.11.1.1 as Embedded Server to WildFly 8.2.0.Final. following instructions are intended to use with jboss-cli.
- Install jars of Derby as a module into WildFly (assume jar files are located in /tmp)
module add \ --name=org.apache.derby \ --resources=/tmp/derby.jar,/tmp/derbynet.jar,/tmp/derbytools.jar \ --resource-delimiter=, \ --dependencies=javax.api,javax.transaction.api
- Register JDBC Driver named "derby-embedded"
/subsystem=datasources/jdbc-driver=derby-embedded:add(driver-name=derby-embedded, \ driver-module-name=org.apache.derby, \ driver-class-name=org.apache.derby.jdbc.EmbeddedDriver, \ driver-datasource-class-name=org.apache.derby.jdbc.EmbeddedDataSource, \ driver-xa-datasource-class-name=org.apache.derby.jdbc.EmbeddedXADataSource)
- Deploy a MBean which executes the shutdown procedure of Derby
git clone https://github.com/lbtc-xxx/derby-shutdown-service cd derby-shutdown-service; mvn clean package cp target/derby-shutdown-service.jar $WILDFLY_HOME/standalone/deployments
- Define a system property which triggers Derby to listen a port
/system-property=derby.drda.startNetworkServer:add(value=true)
- Define a system property to specify the port Derby will be listening
/system-property=derby.drda.portNumber:add(value="1527")
- Define a system property to specify where log file of Derby will be wrote
/system-property=derby.stream.error.file:add(value="${jboss.server.log.dir}/derby.log")
- Define a system property to append derby.log to exist one
/system-property=derby.infolog.append:add(value="true")
- (For Hibernate user) Add following dependency to
modules/system/layers/base/org/hibernate/main/module.xml
<module name="org.apache.derby"/>
This prevents following warning:WARN [org.hibernate.dialect.DerbyDialect] (ServerService Thread Pool -- 72) HHH000328: Unable to load/access derby driver class sysinfo to check versions : org.apache.derby.tools.sysinfo from [Module "org.hibernate:main" from local module loader @11028347 (finder: local module finder @14899482 (roots: /Users/kyle/servers/wildfly-8.2.0.Final/modules,/Users/kyle/servers/wildfly-8.2.0.Final/modules/system/layers/base))]
- Define a DataSource
- Test connection
/subsystem=datasources/data-source=DerbyEmbeddedDS:test-connection-in-pool
For Regular DataSource:
data-source add \ --name=DerbyEmbeddedDS \ --driver-name=derby-embedded \ --connection-url=jdbc:derby:${jboss.server.base.dir}/derbydata;create=true \ --jndi-name=java:jboss/jdbc/DerbyEmbeddedDS \ --user-name=app \ --password=app
For XA DataSource:
xa-data-source add \ --name=DerbyEmbeddedXADS \ --driver-name=derby-embedded \ --jndi-name=java:jboss/jdbc/DerbyEmbeddedXADS \ --user-name=app \ --password=app \ --same-rm-override=false \ --xa-datasource-properties={ \ "DatabaseName" => "${jboss.server.base.dir}/derbyxadata", \ "CreateDatabase" => "create"}
Also you need to ensure that shutdown script such as /etc/init.d/wildfly
to not execute forcing termination (kill -9
) unexpectedly. it will be triggered by exceed timeout of 30 seconds as default and it may bring database corruption in case that executing force shutdown during shutdown process of Derby. I think that longer timeout would be considerable for poor environment.
References
Index needed on jobexecutionid column in step_execution table
TweetPosted on Monday Jan 05, 2015 at 09:56PM in jberetweb
Today I deployed new jberetweb to my production system which have 1 million rows in step_execution table, and felt jberetweb slow. I looked it and found the cause is sequential scan.
jbatch=# explain analyze select * from step_execution where jobexecutionid = 384846; QUERY PLAN ------------------------------------------------------------------------------------------------------------------ Seq Scan on step_execution (cost=0.00..36817.53 rows=4 width=626) (actual time=101.046..101.047 rows=2 loops=1) Filter: (jobexecutionid = 384846) Rows Removed by Filter: 1102459 Total runtime: 101.074 msSo I created an index on jobexecutionid column in step_execution table, then jberetweb starts running fast.
jbatch=# create index step_execution_jobexecutionid_idx on step_execution (jobexecutionid); CREATE INDEX jbatch=# explain analyze select * from step_execution where jobexecutionid = 384846; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------- Index Scan using step_execution_jobexecutionid_idx on step_execution (cost=0.43..8.50 rows=4 width=626) (actual time=0.054..0.056 rows=2 loops=1) Index Cond: (jobexecutionid = 384846) Total runtime: 0.113 msMaybe more indexes are needed for default JBeret schema if I implement some filtering function to jberetweb.
Job operation features are implemented to jberetweb
TweetPosted on Sunday Jan 04, 2015 at 09:26PM in jberetweb
Now jberetweb is able to operate JobOperator interface through remote EJB invocation, so finally jberetweb can start batch jobs. the Start Job window popups when "Start Job" anchor is clicked on the upper right corner. here's a screenshot:
To use this feature, some preparation are needed. first, you have to expose a remote EJB interface of javax.batch.operations.JobOperator from your batch application archive. an example of simplest one is available here. also entire of the project is here.
You can just put this class to any package in your batch application archive. after that, you can see some notification of JNDI names in your WildFly console at every deployment like this:
21:06:45,501 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-10) JNDI bindings for session bean named JobOperatorFacade in deployment unit deployment "jbatchtest-1.0-SNAPSHOT.war" are as follows: java:global/jbatchtest-1.0-SNAPSHOT/JobOperatorFacade!javax.batch.operations.JobOperator java:app/jbatchtest-1.0-SNAPSHOT/JobOperatorFacade!javax.batch.operations.JobOperator java:module/JobOperatorFacade!javax.batch.operations.JobOperator java:jboss/exported/jbatchtest-1.0-SNAPSHOT/JobOperatorFacade!javax.batch.operations.JobOperator java:global/jbatchtest-1.0-SNAPSHOT/JobOperatorFacade java:app/jbatchtest-1.0-SNAPSHOT/JobOperatorFacade java:module/JobOperatorFacade
Then save first one of yours ("java:global/jbatchtest-1.0-SNAPSHOT/JobOperatorFacade!javax.batch.operations.JobOperator" for example), then put that string to a build parameter of jberetweb (after "-DjobOperator.jndi="). please refer "How to use" section of README.md for build instruction.
Other operations such as restart, stop, abandon are implemented too so I will write more about it later. jberetweb can be obtained from GitHub.
jberetweb, JBeret job repository viewer
TweetPosted on Friday Jan 02, 2015 at 01:01AM in jberetweb
What are JBeret and jberetweb?
JBeret is the out-of-the-box JSR352 JBatch implementation of the WildFly application server. It manages its statuses of jobs and steps in several types of data storage, like RDBMS, which is called repository. But it has no management console or even a standardized way to see it efficiently (I've been watching the repository through SQL!). So, I have created jberetweb as a small web application which shows the JDBC job repository of JBeret.
jberetweb can be obtained at GitHub.
What can be done with jberetweb?
It shows recent job executions with their names, the start/end time and the batch status on the table in the upper half of the page. These rows are clickable. Additional information, like job parameters and step executions, will be shown when any row of the job executions table is clicked. Execution exception data will be shown if the step has failed because an exception occurred. Any problematic rows, such as a failed execution or step, are highlighted. Thanks to JSF's partial rendering and Ajax, paging and operations are fast.
How do I install it?
As I described at README.md in GitHub repository of it, you have to clone and build it with mvn yourself, and some configuration is needed for WildFly before deploying the WAR.
- Create a database on PostgreSQL (jberetweb should run on any other RDBMS, but I haven't tested yet)
- Register a XA data source for the job repository
- Register JNDI name of the JDBC job repository
- Set the job repository type as JDBC
- Define JSF project stage to JNDI
batch xa-data-source add \ --name=JBatchDS \ --driver-name=postgresql \ --jndi-name=java:jboss/jdbc/JBatchDS \ --user-name=postgres \ --password=*** /subsystem=datasources/xa-data-source="JBatchDS"/xa-datasource-properties=ServerName:add(value="localhost") /subsystem=datasources/xa-data-source="JBatchDS"/xa-datasource-properties=PortNumber:add(value="5432") /subsystem=datasources/xa-data-source="JBatchDS"/xa-datasource-properties=DatabaseName:add(value="jbatch") run-batch /subsystem=batch/job-repository=jdbc:write-attribute(name=jndi-name, value=java:jboss/jdbc/JBatchDS) /subsystem=batch:write-attribute(name=job-repository-type, value=jdbc) /subsystem=naming/binding=java\:\/env\/jsf\/ProjectStage:add(binding-type=simple,value=Development,class=java.lang.String)
NOTE:
- JBeret creates the schema automatically if any tables aren't found, so make sure the database user can execute DDLs.
- Use XA datasource for both the job repository and your application database.
Here's some related pointers:
- [WFLY-3174] Add view of batch jobs with ability to view, restart and stop - JBoss Issue Tracker
- JSR 352 - Viewing batch jobs in admin console | JBoss Developer
I would be grateful for your feedback because it's my first software which is public on GitHub.
Install Apache Roller 5.1.0-SNAPSHOT to WildFly
TweetPosted on Friday May 16, 2014 at 05:40PM in Technology
I installed Apache Roller 5.0.3 to WildFly at this article, but unfortunately it was so annoying procedure. Roller 5.0.3 comes with official installation guide to JBoss6, but it seems to be obsoleted for WildFly, so I had to such struggle to install Roller to WildFly.
But, I heard that from a developer of Roller, latest Roller and its installation guide is updated as compatible with newer JBoss version. also some problems at deploying to WildFly are fixed, so it became more easy to deploy to newer JBoss version, so I recommend latest Roller to who wants to use Roller with WildFly. The guide is fine and I guess that it's might be better to read it than this entry.
Environment
- Apache Roller 5.1.0-SNAPSHOT
- Apache Maven 3.1.1
- WildFly 8.1.0.CR1
- Oracle JDK8u5
- PostgreSQL 9.2.4
- OS X 10.9.3
Preconditions
- Appropriate JDBC driver is already installed.
Procedures
- Checkout latest Apache Roller
svn co https://svn.apache.org/repos/asf/roller/trunk roller_trunk
- Build
cd roller_trunk; mvn clean install
The WAR file will be built at roller_trunk/app/target/roller.war
- Create a database (with psql)
create database roller owner wildfly encoding 'UTF8' TEMPLATE template0;
- Create a DataSource (with jboss-cli)
data-source add \ --name=RollerDS \ --driver-name=postgresql-9.3-1100.jdbc41.jar \ --connection-url=jdbc:postgresql://localhost:5432/roller \ --jndi-name=java:/RollerDS \ --user-name=wildfly \ --password=*** \ --check-valid-connection-sql="SELECT 1" \ --background-validation-millis=60000 \ --validate-on-match=true \ --jta=false
- Set default datasource
/subsystem=jpa:write-attribute(name=default-datasource, value="java:/RollerDS")
- Create a JavaMail session
/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=RollerSMTP:add( \ host=smtp.gmail.com, \ port=465) /subsystem=mail/mail-session=RollerMail:add(jndi-name="java:/RollerMail", from="jane.doe@gmail.example.com", debug=true) /subsystem=mail/mail-session=RollerMail/server=smtp:add( \ outbound-socket-binding-ref=RollerSMTP, \ ssl=true, \ username=jane.doe@gmail.example.com, \ password=***)
How to define a JavaMail session using CLI might be useful if you want further information about configuration of JavaMail session for WildFly.
- Create a directory at $WILDFLY_HOME/modules/org/apache/roller/configuration/main and put files below
- module.xml
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.1" name="org.apache.roller.configuration"> <resources> <resource-root path="."/> </resources> </module>
- roller-custom.properties
installation.type=auto mediafiles.storage.dir=/Users/kyle/tmp/roller510/rollerdata/mediafiles search.index.dir=/Users/kyle/tmp/roller510/rollerdata/searchindex log4j.appender.roller.File=/Users/kyle/tmp/roller510/rollerdata/roller.log database.configurationType=jndi database.jndi.name=java:/RollerDS mail.configurationType=jndi mail.jndi.name=java:/RollerMail
- hibernate.cfg.xml
<hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL9Dialect</property> </session-factory> </hibernate-configuration>
- module.xml
- Restart wildfly
- Browse /roller of your application server and do some initializing process
- Set installation.type=manual in roller-custom.properties
Remarks
It works fine now, so I would try some customizing and posting with Roller.
I still seeing an error of JavaMail or something. I would investigate it later.
WARN 2014-05-16 16:01:39,233 WebloggerStartup:prepare - Failed to setup mail provider, continuing anyways. Reason: ERROR connecting to mail server