What is meant by Context binding?
A binding context is an object that holds data that you can reference from your bindings. While applying bindings, Knockout automatically creates and manages a hierarchy of binding contexts. The root level of the hierarchy refers to the viewModel parameter you supplied to ko.applyBindings(viewModel). Then, each time you use a control flow binding such as with or foreach, that creates a child binding context that refers to the nested view model data.
Thanks:-)
public class B { public static void main(String[] args) throws javax.naming.NoInitialContextException { maths mat=new A(); mat.add(); mat.sub(); String name; try { name = new B().getName(); System.out.println(name); } catch (NamingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void createName() throws NamingException { Context context = (Context) new InitialContext(); ((InitialContext) context).bind("java:comp/env", "MyApp"); } public String getName() throws NamingException { Context context = (Context) new InitialContext(); return (String) ((InitialContext) context).lookup("java:comp/env"); } }
if i run this program means it will show error give some solution....
error
javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {} [Root exception is java.lang.NullPointerException] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:238) at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:322) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:352) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:436) at javax.naming.InitialContext.lookup(InitialContext.java:450) at Model.B.getName(B.java:26) at Model.B.main(B.java:13) Caused by: java.lang.NullPointerException at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:230) ... 6 more
Hi, the problem with jndi credentials. For Example look into the given example for weblogic jndi.
public static void main(String[] args) {
// providing the weblogic jndi credentials
Hashtable< String, String> hashTable=new Hashtable<String, String>();
hashTable.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
hashTable.put(Context.PROVIDER_URL, "t3://localhost:7001/");
hashTable.put(Context.SECURITY_PRINCIPAL, "weblogic");
hashTable.put(Context.SECURITY_CREDENTIALS, "weblogic123");
try{
Context context=new InitialContext(hashTable);
Object object=context.lookup("JDBCDataSourceJNDI");
System.out.println("DataSource="+object.getClass().getName());
DataSource dataSource=(DataSource)object;
Connection connection=dataSource.getConnection();
System.out.println("connection ="+connection);
}
catch(NamingException nammingException ) {
nammingException.printStackTrace();
}
catch(SQLException sqlException) {
sqlException.printStackTrace();
}
}
Note Set the class path for: weblogic.jar and wlclient.jar and also configure the weblogic connection pool for weblogic by using creating the datasource .
In this above example "JDBCDataSourceJNDI" is a datasource name that is created by myself and also weblogic and weblogic123 are weblogic credentials.