Category: Glassfish

VisualVM problem connecting to monitor Glassfish

We had a issue getting VisualVM to connect to one of our Glassfish servers, in order for us to monitor it.

The problem was being caused by the server being behind our firewall, although the issue still existed after we had opened port 8686.

netstat -ano command was showing us that the port was open, but no reasons as to why it wouldn’t connect:

tcp 0 0 :::8686 :::* LISTEN off (0.00/0/0)

Another one of our servers which is behind an older less secure firewall was connecting fine.

After much searching & head scratching, we found that we needed to add the following line to the JVM Option within Glassfish:

-Djava.rmi.server.hostname=YOUR_SERVERS_NAME

See this Oracle blog post for the reason why this is needed.

Summary:
If you are trying to access a server which is behind a NAT – you will most probably have to start your server with the option
-Djava.rmi.server.hostname=

so that the RMI stubs sent to the client contain the server’s public address allowing it to be reached by the clients from the outside.

Glassfish JVM crash issues under Alfresco 3.4d

We’re running Alfresco 3.4d on Glassfish 3.1 / Redhat 5.7

We noticed last week that ‘Java SE Development Kit 6 Update 26’ was occasionally crashing the JVM by using all the available memory, when Alfresco was using resources outside of the JVM.

We solved this by installing ‘Java SE Development Kit 6 Update 29’.

Just thought that we would post that out there, just in case your facing similar issues and haven’t a clue what is causing them, when the JVM crashes it doesn’t post its issues into the Glassfish server.log file, as that has crashed milliseconds beforehand.

JasperReports Server 4.0 on Glassfish 3.1 / 3.2.1

1. Download JasperReports Server installation package

2. Unzip this package and then following the steps in chapter 5 ‘Installing the War File Distribution’ within JasperReports-Server-CP-Install-Guide.pdf.

3. If you are running Mysql 5.5, then there is an issue posted here

Scroll down the page to ‘5. Known Issues

* 21953: The JasperReports Server repository database has issues under MySQL 5.5. There is a conflict with a new reserved word: MAXVALUE. Also, the storage engine needs to be specified as engine=Innodb (instead of type=Innodb).

In order to use the command ‘maxValue‘, you need to replace with all ‘maxValue‘ lines which exist without quotes to have quotes, so ‘`maxValue`‘ and change any ‘Type=Innodb‘ to ‘ENGINE=Innodb‘, within all the *.ddl files in /jasperreports-server-cp-4.0.0-bin/buildomatic/install_resources/sql/mysql/

4. Now edit the file default_master.properties, add the following settings for glassfish

appServerType = glassfish2
appServerDir =/Glassfish3.1/glassfish

5. edit /jasperreports-server-cp-4.0.0-bin/buildomatic/bin/validation.xml

add following to line 342

<equals arg1="${appServerType}" arg2="glassfish2" />

Before code looks like this:

<if>
<not>
<or>
<equals arg1="${appServerType}" arg2="skipAppServerCheck" />
<equals arg1="${appServerType}" arg2="tomcat5" />
<equals arg1="${appServerType}" arg2="tomcat6" />
<equals arg1="${appServerType}" arg2="jboss" />
</or>
</not>

After you code should look like this, part in bold is the change:

<if>
<not>
<or>
<equals arg1="${appServerType}" arg2="skipAppServerCheck" />
<equals arg1="${appServerType}" arg2="tomcat5" />
<equals arg1="${appServerType}" arg2="tomcat6" />
<equals arg1="${appServerType}" arg2="jboss" />
<equals arg1="${appServerType}" arg2="glassfish2" />

</or>
</not>

Without this the installation script will not continue. This is probably a bug within the system.

6. Manually install data-pooling and data resources required for glassfish,mysql database username and password should be set correctly in js-glassfish-ds.xml :

when glassfish is running, use asadmin add databaseresources.

/usr/local/glassfish3.1/glassfish/bin/asadmin add-resources  /jasperreports-server-cp-4.0.0-bin/buildomatic/build_conf/default/js-glassfish-ds.xml

7.  Comment out the glassfish datasource autoinstallation script.

Edit /jasperreports-server-cp-4.0.0-bin/buildomatic/bin/app-server.xml, comment out the glassfish2 datasources option

Code before the change:


 <if>
          <equals arg1="${appServerType}" arg2="glassfish2" />
          <then>
              <runasadmin>
                  <arg value="start-domain"/>
                  <arg value="domain1"/>
              </runasadmin>
             <runasadmin>
                  <arg value="add-resources"/>
                  <arg value="${currentConf}/js-glassfish-ds.xml"/>
              </runasadmin>
              <runasadmin failOnError="false">
                  <arg value="create-jvm-options"/>
                  <arg value="${glassfishJvmOpt}"/>
              </runasadmin>                  <runasadmin>
                  <arg value="stop-domain"/>
                  <arg value="domain1"/>
              </runasadmin>    

          </then>
      </if>


Code after the rem’d out statement around line 415, Marked in Bold:


 <if>
          <equals arg1="${appServerType}" arg2="glassfish2" />
          <then>
             <!--  <runasadmin>
                  <arg value="start-domain"/>
                  <arg value="domain1"/>
              </runasadmin>
             <runasadmin>
                  <arg value="add-resources"/>
                  <arg value="${currentConf}/js-glassfish-ds.xml"/>
              </runasadmin>
              <runasadmin failOnError="false">
                  <arg value="create-jvm-options"/>
                  <arg value="${glassfishJvmOpt}"/>
              </runasadmin>                  <runasadmin>
                  <arg value="stop-domain"/>
                  <arg value="domain1"/>
              </runasadmin>    -->

          </then>
      </if>
...


8. Stop glassfish and Run the autoinstall command js-install-ce.bat in Windows or js-install-ce.sh in Unix. If you are using MYSQL 5.5 should use minimal argument to avoid default full installation(Default installation comes with sample data and sample table, but will bring sql insert error in MYSQL 5.5  because the java source code still use MaxValue). Use help can get all the functions.

./js-install-ce.sh minimal (unix)

js-install-ce.bat (windows)

9. All the files should then be copy to /glassfish3.1/glassfish/domains/domain1/autodeploy/jasperserver.war/

10. Create a glassfish-web.xml file in /glassfish3.1/glassfish/domains/domain1/autodeploy/jasperserver.war/WEB-INF/

Paste the following information to this file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<resource-ref>
<res-ref-name>jdbc/dataSource</res-ref-name>
<jndi-name>jdbc/jasperserver</jndi-name>
</resource-ref>
<class-loader delegate="true"/>
</glassfish-web-app>

<jndi-name>jdbc/jasperserver</jndi-name>” is required for glassfish3.1, otherwise the server will throw “javax.naming.NameNotFoundException: JasperServerDataBase not found” error message during deploying the web application. This is not necessary for glassfish3.0. The default setting in web.xml can be picked up by glassfish3.0.

11. Restart glassfish3.1. All should now work!

Glassfish v2.1.1 site redirect

Simple to do, hard to locate the information on how to.
Hopefully you’ll find this a lot easier..

Navigate to :

Configuration, HTTP Service, Virtual Servers, server

Scroll to bottom of page :
Add Property

Name :
redirect_1

Value :
from=/{name of webapp to redirect} url={URL to redirect traffic to}

(dont include the ‘{‘ ‘}’ brackets)

It should look something like this :
from=/mywebapp url=http://www.google.co.uk

Click ‘Save’ button.

Done!

Alfresco community 4.0 installation on Glassfish 3.1

PLEASE NOTE:

The following worked only on Alfresco 3.4d – We tried to get it to work on version 4.0 but it will not.
We have now resorted to using the Tomcat Bundled version of 3.4d as our server is 32bit linux.

Follow the below instructions if you still want, but be it on your own head 🙂

1. Get alfresco war files for deployment in existing application servers package file  alfresco-community-4.0.a.zip from https://process.alfresco.com/ccdl/?file=release/community/build-3755/alfresco-community-4.0.a.zip

2. MySql setting

mysql>create database alfresco;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’%’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’localhost’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

3. Create alfresco documents and index folder

mkdir /usr/local/alfresco

4.Unpack alfresco-community-4.0.a.zip

unzip alfresco-community-4.0.a.zip

5. Configure Alfresco before deploying to glassfish

5.1 alfresco-global.properties

Since alfresco 3.3, all the settings now based on alfresco-global.properties. This file can be found from the alfresco package file alfresco-community-4.0.a.zip. Copy this file from the unzip location to  glassfish lib folder.

cd /alfresco-community-4.0.a/extensions/extension

cp alfresco-global.properties /usr/local/glassfish/domains/domain1/lib/classes/alfresco-global.properties

if Glassfish is installed at /usr/local/glassfish.

5.2 Modify alfresco-global.properties so alfresco can find database and index folder created before

Set alfresco folder
dir.root = /usr/local/alfresco

Set dababase username and password

db.username=YOUR_ALFRESCO_USERNAME
db.password=YOUR_ALFRESCO_PASSWORD
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://localhost/alfresco

6. You need a ‘glassfish-web.xml’ for “useMyFaces” for alfresco. *ONLY needed if your using Glassfish 3.1 * – If using Glassfish 3.0 or below Skip to step 7/7.1 as that needs ‘sun-web.xml’.

7. sun-web.xml:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE sun-web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN”  “http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd”&gt;
<sun-web-app>
<class-loader delegate=”false”/>
<property name=”useMyFaces” value=”true”/>
</sun-web-app>

You can also get this file from http://blogs.sun.com/mandy/resource/sun-web.xml

7.1 Add sun-web.xml to alfresco.war

Go to the unpacked directory created from alfresco-community-4.0.a.zip, create a new directory named WEB-INF and put sun-web.xml on it.

cd /alfresco-community-4.0.a/

mkdir /WEB-INF/

cp /temp/sun-web.xml /WEB-INF/sun-web.xml

jar -uvf alfresco.war WEB-INF/*.xml

The alfresco.war should be edited.

8.  Increase glassfish memory heap setting
Log in as administrator of glassfish from http://glassfishHost:4848/
Application Server->JVM Settings->JVM Options
Change -Xmx256m to -Xmx512m or more.

9.  Deploy the new war file to glassfish.
Log in as administrator of glassshfish from http://glassfishHost:4848/ and deploy alfresco.war.
After a few minutes, alfreso can be visited by hppp://glassfishHost:8080/alfresco

10.  Deploy share

Log in as administrator of glassshfish from http://glassfishHost:4848/ and deploy share.war from the unzip package.

There is a bug in share.war, so you will get the “No ‘login’ page type configured – but page auth required it.”  error message if go to  http://glassfishHost:8080/share.

Solution is download the latest spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar from alfresco SVN

wget http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/3rd-party/src/spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar

cp spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar /usr/local/glassfish/domains/domain1/applications/j2ee-modules/share/WEB-INF/lib/

Restart glassfish, go to http://Glassfishhost:8080/share

Should work!

You can also add the spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar to the share.war and deploy it.

Create Oracle DataSource in Glassfish

1 . Copy JDBC Oracle driver to GLASSFISH/lib, for example, copy ojdbc14.jar to /usr/local/glassfish/lib.

2. Restart Glassfish, log on to Glassfish admin interface, create a new JDBC Connection Pool.
Delete all properties, and add following properties:
user – set this to Oracle userid
password – set this to Oracle password
URL – set this to the URL, Format : jdbc:oracle:thin:@HOSTNAME:PORT:SID.

Test the connection pool by clicking the “ping” button to get the verify  message.

3. Create a JDBC DataSource using the JDBC Connection Pool.

Full details for creating an Oracle connection pool in Glassfish2.1.1 can be found from the link below:

http://mariosgaee.blogspot.com/2009/12/oracle-connection-pool-in-glassfish.html

Full details for creating MySQL connection pool in Glassfish can be found from the link below:

http://www.albeesonline.com/blog/2008/08/06/creating-and-configuring-a-mysql-datasource-in-glassfish-application-server/