public static void setupInitialContext() {
try {
System.out.println("Loading Initial Context");
NamingManager.setInitialContextFactoryBuilder(new InitialContextFactoryBuilder() {
@Override
public InitialContextFactory createInitialContextFactory(Hashtable<?, ?> environment)
throws NamingException {
return new InitialContextFactory() {
@Override
public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
InitialContext context = null;
try {
context = new MockLocalContext();
} catch (Exception ex) {
ex.printStackTrace();
}
return context;
}
};
}
});
System.out.println("Loaded Initial Context");
} catch (NamingException ne) {
ne.printStackTrace();
}
}
public static void main(String[] args) throws NamingException {
setupInitialContext();
InitialContext context = new InitialContext();
context.lookup(DS_ORACLE);
}
MockLocalContext - это класс, который расширяет класс javax.naming.InitialContext.
и это ошибка при создании объекта InitialContext.
Я получаю следующую трассировку стека:
Exception in thread "main" java.lang.StackOverflowError
at com.sun.naming.internal.VersionHelper12$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.naming.internal.VersionHelper12.getJndiProperties(Unknown Source)
at com.sun.naming.internal.ResourceManager.getInitialEnvironment(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at net.citigroup.mexico.pg.pgs.mock.MockLocalContext.<init>(MockLocalContext.java:97)
at net.citigroup.mexico.pg.pgs.mock.MockLocalContext.<init>(MockLocalContext.java:95)
at net.citigroup.mexico.pg.pgs.mock.MockLocalContext$3$1.getInitialContext(MockLocalContext.java:400)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at net.citigroup.mexico.pg.pgs.mock.MockLocalContext.<init>(MockLocalContext.java:97)
at net.citigroup.mexico.pg.pgs.mock.MockLocalContext.<init>(MockLocalContext.java:95)
at net.citigroup.mexico.pg.pgs.mock.MockLocalContext$3$1.getInitialContext(MockLocalContext.java:400)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at net.citigroup.mexico.pg.pgs.mock.MockLocalContext.<init>(MockLocalContext.java:97)
at net.citigroup.mexico.pg.pgs.mock.MockLocalContext.<init>(MockLocalContext.java:95)
at net.citigroup.mexico.pg.pgs.mock.MockLocalContext$3$1.getInitialContext(MockLocalContext.java:400)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
Это одна строка для многих строк с одинаковым содержанием, я просто обрезал ее, чтобы уместить здесь. Спасибо!