[jboss-user] [JBoss and NetBeans] - Re: NameNotFoundException: DefaultDS not bound - Entity Unit

htran_888 do-not-reply at jboss.com
Wed Feb 7 17:16:26 EST 2007


Hi L,

By prepending the "java:/" to DefaultDS in persistence.xml file did fixed the binding issue. I have tried this in the past but did not redeploy correctly. Anyhow, I now receive the following error when running the Client.java on the titan.jar EJB:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at client.Client.main(Client.java:31)

Here is the code for Client.java:

package client;

import travelagent.TravelAgentRemote;
import domain.Cabin;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import javax.rmi.PortableRemoteObject;

public class Client 
  | {
  |     public static void main(String [] args) 
  |     {
  |         try 
  | 	{
  |             Context ctx = getInitialContext();
  |             Object ref = (TravelAgentRemote) ctx.lookup("TravelAgentRemote");
  |             TravelAgentRemote dao = (TravelAgentRemote)
  |                 PortableRemoteObject.narrow(ref,TravelAgentRemote.class);
  | 
  |             Cabin cabin_1 = new Cabin();
  |             cabin_1.setId(1);
  |             cabin_1.setName("Master Suite");
  |             cabin_1.setDeckLevel(1);
  |             cabin_1.setShipId(1);
  |             cabin_1.setBedCount(3);
  | 
  |             dao.createCabin(cabin_1);
  | 
  |             Cabin cabin_2 = dao.findCabin(1);
  |             System.out.println(cabin_2.getName());
  |             System.out.println(cabin_2.getDeckLevel());
  |             System.out.println(cabin_2.getShipId());
  |             System.out.println(cabin_2.getBedCount());
  | 
  |         } 
  |         catch (javax.naming.NamingException ne)
  |         {
  | 	    ne.printStackTrace();
  | 	}
  |     }
  | 
  |     public static Context getInitialContext() 
  |         throws javax.naming.NamingException 
  |     {
  |         return new javax.naming.InitialContext();
  |     }                                                
  | }

Thanks again,

Henry


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4012683#4012683

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4012683



More information about the jboss-user mailing list