在 Weblogic JVM 中设置的自定义参数

发布于 2024-12-16 01:25:50 字数 454 浏览 2 评论 0原文

我需要为 Weblogic 中的每个服务器 JVM 设置一个自定义属性。更好的方法是什么?

我知道我们可以指定如下参数:

  1. 在“域结构”窗格中,展开“服务器”节点。
  2. 单击要配置的服务器的名称。
  3. 在右侧窗格中,单击“服务器启动”。
  4. 选择“锁定”编辑。
  5. 在“参数”文本框中,提供 JVM 选项。插入选项后,单击“保存”。然后单击激活更改。
  6. 重新启动服务器以便使用新设置。

我的问题是这个论点到底是如何定义的?如何在将部署在该 JVM 内的应用程序内使用该参数。

编辑

如果我指定,-DMyArg=MyValue 在代码中, value=System.getproperty("MyValue"); 这应该有效,对吗?

I need a custom property to set per each server JVM in Weblogic. What is the better approach doing it?

I know we can specify the argments like below:

  1. In the Domain Structure pane, expand the Servers node.
  2. Click the name of the server that you want to configure.
  3. In the right pane, click Server Start.
  4. Select Lock & Edit.
  5. In the Arguments text box, provide the JVM options. After inserting your options, click Save. Then click Activate Changes.
  6. Restart the server so that the new settings are used.

My question is how exactly the argument is defined? How to use that argument inside the application that will be deployed inside that JVM.

Edit

If i specify, -DMyArg=MyValue
and in the code, value=System.getproperty("MyValue"); this should work, right?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

獨角戲 2024-12-23 01:25:50

编辑:如果我指定“-DMyArg=MyValue”并在代码中,
值=System.getproperty("MyValue");这应该有效,对吧?

轻微错误,您应该使用

value=System.getProperty("MyArg");

This,但是仅适用于启用 NodeManager 的情况。如果情况并非如此,我所做的就是在 startWeblogic.cmd 中将其设置为 Java_Options 之一

更好的是 setDomainEnv.cmd,其中包含以下行

set EXTRA_JAVA_PROPERTIES=...

Edit: if i specify, "-DMyArg=MyValue" and in the code,
value=System.getproperty("MyValue"); this should work, right?

Slight mistake, you should use

value=System.getProperty("MyArg");

This however only works with NodeManager enabled. If that's not the case, what I do is to set it in the startWeblogic.cmd as one of the Java_Options

Even better is the setDomainEnv.cmd which has lines for

set EXTRA_JAVA_PROPERTIES=...
痴意少年 2024-12-23 01:25:50

在bin目录下编辑setDomainEnv.sh
找到以下行:

如果设置了USER_MEM_ARGS环境变量,则使用它来覆盖ALL MEM_ARGS
添加以下行并相应修改值

对于管理服务器

`if [ "${SERVER_NAME}" = "AdminServer" ] ; then
USER_MEM_ARGS="-Xms256m -Xmx256m -XX:MaxPermSize=256m"
MEM_ARGS="${USER_MEM_ARGS}"
export MEM_ARGS
fi`

对于托管服务器

`if [ "${SERVER_NAME}" != "AdminServer" ] ; then
USER_MEM_ARGS="-Xms512m -Xmx512m -XX:MaxPermSize=256m"
MEM_ARGS="${USER_MEM_ARGS}"
export MEM_ARGS
fi`

Under bin directory edit setDomainEnv.sh
find the below line:

If USER_MEM_ARGS the environment variable is set, use it to override ALL MEM_ARGS
add the below lines and modify the values accordingly

For Admin Server

`if [ "${SERVER_NAME}" = "AdminServer" ] ; then
USER_MEM_ARGS="-Xms256m -Xmx256m -XX:MaxPermSize=256m"
MEM_ARGS="${USER_MEM_ARGS}"
export MEM_ARGS
fi`

For Managed Server

`if [ "${SERVER_NAME}" != "AdminServer" ] ; then
USER_MEM_ARGS="-Xms512m -Xmx512m -XX:MaxPermSize=256m"
MEM_ARGS="${USER_MEM_ARGS}"
export MEM_ARGS
fi`
π浅易 2024-12-23 01:25:50

如果您需要“为 weblogic 中的每个服务器 JVM 设置自定义属性”,那么使用 startWeblogic.cmd 或 setDomainEnv.cmd 是不够的,因为它们将为您的所有服务器设置相同的值。服务器。

如果未启用 NodeManager,您可以做的一件事是手动编辑 config.xml 文件并在 元素> 每个服务器的元素。

但是 - 不建议这样做(请参见此处:http://docs .oracle.com/cd/E23943_01/web.1111/e13716/config_files.htm)。更好地依赖 NodeManger 并使用您描述的过程。

除此之外,上面的答案 value=System.getProperty("MyArg"); 是正确的。

If you need a "custom property to set per each server JVM in weblogic", then using the startWeblogic.cmd or setDomainEnv.cmd won't be enough as they will set the same value for all of your servers.

One thing you could do if the NodeManager is not enabled is manually edit the config.xml file and add/edit the <arguments> element under the <server-start> element for each server.

But - this is not recommended (see here: http://docs.oracle.com/cd/E23943_01/web.1111/e13716/config_files.htm). Much better to rely on the NodeManger and use the procedure you described.

Other than that the above answer value=System.getProperty("MyArg"); is correct.

隔纱相望 2024-12-23 01:25:50

我通常为 DOMAIN_HOME 下的每个托管服务器创建简单的调用脚本,这些脚本又调用 /bin 目录中的通用启动脚本 - 就像 WebLogic 自动为管理服务器创建的脚本一样。我知道你可以通过这种方式覆盖内存参数,并且我很确定你可以更改 JVM。

下面是一个经过测试的 Windows 脚本示例:

cd bin
SET USER_MEM_ARGS=-Xms512m -Xmx512m
startManagedWebLogic.cmd new_ManagedServer_1 localhost:7001

我想在 UNIX 中会是这样的(抱歉,我不太了解 bash 脚本):

cd bin
export USER_MEM_ARGS="-Xms512m -Xmx512m"
./startManagedWebLogic.sh new_ManagedServer_1 localhost:7001

我认为要更改 JVM,它会是这样的:

export JAVA_VENDOR="Oracle"
export USER_MEM_ARGS="-Xms512m –Xmx1g"
./startWebLogic.sh

有兴趣听听任何人的意见对此的反馈。希望它能帮助某人。 。 。

I usually create simple call scripts for each managed server under DOMAIN_HOME, that in turn call the generic start scripts in the /bin directory - like the one that WebLogic automatically creates for the Admin Server. I know you can override memory arguments this way and I'm pretty sure you can change JVM.

Here's an example of a tested script for Windows:

cd bin
SET USER_MEM_ARGS=-Xms512m -Xmx512m
startManagedWebLogic.cmd new_ManagedServer_1 localhost:7001

which I guess in UNIX would be something like this (sorry don't know much about bash scripts):

cd bin
export USER_MEM_ARGS="-Xms512m -Xmx512m"
./startManagedWebLogic.sh new_ManagedServer_1 localhost:7001

I think to change the JVM it would be something like:

export JAVA_VENDOR="Oracle"
export USER_MEM_ARGS="-Xms512m –Xmx1g"
./startWebLogic.sh

Would be interested to hear anyone's feedback on this. Hope it helps someone . . .

緦唸λ蓇 2024-12-23 01:25:50

您可以通过修改以下文件来完成
C:\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain\bin\startWebLogic.cmd

在我的例子中它是域 base_domain。

找到下一行并编辑。

@REM JAVA_OPTIONS   - Java command-line options for running the server. (These
set "JAVA_OPTIONS=%JAVA_OPTIONS% -DyourVariable=value"

例子

@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" (
        exit /b
    )
    @REM STOP DERBY (only if we started it)
    if "%DERBY_FLAG%"=="true" (
        echo Stopping Derby server...
        call "%WL_HOME%\common\derby\bin\stopNetworkServer.cmd"  >"%DOMAIN_HOME%\derbyShutdown.log" 2>&1 

        echo Derby server stopped.
    )

    set ALREADY_STOPPED=true
GOTO :EOF

:generateClassList
    set JAVA_OPTIONS=%JAVA_OPTIONS% -Xshare:off -XX:+UnlockCommercialFeatures -XX:+IgnoreEmptyClassPaths -XX:DumpLoadedClassList=%APPCDS_CLASS_LIST% -XX:+UseAppCDS
GOTO :EOF

:useArchive
    set JAVA_OPTIONS=%JAVA_OPTIONS% -XX:+UnlockCommercialFeatures -Xshare:auto -XX:+UseAppCDS -XX:+IgnoreEmptyClassPaths -XX:SharedArchiveFile=%APPCDS_ARCHIVE% -showversion
    set USING_SHOWVERSION=true
GOTO :EOF


:ENDFUNCTIONS
ECHO HOLA.........................................................................
@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 DERBY_HOME - Derby home directory.
@REM DERBY_CLASSPATH
@REM                - Classpath needed to start Derby.
@REM 
@REM Other variables used in this script include:
@REM SERVER_NAME    - Name of the weblogic server.
set "JAVA_OPTIONS=%JAVA_OPTIONS% -DUPLOAD_HOME=C:\files"
@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 PROXY_SETTINGS - These are tagged on to the end of the JAVA_OPTIONS. This variable is deprecated and should not
@REM                  be used. Instead use JAVA_OPTIONS
@REM 
@REM For additional information, refer to "Administering Server Startup and Shutdown for Oracle WebLogic Server"
@REM *************************************************************************

set SCRIPTPATH=%~dp0
set SCRIPTPATH=%SCRIPTPATH%
for %%i in ("%SCRIPTPATH%") do set SCRIPTPATH=%%~fsi


@REM Call setDomainEnv here.

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

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

set SAVE_JAVA_OPTIONS=%JAVA_OPTIONS%

set SAVE_CLASSPATH=%CLASSPATH%

set TMP_UPDATE_SCRIPT=%TMP%\update.cmd


@REM Start Derby

set DERBY_DEBUG_LEVEL=0

if "%DERBY_FLAG%"=="true" (
    call "%WL_HOME%\common\derby\bin\startNetworkServer.cmd"  >"%DOMAIN_HOME%\derby.log" 2>&1 

)

set JAVA_OPTIONS=%SAVE_JAVA_OPTIONS%

@REM In order to use resource consumption management policies or to get partition's resource consumption metrics, uncomment the following JAVA_OPTIONS

set #JAVA_OPTIONS=-XX:+UnlockCommercialFeatures -XX:+ResourceManagement -XX:+UseG1GC %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%
    )
)

if "%GENERATE_CLASS_LIST%"=="true" (
    CALL :generateClassList
)

if "%USE_ARCHIVE%"=="true" (
    CALL :useArchive
)

echo .

echo .

echo JAVA Memory arguments: %MEM_ARGS%

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 START WEBLOGIC

if NOT "%USE_JVM_SYSTEM_LOADER%"=="true" (
    set LAUNCH_ARGS=-cp %WL_HOME%\server\lib\weblogic-launcher.jar -Dlaunch.use.env.classpath=true
)

if "%USING_SHOWVERSION%"=="true" (
    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% %LAUNCH_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WLS_POLICY_FILE% %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
    %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% %LAUNCH_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WLS_POLICY_FILE% %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% %LAUNCH_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WLS_POLICY_FILE% %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%  >"%WLS_REDIRECT_LOG%" 2>&1 
)

IF ERRORLEVEL 86 IF NOT ERRORLEVEL 87 (set shutDownStatus=86) ELSE (IF ERRORLEVEL 88 IF NOT ERRORLEVEL 89 ( set shutDownStatus=88 ) )


CALL :stopAll

popd

IF EXIST %TMP_UPDATE_SCRIPT% (set fileExists=true) ELSE (set fileExists=false)


if "%shutDownStatus%"=="86" (
    if "%fileExists%"=="true" (
        echo Calling %TMP_UPDATE_SCRIPT%

        cd %TMP:~0,2%
        cd %TMP%
        call %TMP_UPDATE_SCRIPT%
        IF ERRORLEVEL 42 IF NOT ERRORLEVEL 43 (set ustatus=42 )

        @REM restoring the original env before unsetting JAVA_HOME
        @REM in order to unset any JAVA_HOME that was passed in from domainEnv
        if "%ustatus%"=="42" (
            set JAVA_HOME=
        )
    ) else (
        echo ERROR! %TMP_UPDATE_SCRIPT% did not exist
    )
    @REM Call the same script path that was supplied in order to restart ourselves
    @REM restoreOrigEnv will go here

    call "%SCRIPTPATH%\startWebLogic.cmd"

) else (
    if "%shutDownStatus%"=="88" (
        @REM restoreOrigEnv will go here

        call "%SCRIPTPATH%\startWebLogic.cmd"

    )
)

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

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



ENDLOCAL

You can do it by modifying the following file
C:\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain\bin\startWebLogic.cmd

in my case it is the domain base_domain.

find the next line and edit.

@REM JAVA_OPTIONS   - Java command-line options for running the server. (These
set "JAVA_OPTIONS=%JAVA_OPTIONS% -DyourVariable=value"

Example

@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" (
        exit /b
    )
    @REM STOP DERBY (only if we started it)
    if "%DERBY_FLAG%"=="true" (
        echo Stopping Derby server...
        call "%WL_HOME%\common\derby\bin\stopNetworkServer.cmd"  >"%DOMAIN_HOME%\derbyShutdown.log" 2>&1 

        echo Derby server stopped.
    )

    set ALREADY_STOPPED=true
GOTO :EOF

:generateClassList
    set JAVA_OPTIONS=%JAVA_OPTIONS% -Xshare:off -XX:+UnlockCommercialFeatures -XX:+IgnoreEmptyClassPaths -XX:DumpLoadedClassList=%APPCDS_CLASS_LIST% -XX:+UseAppCDS
GOTO :EOF

:useArchive
    set JAVA_OPTIONS=%JAVA_OPTIONS% -XX:+UnlockCommercialFeatures -Xshare:auto -XX:+UseAppCDS -XX:+IgnoreEmptyClassPaths -XX:SharedArchiveFile=%APPCDS_ARCHIVE% -showversion
    set USING_SHOWVERSION=true
GOTO :EOF


:ENDFUNCTIONS
ECHO HOLA.........................................................................
@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 DERBY_HOME - Derby home directory.
@REM DERBY_CLASSPATH
@REM                - Classpath needed to start Derby.
@REM 
@REM Other variables used in this script include:
@REM SERVER_NAME    - Name of the weblogic server.
set "JAVA_OPTIONS=%JAVA_OPTIONS% -DUPLOAD_HOME=C:\files"
@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 PROXY_SETTINGS - These are tagged on to the end of the JAVA_OPTIONS. This variable is deprecated and should not
@REM                  be used. Instead use JAVA_OPTIONS
@REM 
@REM For additional information, refer to "Administering Server Startup and Shutdown for Oracle WebLogic Server"
@REM *************************************************************************

set SCRIPTPATH=%~dp0
set SCRIPTPATH=%SCRIPTPATH%
for %%i in ("%SCRIPTPATH%") do set SCRIPTPATH=%%~fsi


@REM Call setDomainEnv here.

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

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

set SAVE_JAVA_OPTIONS=%JAVA_OPTIONS%

set SAVE_CLASSPATH=%CLASSPATH%

set TMP_UPDATE_SCRIPT=%TMP%\update.cmd


@REM Start Derby

set DERBY_DEBUG_LEVEL=0

if "%DERBY_FLAG%"=="true" (
    call "%WL_HOME%\common\derby\bin\startNetworkServer.cmd"  >"%DOMAIN_HOME%\derby.log" 2>&1 

)

set JAVA_OPTIONS=%SAVE_JAVA_OPTIONS%

@REM In order to use resource consumption management policies or to get partition's resource consumption metrics, uncomment the following JAVA_OPTIONS

set #JAVA_OPTIONS=-XX:+UnlockCommercialFeatures -XX:+ResourceManagement -XX:+UseG1GC %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%
    )
)

if "%GENERATE_CLASS_LIST%"=="true" (
    CALL :generateClassList
)

if "%USE_ARCHIVE%"=="true" (
    CALL :useArchive
)

echo .

echo .

echo JAVA Memory arguments: %MEM_ARGS%

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 START WEBLOGIC

if NOT "%USE_JVM_SYSTEM_LOADER%"=="true" (
    set LAUNCH_ARGS=-cp %WL_HOME%\server\lib\weblogic-launcher.jar -Dlaunch.use.env.classpath=true
)

if "%USING_SHOWVERSION%"=="true" (
    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% %LAUNCH_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WLS_POLICY_FILE% %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%
    %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% %LAUNCH_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WLS_POLICY_FILE% %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% %LAUNCH_ARGS% -Dweblogic.Name=%SERVER_NAME% -Djava.security.policy=%WLS_POLICY_FILE% %JAVA_OPTIONS% %PROXY_SETTINGS% %SERVER_CLASS%  >"%WLS_REDIRECT_LOG%" 2>&1 
)

IF ERRORLEVEL 86 IF NOT ERRORLEVEL 87 (set shutDownStatus=86) ELSE (IF ERRORLEVEL 88 IF NOT ERRORLEVEL 89 ( set shutDownStatus=88 ) )


CALL :stopAll

popd

IF EXIST %TMP_UPDATE_SCRIPT% (set fileExists=true) ELSE (set fileExists=false)


if "%shutDownStatus%"=="86" (
    if "%fileExists%"=="true" (
        echo Calling %TMP_UPDATE_SCRIPT%

        cd %TMP:~0,2%
        cd %TMP%
        call %TMP_UPDATE_SCRIPT%
        IF ERRORLEVEL 42 IF NOT ERRORLEVEL 43 (set ustatus=42 )

        @REM restoring the original env before unsetting JAVA_HOME
        @REM in order to unset any JAVA_HOME that was passed in from domainEnv
        if "%ustatus%"=="42" (
            set JAVA_HOME=
        )
    ) else (
        echo ERROR! %TMP_UPDATE_SCRIPT% did not exist
    )
    @REM Call the same script path that was supplied in order to restart ourselves
    @REM restoreOrigEnv will go here

    call "%SCRIPTPATH%\startWebLogic.cmd"

) else (
    if "%shutDownStatus%"=="88" (
        @REM restoreOrigEnv will go here

        call "%SCRIPTPATH%\startWebLogic.cmd"

    )
)

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

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



ENDLOCAL
感受沵的脚步 2024-12-23 01:25:50

如果您使用的是 Windows,请导航至 %OracleHome%\user_projects\domains\base_domain\bin

在记事本++中编辑 setDomainEnv.cmd

找到设置最终 JAVA_OPTIONS 的行,

set JAVA_OPTIONS=%JAVA_OPTIONS%

您可以在此行上方添加您的客户 java 参数。例如,

set JAVA_OPTIONS=%JAVA_OPTIONS% -Dcustom.prop=value

set JAVA_OPTIONS=%JAVA_OPTIONS%

现在如果您的 WebLogic 正在运行,请停止并重新启动管理控制台。您将能够在命令提示符或 Eclipse 控制台中验证 WebLogic 是否已使用您的客户 java 参数启动,

Starting WLS with line:
C:\PROGRA~1\Java\JDK18~1.0_1\bin\java -server   
-Xms256m -Xmx512m -XX:CompileThreshold=8000 
BLA BLA BLA 
-Dweblogic.home=C:\ORACLE~1\MIDDLE~1\ORACLE~1\wlserver\server 
-Dcustom.prop=value  
weblogic.Server

现在在您的应用程序中您可以通过 System.getProperty("custom.prop") 访问它

If you are using Windows, navigate to %OracleHome%\user_projects\domains\base_domain\bin

Edit the setDomainEnv.cmd in note pad++

Find the line where the final JAVA_OPTIONS are set,

set JAVA_OPTIONS=%JAVA_OPTIONS%

You can have your customer java arguments above this line. Something like,

set JAVA_OPTIONS=%JAVA_OPTIONS% -Dcustom.prop=value

set JAVA_OPTIONS=%JAVA_OPTIONS%

Now if you WebLogic is running please stop and restart the Admin Console. You will be able to verify in the command prompt or eclipse console that WebLogic is started with your customer java args,

Starting WLS with line:
C:\PROGRA~1\Java\JDK18~1.0_1\bin\java -server   
-Xms256m -Xmx512m -XX:CompileThreshold=8000 
BLA BLA BLA 
-Dweblogic.home=C:\ORACLE~1\MIDDLE~1\ORACLE~1\wlserver\server 
-Dcustom.prop=value  
weblogic.Server

Now in your appliation you can access it by System.getProperty("custom.prop")

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文