Reputation: 903
I just created a new application with the DIY cartridge and add a MySQL cartridge to it as well. I also was able to deploy the application online. I cannot use the GlassFish administration console with OpenShift but I need to set up JDBC resources, connection pools. I'm trying to edit the domains.xml of my remote glassfish server using that of my local glassfish server. I'm still unable to connect to the database. This is what I've done so far:
<jdbc-connection-pool is-isolation-level-guaranteed="false" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" name="SamplePool" res-type="javax.sql.DataSource">
<property name="User" value="adminvcsHiYw"></property>
<property name="DatabaseName" value="timetable"></property>
<property name="serverName" value="127.8.28.2"></property>
<property name="PortNumber" value="3306"></property>
<property name="URL" value="jdbc:mysql://127.8.28.2:3306/timetable"></property>
<property name="Password" value="_R-LrpYIcdUf"></property>
</jdbc-connection-pool>
This is the output of rhc tail -a appname
==> app-root/logs/mysql.log <==
150621 7:55:43 InnoDB: highest supported file format is Barracuda.
150621 7:55:43 InnoDB: Waiting for the background threads to start
150621 7:55:44 InnoDB: 5.5.41 started; log sequence number 1686690
150621 7:55:44 [Note] Server hostname (bind-address): '127.8.28.2'; port: 3306
150621 7:55:44 [Note] - '127.8.28.2' resolves to '127.8.28.2';
150621 7:55:44 [Note] Server socket created on IP: '127.8.28.2'.
150621 7:55:44 [Warning] 'proxies_priv' entry '@ [email protected]' ignored in --skip-name-resolve mode.
150621 7:55:44 [Note] Event Scheduler: Loaded 0 events
150621 7:55:44 [Note] /opt/rh/mysql55/root/usr/libexec/mysqld: ready for connections.
Version: '5.5.41' socket: '/var/lib/openshift/5585ff875004465b5500013a/mysql//socket/mysql.sock' port: 3306 MySQL Community Server (GPL)
`
What am I doing wrong? Can anyone help?
Upvotes: 0
Views: 603
Reputation: 903
So to host a java app running on a glassfish server using Openshift you have to:
Clone from github the glassfish DIY you are going to use. The domain.xml configuration file has been modified to run on OpenShift. It already includes the MySQL driver in domain1/lib. The archive also contains the start and stop hooks we need.
In the application page select the Do-It-Yourself, DIY, cartridge
Fill it as shown on the picture below. You should nonetheless choose your app name and your domain.
You will need the OpenShift Client Tools
Configuration
rhc git-clone diyapp
and move the glassfish4 directory (the entire directory, not just its contents) into diyapp
/diy.
Move the start and stop hooks into yourapp/.openshift/action_hooks and check to make sure they're executable. chmod +x start stop
.
├── glassfish4
│ ├── bin
│ ├── glassfish
│ ├── javadb
│ ├── mq
│ └── pkg
├── README.md
├── start
└── stop
Now, add, commit and push the changes you made back to OpenShift:
cd diyapp
git add .
git status
git commit -m "Added GlassFish"
git push
The push will cause your application to restart and execute the new start hook.
Deploying app
To deploy an application, simply copy its war into domain1/autodeploy and run the previous commands again to add, commit and push the changes. GlassFish will automatically deploy your application after launch. If you think something went wrong, use ssh to log into your application and look for a your.war_deployed file in the autodeploy directory:
rhc app ssh diyapp
cd $OPENSHIFT_REPO_DIR/
cd diy/glassfish4/glassfish/domains/domain1/autodeploy/
ls
If there is no such file, take a look at the server logs to find out what went wrong:
cd ../logs/
cat server.log | tail -n100
set up JDBC resources, connection pools
Add a MySQL cartridge to your app.
You cannot use the GlassFish administration console with OpenShift. Neither does glassfish-resources.xml seem to be supported.
Set up the resources you need on a local GlassFish server. Take a look at that server's domain.xml to see what changes were made. Make the same changes to domain1/config/domain.xml in yourapp.
This is what I added
`<jdbc-connection-pool is-isolation-level-guaranteed="false" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" name="SamplePool" res-type="javax.sql.DataSource">
<property name="User" value="adminvcsHiYw"></property>
<property name="DatabaseName" value="timetable"></property>
<property name="serverName" value="127.8.28.2"></property>
<property name="PortNumber" value="3306"></property>
<property name="URL" value="jdbc:mysql://127.8.28.2:3306/timetable"></property>
<property name="Password" value="_R-LrpYIcdUf"></property>
</jdbc-connection-pool>
` So the database name is that of the MySQL cartridge you are going to add. The port name is that of MYSQL, the user name and password are provided once you create the MYSQL cartidge.
OPENSHIFT_MYSQL_DB_HOST=127.9.226.130
. To find out that value, ssh into your application and write the command:
`env | grep MYSQL`
As usual: add, commit and push the changes.
Upvotes: 1