Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'sdkProperties' has private access in 'com.twitter.clientlib.SDKConfig' . #68

Open
illuri2107 opened this issue Nov 13, 2023 · 2 comments

Comments

@illuri2107
Copy link

One line summary of the issue here.

Expected behavior

As concisely as possible, describe the expected behavior.

Actual behavior

As concisely as possible, describe the observed behavior.

Steps to reproduce the behavior

Please list all relevant steps to reproduce the observed behavior.

@githubuser100007
Copy link

githubuser100007 commented Dec 2, 2023

I'd like to add that the issue is that the location of sdkProperties cannot be changed. I cannot deploy a WAR file and have FileInputStream find it.

To lookup any resource in a WAR / Wildfly environment, you have to use:

			InputStream in = this.getClass().getResourceAsStream("/sdk.properties");

But you cannot change this as it is currently hardcoded in the constructor.

What results is a long list of error logs that get generated every time the server starts up.

@githubuser100007
Copy link

When running a Java application in a containerized environment, accessing external files or resources might require a different approach compared to running the application locally. In your case, the code is attempting to load a file named "sdk.properties" using a FileInputStream, but it's unable to find the file within the container.

Here are a few possible solutions:

Use ClassLoader:
Load the file using the ClassLoader instead of a direct file path. This way, you can access resources from the classpath, and it's container-friendly.

InputStream inputStream = getClass().getClassLoader().getResourceAsStream("sdk.properties");
sdkProperties.load(inputStream);

Provide Absolute Path:
If you are sure about the location of the file within the container, provide the absolute path to the file.

String absolutePath = "/path/to/your/sdk.properties";
sdkProperties.load(new FileInputStream(absolutePath));

Use System Property:
Pass the file path as a system property when starting the WildFly server. You can then retrieve the system property in your code.

In your startup script or command line:

-Dsdk.properties.file=/path/to/your/sdk.properties

In your Java code:

String filePath = System.getProperty("sdk.properties.file");
sdkProperties.load(new FileInputStream(filePath));

Make sure to adjust the file path accordingly.

Choose the approach that best fits your application's structure and deployment environment. If the configuration file is part of your application, packaging it within the WAR file might also be a good solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants