wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes I am unable to create initialcontext obejct Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply locked New topic
Author

I am unable to create initialcontext obejct

ramakoteswararao siddabad
Greenhorn

Joined: May 04, 2006
Posts: 2
i am useing weblogic 9.1. I have written following code to access a data source .

public static void main(String[] args) throws NamingException, SQLException {
// TODO Auto-generated method stub
//Hashtable h=new Hashtable();
//InitialContext c=null;
//Properties p=System.getProperties();
//p.put("java.naming.factory.initial","weblogic.jndi.WLInitialContextFactory");
//p.put("java.naming.provider.url","t3://localhost:7001");
//InitialContext c=new InitialContext(p);
Environment env = new Environment();

env.setProviderURL("t3://localhost:7001");

Context ctx = env.getInitialContext();
DataSource d=(DataSource)ctx.lookup("Datasource");



I tryied useing hashtable as well as system properties .i am getting following error .

NolassDefFoundError: javax/management/InvalidAttributeValueException
at weblogic.rmi.internal.Stub.<clinit>(Stub.java:21)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at weblogic.rmi.internal.StubInfo.class$(StubInfo.java:34)
at weblogic.rmi.internal.StubInfo.<clinit>(StubInfo.java:34)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at weblogic.jndi.WLInitialContextFactoryDelegate.class$(WLInitialContextFactoryDelegate.java:179)
at weblogic.jndi.WLInitialContextFactoryDelegate.<clinit>(WLInitialContextFactoryDelegate.java:201)
at weblogic.jndi.spi.EnvironmentManager$DefaultFactoryMaker.<clinit>(EnvironmentManager.java:26)
at weblogic.jndi.spi.EnvironmentManager.getInstance(EnvironmentManager.java:48)
at weblogic.jndi.Environment.getContext(Environment.java:263)
at weblogic.jndi.Environment.getInitialContext(Environment.java:167)
at JndiConnection.main(JndiConnection.java:41)
Exception in thread "main"




***********************************************************

new query.

now i used following code accessing jndi.

Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL,"t3://weblogic:7001");
InitialContext ctx = new InitialContext(props);
DataSource d=(DataSource)ctx.lookup("DataSource");
Connection con=d.getConnection();
Statement s=con.createStatement();
ResultSet rs = s.executeQuery("select * from emp");
ResultSetMetaData m=rs.getMetaData();
System.out.print(m.getColumnCount())



but still I am getting same EXception.

java.lang.NoClassDefFoundError: javax/management/InvalidAttributeValueException
at weblogic.rmi.internal.Stub.<clinit>(Stub.java:21)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at weblogic.rmi.internal.StubInfo.class$(StubInfo.java:34)
at weblogic.rmi.internal.StubInfo.<clinit>(StubInfo.java:34)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at weblogic.jndi.WLInitialContextFactoryDelegate.class$(WLInitialContextFactoryDelegate.java:179)
at weblogic.jndi.WLInitialContextFactoryDelegate.<clinit>(WLInitialContextFactoryDelegate.java:201)
at weblogic.jndi.spi.EnvironmentManager$DefaultFactoryMaker.<clinit>(EnvironmentManager.java:26)
at weblogic.jndi.spi.EnvironmentManager.getInstance(EnvironmentManager.java:48)
at weblogic.jndi.Environment.getContext(Environment.java:263)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
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 JndiConnection.main(JndiConnection.java:35)
Exception in thread "main"
[ May 05, 2006: Message edited by: ramakoteswararao siddabad ]
Chris Whites
Greenhorn

Joined: May 04, 2006
Posts: 3
If you are looking it up from within the Cconatiner, just:

InitialContext ic = new InitialContext();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I am unable to create initialcontext obejct
 
Similar Threads
problem with client
EJB running at client, weblogic security problem
Bootstrap to localhost/127.0.0.1:80 failed. It is likely that the remote side declar
Facing problem in InitialContext in Weblogic 10.0
EJB 3.0 - NoInitialContextException