I get the "The Chromium profile directory is already used/locked by another BrowserContext instance or process" error when I try to run a standard code with only one Browser instance.
Code:
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserContext;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
public class ReadFile {
public static void main(String[] args) {
Browser browser = new Browser(BrowserContext.defaultContext());
BrowserView view = new BrowserView(browser);
JFrame frame = new JFrame("Google");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(view, BorderLayout.CENTER);
frame.setSize(700, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
browser.loadURL("http://google.com");
}
}
What might be the reason for that and how can I solve this problem?
Thanks in advance
The "The Chromium profile directory is already used/locked by another BrowserContext instance or process" error message indicates that there is a concurrent access to the Chromium data folder.
Please take a look at the following article which explains the root cause of this issue and possible ways to resolve it: https://jxbrowser.support.teamdev.com/support/solutions/articles/9000012878-creating-browser
If such exception is thrown during a startup, and your application does not create multiple BrowserContext instances, this usually indicates there is a running "browsercore" process that already uses the particular data directory.