Context binding

 
 

Share on Google+Share on Google+

Manibharathi
Context binding
3 Answer(s)      5 years and 3 months ago
Posted in : JNDI

What is meant by Context binding?

Ads
View Answers

September 13, 2012 at 1:04 PM


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.



September 13, 2012 at 1:10 PM


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



November 21, 2013 at 11:26 AM


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.


Ads









Related Tutorials/Questions & Answers:
Context binding
Context binding  What is meant by Context binding?   A binding context is an object that holds data that you can reference from your... a hierarchy of binding contexts. The root level of the hierarchy refers to the viewModel
context
context  what is context in general in java ?   An association between a name and an object is called a binding, and a set of such bindings is called a context
Advertisements
DYNAMIC BINDING
DYNAMIC BINDING  WHAT IS DYNAMIC BINDING
Binding in Flex
Binding in Flex  Hi....... Explain how binding works in mxml components? Please give the answer with example. Thanks  Ans: Binding in MXML Please see the following code: <s:Button id="btn" label
Binding in flex
Binding in flex  Hi......... Please tell me the Difference between...: 1. When we define a data binding in MXML it will use at compile time and we define a data binding in action script it will use at run time. 2. you use
Servlet Context
Servlet Context  Defined Servlet Context
value and binding attribute
value and binding attribute  What is the difference between value and binding attribute of jsf tag
value and binding attribute
value and binding attribute  What is the difference between value and binding attribute in jsf
XML data binding
XML data binding   hello, What is XML data binding?   hii, XML data binding refers to the process of representing the information in an XML document as an object in computer memory
Version of jgoodies>binding dependency
List of Version of jgoodies>binding dependency
Version of com.jgoodies>binding dependency
List of Version of com.jgoodies>binding dependency
context attribute
context attribute  i have writteh the program lyk this ...still error 405 method not found is coming.please suggest me the solution. import... { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("context
Binding - Java Interview Questions
Binding   Hi Deepak , Interface makes runtime binding where abstract class is compile time binding.you can achieve multiple inheritance through Interface but abstract class not allow. Thank u in advance
What is Application Context?
What is Application Context?  Hello, What is Application Context? Thanks
Binding Error in Spring - Spring
Binding Error in Spring  Error: Neither BindingResult nor plain target object for bean name 'loginBean' available as request attribute I am trying to write a login page in Springs My jsp: User Id : ">
Version of com.jgoodies>jgoodies-binding dependency
List of Version of com.jgoodies>jgoodies-binding dependency
application context file problem
application context file problem  how to configure junit application context file with struts........? it is not finding sessionfactory method
Overriding jaxb binding at client side?
Overriding jaxb binding at client side?  How can override jaxb binding at client side? I have a webservice client which creates xmlgregoriancalendar.... Overriding jaxb binding at client side
Binding and unbinding events
Binding and unbinding events       Binding and unbinding events As the name says "binding events " is  the association of an element
Why binding attribute is required in jsf frame work
Why binding attribute is required in jsf frame work  Why binding attribute is required in jsf frame work. And what use of binding attribute
Message Context in AXIS
Message Context in AXIS  Is there any method in Axis classes to het the size of IN and OUT Message Conetext
Flex data binding example
Flex data binding example       In the example below, data binding in flex is demonstrated. Here data binding means binding or connecting the properties or attributes of flex
Maven Dependency binding >> 1.0
You should include the dependency code given in this page to add Maven Dependency of jgoodies >> binding version1.0 in your project
Maven Dependency binding >> 1.4.0
You should include the dependency code given in this page to add Maven Dependency of com.jgoodies >> binding version1.4.0 in your project
Maven Dependency binding >> 2.0.0
You should include the dependency code given in this page to add Maven Dependency of com.jgoodies >> binding version2.0.0 in your project
Maven Dependency binding >> 2.0.1
You should include the dependency code given in this page to add Maven Dependency of com.jgoodies >> binding version2.0.1 in your project
Maven Dependency binding >> 2.0.2
You should include the dependency code given in this page to add Maven Dependency of com.jgoodies >> binding version2.0.2 in your project
Maven Dependency binding >> 2.0.3
You should include the dependency code given in this page to add Maven Dependency of com.jgoodies >> binding version2.0.3 in your project
Maven Dependency binding >> 2.0.4
You should include the dependency code given in this page to add Maven Dependency of com.jgoodies >> binding version2.0.4 in your project

Ads

 
Advertisement null

Ads