Skip to content

[Bug] The compiled software package cannot run after the directory is moved #23872

Closed
@Joforde

Description

@Joforde

Search before asking

  • I searched in the issues and found nothing similar.

Read release policy

  • I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.

Version

any released version

Minimal reproduce step

build broker

mvn -pl pulsar-broker package -DskipTests
// verify ok
bin/pulsar standalone

rename or move pulsar software package

cd ../;mv pulsar-4.0.1 pulsar;cd pulsar;
// verify failed
bin/pulsar standalone

What did you expect to see?

broker started success

What did you see instead?

Error: Could not find or load main class org.apache.pulsar.PulsarStandaloneStarter
Caused by: java.lang.ClassNotFoundException: org.apache.pulsar.PulsarStandaloneStarter

Anything else?

When compiling, Pulsar caches the absolute path of the JAR package into the classpath.txt.
like:
/home/xxx/pulsar-4.0.1/pulsar-broker/target/pulsar-broker.jar:

When starting the service, Pulsar reads the file that contains the cached absolute paths of the JAR packages:

pulsar/bin/pulsar

Lines 199 to 223 in e5bd774

add_maven_deps_to_classpath() {
MVN="mvn"
if [ "$MAVEN_HOME" != "" ]; then
MVN=${MAVEN_HOME}/bin/mvn
fi
# Need to generate classpath from maven pom. This is costly so generate it
# and cache it. Save the file into our target dir so a mvn clean will get
# clean it up and force us create a new one.
f="${PULSAR_HOME}/distribution/server/target/classpath.txt"
if [ ! -f "${f}" ]
then
(
cd "${PULSAR_HOME}"
${MVN} -pl distribution/server generate-sources &> /dev/null
)
fi
PULSAR_CLASSPATH=${CLASSPATH}:`cat "${f}"`
}
if [ -d "$PULSAR_HOME/lib" ]; then
PULSAR_CLASSPATH=$PULSAR_CLASSPATH:$PULSAR_HOME/lib/*
else
add_maven_deps_to_classpath
fi

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugThe PR fixed a bug or issue reported a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions