Weblogic Cheatsheet

weblogic

https://docs.kony.com/konylibrary/messaging/kms_console_installer_manual_guide-windows/Content/Configure_WebLogic_Server.htm
https://docs.oracle.com/cd/E13222_01/wls/docs81/isv/configuration.html

When we need to change the version of JDK that we want to use, which file do we need to change?

Whenever I need to change the version of JDK that I want to use, I typically change it inside the bin\setDomainEnv.cmd file that is located within the applicable domain.

How can we configure WebLogic 12c to support HTTPS / SSL?

This procedure only cover configuring your development environment to support HTTPS / SSL. To configure WebLogic 12c to support HTTPS / SSL on production, please search the Internet.

  1. Copy your PFX (PKCS12) keystore (or certificate) file to the server. In my environment, I create a folder named keystore inside my bea folder (C:\bea\user_projects\domains\qdomain\keystore) and copy my pfx file there.
  2. Use the keytool command (which comes with Java JDK) to determine the alias from the PKCS12 file
  3. Log into your WebLogic console at /console
  4. Click on "Servers" (it is under the "Environment" section. If you cannot see this link, press CTRL-F and search for Server)
  5. Click on the name of your server
  6. Click on the Configuration tab
  7. Click on the General tab
  8. Check the "SSL Listen Port Enabled" checkbox
  9. Change the "SSL Listen Port" if necessary
  10. Click on the Save button.
  11. Click on the Keystores tab
  12. Click on the Change button and select Custom Identity and Java Standard Trust and click the Save button
  13. In the Custom Identity Keystore field, provide the complete path for the certificate store.
  14. Type PKCS12 into the Custom Identity Keystore Type text box
  15. Type the passphrase into the Custom Identity Keystore Passphrase text box and the Confirm Custom Identity Keystore Passphrase text box
  16. Click on the Save button
  17. Click on the SSL tab
  18. Paste or type the alias (from the certificate / keystore) file mentioned above into the Private Key Alias text box.
  19. Type the passphrase into the Private Key Passphrase text box and the Confirm Private Key Passphrase text box.
  20. Click on Save
  21. Click on Advanced
  22. Select None for Hostname Verification
  23. Make sure that the Use Server Certs check box is checked.
  24. Click on the Save button
  25. Restart your WebLogic

To determine the alias from your PKCS12 file:

keytool -list -v -keystore test.p12 -storetype PKCS12
keytool -list -storetype pkcs12 -keystore my-pfx.pfx -v | grep Alias

How can we convert a certificate from PKCS12 format to jks format?

keytool -importkeystore -srckeystore [MY_FILE.p12] -srcstoretype pkcs12 -srcalias [ALIAS_SRC] -destkeystore [MY_KEYSTORE.jks] -deststoretype jks -deststorepass [PASSWORD_JKS] -destalias [ALIAS_DEST]

How can we change memory setting?

Open up the setDomainEnv.cmd file and somewhere in that file, put:

set USER_MEM_ARGS=-Xms1024m -Xmx1024m -XX:MaxPermSize=512m

How can we delete WebLogic JSP cache during start-up?

rmdir /S /Q C:\bea\user_projects\domains\Dev\classfiles\jsp_servlet
rmdir /S /Q C:\bea\user_projects\domains\Dev\myserver\classfiles\jsp_servlet

C:\bea\user_projects\domains\qdomain\servers\myserver\tmp\_WL_user\current
C:\bea\user_projects\domains\qdomain\servers\myserver\tmp

Put the above code into your startWebLogic.cmd file.

How can we enable class caching?

WebLogic Server now allows you to enable class caching for faster start up. To enable class caching, set an environment variable (CLASS_CACHE=true for UNIX, set CLASS_CACHE=true for Windows) in the startWebLogic script.

How can we enable fastswap?

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application 
    xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/javaee_5.xsd 
    http://xmlns.oracle.com/weblogic/weblogic-application 
    http://xmlns.oracle.com/weblogic/weblogic-application/1.0/weblogic-application.xsd"
>
    <classloader-structure>
        <module-ref>
            <module-uri>quantros.war</module-uri>
        </module-ref>
    </classloader-structure>
    <fast-swap>
        <enabled>true</enabled>
    </fast-swap>
</weblogic-application>

For my WebLogic environment, the weblogic-application.xml file is in C:\app\current\META-.

FastSwap only work for class files. It does not work for JAR files. See also:

How can we configure WebLogic to send the JSESSIONID cookie over HTTPS?

By default, WebLogic send the JSESSIONID without the secure attribute, which means the browser will send the JSESSIONID cookie back to the server on sub-sequent HTTP requests. This may be a security concern (attacker can high jack the session if they are in the proximity of the end user and can capture the non-secure HTTP traffic). In production environment, we should use appropriate settings:

<session-descriptor>
    <timeout-secs>1800</timeout-secs>
    <cookie-http-only>true</cookie-http-only>
    <cookie-secure>true</cookie-secure>
</session-descriptor>

Put the above code into your weblogic.xml file. My weblogic.xml file is located in C:\app\current\quantros.war\WEB-INF. In our DEV environments, we only use HTTP, we can change the above code to:

<session-descriptor>
    <timeout-secs>1800</timeout-secs>
    <cookie-http-only>true</cookie-http-only>
    <cookie-secure>false</cookie-secure>
</session-descriptor>

How can we quickly swap database connection pools?

I used to work in an environment where I, as a developer, need to to configure my development environment to use different database. For example, members of the feature-development team use a different database, and members of the maintenance team use a different database. With WebLogic 8, all the connection pool information are kept inside the config.xml file. Most of the time, I am a member of the feature-development team. For a variety of reason, from time to time, I need to switch to using the "maintenance" database, or the QA database. So I also have config-sedev.xml, config-qa.xml, and when I need to switch database, I just rename config.xml to config-normal.xml, and appropriate file (config-sedev.xml or config-qa.xml) to config.xml. When I am done, I just rename config.xml back to appropriate file (config-sedev.xml or config-qa.xml), and config-normal.xml back to config.xml.

WebLogic 12c keeps each database connection in a separate file inside the "db" folder, so I create the "db-sedev", and "db-qa" folder from the original "db" folder, so whenever I need to use the "sedev" database, I rename "db" to "db-normal", and "db-sedev" to "db", and when I am done, I rename "db" back to "db-sedev", and "db-normal" back to "db".

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License