>> More Visual Web Pack Documentation
Importing a Sun Java Studio Creator 2 Project in NetBeans Visual Web Pack 5.5
Contributed by the Visual Web Pack Tutorials Team
May [Revision number: V5.5.1-1] |
|
|
This tutorial walks you through the process of importing a Sun Java Studio Creator 2.0 or 2.1 project in NetBeans Visual Web Pack 5.5. You resolve data sources, enabling the IDE to access data sources created in either Sun Java Studio Creator 2.0 or 2.1. |
Before you use this tutorial, you must have NetBeans Visual Web Pack 5.5 installed on your system. Familiarize yourself with the basic parts of the IDE. Getting Started With NetBeans Visual Web Pack 5.5 is a useful introduction to NetBeans Visual Web Pack 5.5. All steps in this tutorial are based on a Java Studio Creator project, which uses JSF 1.1 and J2EE 1.4.
This tutorial works with the following technologies and resources
JavaServer Faces Components/
Java EE Platform |
1.2 with Java EE 5*
1.1 with J2EE 1.4
|
Travel Database |
Not required |
BluePrints AJAX Component Library |
Not required |
* As of the date this tutorial was published, only the Sun Java System Application Server supported Java EE 5.
This tutorial has been tailored for use with the Sun Java Application Server PE 9.0 Update Release 1 and with Tomcat 5.5.17.
If you are using a different server, consult the Release Notes and FAQs for known problems and workarounds.
For detailed information about the
supported servers and Java EE platform, see the Release Notes.
Opening a Sun Java Studio Creator 2 Project in NetBeans Visual Web Pack
Before you import a Java Studio Creator 2.0 or 2.1 project in the NetBeans Visual Web Pack, ensure that the project works properly in the original IDE.
- From the main menu, choose File > Open Project.
-
In the Open Project dialog box, browse for the project that you want to import.
Note: Before you open the existing Java Studio Creator project in the NetBeans Visual Web Pack, the IDE prompts you to make a backup of your project, as shown in Figure 1. Click OK to continue.
-
Click Open Project Folder to open the project in the IDE.
The IDE scans the project classpath. This may take a few seconds, depending on the size of the project.
Note: If there is no instance of an application server installed, the IDE prompts you to resolve the missing server.
-
If you are connecting to a Java DB database using the Sun Java System Application Server 9.0, restart the IDE.
Note: If you are using another application server, this step is not necessary.
Resolving a Missing Server
Once you have imported a project from Java Studio Creator 2 to NetBeans Visual Web Pack, you must resolve the missing server if the target server is not set properly. The IDE warns you if the target server is not set properly, as shown in Figure 2. If you have already set the target server, skip this section of the tutorial and go to Resolving a Data Source.
Figure 2: Missing Server Problem Warning |
-
In the Projects window, right-click the project node, and choose Resolve Missing Server Problems.
The Resolve Missing Server Problems dialog box opens with a list of all servers that have been added to the IDE.
-
Select the server you want to use and click OK.
The server is then added to the project.
Note: If the server you want to use does not appear in the dialog box, click Add Server as shown in Figure 3. For more information about installing an instance of an application server to the IDE, see the Configuration Information section of NetBeans Visual Web Pack 5.5 Installation Instructions.
Figure 3: Resolve Missing Server Problem Dialog Box |
-
To verify that the server has been added, expand the Servers node in the Runtime window.
The server has its own node as shown in Figure 4.
Resolving a Data Source
In the NetBeans Visual Web Pack, you must resolve all data sources before you can run the application.
-
In the Runtime window, expand the Databases node, right-click the node of the database connection you want to use, and choose Connect as shown in Figure 5.
The broken database connection icon next to the database connection changes to indicate that the database is connected to the IDE.
Figure 5: A Database Connection |
-
In the Projects window, expand the project node and right-click the Data Source References node.
Note: When there are unresolved data sources, the Data Source References node is red and it has a red badge attached to it. Right-click the Data Source References node and choose Refresh to see if there are any unresolved data sources.
-
In the contextual menu that appears, choose Resolve Data Source(s) as shown in Figure 6.
Figure 6: Resolving a Data Source |
-
In the Resolve Data Source(s) dialog box, select the data source name, and click Add Data Connection as shown in Figure 7.
Note: If the project you are importing uses a Java DB database, go to step 11.
Figure 7: Resolve Data Source(s) Dialog Box |
-
In the Server Type drop-down list, select Add Server Type, as shown Figure 8.
Note: For a list of supported databases, see System Requirements.
Figure 8: Adding a Database Server Type |
-
In the Edit Database Server Types dialog box, click New, as shown in Figure 9. Browse for the database driver JAR file, and click Open. The driver JAR file then appears in the JDBC Driver Jar File(s) pane. If nothing appears in the Driver Class Name field, click Suggest.
Note: The IDE suggests the best possible driver class name for the driver. You can also change the driver class name.
Figure 9: Edit Database Server Types Dialog Box |
- If nothing appears in the URL Template field, type the URL template for the database connection. Follow the example provided in the dialog box.
- Click Close.
- In the Add Database Connection dialog box, select the server type from the drop-down list.
-
Enter a User ID and a Password.
Note: For Java DB databases, the password is the same as the User ID. For example, for the Travel sample database the user name is travel
and the password is travel
.
-
Enter the Database URL and click Add to add the data source, as shown in Figure 10.
The template for Java DB databases is jdbc:derby://localhost:1527/travel
.
Note: For other databases, you must copy the JDBC driver to the server lib directory before you run the application.
Figure 10: Add Database Connection Dialog Box |
- In the Projects window, expand the project node and verify that the Data Source References node is no longer red.
Note: Sometimes the JNDI name for database access receives an incorrect value after importing a project. The workaround is to open the web/WEB-INF/sun-web.xml
file and change the JNDI name from jdbc/Travel_RaveGenerated_1129222276
to jdbc/Travel
.
Running the Project
After resolving the data source, you can run the project.
- In the main menu, choose Run > Run Main Project.
- The IDE builds the project and displays the application in the default browser window.
Summary
Importing a Sun Java Studio Creator 2 project in the NetBeans Visual Web Pack 5.5 consists of four steps:
- Open the project in the NetBeans Visual Web Pack.
- Resolve missing server problems if necessary.
- Resolve all data sources.
- Run the project.
See Also:
This page was last modified: May 24,