Java learning: build an integrated development environment for eclipse + WebLogic 12C + SVN

Source: Internet
Author: User

There are manyArticleIt is said that eclipse needs to install additional plug-ins to support weblogic. This may have been required before, but since BEA's WebLogic was acquired by Oracle, it is now quite simple.

1. First download free Oracle WebLogic Server 12C (12.1.1) Zip distribution and installers for developers

Http://www.oracle.com/technetwork/middleware/fusion-middleware/downloads/index.html

After the installation, eclipse (and WebLogic plug-in integrated) is provided. After the installation is complete, you canStart Menu-> AllProgram-> Oracle Enterprise pack for eclipse"Start

Ii. Failure in enabling eclipse on 64-bit machines

When an error occurs, the following message is displayed:

Java was started but returned exit code = 1

...

I have found many articles on the internet, saying that I have modified the eclipse. ini configuration or re-installed the 32-bit JVM. However, I tried it and found that I still had to modify it in the environment variable:

2.1Add the system environment variable java_home. The value is c: \ Bea \ jdk160_29 \ (change it to the actual physical directory of JDK on your machine)

2.2Add c: \ Bea \ jdk160_29 \ bin \ to the path environment variable (change it to the actual JDK physical directory on your machine)

2.3Add the system environment variable classpath. Its value is.; C: \ Bea \ jdk160_29 \ Lib \ tools. jar; C: \ Bea \ jdk160_29 \ Lib \ DT. jar;(This is modified based on the actual situation)

The easiest way to check whether these variables are correct: In the command line cmd window, enter javac-version. If the Java version is available, it indicates OK.

3. Set WebLogic Server in eclipse

Find the servers panel and click "new server wizard"

Select the Weblogic version

Domain directory of Weblogic

If you have created a dynamic web project, you can also apply the specified project to the WebLogic Server.

(Of course, you can also click Finish). After completing the operation, you can see the status of the current server (if it is not enabled, it will show stopped)

Right-click and choose start to enable WebLogic directly under eclipse.

Iv. SVN plug-in Installation
Enable eclipse, under the Help menu, find install new software..., enter the http://subclipse.tigris.org/update in work

Check both subclipse plugin and subversion book, and click Next. A warning box may pop up during the installation process. Ignore this and choose to continue the installation.

V. Test SVN

5.1Create a dynamic web project

Note: You must select the corresponding WebLogic for the traget runtime and configuration items (this project will be used later to test and deploy WebLogic)

5.2,Check inCode(Check in)

In project explorer, select the created myweb, and thenRight-click team and choose share projet.You can check in the Code (of course, you must enter some basic information, such as the svn resource library path, user name, and password)

5.3,Check out code)

When creating a project, you can also choose to check out directly from the svn server. Method: New-> Other

6. Test WebLogic

6.1,Automatic deployment during project running

Create two JSP files in myweb: Home. jsp and about. jsp.

After startup, eclipse automatically starts WebLogic Server and automatically deploys the myweb application.

6.2,Website renewal page settings

In the preceding example, we must specify the page to be accessed in the address bar, that is, http: // localhost: 7001/myweb/home. JSP is accessed correctly. remove JSP and directly use http: // localhost: 7001/myweb for access. An error occurs:

In IIS, you can set the site's default document to meet this requirement. In WebLogic, you have to use other methods to modify the Web. xml file:

In web. XML,Webcome-file-listInFirstSet the welcome-file node value to home. jsp.

6.3,Manual Application Deployment (War package)

During development, we can use eclipse to automatically implement WebLogic deployment. However, when we launch the service, we usually use war packages for manual deployment.

6.3.1,Export war package through eclipse

Right-click the project myweb and choose>Export->War FileIn this way, a war file is obtained:Myweb. WarIt is essentially a standard compressed file, which can be opened using a compression software such as WinRAR and 7-zip.

6.3.2,Log on to WebLogic to manually deploy the war package

Log on to the http: // localhost: 7001/console Console (the specific path is adjusted according to the Weblogic installation status)

Find the "deployment" interface. If Weblogic is newly installed, the deployment list should be empty. (If you have run the project myweb In the eclipse environment, the deployment list may contain an automatically deployed myweb. We recommend that you delete the automatically deployed myweb in the server panel of the eclipse environment, otherwise, an application with the same name will fail to be manually deployed)

Find the exported myweb. War package, and then press "Next" to go all the way to the West until it is finished.

After the deployment is completed, the application runs automatically.

Enter http: // localhost: 7001/myweb in the browser to view the content of home. jsp.

6.3.2,Domain name binding

It is so annoying to access via http: // localhost: 7001/myweb every time, if you can access fashion like other websites, just like using http://yjmyzz.com. In IIS, you can easily set the Host header of the website. WebLogic also has a similar function, that is, "virtual host"

6.3.2.1,Create a VM

Find VM panel

Create a new virtual host named "ururlhost-myweb"

After creation, double-click "virtualhos-myweb"

Modify "Network Access Point name" and enter the domain name to bind: www.yjmyzz.com

 

6.3.2.2,Mount a myweb application to a VM

On the deployment panel, double-click "myweb" to modify the target attributes and check the virtualhost-myweb check box.

6.3.2.3,Modify port 7001 to port 80

On the server panel, double-click "adminserver" to change the listening port from 7001 to 80.

6.3.2.4,Modify the root path myweb/

To deploy the panel, double-click myweb, modify the context root, and change from "myweb" "/"

After that, you should be able to directly use http: // localhost/to access myweb.

The domain name www.yjmyzz.com we just entered does not actually exist. to verify whether the modification is valid, You can first modify the hosts file of the Local Machine and add a line

127.0.0.1 www.yjmyzz.com

In this way, the local computer can simulate domain name resolution (Note: You can enter Ping www.yjmyzz.com in the command line window for verification. Under normal circumstances, the ping should pass, and the returned IP address is 127.0.0.1 ), enter the http://www.yjmyzz.com directly in the address bar/It should be done (if the browser sets a proxy, it is recommended to remove the proxy first, or add exceptions)

6.3.3,Create Weblogic Web Service

Create a Weblogic Web service project named mywebservice

 

6.3.3.1,Create the object class personentity for Transmission

Package Model; import Java. util. *; public class personentity {private string _ name; private int _ age; private date _ birthday; private float _ salary; /*** @ return the _ name */Public String getname () {return _ name ;} /*** @ Param _ name the _ name to set */Public void setname (string _ name) {This. _ name = _ name;}/*** @ return the _ age */Public int getage () {return _ age ;} /*** @ Param _ age the _ age to set */Public void setage (INT _ age) {This. _ age = _ age;}/*** @ return the _ birthday */public date getbirthday () {return _ birthday ;} /*** @ Param _ birthday the _ birthday to set */Public void setbirthday (date _ birthday) {This. _ Birthday = _ birthday;}/*** @ return the _ salary */public float getsalary () {return _ salary ;} /*** @ Param _ salary the _ salary to set */Public void setsalary (float _ salary) {This. _ salary = _ salary ;}}

6.3.3.2,Create a Web Service "interface contract" and "Implementation"

Interface Definition

 
Package contract; import javax. JWS. webmethod; import javax. JWS. webService; import model. *; @ WebService (name = "person", targetnamespace = "http://jmyang.com/") public interface person {@ webmethod (operationname = "getpersonbyname") Public personentity getpersonbyname (string name );}

Interface implementation

Package contract; import javax. JWS. *; import model. *; @ WebService (portname = "personport", servicename = "personservice", targetnamespace = "http://jmyang.com/", endpointinterface = "contract. person ") public class personimpl implements person {public personentity getpersonbyname (string name) {personentity P = new personentity (); p. setname (name); If (name. equals ("jmyang") {P. setage (30); p. setsalary (1000);} else if (name. equals ("zhangsan") {P. setage (20); p. setsalary (1500);} else {P. setage (25); p. setsalary (1200);} return P ;}}

6.3.3.3,Deployment and WSDL Testing

 

6.3.3,Call Weblogic Web Service in eclipse

6.3.3.1,Create a client to call the jar package

File-> New creates a Weblogic Web service client

Select remote in WSDL and enter the remote address of WSDL.

Specify the path for generating the client jar (use the default one)

Specify "remotely retrieve WSDL from RunTime"

After completion, eclipse will generate a jar package

6.3.3.2,Use the client jar package to call Web Service

Create a Java project and name it wscalldemo. Add the generated jar package to the project attribute.

In eclipse, double-click the personservice. jar package and you will see many automatically generated classes.

Write a few lines of code to test:

Package test; import COM. jmyang. *; public class callwssample {/*** @ Param ARGs */public static void main (string [] ARGs) {personservice service = new personservice (); person serviceinterface = service. getport (person. class); // get the service interface personentity Jimmy = serviceinterface. getpersonbyname ("jmyang"); // call the service system. out. println (Jimmy. getname () + "/" + Jimmy. getage () + "/" + Jimmy. getsalary (); // output result: personentity zhangsan = serviceinterface. getpersonbyname ("zhangsan"); // call the service system. out. println (zhangsan. getname () + "/" + zhangsan. getage () + "/" + zhangsan. getsalary (); // output result ,}}

 

Note: The preceding method is also applicable to calling the. net wcf Service. Note: For string type comparison, in Java Web Service, equals must be used to determine whether the two strings (content) are equal. If the = sign is used, false is always returned, but in a general Java project, the = and equals results are the same (the first time I came into contact with Java Web service, I have not fully understood it yet. I have read some related articles, = is used to determine whether two strings reference the same content, while equals is used to determine whether the two strings have the same content. During testing in a regular Java project, the string is not serialized and transmitted, the reference and content of the two strings inside the JVM are the same, but when used in Web Service, the strings will be serialized and transmitted. When deserialization is performed, it is equivalent to creating a new string instance object, resulting in different references)

 

 

Related Article

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.