-1

I'm using Java Oracle NoSQL Database Server - com.sleepycat.je

<dependency>
        <groupId>com.sleepycat</groupId>
        <artifactId>je</artifactId>
        <version>18.3.12</version>
 </dependency>

And I try to get Berkely DB content - RPM Packages DB in Centos8 docker image

import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;

import java.io.File;

public class TempMain {
public static void main(String[] args) {
    Environment myDbEnvironment = null;

    try {
        // Open the environment, creating one if it does not exist
        EnvironmentConfig envConfig = new EnvironmentConfig();
        envConfig.setAllowCreate(true);
        myDbEnvironment = new Environment(new File("C:\\Centos8\\LayerId\\var\\lib\\rpm\\Packages"),
                envConfig);

    } catch (DatabaseException dbe) {
        //  Exception handling
    }
}
}

But I get the following error:

Exception in thread "main" java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
at java.util.Properties.loadConvert(Properties.java:574)
at java.util.Properties.load0(Properties.java:391)
at java.util.Properties.load(Properties.java:341)
at com.sleepycat.je.dbi.DbConfigManager.applyFileConfig(DbConfigManager.java:449)
at com.sleepycat.je.Environment.setupHandleConfig(Environment.java:313)
at com.sleepycat.je.Environment.<init>(Environment.java:250)
at com.sleepycat.je.Environment.<init>(Environment.java:228)
Sherein
  • 947
  • 1
  • 11
  • 23
  • 1
    `C:\\Centos8` is valid path for CentOS? – MariuszS Jan 02 '20 at 12:58
  • I saved docker image on my local machine and extracted it, Then tried to run this code on var/lib/rpm/Packages file exist in the first layer in centos8 – Sherein Jan 02 '20 at 13:03
  • But where are you running the Java executable? Inside the Docker or in Windows? – m0skit0 Jan 02 '20 at 13:35
  • Is `Packages` an actual Berkeley DB database file, or just a directory containing RPM packages? – Ian McLaird Jan 02 '20 at 13:47
  • I saved Centos:8 docker image to my local computer windows and extracted it. I found "Packages" file in "var/lib/rpm/" path inside the first layer folder. Im trying to get its content using Java as above. – Sherein Jan 02 '20 at 14:00
  • 1. Your question is wrongly tagged. It is unrelated to centos, dnf and rpm. It should be tagged *Windows*. 2. Why do you want to access such file this way? – MariuszS Jan 02 '20 at 17:44
  • 1. Its not wrongly tagged. Its about Centos 8 docker image and new package manager DNF 2. I need to know installed packages in Centos 8 without running centos8 as a docker container. – Sherein Jan 05 '20 at 08:30

1 Answers1

0

your problem for sure related to the Path I would recommend

1.replace \\ with File.pathSeparator

2.In debugging check that the file is existed before using it

Noa
  • 315
  • 1
  • 7
  • 31
  • I saved Centos:8 docker image to my local computer windows and extracted it. I found "Packages" file in "var/lib/rpm/" path inside the first layer folder. Im trying to get its content using Java as above. So the file exist and file separator isn't the issue – Sherein Jan 02 '20 at 13:58
  • I understand that .could you try to use `Files.exists ` to see if your class reach the files? – Noa Jan 02 '20 at 14:00