#* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *#
Notice
About this archetype
Turbine Version: Turbine 5.0.
for skeleton application generation
First, you should have a local database installed and configured prior to beginning the application setup below.
As we are using MySQL by default you need to create the database in MySQL (server version should be at least 5.5, because of new sql driver), e.g. with
mysql -u -p mysql> create database helloWorld; mysql> \q
or other tools. The database should have been started and the database user granted enough rights.
Next, you can invoke the Maven archetype for turbine-webapp-5.0 from the command line as shown below - please update values starting with ‘groupId’ as appropriate.
mvn archetype:generate
-DarchetypeGroupId=org.apache.turbine
-DarchetypeArtifactId=turbine-webapp-5.0
-DarchetypeVersion=1.0.3-SNAPSHOT
-DgroupId=com.mycompany.webapp
-DartifactId=myhelloworld
-Dversion=1.0
-Dturbine_app_name=HelloWorld
-Dturbine_database_adapter=mysql
-Dturbine_database_user=db_username
-Dturbine_database_password=db_password
-Dturbine_database_name=helloworld
-Dturbine_database_timezone=UTC
-Dturbine_database_url=jdbc:mysql://localhost:3306/
-Dgoals=generate-sources,integration-test
You may use
mvn archetype:generate -DarchetypeCatalog=local
to avoid declaring the Darchetype* variables.
This requires you provide a local catalog in $HOME.m2\archetype-catalog.xml. Find further information here: https://maven.apache.org/archetype/archetype-models/archetype-catalog/archetype-catalog.html.
<archetype-catalog ...> org.apache.turbine turbine-webapp-5.0 1.0.3-SNAPSHOT This archetype sets up a web application project based on Apache Turbine 5.0
When invoking archetype:generate like above, you already have set Turbine goals generate-sources,integration-test and you can then skip them later.
Be aware, when you set both mvn commands goals (which are maven phases actually), i.e with
-Dgoals=generate-sources, integration-test
you have to create the database (see above) before finishing the (interactive) archetype commands. Otherwise you could catch up doing this later and after that is done calling the phases afterwards as mentioned below.
Note that the database URL (turbine_database_url) will be appended with your database name in the final pom.xml, so you do not need to specify that in the configuration.
Next, change into the newly generated project folder, in our case
cd myhelloworld
Skip next two steps, if the build was successfull mvn generate-sources ## This will generate the OM layer and SQL ## code for creating the corresponding ## database tables
mvn integration-test ## This executes the SQL code to create ## the application schema defined ## in src/main/torque-schema
You should now check the database tables and if some data is missing insert the sample data file in sample-mysql-data (Torque 4.0 has disabled the datasql task).
mvn clean install
If you get an error like “The driver has not received any packets” probably the database is not up and running or the port may be another one.
Last step on the command line is run the server by invoking mvn jetty:run
Find the Logs in src/main/webapp/logs and
Open a web browser to http://localhost:8081/app
Login should work with user admin/password or user/password.
By default Intake is used as an validation mechanism for authentication. You can change to the default login by setting
action.login=LoginUser in TurbineResources.properties and changing Login.vm appropriately (commented form)
Prerequisites
If running from integration test, check/update
The security test is by default skipped as it requires a running mysql. It tests many of the Fulcrum Torque Turbine security aspects, activate it by calling
mvn test -DskipTests=false
CAVEAT: If initialization fails, double check your database credentials! If invalid the error might be somewhat hidden behind a Torque exception!
To enable application development in Eclipse, run the following command and then import the project into Eclipse.
mvn eclipse:eclipse
Once imported, update your project to be managed by Maven -> Right click on the project name -> Configure -> Convert to Maven project
To test the application can be deployed by Eclipse, select the run configuration “Run On Server” if you have a container configured with your eclipse environment.
You even could debug the app by setting the environment variable to something like this
set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
before running the jetty server.
Be aware of settings and some smaller restrictions, which mostly will be fixed in the upcoming releases.