Topic
6 replies Latest Post - ‏2013-01-22T16:13:58Z by PabloEsparza
rick.lacy
rick.lacy
15 Posts
ACCEPTED ANSWER

Pinned topic RAD 8.5 Beta - Web Preview Server

‏2012-04-02T00:22:17Z |
I have a question about the functionality of this server. It looks to be a replacement for the Ajax Test Server in RAD 8. I found this useful for testing small bits of html and JavaScript. For the old Ajax test server, it used to be the case that I could have a dynamic web project, even one associated with an EAR, and it would still deploy and work. Of course not all container services would be available and the EAR part didn't get deployed, but I could still deploy the web project and test individual html files within it.

This doesn't work for me anymore with the Web Preview server. It says in the console that the application has started successfully. However, attempts to hit the pages from a web browser result in a 404.

Now, if I have a web project that contains only static resources, it deploys and I am able to access it from a web browser. There's also an extra line in the log file that indicates the application is available and gives a url.

Is this a bug or intended behavior? If intentional, it would be nice to get an error message indicating the server can't handle this type of deployment.
  • jim_zhang
    jim_zhang
    1 Post
    ACCEPTED ANSWER

    Re: RAD 8.5 Beta - Web Preview Server

    ‏2012-04-03T18:35:15Z  in response to rick.lacy
    thanks for the feedback Rick, this is a bug. WPS is indeed a replacement for the ATS, and it does support deploying either a static web project (as you have tested successfully) and dynamic web project (which seemed to have failed on you), even if that web module is associated to an EAR project. This must be a bug. We'll look into it.
  • PabloEsparza
    PabloEsparza
    4 Posts
    ACCEPTED ANSWER

    Re: RAD 8.5 Beta - Web Preview Server

    ‏2012-04-03T19:37:49Z  in response to rick.lacy
    Hi Rick,

    I have one question, do you have an index file?? Web Preview Server works in the following way:

    If you right click on the project and then select Run As -> Run on Server and select Web Preview Server. Our server is going to look for an index file. If the html file is named different as index, you will need to add the web page name in the url unless you right click directly on your web page and select Run As -> Run on Server and select Web Preview Server.

    Example:
    MyWebPage.html -> http://localhost:8080/project/MyWebPage.html

    index.html -> http://localhost:8080/project/
    I'll wait for your response, thanks!!
    • rick.lacy
      rick.lacy
      15 Posts
      ACCEPTED ANSWER

      Re: RAD 8.5 Beta - Web Preview Server

      ‏2012-04-05T05:38:45Z  in response to PabloEsparza
      Thanks for looking at this.

      The only html file in the project I tested with is called index.html. I've tried running by selecting the project and by selecting the individual file; neither results in a successful deploy to the server.
      • PabloEsparza
        PabloEsparza
        4 Posts
        ACCEPTED ANSWER

        Re: RAD 8.5 Beta - Web Preview Server

        ‏2012-04-09T17:28:28Z  in response to rick.lacy
        Hi Rick,

        I've investigated this issue and the issue is already fixed in next version. So, the problem will be fixed in the GA release.

        For now, you can do the following things to publish/deploy a Dynamic Web Project:

        1. Run the project in a J2EE Preview server. (in the servers view, right click, select New -> Server, and select J2EE Preview in the tree under Basic folder)
        2. Run the project in a Liberty server. (you can download the attached file and unzip it. Create a WebSphere Application Server V8.5 Beta Liberty Profile, with the Server runtime pointing to the folder that it's already unzipped.)
        If you need more information about this, feel free to post them.
        • SystemAdmin
          SystemAdmin
          590 Posts
          ACCEPTED ANSWER

          Re: RAD 8.5 Beta - Web Preview Server

          ‏2013-01-21T21:20:45Z  in response to PabloEsparza
          Hi PabloEsparza, I found the Web Preview Server is very convenient. I have a question about how a JDBC connection can be configured for it? We know for the WS ApplicationServer, it uses Admin Console.
          • PabloEsparza
            PabloEsparza
            4 Posts
            ACCEPTED ANSWER

            Re: RAD 8.5 Beta - Web Preview Server

            ‏2013-01-22T16:13:58Z  in response to SystemAdmin
            Hi Zhou Wu,

            This configuration needs to be done manually since we don't have plans to include this functionality in Web Preview Server for the moment. I'm listing the steps that need to be completed to configure Web Preview Server to support JDBC applications:

            1.- Open the file <YOUR_WORKSPACE>/.metadata/.plugins/com.ibm.etools.wdt.server.core/tmp0/usr/servers/defaultServer0/server.xml file.
            2.- Add servlet-2.0 and jdbc-4.0 features at the top, if they are not already in the file.
            3.- Add code to the server.xml file to specify the database type and the data source location. More information at: http://publib.boulder.ibm.com/infocenter/radhelp/v8r5/index.jsp?topic=%2Fcom.ibm.websphere.wlp.nd.multiplatform.doc%2Fae%2Ftwlp_dep_jdbc_trace.html For instance:

            <jdbcDriver id="DerbyEmbedded" libraryRef="DerbyLib"/>
            <library id="DerbyLib">
            <fileset dir="C:/myDerbyLocation/lib" includes="derby.jar"/>
            </library>
            <dataSource id="ds1" jndiName="jdbc/exampleDS" jdbcDriverRef="DerbyEmbedded">
            <properties.derby.embedded
            databaseName="C:/myDerbyLocation/data/exampleDB"
            createDatabase="create"
            />
            </dataSource>

            4.- **Optional: Enable JDBC tracing. You can do it following the steps in this infocenter: http://publib.boulder.ibm.com/infocenter/radhelp/v8r5/index.jsp?topic=%2Fcom.ibm.websphere.wlp.nd.multiplatform.doc%2Fae%2Ftwlp_dep_jdbc_trace.html NOTE: bootstrap.properties file is at the same level as server.xml file
            5.- In your servlet java class, you can add something like this:
            @Resource(name = "jdbc/exampleDS")
            DataSource ds1;
            Connection con = ds1.getConnection();
            Statement stmt = null;
            try {
            stmt = con.createStatement();
            // create a table
            stmt.executeUpdate("create table cities
            (name varchar(50) not null primary key, population int, county varchar(30))");
            // insert a test record
            stmt.executeUpdate("insert into cities values ('myHomeCity', 106769, 'myHomeCounty')");
            // select a record
            ResultSet result = stmt.executeQuery("select county from cities where name='myHomeCity'");
            result.next();
            // display the county information for the city.
            +System.out.println("The county for myHomeCity is " + result.getString(1));+
            }
            catch (SQLException e) {
            e.printStackTrace();
            }
            finally {
            try {
            // drop the table to clean up and to be able to rerun the test.
            stmt.executeUpdate("drop table cities");
            }
            catch (SQLException e) {
            e.printStackTrace();
            }
            con.close();
            }
            6.- Add the application to Web Preview Server. In servers view, right-click on Web Preview Server and select Add and Remove...
            7.- In your RAD_Folder/configuration/org.eclipse.osgi, look for server_runtime/lib folder and paste the jar files that I'm attaching. I've attached the jars file for RAD8.5 and RAD8.5.1, so you should select one of them depending on what RAD version are you using.
            8.- Start the server. If it's already running, restart it.
            9.- In RAD, right-click on <YOUR_PROJECT>/Services/REST/your_Servlet and select Show URI. Copy and Paste in a Browser.
            10.- In the console view, you should get something like this:
            AUDIT CWWKZ0001I: Application <YOUR_APPLICATION started in X.X seconds.
            AUDIT CWWKD0000I: The dataSource ds1 is available as jdbc/exampleDB.
            AUDIT CWWKD0000I: The jdbcDriver DerbyEmbedded is available.
            The county for myHomeCity is myHomeCounty
            You can use this url if you need more info: http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/index.jsp?topic=%2Fcom.ibm.websphere.wlp.nd.doc%2Fae%2Ftwlp_dep_jdbc.html

            This should work!! if you have more questions please let me know.

            Pablo,
            regards

            Attachments