|
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):
- we can early implement the multiple instance on one computer, by deploying same application in different domains;
- 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... >> |