On 8/5/06, vasiliy.kiryanov <[EMAIL PROTECTED]> wrote:


Good afternoon.

[http://shale.apache.org/features-jndi-integration.html] link says to me
that I can aquire a java.sql.Connection from this data source ..

but it constantly return null.
from the myfaces BackBean this datasource resolves good.
Does anybody have any ideas?


Shale has become it's own top level project with it's own mailing lists ...
you might want to subscribe to the user list there via the links on <
http://shale.apache.org/mail-lists.html>.

What you are trying looks like it should work.  If you try to look it up in
the usual JNDI way,

   InitialContext initContext = new InitContext();
   DataSource ds = (DataSource) initContext.lookup
("java:comp/env/jdbc/postgres");

does it actually work?  Also, what servlet container are you running on?

Craig

I have next entry in the web.xml
        <resource-ref>
                <description>postgreSQL Datasource</description>
                <res-ref-name>jdbc/postgres</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
        </resource-ref>



and use next class:
public class jndiTest extends AbstractViewController
{
    public jndiTest()
    {
        try
        {

        FacesContext context = FacesContext.getCurrentInstance();
        Application appl = context.getApplication();
        ValueBinding vb =
context.getApplication
().createValueBinding("#{jndi['jdbc/postgres'].connection}");

        Connection conn = (Connection) vb.getValue(context);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

and I call object of this class in this way:
public class TestLoginBackBean extends AbstractViewControllerTestCase
{

    LoginBackBean loginBackBean;

    public TestLoginBackBean(String name)
    {
        super(name);
    }

    public static Test suite()
    {
        return (new TestSuite(TestLoginBackBean.class));
    }

    public void setUp()
    {
        super.setUp();
        loginBackBean = new LoginBackBean();
    }

    public void tearDown()
    {
        loginBackBean = null;
        super.tearDown();
    }

    public void testLoginBackBean_one()
    {
        jndiTest jnditest = new jndiTest();
    }
}
--
View this message in context:
http://www.nabble.com/shale%3A-jndi-lookup-error-tf2055640.html#a5663762
Sent from the Struts - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to