Skip to content

Repository files navigation

WebLogic Two WAR Reproducer

This project builds two Java web apps and one shared library:

  • shared-lib: packaged as shared-lib-1.0.0.jar
  • app-one: packaged as app-one.war
  • app-two: packaged as app-two.war

By default, both WAR files include shared-lib unchanged. Pass -PshadowSharedLibrary=true to build relocated application JARs instead. Gradle Shadow then rewrites the shared package and the servlet bytecode that references it:

  • app-one: APP_ONE_com.example.shared
  • app-two: APP_TWO_com.example.shared

The source code keeps importing com.example.shared; relocation happens after compilation.

Build

With local Gradle:

gradle clean copyWars
gradle clean copyWars -PshadowSharedLibrary=true

Without local Gradle:

docker compose -f docker-compose.build.yml run --rm gradle
docker compose -f docker-compose.build.yml run --rm gradle \
  gradle clean copyWars -PshadowSharedLibrary=true

The deployable WAR files are copied to:

build/deploy/app-one.war
build/deploy/app-two.war

Verify WAR Contents

After building with -PshadowSharedLibrary=true:

unzip -p build/deploy/app-one.war \
  WEB-INF/lib/app-one-1.0.0-relocated.jar > /tmp/app-one-relocated.jar
unzip -p build/deploy/app-two.war \
  WEB-INF/lib/app-two-1.0.0-relocated.jar > /tmp/app-two-relocated.jar

jar tf /tmp/app-one-relocated.jar | grep 'APP_ONE_com/example/shared'
jar tf /tmp/app-two-relocated.jar | grep 'APP_TWO_com/example/shared'
! jar tf /tmp/app-one-relocated.jar | grep '^com/example/shared/'
! jar tf /tmp/app-two-relocated.jar | grep '^com/example/shared/'

This is package relocation, not classloader sharing. WebLogic still gives each WAR its own application classloader, but the debugger now sees different class names. A WebLogic library-ref removes duplicate files without creating one class identity across applications; use an EAR or the domain lib directory when a common parent classloader is required instead.

Download the agent

SERVER_URL=https://dogfood.internal.lightrun.com
COMPANY=
export LIGHTRUN_KEY=
bash -c "$(curl -k -L "$SERVER_URL/public/download/company/$COMPANY/install-agent.sh?platform=linux")"

Run WebLogic

Oracle WebLogic container images are served from Oracle Container Registry. You may need to sign in at https://container-registry.oracle.com/ and accept the license for the WebLogic image first:

docker login container-registry.oracle.com

Then start WebLogic:

docker compose up

The Compose file mounts build/deploy read-only at /u01/oracle/deployments. scripts/start-weblogic-dev.sh waits until WebLogic creates the domain and then links both WARs into the domain's autodeploy directory.

The Lightrun agent from agent/ is mounted read-only at /u01/oracle/lightrun-agent. The startup wrapper adds this JVM option before WebLogic starts:

-agentpath:/u01/oracle/lightrun-agent/lightrun_agent.so

Test URLs:

Admin console:

You can override the image or credentials:

WEBLOGIC_IMAGE=container-registry.oracle.com/middleware/weblogic:14.1.1.0-dev-11 \
docker compose up

Admin credentials live in properties/domain.properties.

To temporarily run WebLogic without Lightrun:

ENABLE_LIGHTRUN_AGENT=false docker compose up

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages