Gang Liu
Weblogic Plus Netbean PDF Print E-mail
Written by Administrator   
Wednesday, 03 February 2010 12:41

Somehow we need start weblogic server extensively(outside of netbean), how can we config weblogic server to let it work with netbean seamlessly? Here I introduce the details about environment setup:

Requirement:

Windows XP

Netbean 6.5 or above (current one is ok);

Oracle WebLogic Server 11g Rel 1 (10.3.2) Net Installer

Oracle Database 11g Release 2 (11.2.0.1.0) JDBC Drivers (ojdbc6.jar)

JDK 1.6 or above

 

Step 1: Install and configure weblogic:

 

1, install Oracle WebLogic Server 11g Rel 1 (10.3.2) Net Installer (all default options)

2, Start->All Programs->Oracle Weblogic->Quick Start

3, create domain with quick start tools( make sure the domain name is “financials”)  ps: please check the official manuals online how to create new domain using quick start, if you have difficulties to use quick start.

4, Start->All Programs->Oracle Weblogic->Quick Start->User Projects->financials

5, Admin Console->JDBC->Data Resource->add new data resource (in our case: host name is 172.16.20.26; database name is v11DV; port number: 1521; username and password are vfindev; Database Driver is Oracle driver thin for service connection)

 

After adding database resource, make sure there is *.xml generated in C:\oracle\Middleware\user_projects\domains\financials\config\jdbc.

 

Step 2: Change weblogic server startup command to open debug port for netbean

change startWebLogic.cmd file in C:\VisionFinancials2009\financials\nbproject:

find SAVE_JAVA_OPTIONS and change it to "set SAVE_JAVA_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTIONS%"

 

Step 3: add weblogic server into netbean (optional if you start weblogic outside of netbean, but it is better to add it, cause we might use weblogic api in future.):

 

we can add weblogic 10.3 on any netbeans version:

goto your profile folder

C:\Documents and
Settings\username\.netbeans\6.5\config\J2EE\InstalledServers

in this path there is a file called .nbattrs

add these lines in it and restart your netbeans ide

if your weblogic 10.3 is located at C:/bea3/wlserver_10.3
and user name for weblogic is weblogic
and password for weblogic is weblogic
and your weblogic domain is located at
C:/bea3/wlserver_10.3/samples/domains/wl_server/

add these lines

<fileobject>

<attr stringvalue="8787"/>

<attr stringvalue="BEA WebLogic Server"/>

<attr

stringvalue="C:/oracle/Middleware/user_projects/domains/financials"/>

<attr stringvalue="true"/>

<attr stringvalue="yourpassword"/>

<attr name="registeredWithoutUI" stringvalue="false"/>

<attr stringvalue="C:\oracle\Middleware\wlserver_10.3"/>

<attr

stringvalue="deployer:WebLogic:http://localhost:7001:C:\oracle\Middleware\wlserver_10.3:C:/oracle/Middleware/user_projects/domains/Financials"/>

<attr stringvalue="your username"/>

</fileobject>

very important
Also you must create an empty file called financials without any extention
in C:\Documents and Settings\dliu\.netbeans\6.5\config\J2EE\InstalledServers

 

 

Step 4: you might encounter the problem of Java heap OutOfMemory issue when compiling project in netbean, the current solution of mine is:

 

Add
default_options="-J-Xms24m -J-Xmx1024m"
in \NetBeans\harness\etc\app.conf

add the following in NetBean’s etc/netbeans.conf file:

# Default location of JDK, can be overridden by using –jdkhome <dir>:
netbeans_jdkhome=”C:\Program Files\Java\jdk1.6.0_05″

 

Step 5: override files in financial project folders with new build.xml and project.properties under nbproject folder.

change build.xml:

<target name="-post-init">
         <echo>handle ${build.web.dir} ......</echo>
        <mkdir dir="${build.web.dir}" />
            <delete includeemptydirs="true">
               <fileset dir="${build.web.dir}" includes="**/*"/>
            </delete>
    </target>
    <!-- copy compiled war file into weblogic domain.-->
    <target name="-post-dist">
        <!--
            <echo>copy-to-weblogic-domain:copy ${dist.war} to ${build.web.dir}....</echo>
            <delete includeemptydirs="true">
               <fileset dir="${build.web.root}" includes="**/*"/>
       </delete>
       -->
        <copy file="${dist.war}" todir="${build.web.root}" overwrite="true" />
        <!--<echo>unziping ${build.web.dist.war} to ${build.web.dir}.....</echo>
        <unzip src="/photoes/${build.web.dist.war}" dest="${build.web.dir}"/>
         <echo>deleting source war file</echo>
        <delete file="${build.web.dist.war}"/> -->
    </target>

change project.properties to make sure the global variable values are expected.

 

Testing Scenario:

Start web application in the “Oracle Weblogic” menu group -> start server -> In netbean, clean and compile financial main project (the war file will auto go to financial domain)-> wait(several seconds) for server auto deploy war file-> open IE, type http://localhost:7001/yourWebAppName

 

Strong Points of Weblogic (Compared to JBoss):

  1. we can early implement the multiple instance on one computer, by deploying same application in different domains;
  2. Clean and compile project, apply changes on server without restarting server.

 

@ECHO OFF

@REM WARNING: This file is created by the Configuration Wizard.
@REM Any changes to this script may be lost when adding extensions to this configuration.

SETLOCAL

@REM --- Start Functions ---

GOTO :ENDFUNCTIONS

:stopAll
    @REM We separate the stop commands into a function so we are able to use the trap command in Unix (calling a function) to stop these services
    if NOT "X%ALREADY_STOPPED%"=="X" (
        GOTO :EOF
    )
    @REM STOP POINTBASE (only if we started it)
    if "%POINTBASE_FLAG%"=="true" (
        echo Stopping PointBase server...
        call "%WL_HOME%\common\bin\stopPointBase.cmd" -port=%POINTBASE_PORT% -name=%POINTBASE_DBNAME%  >"%DOMAIN_HOME%\pointbaseShutdown.log" 2>&1

        echo PointBase server stopped.
    )

    set ALREADY_STOPPED=true
    @REM Restore IP configuration the node manager starts IP Migration
    if NOT "%SERVER_IP%"=="" (
        call "%WL_HOME%\common\bin\wlsifconfig.cmd" -removeif "%IFNAME%" "%SERVER_IP%"
    )
GOTO :EOF


:ENDFUNCTIONS

@REM --- End Functions ---

@REM *************************************************************************
@REM This script is used to start WebLogic Server for this domain.
@REM
@REM To create your own start script for your domain, you can initialize the
@REM environment by calling @USERDOMAINHOME\setDomainEnv.
@REM
@REM setDomainEnv initializes or calls commEnv to initialize the following variables:
@REM
@REM BEA_HOME       - The BEA home directory of your WebLogic installation.
@REM JAVA_HOME      - Location of the version of Java used to start WebLogic
@REM                  Server.
@REM JAVA_VENDOR    - Vendor of the JVM (i.e. BEA, HP, IBM, Sun, etc.)
@REM PATH           - JDK and WebLogic directories are added to system path.
@REM WEBLOGIC_CLASSPATH
@REM                - Classpath needed to start WebLogic Server.
@REM PATCH_CLASSPATH - Classpath used for patches
@REM PATCH_LIBPATH  - Library path used for patches
@REM PATCH_PATH     - Path used for patches
@REM WEBLOGIC_EXTENSION_DIRS - Extension dirs for WebLogic classpath patch
@REM JAVA_VM        - The java arg specifying the VM to run.  (i.e.
@REM                - server, -hotspot, etc.)
@REM USER_MEM_ARGS  - The variable to override the standard memory arguments
@REM                  passed to java.
@REM PRODUCTION_MODE - The variable that determines whether Weblogic Server is started in production mode.
@REM POINTBASE_HOME - Point Base home directory.
@REM POINTBASE_CLASSPATH
@REM                - Classpath needed to start PointBase.
@REM
@REM Other variables used in this script include:
@REM SERVER_NAME    - Name of the weblogic server.
@REM JAVA_OPTIONS   - Java command-line options for running the server. (These
@REM                  will be tagged on to the end of the JAVA_VM and
@REM                  MEM_ARGS)
@REM
@REM For additional information, refer to "Managing Server Startup and Shutdown for Oracle WebLogic Server"
@REM  (http://download.oracle.com/docs/cd/E12839_01/web.1111/e13708/overview.htm).
@REM *************************************************************************

@REM Call setDomainEnv here.

set DOMAIN_HOME=C:\Oracle\Middleware\user_projects\domains\financials
for %%i in ("%DOMAIN_HOME%") do set DOMAIN_HOME=%%~fsi

call "%DOMAIN_HOME%\bin\setDomainEnv.cmd" %*

set SAVE_JAVA_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTIONS%

set SAVE_CLASSPATH=%CLASSPATH%

@REM Start PointBase

set PB_DEBUG_LEVEL=0

if "%POINTBASE_FLAG%"=="true" (
    call "%WL_HOME%\common\bin\startPointBase.cmd" -port=%POINTBASE_PORT% -debug=%PB_DEBUG_LEVEL% -console=false -background=true -ini=%DOMAIN_HOME%\pointbase.ini  >"%DOMAIN_HOME%\pointbase.log" 2>&1

)

set JAVA_OPTIONS=%SAVE_JAVA_OPTIONS%

set SAVE_JAVA_OPTIONS=

set CLASSPATH=%SAVE_CLASSPATH%

set SAVE_CLASSPATH=

if "%PRODUCTION_MODE%"=="true" (
    set WLS_DISPLAY_MODE=Production
) else (
    set WLS_DISPLAY_MODE=Development
)

if NOT "%WLS_USER%"=="" (
    set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.management.username=%WLS_USER%
)

if NOT "%WLS_PW%"=="" (
    set JAVA_OPTIONS=%JAVA_OPTIONS% -Dweblogic.management.password=%WLS_PW%
)

if NOT "%MEDREC_WEBLOGIC_CLASSPATH%"=="" (
    if NOT "%CLASSPATH%"=="" (
        set CLASSPATH=%CLASSPATH%;%MEDREC_WEBLOGIC_CLASSPATH%
    ) else (
        set CLASSPATH=%MEDREC_WEBLOGIC_CLASSPATH%
    )
)

echo .

echo .

echo JAVA Memory arguments: %MEM_ARGS%

echo .

echo WLS Start Mode=%WLS_DISPLAY_MODE%

echo .

echo CLASSPATH=%CLASSPATH%

echo .

echo PATH=%PATH%

echo .

echo ***************************************************

echo *  To start WebLogic Server, use a username and   *

echo *  password assigned to an admin-level user.  For *

echo *  server administration, use the WebLogic Server *

echo *  console at http:\\hostname:port\console        *

echo ***************************************************

@REM Set up IP Migration related variables.

@REM Set interface name.

if NOT "%Interface%"=="" (
    set IFNAME=%Interface%
) else (
    set IFNAME=
)

@REM Set IP Mask.

if NOT "%NetMask%"=="" (
    set IPMASK=%NetMask%
) else (
    set IPMASK=
)

@REM Perform IP Migration if SERVER_IP is set by node manager.

if NOT "%SERVER_IP%"=="" (
    call "%WL_HOME%\common\bin\wlsifconfig.cmd" -addif "%IFNAME%" "%SERVER_IP%" "%IPMASK%"
)

@REM START WEBLOGIC

echo starting weblogic with Java version:

%JAVA_HOME%\bin\java %JAVA_VM% -version

if "%WLS_REDIRECT_LOG%"=="" (
    echo Starting WLS with line:
    echo %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
    %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
) else (
    echo Redirecting output from WLS window to %WLS_REDIRECT_LOG%
    %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%  >"%WLS_REDIRECT_LOG%" 2>&1
)

CALL :stopAll

popd

@REM Exit this script only if we have been told to exit.

if "%doExitFlag%"=="true" (
    exit
)



ENDLOCAL


Read 0 Comments... >>
 
Street View Plugin Updated PDF Print E-mail
Written by Administrator   
Wednesday, 20 January 2010 15:53
Updated Street View Plugin, we can define Google API key, and disable the google search bar on map. You could download in download section.

Read 0 Comments... >>
 
Setup Multiple JBOSS server on the same machine PDF Print E-mail
Written by Administrator   
Wednesday, 16 December 2009 17:22

It is very possible that we need to setup different server on the same machine, because one for testing, another for productive server. There are already lots of arguments for this issue about JBOSS server. I tested this alot, found there is still a way to run multiple JBOSS server on the same machine. and here posted my experience here:

We assume we need to run server_one and server_two on our local computer:

The steps for setup two different instances are here(make sure our JBOSS version is over 5.0):

Step 1: create new folder in $jboss_installation_folder/server/ for each instance you want to create, the simplest way for testing is copying default folder as another one with different name;

Step 2: change server.xml under $jboss_installation_folder /server/$instance_name/deploy/jbossweb.sar, search

“<!-- A HTTP/1.1 Connector on port 8080 -->

<Connector protocol="HTTP/1.1" port="18888" address="${jboss.bind.address}"

connectionTimeout="20000" redirectPort="8443" />”

change port number as unique one.

Step 3: change bindings-jboss-beans.xml under “$jboss_installation_folder /server/$instance_name/conf/bindingservice.beans/META-INF.

find every element like “<port>…</port>” change the port number to unique one.

Repeate these steps to create another folder called server_two under server folder.

 Then, in the consol windows. We run the commands like:

Step 4: In $jboss_installation_folder/bin , we need different run.conf.bat for each instance:

Copy run.conf.bat into run.conf2.bat, edit run.conf2.bat, find “

set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n"”

change the “address” into different number other than run.conf.bat.

then copy run.bat into for example run2.bat, change “set "RUN_CONF=%DIRNAME%run.conf.bat"” into “set "RUN_CONF=%DIRNAME%run.conf2.bat"” in run2.bat.

Step 5: In console windows:

cd $JBOSS_installation_folder\bin

run.bat -c server_one

open another consol windows:

cd $JBOSS_installation_folder\bin

run2.bat -c server_two

 



Read 0 Comments... >>
Last Updated on Thursday, 17 December 2009 08:58
 
Quick to know AJAX PDF Print E-mail
Written by Administrator   
Friday, 18 December 2009 14:15

There are already professional explanation about AJAX. To me, it do with the issue when we try to display the changes on server side without reflashing the whole page, while Javascript only do with client side. I gave a simple example here to quickly know usage of AJAX.

The purpose of this example is to display the server side system time on client browser pages in real time.

Firstly, we have a div element on the front page:

<div id="intro"></div>

Secondly, we have php function to get server system time:

Thirdly, we initilize the AJAX object:

function getHTTPObject(){
if (window.ActiveXObject)
 return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest)
 return new XMLHttpRequest();
else {
 alert("Your browser does not support AJAX.");
 return null;
 }
}

Then we have one function to work around with AJAX object:

function setOutput(){
if(httpObject.readyState == 4){
document.getElementById('intro').innerHTML
= "In Montreal on " +httpObject.responseText;
}
}

Finally, there is another function to bridge PHP function to setOutput() js function:

function getMyToday()
{
httpObject = getHTTPObject();
if (httpObject != null) {
httpObject.open("GET", "getMyToday.php", true);
httpObject.send(null);
httpObject.onreadystatechange = setOutput;
}
}

 

 

 


Read 0 Comments... >>
Last Updated on Saturday, 19 December 2009 20:08
 
JNLP Senario PDF Print E-mail
Written by Administrator   
Tuesday, 17 November 2009 10:56

"To deploy your Java Web Start application, first compile the source code and package it as a JAR file. Java Web Start applications are launched by using the Java Network Launch Protocol (JNLP). Hence, you must create a JNLP file to deploy your application. The Deployment Toolkit script contains useful JavaScript functions that can be used to deploy Java Web Start applications on a web page." - Sun Microsystem.

Basically there is not much requirment for Web Start Application working, even we don't need server Java working environment, at least for sure the client need JRE, but it will be done automatically by JNLP deployer even there is no JRE installed in client machine.  Essentically we only need three files to let JNLP work: client web interface(the web page to call jnlp file); JNLP file(actually it is a configuration file); JAR file(the really working Java program). Here I gave my simple example to see how JNLP works:

Web page (index.html):

<html>
 <body>
 <h1>Java Web Start Application Demo</h1>

 <script src="http://www.java.com/js/deployJava.js"/>
 <embed hidden="true" type="application/npruntime-scriptable-plugin;DeploymentToolkit" id="deployJavaPlugin"/>
 <script>
 var url = "http://localhost:8080/TestJNLP/applet/app.jnlp";
 deployJava.createWebStartLaunchButton(url, '1.6.0');
 </script>
 <a onmouseover="window.status=''; return true;"
 href='javascript:if (!deployJava.isWebStartInstalled("1.6.0"))
 {if (deployJava.installLatestJRE())
 {if (deployJava.launch("http://localhost:8080/TestJNLP/applet/app.jnlp")) {}}}
 else {if (deployJava.launch("http://localhost:8080/TestJNLP/applet/app.jnlp")) {}}'>
 Launch Application
 </a>
 </body>
</html>

JNLP file:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="/photoes/">
 <information>
 <title>test</title>
 <vendor>test</vendor>
 </information>
 <resources>
 <j2se version="1.6+"
 href="http://java.sun.com/products/autodl/j2se"/>
 <jar href="http://localhost:8080/TestJNLP/applet/calendar.jar" main="true" />

 </resources>
 <application-desc name="Dynamic Tree Demo Application"
 main-class="com.toedter.calendar.JCalendar"
 width="300"
 height="300">
 </application-desc>
</jnlp>

JAR file:

the jar file is your java application which already compiled into a compressed file. here my java application is a calender java penal.

You can click  Launch Calendar to see the effect.

 

 


Read 0 Comments... >>
Last Updated on Tuesday, 17 November 2009 11:19
 
<< Start < Prev 1 2 3 4 5 6 Next > End >>

Page 1 of 6

Paypal Donation

Live Help!

Login Form