Practical application of deploying web on glassfish

Source: Internet
Author: User
Tags glassfish netbeans

From: http://www.verybc.com/a/hulianwang/2009/1124/9298.html

 

 

This article describes how to deploy a web application on glassfish. The configurations used in this tutorial are netbeans5.5.1 and glassfish V2.

This article describes how to deploy practical Web applications on glassfish. The configuration applied in that tutorial is netbeans5.5.1 and glassfish V2.

This article describes how to deploy Web applications on glassfish.

1. Selection of development items

Java EE, or the actual development of JSF, netbeans and glassfish are the best choice. The former has extraordinary support for the latter. But pay attention to the version of netbeans. 5.5 does not support glassfish V2. Netbeans6 is still unstable, so the best version at this stage is netbeans5.5.1.

This article describes the practical application of Java EE development in netbeans. An official document introduces the practical application of Java ee. It mainly describes the deployment and configuration of Web application in the production environment in glassfish.

2. Download and install glassfish v2

1) download and decompress the package. After the download is complete, run the following command:

Java-xmx256m-jar glassfish_filetitle.jar

After you click to accept the pop-up rules (Sun is boring, and all the software is clearly a common compressed package, rather than a jar to show you the Rules ), glassfish will be decompressed to a list named glassfish.
2) Correct the port

Glassfish is installed by Ant. The installation script is in setup. XML, and some configurations, such as ports, are not correct. The following settings are used in setup. xml:

XML source code

<Property title = "domain. Title" value = "domain1"/> Domain Name
<Property title = "instance. Title" value = "server"/>
<Property title = "Admin. User" value = "admin"/> programming Username
<Property title = "Admin. passexpress" value = "adminadmin"/> programming Password
<Property title = "Admin. Port" value = "4848"/> management platform port
<Property title = "instance. Port" value = "8080"/> Example port, which is used to access the Web
<Property title = "orb. Port" value = "3700"/>
<Property title = "imq. Port" value = "7676"/>
<Property title = "HTTPS. Port" value = "8181"/> HTTPS Port

Correct the preceding settings as needed and run ant-F setup. xml. If ant is not installed in the system, there is an ant1.6 version under glassfish \ Lib \ ant. After the installation is complete, go to glassfish/bin and run the following command on the console to start glassfish:

Asadmin start-domain domain1 // domain1 is the domain. Title set above. The default domain1

After the startup, the test may have been started correctly.

Asadmin stop-domain domain1 // stop the server
Iii. Practical Application of Web deployment

There are three methods: Put the war or ear in the glassfish/domain/autodeploy list without any score, and the glassfish will be automatically deployed after it is started. The second is to deploy and use the command asadmin deploy. In addition, asadmin updeploy uninstalls the actual application. Get more help through asadmin deploy -- help and asadmin undeploy -- help.

Third, go to the glassfish console through the recommended method. The default user is admin and the password is adminadmin. The following page is displayed:

Go to the left-side menu, applications-> Web applications, and check the actual application that has been deployed in the list. to deploy new applications, click deploy and select the local war, set the context path and click OK. No matter the deployment succeeds or fails, the corresponding message is displayed.

Note: after this method, you do not have to stop remote deployment. You only need to open the Management Console on the target server and select a local war, so that you will not be able to quickly deploy it to the remote server, this is especially convenient, and is also the reason for recommendation. Deploy EJB in enterprise applications.

4. Configure the JDBC Data Source

For actual use of Java EE, you often need to set the data source in advance. Otherwise, javax. Naming. namenotfoundexception will be reported during deployment.

The configuration tip is to go to resources> JDBC, And the JDBC resources and connection pools will be displayed.

Set connection pools first. Take MYSQL as an example. Click new and name it mysqlpools. Select javax. SQL. connectionpooldatasource for resourcetype, and select MySql for database vendor. Then click beside to go to the next page. The most important thing is to set additional properties, that is, the JDBC connection configuration, set the URL, user, passexpress, more related to keep the default value, and add attributes as needed. After setting the connection pool, set JDBC resources and create a new JDBC with the same name as the data source used by the persistence unit in your web application.
Then deploy the web application again, and then it will run normally.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.